QUESTION:
Why does the IDL "CDF_TT2000" routine produce an incorrect result in this case:
IDL> cdf_tt2000,x1,2012,1,1,11,/c
IDL> cdf_tt2000,x2,2012,1,1,12,/c
IDL> print,(x2-x1)/1d9
86400.000
--but produces the correct result as follows?
IDL> cdf_tt2000,x1,2012,1,1,11,0,/c
IDL> cdf_tt2000,x2,2012,1,1,12,0,/c
IDL> print,(x2-x1)/1d9
3600.0000
ANSWER:
The IDL Help page for the "CDF_TT2000" specifies a usage syntax of:
CDF_TT2000, Epoch, Year, Month, Day [, Hour, Minute, Second, Milli, Micro, Nano] [, /BREAKDOWN_EPOCH] [, /COMPUTE_EPOCH] [, /TOINTEGER]
where:
[, Hour, Minute, Second, Milli, Micro, Nano]
indicates that these six optional positional parameters, are intended to all be used together as a group (and not without the other five parameters).
The "[]" characters indicates optional syntax elements:
http://www.exelisvis.com/docs/IDL_Syn...
The behavior "CDF_TT2000" when using only some but not all of the mentioned positional parameter is not defined.
In the case of using only the Hour parameter without its sibling optional parameters (i.e., Minute, Second, Milli, Micro, Nano), the resulting output is incorrect.
In the case of using the Hour and the Minute parameters without the other sibling optional parameters (i.e., Second, Milli, Micro, Nano), the resulting output is happens to be correct, but this usage is not prescribed.
INCORRECT USAGE WITH /COMPUTE_EPOCH KEYWORD:
IDL> cdf_tt2000,x1,2012,1,1,11,/c
IDL> cdf_tt2000,x1,y,mm,d,h,m,s,mls,mcs,ns,/b
IDL> help, y,mm,d,h,m,s,mls,mcs,ns
Y DOUBLE = 2012.0000
MM DOUBLE = 1.0000000
D DOUBLE = 12.000000
H DOUBLE = 0.00000000
M DOUBLE = 0.00000000
S DOUBLE = 0.00000000
MLS DOUBLE = 0.00000000
MCS DOUBLE = 0.00000000
NS DOUBLE = 0.00000000
IDL> cdf_tt2000,x2,2012,1,1,12,/c
IDL> cdf_tt2000,x1,y,mm,d,h,m,s,mls,mcs,ns,/b
IDL> help, y,mm,d,h,m,s,mls,mcs,ns
Y DOUBLE = 2012.0000
MM DOUBLE = 1.0000000
D DOUBLE = 13.000000
H DOUBLE = 0.00000000
M DOUBLE = 0.00000000
S DOUBLE = 0.00000000
MLS DOUBLE = 0.00000000
MCS DOUBLE = 0.00000000
NS DOUBLE = 0.00000000
Incorrect usage, but the result happens to be valid...
IDL> cdf_tt2000,x2,2012,1,1,12,0,/c
IDL> cdf_tt2000,x1,y,mm,d,h,m,s,mls,mcs,ns,/b
IDL> help,y,mm,d,h,m,s,mls,mcs,ns
Y DOUBLE = 2012.0000
MM DOUBLE = 1.0000000
D DOUBLE = 1.0000000
H DOUBLE = 12.000000
M DOUBLE = 0.00000000
S DOUBLE = 0.00000000
MLS DOUBLE = 0.00000000
MCS DOUBLE = 0.00000000
NS DOUBLE = 0.00000000
PROPER USAGE WITH /COMPUTE_EPOCH KEYWORD:
IDL> cdf_tt2000,x1,2012,1,1,11,0,0,0,0,0,/c
IDL> cdf_tt2000,x1,y,mm,d,h,m,s,mls,mcs,ns,/b
IDL> help, y,mm,d,h,m,s,mls,mcs,ns
Y DOUBLE = 2012.0000
MM DOUBLE = 1.0000000
D DOUBLE = 1.0000000
H DOUBLE = 11.000000
M DOUBLE = 0.00000000
S DOUBLE = 0.00000000
MLS DOUBLE = 0.00000000
MCS DOUBLE = 0.00000000
NS DOUBLE = 0.00000000
IDL> cdf_tt2000,x2,2012,1,1,12,0,0,0,0,0,/c
IDL> cdf_tt2000,x2,y,mm,d,h,m,s,mls,mcs,ns,/b
IDL> help, y,mm,d,h,m,s,mls,mcs,ns
Y DOUBLE = 2012.0000
MM DOUBLE = 1.0000000
D DOUBLE = 1.0000000
H DOUBLE = 12.000000
M DOUBLE = 0.00000000
S DOUBLE = 0.00000000
MLS DOUBLE = 0.00000000
MCS DOUBLE = 0.00000000
NS DOUBLE = 0.00000000
Used in this way for the original calculations at the top of this post, you can expect to get the correct answer, for a difference of 1 hour or 3600 seconds:
IDL> cdf_tt2000,x1,2012,1,1,11,0,0,0,0,0,/c
IDL> cdf_tt2000,x2,2012,1,1,12,0,0,0,0,0,/c
IDL> print,(x2-x1)/1d9
3600.0000