Skip to content

Python wrapper to run, read, and plot the SAMI2 ionospheric model

License

Notifications You must be signed in to change notification settings

JonathonMSmith/sami2py

 
 

sami2py: sami2py is another model of the ionosphere python style

docs
tests

Overview

Sami2py is a python module that runs the SAMI2 model, as well as archives, loads and plots the resulting modeled values. SAMI2 is a model developed by the Naval Research Laboratory to simulate the motions of plasma in a 2D ionospheric environment along a dipole magnetic field [Huba et al, 2000]. SAMI2 solves for the chemical and dynamical evolution of seven ion species in this environment (H+, He+, N+, O+, N2+, NO+, and O2+).

The implementation used here includes several added options to the original release of SAMI2. A full list is included in https://sami2py.readthedocs.io/en/latest/modifications.html, but several of these include:
  • The ability to scale the neutral atmosphere in which the ions form through direct modification of the exospheric neutral temperature for extreme solar minimum conditions, as discussed by Emmert et al [2010].
  • The ability to input custom ExB drifts as a Fourier series.

This implementation is based on the matlab version used in Klenzing et al [2013].

Installation

First, checkout the repository:

git clone https://github.com/sami2py/sami2py.git

Change directories into the repository folder and run the setup.py file. For a local install use the "--user" flag after "install".

cd sami2py
python setup.py install

If something has gone wrong, you may be prompted to manually install the fortran executables.

make -C sami2py/fortran compile

or, on windows,

make -C sami2py\fortran compile

Note that you will need a fortran compiler (gfortran is the default setup) and make installed on your system. For more information, please refer to the documentation.

Example

In iPython, run:

import sami2py

If this is your first import of sami2py, it will remind you to set the top level directory that will hold the model output. This should be a string containing the path to the directory you want to store the data in, such as path='/Users/me/data/sami2py' or path='C:\home\data'. This should be outside the main code directory, so model output files are not confused with model inputs or source code. If you are using Git, it will also ensure that Git does not try to store your local code runs within the repository.

sami2py.utils.set_archive_dir(path=path)

sami2py will raise an error if this is not done before trying to run the model.

sami2py.run_model(tag='run_name', lon=0, year=2012, day=210)

Note that the sami2 model runs for 24 hours to clear transients, then begins to output data.

Now load the resultant data:

ModelRun = sami2py.Model(tag='run_name', lon=0, year=2012, day=210)

Plotting

Currently, sami2py contains a basic plotting module, designed for a quick check of ion density.

After loading a model as above, a quick-look figure can be generated by

fig = ModelRun.plot_lat_alt()

which shows the O:sup`+`density for the initial time step. Additional time steps can be plotted by using the time_step keyword, while other ions can be specified with the species keyword (see docstring).

fig = ModelRun.plot_lat_alt(time_step=10, species=1)

How to Cite

When referring to this software package, please cite the original paper by Huba et al [2000] https://doi.org/10.1029/2000JA000035 as well as the package by Klenzing et al [2019] https://doi.org/10.5281/zenodo.2875799. Note that this doi will always point to the latest version of the code. The specific version doi can be found at the top of this page.

Additionally, please include the following text in the acknowledgements: "This work uses the SAMI2 ionosphere model written and developed by the Naval Research Laboratory."

References

  • Huba, J.D., G. Joyce, and J.A. Fedder, Sami2 is Another Model of the Ionosphere (SAMI2): A new low‐latitude ionosphere model, J. Geophys. Res., 105, Pages 23035-23053, https://doi.org/10.1029/2000JA000035, 2000.
  • Emmert, J.T., J.L. Lean, and J.M. Picone, Record‐low thermospheric density during the 2008 solar minimum, Geophys. Res. Lett., 37, https://doi.org/10.1029/2010GL043671, 2010.
  • Klenzing, J., A. G. Burrell, R. A. Heelis, J. D. Huba, R. Pfaff, and F. Simões, Exploring the role of ionospheric drivers during the extreme solar minimum of 2008, Ann. Geophys., 31, 2147-2156, https://doi.org/10.5194/angeo-31-2147-2013, 2013.

About

Python wrapper to run, read, and plot the SAMI2 ionospheric model

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Fortran 88.6%
  • Python 10.4%
  • Other 1.0%