Skip to main content

IRI-2026 Python Wrapper

iri26py is a wrapper around the IRI-2026 empirical model.

This repository includes a version of the IRI-2026 model where the call signatures have been modified for ease of integration with Python. The integration is achieved by means of a FORTRAN shim (irishim.f90) that is compiled into a module using F2PY. Data files associated with IRI-2026 are included in the data folder and are available at runtime. The wrapper automatically retrieves the latest available ig_rz.dat and apf107.dat files on import.

Prerequisites

A Fortran compiler is REQUIRED.

Linux

Ensure that you have the following development packages installed:

  • build-essential (for gcc, g++, make, etc.)
  • gfortran (Fortran compiler)

macOS

Ensure that you have the Xcode Command Line Tools installed. You can install them by running:

xcode-select --install

Install homebrew if you haven't already, and then install gfortran:

brew install gfortran

Note: For macOS Big Sur and above, you may need to add the following line to your environment script (~/.zshrc if using ZSH, or the relevant shell init script):

export LIBRARY_PATH="$LIBRARY_PATH:/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib"

Then reopen the terminal. This fixes the issue where -lSystem fails for gfortran.

Windows (amd64 or x86_64 targets)

On Windows, MSYS2 is the preferred distribution for installing the Fortran compiler toolchain (for GNU Compiler Collection).

  • Install MSYS2. Note the directory where MSYS2 was installed (defaults to C:\msys64) [referred to as MSYS_INSTALL_DIR]. It is not recommended to change this directory.
  • Launch the MSYS2 terminal (MSYS2 MSYS application on the start menu)
  • Update MSYS2 environment (assuming fresh install):
    pacman -Syu # Restart the terminal
    pacman -Su  # Update packages
    
  • Install the GNU Compiler Collection:
    pacman -S --needed base-devel mingw-w64-ucrt-x86_64-toolchain mingw-w64-ucrt-x86_64-gcc-fortran
    
  • Add MSYS_INSTALL_DIR\ucrt64\bin (defaults to C:\msys64\ucrt64\bin) to PATH:
    • Search for env in the Start menu,
    • Select "Edit the system environment variables",
    • Click "Environment Variables",
    • Double click 'Path' under 'User variables for USER'
    • Click "New"
    • Type in, or paste the full path to ucrt64\bin (defaults to C:\msys64\ucrt64\bin)
    • Click "Ok" on the environment variable windows to save the changes.
  • Continue with installation instructions for the Python packages below, in a new, regular terminal (e.g. Command Prompt or PowerShell with Python installed).

Installation

From PyPI

pip install iri26py

From GitHub

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

Usage

Quick Test

On the command line, execute Iri26Test. This should produce a plot of noon and midnight electron density profiles.

Python

from iri26py import Iri2026, alt_grid
from datetime import datetime, UTC
import matplotlib.pyplot as plt

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

# ds is an xarray Dataset
# Plot electron density profile
ds.Ne.plot(y='alt_km')
plt.show()

Output Dataset Format

  • Coordinates
    • Altitude (alt_km): Altitude in km
  • Data Variables (as a function of altitude)
    • Electron density (Ne) in cm-3
    • Electron temperature (Te) in K
    • Ion temperature (Ti) in K
    • O+, H+, He+, O2+, NO+, N+ and cluster ion densities (cm-3)
  • Attributes
    • settings: JSON string of settings (iri26py.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 as returned in the OARR struct (refer to IRI-2026 documentation). These 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.

Example Plot

An example script to generate a plot of the ion densities and temperatures is available in the tests/test_iri2026.py file.

Citation

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

@software{sunipkm_iri26py_2026,
  author       = {Sunip K. Mukherjee},
  title        = {{iri26py}: A Python Wrapper for the IRI-2026 Empirical Model},
  year         = 2026,
  publisher    = {GitHub},
  url          = {https://github.com/sunipkm/iri26py},
}

Release files for iri26py 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for iri26py 0.0.1
File Size Uploaded
iri26py-0.0.1.tar.gz 2.1 MB Details

Release files / iri26py-0.0.1.tar.gz

Download URL iri26py-0.0.1.tar.gz
Size 2.1 MB
Tags Source
SHA-256 checksum
How to use checksums
665e7b947749b333f21149401b68e535563843f591af0bbeb7b667299b3e0b1f
BLAKE2b-256 checksum
How to use checksums
e598266a258e9f6fee84b05ea5f646abc846a5275d7dd48737a00045d6cc37a1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.13

Release history Release notifications | RSS feed

This release

0.0.1 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page