pyvlasiator 0.1.0__py3-none-any.whl
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/__init__.py +0 -0
- pyvlasiator/plot/__init__.py +14 -0
- pyvlasiator/plot/plot.py +1115 -0
- pyvlasiator/pyvlasiator.py +2 -0
- pyvlasiator/vlsv/__init__.py +7 -0
- pyvlasiator/vlsv/reader.py +959 -0
- pyvlasiator/vlsv/variables.py +187 -0
- pyvlasiator-0.1.0.dist-info/LICENSE.md +21 -0
- pyvlasiator-0.1.0.dist-info/METADATA +61 -0
- pyvlasiator-0.1.0.dist-info/RECORD +11 -0
- pyvlasiator-0.1.0.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
# Predefined physical constants
|
|
2
|
+
|
|
3
|
+
from math import pi
|
|
4
|
+
|
|
5
|
+
QE = -1.60217662e-19 # electron charge, [C]
|
|
6
|
+
ME = 9.10938356e-31 # electron mass, [kg]
|
|
7
|
+
QI = 1.60217662e-19 # proton mass, [C]
|
|
8
|
+
MI = 1.673557546e-27 # proton mass, [kg]
|
|
9
|
+
C = 299792458.0 # speed of light, [m/s]
|
|
10
|
+
MU0 = 4 * pi * 1e-7 # Vacuum permeability, [H/m]
|
|
11
|
+
EPSILON0 = 1 / (C**2 * MU0) # Vacuum permittivity, [F/m]
|
|
12
|
+
KB = 1.38064852e-23 # Boltzmann constant, [m²kg/(s²K)]
|
|
13
|
+
RE = 6.371e6 # Earth radius, [m]
|
|
14
|
+
|
|
15
|
+
speciesdict = {
|
|
16
|
+
"avgs": "p",
|
|
17
|
+
"proton": "p",
|
|
18
|
+
"helium": "He",
|
|
19
|
+
"oxygen": "O",
|
|
20
|
+
"electron": "e",
|
|
21
|
+
}
|
|
22
|
+
speciesamu = {
|
|
23
|
+
"avgs": 1,
|
|
24
|
+
"proton": 1,
|
|
25
|
+
"helium": 4,
|
|
26
|
+
"oxygen": 16,
|
|
27
|
+
"electron": 5.4461702e-4,
|
|
28
|
+
}
|
|
29
|
+
speciescharge = {
|
|
30
|
+
"avgs": 1,
|
|
31
|
+
"proton": 1,
|
|
32
|
+
"helium": 2,
|
|
33
|
+
"oxygen": 1,
|
|
34
|
+
"electron": -1,
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
# Define units, LaTeX markup names, and LaTeX markup units for intrinsic values
|
|
38
|
+
units_predefined = {
|
|
39
|
+
"Rhom": ("kg/m3", r"$\rho_m$", r"$\mathrm{kg}\,\mathrm{m}^{-3}$"),
|
|
40
|
+
"rhoq": ("C/m3", r"$\rho_q$", r"$\mathrm{C}\,\mathrm{m}^{-3}$"),
|
|
41
|
+
"rho": ("1/m3", r"$n_\mathrm{p}$", r"$\mathrm{m}^{-3}$"),
|
|
42
|
+
"rho_v": ("1/m2s", r"$\Gamma_\mathrm{p}$", r"$\mathrm{m}^{-2}$s"),
|
|
43
|
+
"v": ("m/s", r"$V$", r"$\mathrm{m}\,\mathrm{s}^{-1}$"),
|
|
44
|
+
"b": ("T", r"$B$", "T"),
|
|
45
|
+
"b_vor": ("T", r"$B_\mathrm{vol}$", "T"),
|
|
46
|
+
"background_b": ("T", r"$B_\mathrm{bg}$", "T"),
|
|
47
|
+
"perturbed_b": ("T", r"$B_\mathrm{pert}$", "T"),
|
|
48
|
+
"bgb": ("T", r"$B_\mathrm{bg}$", "T"),
|
|
49
|
+
"perb": ("T", r"B_\mathrm{pert}$", "T"),
|
|
50
|
+
"perb_vor": ("T", r"B_\mathrm{vol,pert}$", "T"),
|
|
51
|
+
"e": ("V/m", r"$E$", r"$\mathrm{V}\,\mathrm{m}^{-1}$"),
|
|
52
|
+
"e_vor": ("V/m", r"$E_\mathrm{vol}$", r"$\mathrm{V}\,\mathrm{m}^{-1}$"),
|
|
53
|
+
"exhall_000_100": (
|
|
54
|
+
"V/m",
|
|
55
|
+
r"$E_\mathrm{Hall,000,100}$",
|
|
56
|
+
r"$\mathrm{V}\,\mathrm{m}^{-1}$",
|
|
57
|
+
),
|
|
58
|
+
"exhall_001_101": (
|
|
59
|
+
"V/m",
|
|
60
|
+
r"$E_\mathrm{Hall,001,101}$",
|
|
61
|
+
r"$\mathrm{V}\,\mathrm{m}^{-1}$",
|
|
62
|
+
),
|
|
63
|
+
"exhall_010_110": (
|
|
64
|
+
"V/m",
|
|
65
|
+
r"$E_\mathrm{Hall,010,110}$",
|
|
66
|
+
r"$\mathrm{V}\,\mathrm{m}^{-1}$",
|
|
67
|
+
),
|
|
68
|
+
"exhall_011_111": (
|
|
69
|
+
"V/m",
|
|
70
|
+
r"$E_\mathrm{Hall,011,111}$",
|
|
71
|
+
r"$\mathrm{V}\,\mathrm{m}^{-1}$",
|
|
72
|
+
),
|
|
73
|
+
"eyhall_000_010": (
|
|
74
|
+
"V/m",
|
|
75
|
+
r"$E_\mathrm{Hall,000,010}$",
|
|
76
|
+
r"$\mathrm{V}\,\mathrm{m}^{-1}$",
|
|
77
|
+
),
|
|
78
|
+
"eyhall_001_011": (
|
|
79
|
+
"V/m",
|
|
80
|
+
r"$E_\mathrm{Hall,001,011}$",
|
|
81
|
+
r"$\mathrm{V}\,\mathrm{m}^{-1}$",
|
|
82
|
+
),
|
|
83
|
+
"eyhall_100_110": (
|
|
84
|
+
"V/m",
|
|
85
|
+
r"$E_\mathrm{Hall,100,110}$",
|
|
86
|
+
r"$\mathrm{V}\,\mathrm{m}^{-1}$",
|
|
87
|
+
),
|
|
88
|
+
"eyhall_101_111": (
|
|
89
|
+
"V/m",
|
|
90
|
+
r"$E_\mathrm{Hall,101,111}$",
|
|
91
|
+
r"$\mathrm{V}\,\mathrm{m}^{-1}$",
|
|
92
|
+
),
|
|
93
|
+
"ezhall_000_001": (
|
|
94
|
+
"V/m",
|
|
95
|
+
r"$E_\mathrm{Hall,000,001}$",
|
|
96
|
+
r"$\mathrm{V}\,\mathrm{m}^{-1}$",
|
|
97
|
+
),
|
|
98
|
+
"ezhall_010_011": (
|
|
99
|
+
"V/m",
|
|
100
|
+
r"$E_\mathrm{Hall,010,011}$",
|
|
101
|
+
r"$\mathrm{V}\,\mathrm{m}^{-1}$",
|
|
102
|
+
),
|
|
103
|
+
"ezhall_100_101": (
|
|
104
|
+
"V/m",
|
|
105
|
+
r"$E_\mathrm{Hall,100,101}$",
|
|
106
|
+
r"$\mathrm{V}\,\mathrm{m}^{-1}$",
|
|
107
|
+
),
|
|
108
|
+
"ezhall_110_111": (
|
|
109
|
+
"V/m",
|
|
110
|
+
r"$E_\mathrm{Hall,110,111}$",
|
|
111
|
+
r"$\mathrm{V}\,\mathrm{m}^{-1}$",
|
|
112
|
+
),
|
|
113
|
+
"pressure": ("Pa", r"$P$", "Pa"),
|
|
114
|
+
"pressure_dt2": ("Pa", r"$P_{\mathrm{d}t/2}}$", "Pa"),
|
|
115
|
+
"pressure_r": ("Pa", r"$P_r$", "Pa"),
|
|
116
|
+
"pressure_v": ("Pa", r"$P_v$", "Pa"),
|
|
117
|
+
"ptensordiagonar": ("Pa", r"$\mathcal{P}_\mathrm{diag}$", "Pa"),
|
|
118
|
+
"ptensoroffdiagonar": ("Pa", r"$\mathcal{P}_\mathrm{off-diag}$", "Pa"),
|
|
119
|
+
"minvalue": ("s3/m6", r"$f_\mathrm{Min}$", r"$\mathrm{m}^{-6}\,\mathrm{s}^{3}$"),
|
|
120
|
+
"effectivesparsitythreshold": (
|
|
121
|
+
"s3/m6",
|
|
122
|
+
r"$f_\mathrm{Min}$",
|
|
123
|
+
r"$\mathrm{m}^{-6}\,\mathrm{s}^{3}$",
|
|
124
|
+
),
|
|
125
|
+
"rho_loss_adjust": (
|
|
126
|
+
"1/m3",
|
|
127
|
+
r"$\Delta_\mathrm{loss} n_\mathrm{p}$",
|
|
128
|
+
r"$\mathrm{m}^{-3}$",
|
|
129
|
+
),
|
|
130
|
+
"energydensity": (
|
|
131
|
+
"eV/cm3",
|
|
132
|
+
r"$\rho_{\mathrm{energy}}$",
|
|
133
|
+
r"$\mathrm{eV}\,\mathrm{cm}^{-3}$",
|
|
134
|
+
),
|
|
135
|
+
"precipitationdiffflux": (
|
|
136
|
+
"1/(cm2 sr s eV)",
|
|
137
|
+
r"$\Delta F_\mathrm{precipitation}$",
|
|
138
|
+
r"$\mathrm{cm}^{-2} \,\mathrm{sr}^{-1}\,\mathrm{s}^{-1}\,\mathrm{eV}^{-1}$",
|
|
139
|
+
),
|
|
140
|
+
"T": ("K", r"$T$", "K"),
|
|
141
|
+
"Tpar": ("K", r"$T$", "K"),
|
|
142
|
+
"Tperp": ("K", r"$T$", "K"),
|
|
143
|
+
"Panisotropy": ("", r"$P_\perp / P_\parallel$", ""),
|
|
144
|
+
"Tanisotropy": ("", r"$T_\perp / T_\parallel$", ""),
|
|
145
|
+
"VS": ("m/s", r"$V_S$", r"$\mathrm{m}\,\mathrm{s}^{-1}$"),
|
|
146
|
+
"VA": ("m/s", r"$V_A$", r"$\mathrm{m}\,\mathrm{s}^{-1}$"),
|
|
147
|
+
"MS": ("", r"$M_S$", ""),
|
|
148
|
+
"MA": ("", r"$M_A$", ""),
|
|
149
|
+
"Ppar": ("Pa", r"$P_\parallel$", "Pa"),
|
|
150
|
+
"Pperp": ("Pa", r"$P_\perp$", "Pa"),
|
|
151
|
+
"Beta": ("", r"$\beta$", ""),
|
|
152
|
+
"BetaStar": ("", r"$\beta^\ast$", ""),
|
|
153
|
+
"Gyroperiod": ("s", r"$T_{gyro}$", "s"),
|
|
154
|
+
"PlasmaPeriod": ("s", r"$T_{plasma}$", "s"),
|
|
155
|
+
"Gyrofrequency": ("rad/s", r"$\omega_{g}$", r"\mathrm{rad}/\mathrm{s}"),
|
|
156
|
+
"Omegap": ("rad/s", r"$\omega_{p}$", r"\mathrm{rad}/\mathrm{s}"),
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
def pass_op(variable):
|
|
161
|
+
# do nothing
|
|
162
|
+
return variable
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
def magnitude(variable):
|
|
166
|
+
return np.linalg.norm(np.asarray(variable), axis=-1)
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
def sumv(variable):
|
|
170
|
+
# Note: this is used to sum over multipops, thus the summing axis is zero
|
|
171
|
+
if np.ndim(variable) > 3:
|
|
172
|
+
print("Error: Number of dimensions is too large")
|
|
173
|
+
return
|
|
174
|
+
else:
|
|
175
|
+
# First dimension: populations
|
|
176
|
+
# Second dimension: cells
|
|
177
|
+
# Third dimension: components
|
|
178
|
+
return np.sum(np.array(variable), axis=0)
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
# Dict of operators. The user can apply these to any variable,
|
|
182
|
+
# including more general datareducers. Can only be used to reduce one
|
|
183
|
+
# variable at a time
|
|
184
|
+
data_operators = {}
|
|
185
|
+
data_operators["pass"] = pass_op
|
|
186
|
+
data_operators["magnitude"] = magnitude
|
|
187
|
+
data_operators["sum"] = sumv
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Hongyang Zhou <hyzhou@umich.edu> and contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: pyvlasiator
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary:
|
|
5
|
+
Author: Hongyang Zhou
|
|
6
|
+
Author-email: hyzhou@umich.edu
|
|
7
|
+
Requires-Python: >=3.11,<4.0
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
12
|
+
Provides-Extra: plot
|
|
13
|
+
Requires-Dist: matplotlib (>=3.7.2,<4.0.0) ; extra == "plot"
|
|
14
|
+
Requires-Dist: numpy (>=1.25.1,<2.0.0)
|
|
15
|
+
Requires-Dist: pytest-benchmark (>=4.0.0,<5.0.0)
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
|
|
18
|
+
# pyvlasiator
|
|
19
|
+
|
|
20
|
+
<p align="center">
|
|
21
|
+
<a href="https://github.com/henry2004y/pyvlasiator/actions">
|
|
22
|
+
<img src="https://github.com/henry2004y/pyvlasiator/actions/workflows/CI.yml/badge.svg">
|
|
23
|
+
</a>
|
|
24
|
+
<a href="https://henry2004y.github.io/pyvlasiator/">
|
|
25
|
+
<img src="https://img.shields.io/badge/docs-dev-blue">
|
|
26
|
+
</a>
|
|
27
|
+
<a href="LICENSE">
|
|
28
|
+
<img src="https://img.shields.io/badge/license-MIT-blue">
|
|
29
|
+
</a>
|
|
30
|
+
<a href="https://app.codecov.io/gh/henry2004y/pyvlasiator/">
|
|
31
|
+
<img src="https://img.shields.io/codecov/c/github/henry2004y/pyvlasiator">
|
|
32
|
+
</a>
|
|
33
|
+
</p>
|
|
34
|
+
|
|
35
|
+
Lightweight Python package for processing Vlasiator data.
|
|
36
|
+
|
|
37
|
+
## Installation
|
|
38
|
+
|
|
39
|
+
`pyvlasiator` can be installed via
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
$ pip install pyvlasiator
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Usage
|
|
46
|
+
|
|
47
|
+
`pyvlasiator` can be used to process VLSV files generated from Vlasiator.
|
|
48
|
+
|
|
49
|
+
```python
|
|
50
|
+
from pyvlasiator.vlsv import Vlsv
|
|
51
|
+
|
|
52
|
+
file = "test.vlsv"
|
|
53
|
+
meta = Vlsv(file)
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Plotting is supported via Matplotlib. For more detailed usage, please refer to the [documentation](https://henry2004y.github.io/pyvlasiator/).
|
|
57
|
+
|
|
58
|
+
## License
|
|
59
|
+
|
|
60
|
+
`pyvlasiator` was created by Hongyang Zhou. It is licensed under the terms of the MIT license.
|
|
61
|
+
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
pyvlasiator/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
pyvlasiator/plot/__init__.py,sha256=VFZ3mB3iGHqqDVpsyMGLDUov8FiDydMdAhvtbnTvWtM,235
|
|
3
|
+
pyvlasiator/plot/plot.py,sha256=RZqy5zFRds0FVpbLlbAugYBnHKIMdflcuWRluTXF1nQ,34012
|
|
4
|
+
pyvlasiator/pyvlasiator.py,sha256=11dp6PsBPHacbGHtzI7mdS8NreiBNYuwbI5cx_5bfDw,62
|
|
5
|
+
pyvlasiator/vlsv/__init__.py,sha256=T1_Znxt_H7XL-Al5IG0C_CKBw_u2VkeVQ3O1INH29po,81
|
|
6
|
+
pyvlasiator/vlsv/reader.py,sha256=MdnmJCphhGJqLNYxxfv3ku1plyZ9p_jCeGLFejStTh8,35046
|
|
7
|
+
pyvlasiator/vlsv/variables.py,sha256=JTVGUBTs8CX7aonW_vVNKNca3hNsVsr3DXL7NesqeTo,5987
|
|
8
|
+
pyvlasiator-0.1.0.dist-info/LICENSE.md,sha256=UbZmGbnA73ReemkiNPRNfqgGtpPwiGFJiOZo0gxiP_o,1125
|
|
9
|
+
pyvlasiator-0.1.0.dist-info/METADATA,sha256=U9Ni1vF5XdTr86gdUSixjVj_fAoA8fcyjFaWbezjQWA,1697
|
|
10
|
+
pyvlasiator-0.1.0.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
|
11
|
+
pyvlasiator-0.1.0.dist-info/RECORD,,
|