Python bindings for NRLMSIS-2.1 model
Project description
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
A Fortran compiler is REQUIRED to build the FORTRAN extension module.
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
- Altitude (
- 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.latandlon: Latitude and longitude for where the model was evaluated.- Additional attributes are provided as JSON dictionaries containing a
value, itsunit, a longer name (long_name) and an associateddescription, if available.
The dataset is NetCDF4 compatible.
Examples
An example script to generate the following plot is available in the in tests/test_msis21.py.
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 = nov,
year = 2025,
publisher = {GitHub},
version = {v0.0.2},
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
File details
Details for the file msis21py-0.0.2.tar.gz.
File metadata
- Download URL: msis21py-0.0.2.tar.gz
- Upload date:
- Size: 182.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1142f3d6b2d8a5199e6a9a70b507c78d88529df334286f97848a075df2094b49
|
|
| MD5 |
f5a1f0e42552d682b49d778ad49d40d5
|
|
| BLAKE2b-256 |
a4699bc61387228a0202e6ffe43cc8b64519ed5b43141e6bc1b5ac9c8bca676b
|