Skip to main content

Python bindings for NRLMSIS-2.1 model

Project description

DOI

NRLMSIS-2.1 Python Wrapper

msis21py is a wrapper around the NRLMSIS-2.1 empirical model.

This repository uses the NRLMSIS-2.1 model as is with Python. The integration is achieved by means of a FORTRAN shim (msis21shim.f90) that is compiled into a module using F2PY. The parameter file msis21.parm is automatically provided at runtime.

Installation

From PyPI

pip install msis21py

From GitHub

pip install msis21py@git+https://github.com/sunipkm/msis21py

Usage

from msis21py import NrlMsis21, alt_grid
from datetime import datetime, UTC
import matplotlib.pyplot as plt

# Instantiate the model
msis = NrlMsis21()
# Note: msis is a singleton (thread safety with FORTRAN)
# Evaluate the model
ds = msis.evaluate(
    datetime(2022, 3, 12, 0, 0, 0, tzinfo=UTC),
    40, -70,
    alt_grid()
)

# ds is an xarray Dataset
# Plot neutral temperature profile
ds.Tn.plot(y='alt_km')
plt.show()

Output Dataset Format

  • Coordinates
    • Altitude (alt_km): Altitude in km
  • Data Variables (as a function of altitude)
    • Densities of O, O2, N2, H, He, Ar, N, Anomalous O, and NO in cm-3
    • Neutral temperature (Tn) in K
    • Mass density (mden) in g cm-3
  • Attributes
    • settings: JSON string of settings (msis21py.Settings) used to evaluate the model.
    • date: ISO formatted date and time for which the model was evaluated.
    • lat and lon: Latitude and longitude for where the model was evaluated.
    • Additional attributes are provided as JSON dictionaries containing a value, its unit, a longer name (long_name) and an associated description, if available.

The dataset is NetCDF4 compatible.

License

This project is licensed under the MIT License. See the LICENSE file for details. The NRLMSIS-2.1 model is in the public domain as per the original license, and is a product of the U.S. Government that is restricted to academic and research use only. Please refer to the original license for more details. Please follow the citation guidelines provided by NRL when using the model in your work.

Citation

If you use this code in your work, please cite the repository:

@software{sunipkm_msis21py_2025,
  author       = {Sunip K. Mukherjee},
  title        = {{msis21py}: A Python Wrapper for the NRLMSIS-2.1 Empirical Model},
  month        = jun,
  year         = 2025,
  publisher    = {GitHub},
  version      = {v0.0.1},
  doi          = {https://zenodo.org/badge/latestdoi/1090668363},
  url          = {https://github.com/sunipkm/msis21py},
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

msis21py-0.0.1.tar.gz (21.7 kB view details)

Uploaded Source

File details

Details for the file msis21py-0.0.1.tar.gz.

File metadata

  • Download URL: msis21py-0.0.1.tar.gz
  • Upload date:
  • Size: 21.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for msis21py-0.0.1.tar.gz
Algorithm Hash digest
SHA256 de734074a191c7f296a73579d4a40f724d41837182b229577fd6cbae1729b087
MD5 ec76470af20ea087548bc5dcb757612a
BLAKE2b-256 ea7a392d3fed16888c7690124bdc8b31868ceba6af8062d78c3969effc43aeed

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page