Python wrapper¶
A Python wrapper has been developed and released to be able to make some quick plots and take a look at the results easily.
It consists on calling a compiled Fortran program, so the performance is far from good. Take that into account when using this Python wrapper.
Installation of the Python package¶
System requirements (same as Fortran modules + the python part):
Python >=3.6
python-pip
gfortran
libnetcdff (more info at https://www.unidata.ucar.edu/software/netcdf/docs-fortran/)
To install the package, go to src/swami and execute in bash make_wrapper.sh. It will generate a swami.x executable.
If you are using Ubuntu 18.04 64bits, the executable included in the distributed version should work.
Once that is done, install the python package in a virtual environment or in your preferred python distribution.
python3 setup.py sdist
pip install swami-1.0.tar.gz
Python interface¶
- class swami.MCMOutput(dens, temp, wmm, d_H, d_He, d_O, d_N2, d_O2, d_N, tinf, dens_unc, dens_std, temp_std, xwind, ywind, xwind_std, ywind_std, alti, lati, longi, loct, doy, f107, f107m, kp1, kp2)[source]¶
- dens: float¶
Alias for field number 0
- temp: float¶
Alias for field number 1
- wmm: float¶
Alias for field number 2
- d_H: float¶
Alias for field number 3
- d_He: float¶
Alias for field number 4
- d_O: float¶
Alias for field number 5
- d_N2: float¶
Alias for field number 6
- d_O2: float¶
Alias for field number 7
- d_N: float¶
Alias for field number 8
- tinf: float¶
Alias for field number 9
- dens_unc: float¶
Alias for field number 10
- dens_std: float¶
Alias for field number 11
- temp_std: float¶
Alias for field number 12
- xwind: float¶
Alias for field number 13
- ywind: float¶
Alias for field number 14
- xwind_std: float¶
Alias for field number 15
- ywind_std: float¶
Alias for field number 16
- alti: float¶
Alias for field number 17
- lati: float¶
Alias for field number 18
- longi: float¶
Alias for field number 19
- loct: float¶
Alias for field number 20
- doy: float¶
Alias for field number 21
- f107: float¶
Alias for field number 22
- f107m: float¶
Alias for field number 23
- kp1: float¶
Alias for field number 24
- kp2: float¶
Alias for field number 25
- class swami.MCM(exec_swami: Optional[os.PathLike] = None, path_to_data: Optional[os.PathLike] = None)[source]¶
MCM Model wrapper.
- Parameters
exec_swami (os.PathLike, optional) – Path to the executable. Defaults to the one included.
path_to_data (os.PathLike, optional) – Path to the data. Defaults to the included package.
- run(altitude: float, day_of_year: float, local_time: float, latitude: float, longitude: float, f107: float, f107m: float, kp1: float, kp2: float, get_uncertainty: bool = False, get_winds: bool = False) swami.MCMOutput [source]¶
Run the model
Returns a MCMOutput object with the results as attributes.
- Parameters
altitude (float) – Altitude in km
day_of_year (float) – Day of the year [0-366]
local_time (float) – Local time, h [0-24]
latitude (float) – Latitude, deg [-90 to 90]
longitude (float) – Longitude, deg [0-360]
f107 (float) – F10.7, instantaneous flux at (t - 24hr)
f107m (float) – F10.7, average of the last 81 days
kp1 (float) – Kp, delayed by 3 hours
kp2 (float) – Kp, mean of previous 24 hours
get_uncertainty (bool, optional) – Uncertainties will be returned. Defaults to False.
get_winds (bool, optional) – Winds will be returned. Defaults to False.
- Returns
NamedTuple with the results
- Return type