Code covered by the BSD License  

Highlights from
International Reference Ionosphere (IRI) Model

4.6 | 6 ratings Rate this file 48 Downloads (last 30 days) File Size: 28 KB File ID: #34863
image thumbnail

International Reference Ionosphere (IRI) Model



31 Jan 2012 (Updated )

Get the International Reference Ionosphere (IRI) output parameters.

| Watch this File

File Information

Computes the International Reference Ionosphere (IRI), which is an internationally recognized model for various ionospheric properties. I would call it more of a hack than a true IRI implementation as it works by querying an online interface using the curl command on an operating system terminal. Because of this, it requires an internet connection and is pretty slow, but if high speed is not an important issue for you, this can be an easy way to get IRI data into MATLAB. There are two functions that call different IRI versions. Function iri2007 calls the 2007 version found at, and function iri2012 calls the more recent 2012 version whose online interface is at
An example script for how to use the functions is given as iritest.m. This is also the script that generated the attached screenshot. Using a parfor loop on my dual core computer, both the iri2007 and the iri2012 functions took about 5 minutes to run. (For comparison, the IGRF (commented out in the script) takes just over 1 second to run.) You can select which of the two provided functions to test with the function handle fun2test on line 13, and when using a parfor loop (set by the boolean useparfor on line 14), the function's progress can be displayed by utilizing the function parfor_progress on the File Exchange (File ID: 32101).
As stated, the query is made using the command curl in an operating system terminal. This program is built-in to Unix (and Mac I believe) but not Windows. Windows users can download cURL from You'll have to download the appropriate executable for your operating system, and I recommend putting it in the same directory as the provided functions.

There is an odd quirk for the iri2007 program: Sweeps in longitude are only possible for the default altitude (100 km). If you input a vector of longitudes and the altitude is not 100 km, the function will make as many single calls to the online interface as longitudes input rather than utilize the profile sweep functionality (since that does not work). Previously, there were some different quirks in the iri2012 interface, but those have been fixed, and I currently know of no issues with the interface itself. Let me know if you have trouble with the iri2012 version.


This file inspired Msis E 90.

Required Products MATLAB
MATLAB release MATLAB 7.5 (R2007b)
MATLAB Search Path
Other requirements curl.exe (can be downloaded at if not included in your operating system).
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (17)
02 Oct 2014 Cory

Cory (view profile)

For anyone with the Curl error, you have to download the command (for Windows for sure, not sure about other OS) and set the directory or have it in the same directory. See the description.

01 Oct 2014 Cory

Cory (view profile)

Good stuff! Small error: if I want to look at December 31st in a non-leap year in a sweep (e.g. 12/31/1990), the code computes the sweep stop as 365 + (sweepstep)/10, e.g. 365.1. The IRI 2012 interface rejects this.

I've removed the step/10 bit as a stopgap, but good to correct in later versions.

Comment only
25 Sep 2014 Md. Golam Mostafa  
23 Apr 2014 alberto akel

I tested the iritest,but shows error as below:
Error using iri (line 603)
Curl command did not work. It returned status:127

Comment only
22 Apr 2014 Chao-Yen

I trid the iritest, but it shows some error as below : Error using iri (line 603)
Curl command did not work. It
returned status:1,
would you please fixed it or tell me what's wrong. Thanks

03 Apr 2014 Drew Compston

Guanyi, The IRI 2007 model online interface I have been using for this function does not allow for inputting the 10.7 indices (just Rz12 and IG12). But it looks like they have an updated model (IRI 2012) that does incorporate that. I'll provide an updated version soon that utilizes the new model.

Comment only
03 Apr 2014 Guanyi

Guanyi (view profile)

I tried the iritest. Many thanks for such a powerful programs. However, when I tried to input F10.7 in the program, I found that it is in the output. Can I use the observed 10.7 index as an input? How should I modified the program? Thanks!

04 Apr 2013 Derek

Derek (view profile)

Drew, thank you! That fixed my problems! Thanks again for this awesome code!

Comment only
01 Apr 2013 Drew Compston

Derek, there were some problems in some of the time sweeps (unrelated to number of points) which I just fixed and uploaded. Longitude sweeps can also be tricky: First of all, they only work for altitude = 100, and something like [-2 -1 0 1 2] will not work because the negative numbers wrap around to near 360, resulting in a big gap. Please feel free to post any other specific examples where maybe it should calculate a linear sweep but doesn't.

Comment only
27 Mar 2013 Derek

Derek (view profile)

Actually, I retract my statement saying "I believe this is because sweepstop = min([sweep(end) + sweepstep/10, sweepmax]); should be sweepstop = [sweep(end) + sweepstep/10, sweepmax];"

Comment only
27 Mar 2013 Derek

Derek (view profile)

Thank you for submitting this code and updating it. On that note, I believe there is an issue with sweeping linear arrays greater than 500 elements. The program should enter into case {1 2 3 4 5 6 7} however, it instead moves to case 8. If the adjustment is made to force the program into case {1 2 3 4 5 6 7}, sweeping still fails. I believe this is because sweepstop = min([sweep(end) + sweepstep/10, sweepmax]); should be sweepstop = [sweep(end) + sweepstep/10, sweepmax];

Comment only
11 Oct 2012 Brandon

On line 496 in iri.m, there is a conversion from time into hours (in decimal form), and I think there is a mistake. The conversion divides seconds by 360 when I think it should be 3600.

Comment only
22 May 2012 Drew Compston

Krishna, as you pointed out, there was a bug in my geocentric coordinate conversion which might have caused your confusion. Look at it when the new version I just uploaded gets approved. When the input COORD is 'geoc', input LATITUDE is elevation, input LONGITUDE is azimuth, and input ALTITUDE is range.

Comment only
22 May 2012 Krishna Prasad

Hi This is a great piece of code.But I have a small doubt.When the input is geocentric coordinate system we need azimuth,elevation and range to convert it to geodetic coordinates your code converts does this conversion but where does you give elevation,azimuth and range as input.And there is minor bug in the code where you used sph2cart function.Have a look at it.May be I am wrong I am not sure.But this is really awesome stuff it helped me a lot..

Comment only
13 Feb 2012 Allen Kummer  
13 Feb 2012 Allen Kummer  
13 Feb 2012 Allen Kummer

For robustness, I would suggest updating the definition for endcmd at line 386 with below. As written, if your path has a space in it, curl gets confused, so adding quotes around the path name helps.

Otherwise the file seems to work great!

Also, for your information, at least my mac has curl built in.

endcmd = [Rz12 IG12 tec_hmax ...
'&ne_top=' ne_top ...
'&imap=' fpeak ...
'&ffof2=' storm ...
'&ib0=' bottom ...
'&probab=' f1prob ...
'&dreg=' d_reg ...
'&tset=' Te_top ...
'&icomp=' ioncomp ...
sprintf('&nmf2=%g.', f2peak_N) ...
sprintf('&f2=%g.', f2peak_M) ...
sprintf('&vars=%i', 11:50) ...
'" > "' ...
fullfile(fpath, 'temp.html"')];

Comment only
02 Feb 2012

Fixed typo in title/description.

13 Feb 2012

Fixed some more typos in the comments of the files and made the changes suggested in Allen Kummer's comments.

13 Feb 2012

Fixed a problem where the online interface didn't do a full sweep for fractional steps and added an error check on reading temp.html from the interface.

22 May 2012

Fixed geocentric coordinate conversion bug.

07 Aug 2012

Updated initial comment block, added an error check on calling curl, fixed/updated some of the other error checks, and added capability to run example script without Mapping Toolbox.

11 Oct 2012

Fixed bug pointed out by Brandon (old line 459 actually I believe, not 496) and also fixed an odd issue with the online interface output for longitude sweeps and non-default altitude (first noticed by John H.).

18 Jan 2013

Fixed problem where online interface would hang without returning anything for some inputs (including in iritest.m).

01 Apr 2013

Fixed some problems in sweeping day of year/month/etc.

28 Apr 2014

Added more information on inputs in initial comment block, provided functions to call both IRI-2007 and IRI-2012, added capability to run functions in a parfor loop, changed output from multiple vectors to single matrix.

09 Aug 2014

Made iri2012 compatible with new online interface having auroral boundary option.

11 Aug 2014

Fixed error in input argument order in the list in the initial comment block for the iri2012 function.

06 Oct 2014

Fixed issue with non-leap year day of year sweeps (as pointed out by Cory in comments above).

Contact us