PyIRI
PyIRI is a modern Python implementation of the International Reference Ionosphere (IRI) model.
It provides fast, global, and altitude‑dependent evaluation of ionospheric parameters using a new spherical harmonics (SH) architecture.
The model supports multiple coordinate systems and efficiently evaluates all grid points and time frames simultaneously.
Highlights
- Spherical harmonics framework for: foF2, hmF2, B0, B1 and foEs
- Supports GEO, QD, and MLT coordinate systems
- Compatible with both the new SH‑based and legacy URSI/CCIR coefficient models
- Modular and fully in Python — no external dependencies or Fortran libraries
Installation
Install from PyPI:
pip install PyIRI
Or clone and install from the GitHub repository:
git clone https://github.com/victoriyaforsythe/PyIRI.git
cd PyIRI
pip install .
For more details and usage examples, see the Jupyter tutorials.
Example: Monthly Mean Ionospheric Parameters
PyIRI computes monthly mean ionospheric parameters for a user‑defined grid. The evaluation occurs simultaneously across all grid points and for all desired Universal Time (UT) frames.
import numpy as np
import PyIRI
import PyIRI.edp_update as ml
import PyIRI.sh_library as sh
Define year and month of interest:
year = 2020
month = 4
Create any horizontal grid (regular or irregular, global or regional). Grid arrays must be flattened into 1‑D NumPy arrays:
dlon = 5
dlat = 5
alon_2d, alat_2d = np.mgrid[-180:180 + dlon:dlon, -90:90 + dlat:dlat]
alon = alon_2d.ravel()
alat = alat_2d.ravel()
Create a time array in decimal hours:
hr_res = 1
aUT = np.arange(0, 24, hr_res)
Compute F2, F1, E‑region, and sporadic E layer parameters using the new spherical harmonics coefficients:
hmF2_model = 'SHU2015' # Also available: 'AMTB2013', 'BSE1979'
foF2_coeff = 'URSI' # Also available: 'CCIR'
coord = 'GEO' # Also available: 'QD' for Quasi-Dipole Lon and Quasi-Dipole Lat inputs
# 'MLT' for MLT and Quasi-Dipole Lat inputs
F2, F1, E, Es, sun, mag = sh.IRI_monthly_mean_par(
year, month, aUT, alon, alat,
coeff_dir=None,
foF2_coeff=foF2_coeff,
hmF2_model=hmF2_model,
coord=coord,
solidx='IG12',
solmin=0,
solmax=100,
no_Es_old_output=False)
# In version 0.1.6, the sh.IRI_monthly_mean_par function did not return the sporadic E layer dict
# To return the Es dict along with the others, make sure to toggle no_Es_old_output=False
# This argument is deprecated in version 0.1.7 and will be removed in version 0.2+
Alternatively, the original URSI or CCIR climatological coefficients can be used:
ccir_or_ursi = 0 # 0 = CCIR, 1 = URSI
F2, F1, E, Es, sun, mag = ml.IRI_monthly_mean_par(
year, month, aUT, alon, alat,
PyIRI.coeff_dir, ccir_or_ursi)
Example: Daily Ionospheric Parameters (F10.7 Driven)
PyIRI also computes daily ionospheric parameters, interpolated in both time and solar activity. The user provides the F10.7 index for the day of interest.
Define the F10.7 index in solar flux units (sfu):
F107 = 100
Create altitude array in km:
aalt = np.arange(90, 1000, 1)
Define day of interest:
day = 1
Run PyIRI (with spherical harmonic coefficients):
F2, F1, E, Es, sun, mag, EDP = sh.IRI_density_1day(
year, month, day, aUT, alon, alat, aalt, F107,
coeff_dir=None,
foF2_coeff=foF2_coeff,
hmF2_model=hmF2_model,
coord=coord,
no_Es_old_output=False)
# In version 0.1.6, the sh.IRI_density_1day function did not return the sporadic E layer dict
# To return the Es dict along with the others, make sure to toggle no_Es_old_output=False
# This argument is deprecated in version 0.1.7 and will be removed in version 0.2+
Or, use the original CCIR/URSI version for compatibility:
F2, F1, E, Es, sun, mag, EDP = ml.IRI_density_1day(
year, month, day, aUT, alon, alat, aalt, F107,
PyIRI.coeff_dir, ccir_or_ursi)
Total Electron Content (TEC)
PyIRI does not calculate the Total Electron Content (TEC) automatically because altitude spacing affects accuracy. The TEC can be derived from the electron density profile (EDP) using:
TEC = PyIRI.main_library.edp_to_vtec(edp, aalt, min_alt=0.0, max_alt=202000.0)
Example: Single‑Location Diurnal Variation
To evaluate parameters at a single location, provide scalar longitude and latitude values:
alon = 10.
alat = 20.
Run PyIRI (with spherical harmonic coefficients):
F2, F1, E, Es, sun, mag, EDP = sh.IRI_density_1day(
year, month, day, aUT, alon, alat, aalt, F107,
coeff_dir=None,
foF2_coeff=foF2_coeff,
hmF2_model=hmF2_model,
coord=coord,
no_Es_old_output=False)
# In version 0.1.6, the sh.IRI_monthly_mean_par function did not return the sporadic E layer dict
# To return the Es dict along with the others, make sure to toggle no_Es_old_output=False
# This argument is deprecated in version 0.1.7 and will be removed in version 0.2+)
Tutorials
Comprehensive Jupyter notebooks are available in docs/tutorials:
Daily_parameters.ipynbSingle_location.ipynbCoordinate_Transformation.ipynbPyIRI_year_run.ipynbGenerate_Apex_Coefficients.ipynbGenerate_SH_coefficients.ipynb
Routine Package Maintenance: IGRF Updates
The PyIRI model relies on an accurate representation of the Earth's magnetic field for the spherical harmonics library. PyIRI uses the quasi-dipole (QD) magnetic coordinate system. These coordinates, which ultimately derive from the International Geomagnetic Reference Field (IGRF) coefficients, are computed by apexpy and then fit via Spherical Harmonics (SH) for easy reference. When a new IGRF definition is released, the previous set of IGRF coefficient files (especially the last five years, which are an extrapolation) become obsolete. To maintain PyIRI when a new IGRF definition comes out, maintainers must first ensure that apexpy has been updated to incorporate the latest IGRF coefficients. Once apexpy is current, it must be rerun to generate a new apex.nc coefficient file via SH fits. This process synchronizes PyIRI's magnetic coordinate grids with the updated IGRF and ensures the model remains accurate in MLT–QDLat space for the new epoch.
Citation
If you use PyIRI in your research, please cite:
Forsythe, V. (2025). PyIRI: Python implementation of the IRI model using spherical harmonics. Zenodo. https://doi.org/10.5281/zenodo.8235173
Servan-Schreiber, N., Forsythe, V., et al. (2025). A Major Update to the PyIRI model. Space Weather, submitted.
Metadata
Release files for PyIRI 0.1.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pyiri-0.1.7.tar.gz | 20.2 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyiri-0.1.7-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 40.3 MB
Release files / pyiri-0.1.7.tar.gz
| Download URL | pyiri-0.1.7.tar.gz |
|---|---|
| Size | 20.2 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f30098cfaf73a916f8363e752f1f1bfb2015b19b915bf707b797640c473300c3
|
|
BLAKE2b-256 checksum How to use checksums |
5bc5fc162e84d4804760e8245a5fcf7d2814a9e4c69a91a56bad7896add33bf9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / pyiri-0.1.7-py3-none-any.whl
| Download URL | pyiri-0.1.7-py3-none-any.whl |
|---|---|
| Size | 20.2 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6f86cec1dc919f7f576e8cfc68d0bdb761e8ff062b9be0c2b66c55e92a662db8
|
|
BLAKE2b-256 checksum How to use checksums |
7ef1541c244347462bc8018dc6f1b6f20fc0891ab04d73736b53b2597cd150d6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|