IDL/Solarsoft time routines


This file tries to summarize some of the huge variety of ways to re-formulate times using Solarsoft.

TAI and UTC formats

First note that a time expressed in TAI units is different to that expressed in UTC units. The difference can be about 30 seconds (it varies with time!).

To convert a TAI time to a UTC time, do the following:

IDL> time_utc=anytim2utc(time_tai)

To create a time in a useful string format, try one of the following:

IDL> print,anytim2utc(time_tai, /ccsds)
2011-02-16T07:38:03.570

IDL> print,anytim2utc(time_tai, /ccsds, /truncate)
2011-02-16T07:38:03

IDL> print,anytim2utc(time_tai, /ccsds, /truncate, /time)
07:38:03

IDL> print,anytim2utc(time_tai, /ccsds, /date)
2011-02-16

If you want the month given as string, then do:

IDL> print,anytim2utc(time_tai, /vms, /date)
16-Feb-2011

Converting to EX format

The EX format is sometimes handy as it breaks the time into a 7-element array containing year, month, day, hour, minute, second and millisecond, with each given as an integer. The best way seems to be

IDL> extime = anytim(time, /ex)

The routine anytim2ex() does not seem to work very well.

Day-of-year (DOY) format

This is the number of a day counted from 1-January, which is useful in some circumstances:

IDL> print,doy('16-feb-2011')
       47

Note that leap years are correctly handled, and 1-January is DOY=1.

To convert from a DOY to a regular time format, we have the following example:

IDL> d=doy('10-oct-2020')
IDL> print,doy2ex(d+180,2020,/string)
 8-APR-21

This shows how to add 180 days to a date and return the new date. If you drop the /string keyword, then the output is in EX format, which can be converted with the anytim routines to other formats.

Converting to year-month-day directory structure

A standard time format can be converted to a year-month-day format directory structure with:

IDL> print,time2fid('25-dec-2010 12:00',/full_year,delim='/')
2010/12/25

Convert a time to file ID (fid) format

This can be useful if you have a data file corresponding to a specific time, and you want to save some derived data into a file that contains the data and time as part of the filename. For example,

IDL> print,time2fid('23-oct-2010 09:40',/full_year,/time)
20101023_0940

Getting current time in SSW format

I'm not aware of a SSW routine to do this so my procedure is to make use of the built-in systime.pro routine. This can return the current time in Julian Day (JD) format, which can then be reformatted into the modified Julian Day (MJD) structure that the SSW anytim routines use. For example:

IDL> jd=systime(/julian,/utc)
IDL> mjd=jd-2400000.5d
IDL> mjd_str={ mjd: floor(mjd), time: (mjd-floor(mjd))*8.64d7 }
IDL> print,anytim2utc(/ccsds,mjd_str)
2018-09-10T20:46:15.000

Another useful routine is the built-in caldat routine:

IDL> caldat, jd, m, d, y, hr, min, sec

which breaks the Julian Day into month, day, year, etc. This is useful if you want to quickly get the current year, for example.

Time of a Carrington map

The new era of Parker Solar Probe and Solar Orbiter coordination means that remote-sensing people need to get used to working with Carrington maps. The routine carr2ex gives the start time of a specific Carrington number:

IDL> print,anytim2utc(/ccsds,carr2ex(2209))
2018-09-29T13:56:17.248

Although an integer was specified here, the input can also be a fractional Carrington number.

Also note that if you have Carrington longitude and latitude coordinates then you can convert them to heliocentric (x,y) coordinates with carr2xy.pro. For example,

IDL> print,carr2xy([200,5],date='2020-01-14T00:00')
-839.488 122.613


Page maintained by Dr Peter R Young.