Skip to content

Instantly share code, notes, and snippets.

@scivision
Last active February 11, 2026 20:47
Show Gist options
  • Select an option

  • Save scivision/4cecadd143458c0e5c844c67c57ac89b to your computer and use it in GitHub Desktop.

Select an option

Save scivision/4cecadd143458c0e5c844c67c57ac89b to your computer and use it in GitHub Desktop.
Examples of using E-CHAIM model

E-CHAIM altitude profile example

E-CHAIM ionospheric model is available for C, IDL, and Matlab. We will describe the Matlab version only here. There is a bug in E-CHAIM 4.3.0 and 4.3.1, and E-CHAIM 4.3.2 Matlab .zip is corrupted. I have emailed E-CHAIM team to let them know.

Until the E-CHAIM 4.3.2 download is fixed, use E-CHAIM Matlab release 4.2.1. Free registration is required to download the E-CHAIM Zip archive. Extract this archive from Matlab:

unzip('Release_Matlab_CDB-4.2.1.zip')

cd('Release_Matlab_CDB-4.2.1/')

The “ECHAIM.p” file is a function ECHAIM() accessed from Matlab. Unlike the “.m” script files one is used to, “.p” files are encrypted to keep source code private, but can be run just like “.m” files.

Let’s run a Matlab E-CHAIM self-test that will automatically compile the MEX code. If you get an error message about compilers not being setup, there should be a link in the Matlab error on how to setup the MEX compilers. From Matlab:

ECHAIM(‘test’)

If you get error

Unrecognized function or variable 'matlab_nrlmsise'

ECHAIM('create_nrlmsise')

Then, generate an electron density altitude profile by running this example script "altitude_profile.m"

Electron Density Profile

dates_use = datetime(2013, 1, 23, 11, 24, 50);
lat_use = 55;
lon_use = 69.5;
alts_use = 60:1:1000;
Y = ECHAIM (lat_use, lon_use, dates_use, alts_use);
plot(Y.dens, Y.Alt)
set(gca, XScale='log', Xlim=[1e9,1e12])
title(sprintf("%s [%0.2f %0.2f]", string(t), lat_use, lon_use))
ylabel('Altitude [km]')
xlabel('Electron Number Density [e^- / m^3]')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment