1
1
"""Interface for running and creating input for the MSIS models."""
2
2
3
3
import threading
4
+ from enum import IntEnum
4
5
from pathlib import Path
5
6
6
7
import numpy as np
21
22
lib ._lock = threading .Lock ()
22
23
23
24
25
+ class Variable (IntEnum ):
26
+ """
27
+ Enumeration of output data indices for the pymsis run calls.
28
+
29
+ This can be used to access the data from the output arrays instead of having
30
+ to remember the order of the output. For example,
31
+ ``output_array[..., Variable.MASS_DENSITY]``.
32
+
33
+ Attributes
34
+ ----------
35
+ MASS_DENSITY
36
+ Index of total mass density (kg/m3).
37
+ N2
38
+ Index of N2 number density (m-3).
39
+ O2
40
+ Index of O2 number density (m-3).
41
+ O
42
+ Index of O number density (m-3).
43
+ HE
44
+ Index of He number density (m-3).
45
+ H
46
+ Index of H number density (m-3).
47
+ AR
48
+ Index of Ar number density (m-3).
49
+ N
50
+ Index of N number density (m-3).
51
+ ANOMALOUS_O
52
+ Index of anomalous oxygen number density (m-3).
53
+ NO
54
+ Index of NO number density (m-3).
55
+ TEMPERATURE
56
+ Index of temperature (K).
57
+
58
+ """
59
+
60
+ MASS_DENSITY = 0
61
+ N2 = 1
62
+ O2 = 2
63
+ O = 3 # noqa: E741 (ambiguous name)
64
+ HE = 4
65
+ H = 5
66
+ AR = 6
67
+ N = 7
68
+ ANOMALOUS_O = 8
69
+ NO = 9
70
+ TEMPERATURE = 10
71
+
72
+
24
73
def run (
25
74
dates : npt .ArrayLike ,
26
75
lons : npt .ArrayLike ,
@@ -35,13 +84,25 @@ def run(
35
84
** kwargs : dict ,
36
85
) -> npt .NDArray :
37
86
"""
38
- Call MSIS looping over all possible inputs.
39
-
40
- If ndates is the same as nlons, nlats, and nalts, then a flattened
41
- multi-point input array is assumed. Otherwise, the data
42
- will be expanded in a grid-like fashion. The possible
43
- return shapes are therefore (ndates, 11) and
44
- (ndates, nlons, nlats, nalts, 11).
87
+ Call MSIS to calculate the atmosphere at the provided input points.
88
+
89
+ **Satellite Fly-Through Mode:**
90
+ If ndates is the same length as nlons, nlats, and nalts, then the
91
+ input arrays are assumed to be aligned and no regridding is done.
92
+ This is equivalent to a satellite fly-through, producing an output
93
+ return shape of (ndates, 11).
94
+
95
+ **Grid Mode:**
96
+ If the input arrays have different lengths the data will be expanded
97
+ in a grid-like fashion broadcasting to a larger shape than the input
98
+ arrays. This is equivalent to a full atmosphere simulation where you
99
+ want to calculate the data at every grid point. The output shape will
100
+ be 5D (ndates, nlons, nlats, nalts, 11), with potentially single element
101
+ dimensions if you have a single date, lon, lat, or alt.
102
+
103
+ The output array can be indexed with the :class:`~.Variable` enum
104
+ for easier access. ``output_array[..., Variable.MASS_DENSITY]``
105
+ returns the total mass density.
45
106
46
107
Parameters
47
108
----------
@@ -58,7 +119,7 @@ def run(
58
119
f107as : ArrayLike, optional
59
120
F10.7 running 81-day average centered on the given date(s)
60
121
aps : ArrayLike, optional
61
- | Ap for the given date(s), (1-6 only used if `geomagnetic_activity=-1`)
122
+ | Ap for the given date(s), (1-6 only used if `` geomagnetic_activity=-1` `)
62
123
| (0) Daily Ap
63
124
| (1) 3 hr ap index for current time
64
125
| (2) 3 hr ap index for 3 hrs before current time
@@ -75,6 +136,8 @@ def run(
75
136
MSIS version number, one of (0, 2.0, 2.1).
76
137
**kwargs : dict
77
138
Single options for the switches can be defined through keyword arguments.
139
+ For example, run(..., geomagnetic_activity=-1) will set the geomagnetic
140
+ activity switch to -1 (storm-time ap mode).
78
141
79
142
Returns
80
143
-------
0 commit comments