Removes previously defined holidays and weekends from the Julian day portion of !DT structures in a date/time variable.
NOTE: Avoid using DT_COMPRESS for normal XY plotting with the PLOT and OPLOT commands. Use the Compress keyword with PLOT and OPLOT to create compressed date/time results.
Note that the result of DT_COMPRESS is a double array of Julian days, not another array of !DT structures.
march1 = VAR_TO_DT(1992, 3, 1, 11, 30, 0) PRINT, march1
{ 1992 3 1 11 30 0.00000 87462.479, 0}
marray = DTGEN(march1,31, /Day)
PRINT, marray
{ 1992 3 1 0 0 0.00000 87462.479 0}
.
.
{ 1992 3 31 0 0 0.00000 87492.479 0}
CREATE_WEEKENDS, ['Saturday', 'Sunday']
cmarray = DT_COMPRESS(marray) PRINT, cmarray
62472.5 62473.0 62474.0 62475.0
62476.0 62477.0 62477.5 62477.5
62478.0 62479.0 62480.0 62481.0
62482.0 62482.5 62482.5 62483.0
62484.0 62485.0 62486.0 62487.0
62487.5 62487.5 62488.0 62489.0
62490.0 62491.0 62492.0 62492.5
62492.5 62493.0 62494.0
First, the compressed days (the ones ending in .5) must be incremented to the value of the next whole day. Second, the Time portion of the Julian numbers representing weekdays must be restored.
The following code accomplishes both of these objectives:
FOR i=0, 30 DO BEGIN $
whole_day = DOUBLE(FIX(cmarray(i))) $
delta_day = cmarray(i) - whole_day $
IF (delta_day GE 0.4) AND $
(delta_day LE 0.6) THEN BEGIN $
marray(i) = whole_day + 1.0d $
ENDIF $
ELSE BEGIN $
fract_day = marray(i).julian - $
DOUBLE(FIX(marray(i).julian)) $
cmarray(i) = whole_day + fract_day $
ENDELSE $
ENDFOR
cmarray
can be used to generate a date/time plot for a specialized plotting applicationone where the regular PLOT routine is not sufficient. For example, this data could be used to generate a bar chart.Before using this date data, however, you must first call PLOT or OPLOT with the XType keyword set to 2. This establishes the plot axis and coordinate system, and allows the date/time axis to be generated from an array of Julian numbers.
christmas = VAR_TO_DT(1992, 12, 25) PRINT, christmas
{ 1992 12 31 0 0 0.00000 87761.000 0}
day1 = VAR_TO_DT(1992, 1, 1) yarray = DTGEN(day1, 366)
x = ['1-1-92', '5-31-92','7-4-92', $
'-1-92', '11-24-92', '12-25-92']
holidays = STR_TO_DT(x, Date_Fmt=1)
CREATE_HOLIDAYS, holidays
cyarray = DT_COMPRESS(yarray)
For more information on date/time, see the PV-WAVE User's Guide.