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):

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.SwamiModel(model: Optional[str] = None, exec_swami: Optional[os.PathLike] = None, path_to_data: Optional[os.PathLike] = None)[source]

SWAMI Model wrapper. Includes MCM, DTM2020 and UM

Parameters
  • model (str, optional) – Model to use. Defaults to MCM. Valid values are: MCM, DTM2020, UM

  • 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)[source]

Run the model

Returns a dictionary with keys ‘MCM’, ‘DTM2020’ or ‘UM’, which is another dictionary with ‘temp’, ‘dens’, etc. Also, ‘_input’ is another subdictionary including the input parameters.

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

  • f107m (float) – F10.7 averaged

  • kp1 (float) – Kp

  • kp2 (float) – Kp

  • get_uncertainty (bool, optional) – It uncertainties should be returned. Defaults to False.

Returns

Dictionary with values per model

Return type

dict