Skip to main content

Python implementation of International Reference Ionosphere

Project description

Black circle with PyIRI logo of two snakes marking the EIA

PyIRI

PyPI Package latest release Build Status Documentation Status DOI Coverage Status

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, and E‑region 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_peak, 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)

Alternatively, the original URSI or CCIR climatological coefficients can be used:

ccir_or_ursi = 0  # 0 = CCIR, 1 = URSI
f2, f1, e_peak, es_peak, 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, 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)

Or, use the original CCIR/URSI version for compatibility:

f2, f1, e_peak, es_peak, 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, 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)

Example: Sporadic E

Sporadic E fields require more spherical harmonic coefficients and were therefore decoupled from the main call:

Run PyIRI Es (with spherical harmonic coefficients) for solar min and solar max:

Es = sh.sporadic_E_monthly_mean(year,
                                month,
                                aUT,
                                alon,
                                alat,
                                coeff_dir=None,
                                coord='GEO')

Run PyIRI Es (with spherical harmonic coefficients) for a given day and F10.7 input:

Es = sh.sporadic_E_1day(year,
                        month,
                        day,
                        aUT,
                        alon,
                        alat,
                        F107,
                        coeff_dir=None,
                        coord='GEO')

Tutorials

Comprehensive Jupyter notebooks are available in docs/tutorials:

  • Mean_monthly_parameters.ipynb
  • Daily_parameters.ipynb
  • Single_location.ipynb
  • Coordinate_Transformation.ipynb
  • PyIRI_year_run.ipynb
  • Generate_Apex_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.

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

pyiri-0.1.6.tar.gz (34.9 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyiri-0.1.6-py3-none-any.whl (35.0 MB view details)

Uploaded Python 3

File details

Details for the file pyiri-0.1.6.tar.gz.

File metadata

  • Download URL: pyiri-0.1.6.tar.gz
  • Upload date:
  • Size: 34.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for pyiri-0.1.6.tar.gz
Algorithm Hash digest
SHA256 1c69a2c61f25a598208bacc7e11fa087fe92a9b25af9fefcc29949ae2a74a7c9
MD5 8e9fb26bd9b67af22c322fef13fc2fa8
BLAKE2b-256 e19bf866dc7611d9bb05334cd0b905c80999c23ddc593048e0304b37da9de530

See more details on using hashes here.

File details

Details for the file pyiri-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: pyiri-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 35.0 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for pyiri-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 3d132fac9580c6345838be4bf3b14635a8202c2398e79b0d58d19bbddfbedc96
MD5 e4190a46ff6702f8de54a012c623b42a
BLAKE2b-256 f48bc21a9e94270ff98f348474462a50041d7b6c7d381fc7687d1e06303b5af1

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