pyvlasiator 0.1.7__tar.gz → 0.1.10__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pyvlasiator-0.1.7 → pyvlasiator-0.1.10}/PKG-INFO +68 -63
- pyvlasiator-0.1.10/pyproject.toml +31 -0
- pyvlasiator-0.1.10/setup.cfg +4 -0
- {pyvlasiator-0.1.7 → pyvlasiator-0.1.10}/src/pyvlasiator/plot/plot.py +23 -7
- {pyvlasiator-0.1.7 → pyvlasiator-0.1.10}/src/pyvlasiator/vlsv/reader.py +2 -1
- pyvlasiator-0.1.10/src/pyvlasiator.egg-info/PKG-INFO +68 -0
- pyvlasiator-0.1.10/src/pyvlasiator.egg-info/SOURCES.txt +16 -0
- pyvlasiator-0.1.10/src/pyvlasiator.egg-info/dependency_links.txt +1 -0
- pyvlasiator-0.1.10/src/pyvlasiator.egg-info/requires.txt +14 -0
- pyvlasiator-0.1.10/src/pyvlasiator.egg-info/top_level.txt +1 -0
- pyvlasiator-0.1.10/tests/test_pyvlasiator.py +172 -0
- pyvlasiator-0.1.7/pyproject.toml +0 -28
- {pyvlasiator-0.1.7 → pyvlasiator-0.1.10}/LICENSE.md +0 -0
- {pyvlasiator-0.1.7 → pyvlasiator-0.1.10}/README.md +0 -0
- {pyvlasiator-0.1.7 → pyvlasiator-0.1.10}/src/pyvlasiator/__init__.py +0 -0
- {pyvlasiator-0.1.7 → pyvlasiator-0.1.10}/src/pyvlasiator/plot/__init__.py +0 -0
- {pyvlasiator-0.1.7 → pyvlasiator-0.1.10}/src/pyvlasiator/pyvlasiator.py +0 -0
- {pyvlasiator-0.1.7 → pyvlasiator-0.1.10}/src/pyvlasiator/vlsv/__init__.py +0 -0
- {pyvlasiator-0.1.7 → pyvlasiator-0.1.10}/src/pyvlasiator/vlsv/variables.py +0 -0
|
@@ -1,63 +1,68 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
2
|
-
Name: pyvlasiator
|
|
3
|
-
Version: 0.1.
|
|
4
|
-
Summary: Python utilities for processing Vlasiator data
|
|
5
|
-
Author: Hongyang Zhou
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
Provides-Extra:
|
|
13
|
-
Requires-Dist:
|
|
14
|
-
Requires-Dist:
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
<
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
<a href="https://
|
|
27
|
-
<img src="https://
|
|
28
|
-
</a>
|
|
29
|
-
<a href="
|
|
30
|
-
<img src="https://
|
|
31
|
-
</a>
|
|
32
|
-
<a href="https://
|
|
33
|
-
<img src="https://img.shields.io/
|
|
34
|
-
</a>
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pyvlasiator
|
|
3
|
+
Version: 0.1.10
|
|
4
|
+
Summary: Python utilities for processing Vlasiator data
|
|
5
|
+
Author-email: Hongyang Zhou <hyzhou@umich.edu>
|
|
6
|
+
Requires-Python: <4.0,>=3.11
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
License-File: LICENSE.md
|
|
9
|
+
Requires-Dist: numpy>=1.25.1
|
|
10
|
+
Provides-Extra: plot
|
|
11
|
+
Requires-Dist: matplotlib<4,>=3.7.2; extra == "plot"
|
|
12
|
+
Provides-Extra: dev
|
|
13
|
+
Requires-Dist: pytest<8,>=7.4.0; extra == "dev"
|
|
14
|
+
Requires-Dist: pytest-benchmark<5,>=4.0.0; extra == "dev"
|
|
15
|
+
Requires-Dist: pytest-cov<5,>=4.1.0; extra == "dev"
|
|
16
|
+
Requires-Dist: requests<3,>=2.31.0; extra == "dev"
|
|
17
|
+
Requires-Dist: jupyter<2,>=1.0.0; extra == "dev"
|
|
18
|
+
Requires-Dist: myst-nb<2,>=1.0.0; extra == "dev"
|
|
19
|
+
Requires-Dist: sphinx-autoapi<4,>=3.0.0; extra == "dev"
|
|
20
|
+
Requires-Dist: sphinx-rtd-theme<2,>=1.2.2; extra == "dev"
|
|
21
|
+
Dynamic: license-file
|
|
22
|
+
|
|
23
|
+
# pyvlasiator
|
|
24
|
+
|
|
25
|
+
<p align="center">
|
|
26
|
+
<a href="https://badge.fury.io/py/pyvlasiator">
|
|
27
|
+
<img src="https://badge.fury.io/py/pyvlasiator.svg" alt="PyPI version" height="18">
|
|
28
|
+
</a>
|
|
29
|
+
<a href="https://github.com/henry2004y/pyvlasiator/actions">
|
|
30
|
+
<img src="https://github.com/henry2004y/pyvlasiator/actions/workflows/CI.yml/badge.svg">
|
|
31
|
+
</a>
|
|
32
|
+
<a href="https://henry2004y.github.io/pyvlasiator/">
|
|
33
|
+
<img src="https://img.shields.io/badge/docs-dev-blue">
|
|
34
|
+
</a>
|
|
35
|
+
<a href="LICENSE">
|
|
36
|
+
<img src="https://img.shields.io/badge/license-MIT-blue">
|
|
37
|
+
</a>
|
|
38
|
+
<a href="https://app.codecov.io/gh/henry2004y/pyvlasiator/">
|
|
39
|
+
<img src="https://img.shields.io/codecov/c/github/henry2004y/pyvlasiator">
|
|
40
|
+
</a>
|
|
41
|
+
</p>
|
|
42
|
+
|
|
43
|
+
Lightweight Python package for processing [Vlasiator](https://github.com/fmihpc/vlasiator) data, alternative to [Analysator](https://github.com/fmihpc/analysator).
|
|
44
|
+
|
|
45
|
+
## Installation
|
|
46
|
+
|
|
47
|
+
`pyvlasiator` can be installed via
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
python -m pip install pyvlasiator
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Usage
|
|
54
|
+
|
|
55
|
+
`pyvlasiator` can be used to process VLSV files generated from Vlasiator.
|
|
56
|
+
|
|
57
|
+
```python
|
|
58
|
+
from pyvlasiator.vlsv import Vlsv
|
|
59
|
+
|
|
60
|
+
file = "test.vlsv"
|
|
61
|
+
meta = Vlsv(file)
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Plotting is supported via Matplotlib. For more detailed usage, please refer to the [documentation](https://henry2004y.github.io/pyvlasiator/).
|
|
65
|
+
|
|
66
|
+
## License
|
|
67
|
+
|
|
68
|
+
`pyvlasiator` was created by Hongyang Zhou. It is licensed under the terms of the MIT license.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "pyvlasiator"
|
|
3
|
+
version = "0.1.10"
|
|
4
|
+
description = "Python utilities for processing Vlasiator data"
|
|
5
|
+
authors = [
|
|
6
|
+
{name = "Hongyang Zhou", email = "hyzhou@umich.edu"},
|
|
7
|
+
]
|
|
8
|
+
readme = "README.md"
|
|
9
|
+
requires-python = ">=3.11, <4.0"
|
|
10
|
+
dependencies = [
|
|
11
|
+
"numpy>=1.25.1",
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
[project.optional-dependencies]
|
|
15
|
+
plot = [
|
|
16
|
+
"matplotlib>=3.7.2, <4",
|
|
17
|
+
]
|
|
18
|
+
dev = [
|
|
19
|
+
"pytest>=7.4.0, <8",
|
|
20
|
+
"pytest-benchmark>=4.0.0, <5",
|
|
21
|
+
"pytest-cov>=4.1.0, <5",
|
|
22
|
+
"requests>=2.31.0, <3",
|
|
23
|
+
"jupyter>=1.0.0, <2",
|
|
24
|
+
"myst-nb>=1.0.0, <2",
|
|
25
|
+
"sphinx-autoapi>=3.0.0, <4",
|
|
26
|
+
"sphinx-rtd-theme>=1.2.2, <2",
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
[build-system]
|
|
30
|
+
requires = ["setuptools"]
|
|
31
|
+
build-backend = "setuptools.build_meta"
|
|
@@ -369,11 +369,12 @@ def _plot2d(
|
|
|
369
369
|
else:
|
|
370
370
|
pArgs = set_args(meta, var, axisunit)
|
|
371
371
|
data = prep2d(meta, var, comp)
|
|
372
|
+
normal = -1
|
|
372
373
|
|
|
373
374
|
x1, x2 = get_axis(pArgs.axisunit, pArgs.plotrange, pArgs.sizes)
|
|
374
375
|
|
|
375
376
|
if var in ("fg_b", "fg_e", "vg_b_vol", "vg_e_vol") or var.endswith("vg_v"):
|
|
376
|
-
_fillinnerBC(data)
|
|
377
|
+
_fillinnerBC(data, meta, var, pArgs, normal)
|
|
377
378
|
|
|
378
379
|
norm, ticks = set_colorbar(colorscale, vmin, vmax, data)
|
|
379
380
|
|
|
@@ -700,17 +701,17 @@ def prep2dslice(meta: Vlsv, var: str, dir: int, comp: int, pArgs: PlotArgs):
|
|
|
700
701
|
if comp != -1:
|
|
701
702
|
data = data3D[icut, :, :, comp]
|
|
702
703
|
else:
|
|
703
|
-
data = np.linalg.norm(data3D[icut, :, :, :], axis=
|
|
704
|
+
data = np.linalg.norm(data3D[icut, :, :, :], axis=2)
|
|
704
705
|
elif dir == 1:
|
|
705
706
|
if comp != -1:
|
|
706
707
|
data = data3D[:, icut, :, comp]
|
|
707
708
|
else:
|
|
708
|
-
data = np.linalg.norm(data3D[:, icut, :, :], axis=
|
|
709
|
+
data = np.linalg.norm(data3D[:, icut, :, :], axis=2)
|
|
709
710
|
elif dir == 2:
|
|
710
711
|
if comp != -1:
|
|
711
712
|
data = data3D[:, :, icut, comp]
|
|
712
713
|
else:
|
|
713
|
-
data = np.linalg.norm(data3D[:, :, icut, :], axis=
|
|
714
|
+
data = np.linalg.norm(data3D[:, :, icut, :], axis=2)
|
|
714
715
|
else: # moments, dccrg grid
|
|
715
716
|
# vlasov grid, AMR
|
|
716
717
|
if data3D.ndim == 1:
|
|
@@ -797,11 +798,26 @@ def get_axis(axisunit: AxisUnit, plotrange: tuple, sizes: tuple) -> tuple:
|
|
|
797
798
|
return x, y
|
|
798
799
|
|
|
799
800
|
|
|
800
|
-
def _fillinnerBC(data: np.ndarray):
|
|
801
|
+
def _fillinnerBC(data: np.ndarray, meta: Vlsv, var: str, pArgs: PlotArgs, normal: int):
|
|
801
802
|
"""
|
|
802
|
-
Fill sparsity/inner boundary cells with NaN.
|
|
803
|
+
Fill sparsity/inner boundary cells with NaN using density as a mask.
|
|
803
804
|
"""
|
|
804
|
-
|
|
805
|
+
if "/" in var:
|
|
806
|
+
species = var.split("/")[0]
|
|
807
|
+
rho_var = f"{species}/vg_rho"
|
|
808
|
+
else:
|
|
809
|
+
# Default to proton density for field quantities
|
|
810
|
+
rho_var = "proton/vg_rho"
|
|
811
|
+
|
|
812
|
+
if not meta.has_variable(rho_var):
|
|
813
|
+
data[data == 0] = np.nan
|
|
814
|
+
return
|
|
815
|
+
|
|
816
|
+
if normal != -1:
|
|
817
|
+
rho_data = prep2dslice(meta, rho_var, normal, -1, pArgs)
|
|
818
|
+
else:
|
|
819
|
+
rho_data = prep2d(meta, rho_var, -1)
|
|
820
|
+
data[rho_data == 0] = np.nan
|
|
805
821
|
|
|
806
822
|
|
|
807
823
|
def set_colorbar(
|
|
@@ -43,6 +43,7 @@ class Vlsv:
|
|
|
43
43
|
self.celldict = {}
|
|
44
44
|
self.maxamr = -1
|
|
45
45
|
self.vg_indexes_on_fg = np.array([]) # SEE: map_vg_onto_fg(self)
|
|
46
|
+
self.precipitationenergybins = {}
|
|
46
47
|
|
|
47
48
|
self._read_xml_footer()
|
|
48
49
|
|
|
@@ -484,8 +485,8 @@ class Vlsv:
|
|
|
484
485
|
|
|
485
486
|
return lsize
|
|
486
487
|
|
|
488
|
+
nIORanks = self.read_parameter("numWritingRanks") # Int32
|
|
487
489
|
if fgDecomposition is None:
|
|
488
|
-
nIORanks = self.read_parameter("numWritingRanks") # Int32
|
|
489
490
|
fgDecomposition = getDomainDecomposition(bbox, nIORanks)
|
|
490
491
|
|
|
491
492
|
offsetnow = 0
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pyvlasiator
|
|
3
|
+
Version: 0.1.10
|
|
4
|
+
Summary: Python utilities for processing Vlasiator data
|
|
5
|
+
Author-email: Hongyang Zhou <hyzhou@umich.edu>
|
|
6
|
+
Requires-Python: <4.0,>=3.11
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
License-File: LICENSE.md
|
|
9
|
+
Requires-Dist: numpy>=1.25.1
|
|
10
|
+
Provides-Extra: plot
|
|
11
|
+
Requires-Dist: matplotlib<4,>=3.7.2; extra == "plot"
|
|
12
|
+
Provides-Extra: dev
|
|
13
|
+
Requires-Dist: pytest<8,>=7.4.0; extra == "dev"
|
|
14
|
+
Requires-Dist: pytest-benchmark<5,>=4.0.0; extra == "dev"
|
|
15
|
+
Requires-Dist: pytest-cov<5,>=4.1.0; extra == "dev"
|
|
16
|
+
Requires-Dist: requests<3,>=2.31.0; extra == "dev"
|
|
17
|
+
Requires-Dist: jupyter<2,>=1.0.0; extra == "dev"
|
|
18
|
+
Requires-Dist: myst-nb<2,>=1.0.0; extra == "dev"
|
|
19
|
+
Requires-Dist: sphinx-autoapi<4,>=3.0.0; extra == "dev"
|
|
20
|
+
Requires-Dist: sphinx-rtd-theme<2,>=1.2.2; extra == "dev"
|
|
21
|
+
Dynamic: license-file
|
|
22
|
+
|
|
23
|
+
# pyvlasiator
|
|
24
|
+
|
|
25
|
+
<p align="center">
|
|
26
|
+
<a href="https://badge.fury.io/py/pyvlasiator">
|
|
27
|
+
<img src="https://badge.fury.io/py/pyvlasiator.svg" alt="PyPI version" height="18">
|
|
28
|
+
</a>
|
|
29
|
+
<a href="https://github.com/henry2004y/pyvlasiator/actions">
|
|
30
|
+
<img src="https://github.com/henry2004y/pyvlasiator/actions/workflows/CI.yml/badge.svg">
|
|
31
|
+
</a>
|
|
32
|
+
<a href="https://henry2004y.github.io/pyvlasiator/">
|
|
33
|
+
<img src="https://img.shields.io/badge/docs-dev-blue">
|
|
34
|
+
</a>
|
|
35
|
+
<a href="LICENSE">
|
|
36
|
+
<img src="https://img.shields.io/badge/license-MIT-blue">
|
|
37
|
+
</a>
|
|
38
|
+
<a href="https://app.codecov.io/gh/henry2004y/pyvlasiator/">
|
|
39
|
+
<img src="https://img.shields.io/codecov/c/github/henry2004y/pyvlasiator">
|
|
40
|
+
</a>
|
|
41
|
+
</p>
|
|
42
|
+
|
|
43
|
+
Lightweight Python package for processing [Vlasiator](https://github.com/fmihpc/vlasiator) data, alternative to [Analysator](https://github.com/fmihpc/analysator).
|
|
44
|
+
|
|
45
|
+
## Installation
|
|
46
|
+
|
|
47
|
+
`pyvlasiator` can be installed via
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
python -m pip install pyvlasiator
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Usage
|
|
54
|
+
|
|
55
|
+
`pyvlasiator` can be used to process VLSV files generated from Vlasiator.
|
|
56
|
+
|
|
57
|
+
```python
|
|
58
|
+
from pyvlasiator.vlsv import Vlsv
|
|
59
|
+
|
|
60
|
+
file = "test.vlsv"
|
|
61
|
+
meta = Vlsv(file)
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Plotting is supported via Matplotlib. For more detailed usage, please refer to the [documentation](https://henry2004y.github.io/pyvlasiator/).
|
|
65
|
+
|
|
66
|
+
## License
|
|
67
|
+
|
|
68
|
+
`pyvlasiator` was created by Hongyang Zhou. It is licensed under the terms of the MIT license.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
LICENSE.md
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
src/pyvlasiator/__init__.py
|
|
5
|
+
src/pyvlasiator/pyvlasiator.py
|
|
6
|
+
src/pyvlasiator.egg-info/PKG-INFO
|
|
7
|
+
src/pyvlasiator.egg-info/SOURCES.txt
|
|
8
|
+
src/pyvlasiator.egg-info/dependency_links.txt
|
|
9
|
+
src/pyvlasiator.egg-info/requires.txt
|
|
10
|
+
src/pyvlasiator.egg-info/top_level.txt
|
|
11
|
+
src/pyvlasiator/plot/__init__.py
|
|
12
|
+
src/pyvlasiator/plot/plot.py
|
|
13
|
+
src/pyvlasiator/vlsv/__init__.py
|
|
14
|
+
src/pyvlasiator/vlsv/reader.py
|
|
15
|
+
src/pyvlasiator/vlsv/variables.py
|
|
16
|
+
tests/test_pyvlasiator.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
pyvlasiator
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
import requests
|
|
3
|
+
import tarfile
|
|
4
|
+
import os
|
|
5
|
+
import numpy as np
|
|
6
|
+
from pyvlasiator.vlsv import Vlsv
|
|
7
|
+
import pyvlasiator.plot
|
|
8
|
+
import matplotlib as mpl
|
|
9
|
+
import packaging.version
|
|
10
|
+
|
|
11
|
+
filedir = os.path.dirname(__file__)
|
|
12
|
+
|
|
13
|
+
if os.path.isfile(filedir + "/data/bulk.1d.vlsv"):
|
|
14
|
+
pass
|
|
15
|
+
else:
|
|
16
|
+
url = (
|
|
17
|
+
"https://raw.githubusercontent.com/henry2004y/vlsv_data/master/testdata.tar.gz"
|
|
18
|
+
)
|
|
19
|
+
testfiles = url.rsplit("/", 1)[1]
|
|
20
|
+
r = requests.get(url, allow_redirects=True)
|
|
21
|
+
open(testfiles, "wb").write(r.content)
|
|
22
|
+
|
|
23
|
+
path = filedir + "/data"
|
|
24
|
+
|
|
25
|
+
if not os.path.exists(path):
|
|
26
|
+
os.makedirs(path)
|
|
27
|
+
|
|
28
|
+
with tarfile.open(testfiles) as file:
|
|
29
|
+
file.extractall(path)
|
|
30
|
+
os.remove(testfiles)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class TestVlsv:
|
|
34
|
+
dir = "tests/data/"
|
|
35
|
+
files = (dir + "bulk.1d.vlsv", dir + "bulk.2d.vlsv", dir + "bulk.amr.vlsv")
|
|
36
|
+
|
|
37
|
+
def test_load(self):
|
|
38
|
+
meta = Vlsv(self.files[0])
|
|
39
|
+
assert meta.__repr__().startswith("File")
|
|
40
|
+
assert meta.time == 10.0
|
|
41
|
+
|
|
42
|
+
def test_load_error(self):
|
|
43
|
+
with pytest.raises(FileNotFoundError):
|
|
44
|
+
meta = Vlsv("None")
|
|
45
|
+
|
|
46
|
+
def test_read_variable(self):
|
|
47
|
+
meta = Vlsv(self.files[0])
|
|
48
|
+
assert np.array_equal(meta.cellindex, np.arange(9, -1, -1, dtype=np.uint64))
|
|
49
|
+
# unsorted ID
|
|
50
|
+
cellid = meta.read_variable("CellID", sorted=False)
|
|
51
|
+
assert np.array_equal(cellid, np.arange(10, 0, -1, dtype=np.uint64))
|
|
52
|
+
# sorted var by default
|
|
53
|
+
data = meta.read_variable("vg_boundarytype")
|
|
54
|
+
assert np.array_equal(data, np.array([4, 4, 1, 1, 1, 1, 1, 1, 3, 3]))
|
|
55
|
+
# ID finding (noAMR)
|
|
56
|
+
loc = [2.0, 0.0, 0.0]
|
|
57
|
+
id = meta.getcell(loc)
|
|
58
|
+
coords = meta.getcellcoordinates(id)
|
|
59
|
+
assert coords == pytest.approx([3.0, 0.0, 0.0])
|
|
60
|
+
assert meta.read_variable("proton/vg_rho", id) == pytest.approx(1.2288102e0)
|
|
61
|
+
assert meta.read_variable("proton/vg_rho", [id]) == pytest.approx(1.2288102e0)
|
|
62
|
+
# Nearest ID with VDF stored
|
|
63
|
+
assert meta.getnearestcellwithvdf(id) == 5
|
|
64
|
+
|
|
65
|
+
def test_read_vspace(self):
|
|
66
|
+
meta = Vlsv(self.files[0])
|
|
67
|
+
vcellids, vcellf = meta.read_vcells(5)
|
|
68
|
+
V = meta.getvcellcoordinates(vcellids)
|
|
69
|
+
assert V[-1] == pytest.approx((2.45, 1.95, 1.95))
|
|
70
|
+
|
|
71
|
+
def test_read_amr(self):
|
|
72
|
+
metaAMR = Vlsv(self.files[2])
|
|
73
|
+
assert metaAMR.maxamr == 2
|
|
74
|
+
# AMR data reading, DCCRG grid
|
|
75
|
+
sliceoffset = abs(metaAMR.coordmin[1])
|
|
76
|
+
idlist, indexlist = metaAMR.getslicecell(
|
|
77
|
+
sliceoffset, 1, metaAMR.coordmin[1], metaAMR.coordmax[1]
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
# ID finding (AMR)
|
|
81
|
+
loc = [2.5e6, 2.5e6, 2.5e6] # exact cell center
|
|
82
|
+
id = metaAMR.getcell(loc)
|
|
83
|
+
assert metaAMR.getcellcoordinates(id) == pytest.approx(loc)
|
|
84
|
+
|
|
85
|
+
data = metaAMR.read_variable("proton/vg_rho")
|
|
86
|
+
dataslice = metaAMR.refineslice(idlist, data[indexlist], 1)
|
|
87
|
+
assert np.sum(dataslice) == pytest.approx(7.6903526e8)
|
|
88
|
+
|
|
89
|
+
def test_read_fg_variable(self):
|
|
90
|
+
metaAMR = Vlsv(self.files[2])
|
|
91
|
+
data = metaAMR.read_variable("fg_e")
|
|
92
|
+
ncells, namr = metaAMR.ncells, metaAMR.maxamr
|
|
93
|
+
assert data.shape == (
|
|
94
|
+
ncells[0] * namr**2,
|
|
95
|
+
ncells[1] * namr**2,
|
|
96
|
+
ncells[2] * namr**2,
|
|
97
|
+
3,
|
|
98
|
+
) and data[4, 0, 0, :] == pytest.approx([7.603512e-07, 2e-04, -2e-04])
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
class TestPlot:
|
|
102
|
+
dir = "tests/data/"
|
|
103
|
+
files = (dir + "bulk.1d.vlsv", dir + "bulk.2d.vlsv", dir + "bulk.amr.vlsv")
|
|
104
|
+
mpl.use("Agg")
|
|
105
|
+
version_str = mpl.__version__
|
|
106
|
+
version = packaging.version.parse(version_str)
|
|
107
|
+
|
|
108
|
+
def test_1d_plot(self):
|
|
109
|
+
meta = Vlsv(self.files[0])
|
|
110
|
+
v = meta.plot("proton/vg_rho")[0].get_ydata()
|
|
111
|
+
assert np.array_equal(v, meta.read_variable("proton/vg_rho"))
|
|
112
|
+
v = meta.scatter("proton/vg_rho").get_offsets()
|
|
113
|
+
assert np.array_equal(v[0].data[0], -10.0)
|
|
114
|
+
|
|
115
|
+
def test_2d_plot(self):
|
|
116
|
+
meta = Vlsv(self.files[1])
|
|
117
|
+
v = meta.pcolormesh("proton/vg_rho").get_array()
|
|
118
|
+
assert v[99, 60] == pytest.approx(999535.8) and v.data.size == 6300
|
|
119
|
+
v = meta.pcolormesh(
|
|
120
|
+
"proton/vg_rho", axisunit=pyvlasiator.plot.AxisUnit.SI
|
|
121
|
+
).get_array()
|
|
122
|
+
assert v[99, 60] == pytest.approx(999535.8) and v.data.size == 6300
|
|
123
|
+
v = meta.contour("proton/vg_rho").get_array()
|
|
124
|
+
assert v[-3] == 4000000.0
|
|
125
|
+
v = meta.contourf("proton/vg_rho").get_array()
|
|
126
|
+
assert v[-3] == 3600000.0
|
|
127
|
+
v = meta.contourf(
|
|
128
|
+
"proton/vg_rho", colorscale=pyvlasiator.plot.ColorScale.Log
|
|
129
|
+
).get_array()
|
|
130
|
+
assert v[-3] == 3600000.0
|
|
131
|
+
v = meta.pcolormesh("vg_b_vol").get_array()
|
|
132
|
+
assert v[0, 1] == pytest.approx(3.0051286e-09)
|
|
133
|
+
v = meta.pcolormesh(
|
|
134
|
+
"vg_b_vol", comp=1, colorscale=pyvlasiator.plot.ColorScale.SymLog
|
|
135
|
+
).get_array()
|
|
136
|
+
assert v[0, 1] == pytest.approx(-9.284285146238247e-12)
|
|
137
|
+
v = meta.pcolormesh("fg_b", comp=0).get_array()
|
|
138
|
+
assert v[99, 60] == pytest.approx(-2.999047e-09) and v.data.size == 6300
|
|
139
|
+
|
|
140
|
+
def test_3d_amr_slice(self):
|
|
141
|
+
meta = Vlsv(self.files[2])
|
|
142
|
+
v = meta.pcolormesh("proton/vg_rho").get_array()
|
|
143
|
+
assert v[15, 31] == pytest.approx(1.0483886e6) and v.data.size == 512
|
|
144
|
+
|
|
145
|
+
def test_stream_plot(self):
|
|
146
|
+
meta = Vlsv(self.files[1])
|
|
147
|
+
p = meta.streamplot("proton/vg_v", comp="xy")
|
|
148
|
+
assert type(p) == mpl.streamplot.StreamplotSet
|
|
149
|
+
|
|
150
|
+
def test_vdf_plot(self):
|
|
151
|
+
meta = Vlsv(self.files[0])
|
|
152
|
+
loc = [2.0, 0.0, 0.0]
|
|
153
|
+
v = meta.vdfslice(loc, verbose=True).get_array()
|
|
154
|
+
assert v[19, 25] == 238.24398578141802
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
def load(files):
|
|
158
|
+
"""
|
|
159
|
+
Benchmarking VLSV loading.
|
|
160
|
+
"""
|
|
161
|
+
meta = Vlsv(files[0])
|
|
162
|
+
meta = Vlsv(files[1])
|
|
163
|
+
meta = Vlsv(files[2])
|
|
164
|
+
return meta
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
def test_load(benchmark):
|
|
168
|
+
dir = "tests/data/"
|
|
169
|
+
files = (dir + "bulk.1d.vlsv", dir + "bulk.2d.vlsv", dir + "bulk.amr.vlsv")
|
|
170
|
+
result = benchmark(load, files)
|
|
171
|
+
|
|
172
|
+
assert type(result) == Vlsv
|
pyvlasiator-0.1.7/pyproject.toml
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
[tool.poetry]
|
|
2
|
-
name = "pyvlasiator"
|
|
3
|
-
version = "0.1.7"
|
|
4
|
-
description = "Python utilities for processing Vlasiator data"
|
|
5
|
-
authors = ["Hongyang Zhou <hyzhou@umich.edu>"]
|
|
6
|
-
readme = "README.md"
|
|
7
|
-
|
|
8
|
-
[tool.poetry.dependencies]
|
|
9
|
-
python = "^3.11"
|
|
10
|
-
numpy = "^1.25.1"
|
|
11
|
-
matplotlib = {version = "^3.7.2", optional = true}
|
|
12
|
-
|
|
13
|
-
[tool.poetry.extras]
|
|
14
|
-
plot = ["matplotlib"]
|
|
15
|
-
|
|
16
|
-
[tool.poetry.group.dev.dependencies]
|
|
17
|
-
pytest = "^7.4.0"
|
|
18
|
-
pytest-benchmark = "^4.0.0"
|
|
19
|
-
pytest-cov = "^4.1.0"
|
|
20
|
-
requests = "^2.31.0"
|
|
21
|
-
jupyter = "^1.0.0"
|
|
22
|
-
myst-nb = "^1.0.0"
|
|
23
|
-
sphinx-autoapi = "^3.0.0"
|
|
24
|
-
sphinx-rtd-theme = "^1.2.2"
|
|
25
|
-
|
|
26
|
-
[build-system]
|
|
27
|
-
requires = ["poetry-core"]
|
|
28
|
-
build-backend = "poetry.core.masonry.api"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|