File Exchange

image thumbnail

International Reference Ionosphere (IRI) Model

version 1.14 (28 KB) by

Get the International Reference Ionosphere (IRI) output parameters.

4.58333
13 Ratings

52 Downloads

Updated

View License

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 http://omniweb.gsfc.nasa.gov/vitmo/iri_vitmo.html, and function iri2012 calls the more recent 2012 version whose online interface is at http://omniweb.gsfc.nasa.gov/vitmo/iri2012_vitmo.html.
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 http://curl.haxx.se/download.html. 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.

Comments and Ratings (34)

Saeed Bello

1. Kindly please help use to update the code to read iri2016. Specifically the new 'F-peak height' input.
2. Also,I got an error after updating the address at line 795 for iri2012.
The error looks like this:
??? Error using ==> iri2012 at 904
Curl command did not work. It returned status:60, % Total % Received % Xferd Average Speed
Time Time Time Current
                    Dload Upload Total Spent Left Speed

  0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
  0 0 0 0 0 0 0 0 --:--:-- 0:00:01 --:--:-- 0
  0 0 0 0 0 0 0 0 --:--:-- 0:00:02 --:--:-- 0
  0 0 0 0 0 0 0 0 --:--:-- 0:00:03 --:--:-- 0
  0 0 0 0 0 0 0 0 --:--:-- 0:00:04 --:--:-- 0
  0 0 0 0 0 0 0 0 --:--:-- 0:00:04 --:--:-- 0
curl: (60) SSL certificate problem: unable to get local issuer certificate
More details here: https://curl.haxx.se/docs/sslcerts.html

curl performs SSL certificate verification by default, using a "bundle"
 of Certificate Authority (CA) public keys (CA certs). If the default
 bundle file isn't adequate, you can specify an alternate file
 using the --cacert option.
If this HTTPS server uses a certificate signed by a CA represented in
 the bundle, the certificate verification probably failed due to a
 problem with the certificate (it might be expired, or the name might
 not match the domain name in the URL).
If you'd like to turn off curl's verification of the certificate, use
 the -k (or --insecure) option.
HTTPS-proxy has similar options --proxy-cacert and --proxy-insecure.

Deans Yu

notice::::if used @ D's update method, you will get iri-2016 value not iri-2012

D

D (view profile)

The IRI model website is encrypted now (it is now https and not http). Please update the following address at line number 795 from

'" http://omniweb.gsfc.nasa.gov/cgi/vitmo/vitmo_model.cgi > "'

to

'" https://omniweb.gsfc.nasa.gov/cgi/vitmo/vitmo_model.cgi > "'

Drew Compston

Drew Compston (view profile)

Saeed: your error is likely caused by the IG12 input (9th input) not being a scalar. That input should be a scalar between -50 and 400 (which the help text in the beginning specifies).

Moraes: Sorry I missed your question. This should be possible, though I don't have the time to work out the details. It's a matter of figuring out where the geomagnetic poles are from the IGRF and then applying a coordinate transform. This page and the references therein might be helpful for this problem: https://www.spenvis.oma.be/help/background/coortran/coortran.html

Saeed Bello

Thank you for this code. Kindly help me fix this error after running this command:
out = iri2012(time, latitude, longitude, height, utc, coord, ...
    curldir, bottom)
The error is:
??? Operands to the || and && operators must be convertible to logical scalar
values.

Error in ==> iri2012 at 576
if isempty(IG12) || (IG12 >= -50 && IG12 <= 400)
 
Thank you

Alison Moraes

Dear Drew,
Is there a way to compute the geomagnetic coordinate having the geodetic coordinate as input?
Regards,
Moraes

Drew Compston

Drew Compston (view profile)

Auroral: You need an active internet connection for curl to work. Is the computer you are using connected to the internet? Sounds like maybe not.

Auroral

Auroral

downloaded curl.exe iritest program still came out the 'curl error';
besides , when running my own program using iri2007/2012, always inform error that----' Failed to connect to omniweb.gsfc.nasa.gov port 80: Timed out' somebody help me ?

Has anyone tried using this in octave?

rui zhou

a

Drew Compston

Drew Compston (view profile)

The output of the iri2012 program is an Nx44 array, where N is the number of input locations/times. To get the 13th output of the IRI, simply select the 13th column of the output array. For example:
>> TEC = out(:, 13);
So in iritest, you could replace all the instances of out(:, 1) with out(:, 13) to plot TEC rather than electron density. There are four instances on lines 42, 54, 73, and 80.

Sri Ekawati

the iritest program compute and shows the Electron Density (Ne) only... As we know that output of IRI2012 have 44 output. How to get value of TEC (for example, output no. 13).... could anyone help me please

Sri Ekawati

@Muresan Aronia : First, I have same problem with you. But when I download the curl.exe and placed the matlab program at the same directory.. the program is successfull.... FYI, I use Windows..

Drew Compston

Drew Compston (view profile)

It's hard for me to troubleshoot problems you might be having with curl, especially with as little information as has been given in some of these comments. There is a link in the description to the curl executable program I use in this MATLAB code. I will point out: Someone I work with had trouble getting this to work on her Mac. It had something to do with the curl file provided by MATLAB in her version. I think we fixed it by removing the curl file from the MATLAB install files. But that's all I remember now.

Hi everyone.I'm trying to simulate the IRI model but I get the same error with the Curl command.I read above that somebody says to download the curl command but I couldn't find something like this.Could anyone help me?

Hi everyone.I'm trying to simulate the IRI model but I get the same error with the Curl command.I read above that somebody says to download the curl command but I couldn't find something like this.Could anyone help me?

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.

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.

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

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

Drew Compston

Drew Compston (view profile)

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.

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!

Derek

Derek (view profile)

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

Drew Compston

Drew Compston (view profile)

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.

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];"

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];

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.

Drew Compston

Drew Compston (view profile)

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.

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..
Thanks

Allen Kummer

Allen Kummer

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) ...
    '" http://omniweb.gsfc.nasa.gov/cgi/vitmo/vitmo_model.cgi > "' ...
    fullfile(fpath, 'temp.html"')];

Updates

1.14

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

1.13

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

1.12

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

1.11

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.

1.10

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

1.9

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

1.8

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.).

1.7

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.

1.5

Fixed geocentric coordinate conversion bug.

1.3

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.

1.2

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

1.1

Fixed typo in title/description.

MATLAB Release
MATLAB 7.5 (R2007b)
Acknowledgements

Inspired: MSIS-E-90

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video