00.355187
91.9201
00.22395
63.9256
97.4526
.
.
.
; Generates an initial date/time variable to use with the
; DTGEN function.
fday = VAR_TO_DT(1992, 4, 1, 1, 1, 1)
; Creates a variable for generating seven seconds of data.
num = 7
; Generates date/time variable with date/time structures for the
; first seven seconds of April.
x = DTGEN(fday, num, /Second)
; Reads the data from the file datafile.dat and assigns it to the
; variable y. The values for all seconds, 86400, are actually
; read into y. However, only the first seven seconds are plotted
; for this example.
status = DC_READ_FREE('datafile.dat', y, /Col)
; Plots the first seven seconds of data.
PLOT, x, y, Psym = -4
; Generates an initial date/time variable to use with the
; DTGEN function.
fday = VAR_TO_DT(1992, 4, 1, 1, 1, 1)
; Creates a variable to use with the DTGEN function for generating
; an array of date/time structures.
num = 20
; Generates a date/time variable with date/time structures for
; 20 minutes in April.
x = DTGEN(fday, num, /Minute)
; Reads the data from the file datafile.dat into the variable y.
status = DC_READ_FREE('datafile.dat', y, /Col)
; Plots the first 20 minutes of data with boxes around the
; date/time axis.
PLOT, x, y, Psym=-4, /Box
; Create an initial date/time variable to use with the DTGEN
; function.
fday = VAR_TO_DT(1992, 4, 1, 1, 1, 1)
; Create a variable used with the DTGEN function to create an
; array of date/time structures.
num = 24
; Create 24 date/time structures for the hours of the day.
x = DTGEN(fday, num, /Hour)
; Read the data into the variable y.
status = DC_READ_FREE('datafile.dat', y, /Col)
Plot, x, y, Psym = -4, /Box
note | This data file is an example file only. It is used to generate plots for various levels of date/time data. |
; Create date/time structures to hold date/time data for the days
; in January and February.
dates = REPLICATE({!DT}, 60)
; This procedure defines the weekend days.
CREATE_WEEKENDS, ['sun', 'sat']
; Reads the data from Column 1 into the variable amount. Reads
; the data from Column 2 into the variable dates. The date/times
; from Column 2 are converted to date/time data. The NSkip keyword
; skips over the first two header lines in the file.
status = DC_READ_FREE('sales1.dat', amount, dates, /Col, $
Dt_Template = [1], Delim = [" "], NSkip = 2, $
Get_Columns = [1, 2])
; Creates variables to be used with DT_Range. These variables
; establish a range for plotting each day of month in January.
sdate = VAR_TO_DT(1991, 1, 1)
edate = VAR_TO_DT(1991, 1, 30)
; Plots the date/time data on the x-axis and the daily sales for
; the month of January on the y-axis. Weekends are compressed.
; Setting the Start_Level keyword to 3 forces the plot to use
; days as the first axis level. The DT_Range keyword defines the
; range of date/time data that will be plotted. In this example
; only the days of January are plotted.
PLOT, dates, amount, /Compress, Start_Level = 3, $
DT_Range = [sdate.julian, edate.julian]
; Create date/time structure to read date/time data into.
dates = REPLICATE({!DT}, 18)
; Read sales data into the amount variable. Read and convert
; date/time data into the dates variable.
status = DC_READ_FREE('sales1.dat', amount, dates, /Col, $
Dt_Template = [1], Delim = [" "], Get_Columns = [3,4], $
NSkip = 2)
; The keyword Start_Level selects weeks for plotting.
PLOT, dates, amount, Start_Level =4, PSym = -4
note | By default, week boundaries are plotted as Mondays. To label a different day of the week, use the Week_Boundary keyword. To specify an exact axis range, use the Dt_Range keyword. Looking at the above example, to have the tick labeling occur on the day of the week of the first data point, and to plot only the first 12 weeks of data use the following: PLOT,dates,amount,Start_level=4, Psym=-4, $ Dt_Range=[dates(0).Julian,dates(12).Julian], $ Week_boundary=DAY_OF_WEEK(dates(0)) |
; Creates date/time structures for the months of the year.
dates = REPLICATE({!DT}, 12)
; Reads monthly sales data into the amount variable. Reads
; date/time data into the variable dates as date/time data.
status = DC_READ_FREE('sales1.dat', amount, dates, /Col, $
Dt_Template = [1], Delim = [' '], NSkip = 2, $
Get_Columns = [5,6])
; Plots data with several months abbreviated to fit labels for
; all 12 months on the date/time axis.
PLOT, dates, amount, /Month_Abbr
; Creates variables to hold the date information for the four
; quarters of the year.
year = intarr(4) & month = intarr(4)
day = intarr(4)
; Reads the sales data into the amount variable. Reads the
; date information into the variables, year, month, and day.
status = DC_READ_FIXED('sales1.dat', amount, year, month, day, $
/Col, NSkip = 2, FORMAT = ('39X, I4, 1X, 3I2)')
; Converts the date information to a date/time variable.
dates = VAR_TO_DT(year, month, day)
; Plots the data with only one level of axis labeling.
; Without the Max_Levels keyword assignment, the labels
; for years would also be printed out.
PLOT, dates, amount, Start_Level = 6, /Max_Levels
; These are the projected sales for each quarter of 1991.
amount1 = [3507, 2310, 2917, 1807]
; Plots projected sales of each quarter as individual diamonds.
OPLOT, dates, amount1, PSym = 4
; Defines the d variable as a long array containing 4 elements.
; This variable contains the Julian dates read in from Column 10.
d = lonarr(4)
; Reads the sales data into the amount variable. Reads the
; date information into variable d.
status = DC_READ_FREE('sales1.dat', amount, d, /Col, $
Delim = [" "], NSkip = 2, Get_Columns = [9, 10])
; Converts date information in variable d to date/time variable.
dates = JUL_TO_DT(d)
; Plots yearly sales. The Start_Level keyword ensures that the
; years are labeled on the first level of the x-axis. If this
; keyword were omitted, quarters would be the first level of
; labeling.
PLOT, dates, amount, Start_Level = 7
; Defines dates variable as a long array containing 4 elements.
dates = LONARR(4)
; Reads the sales data into the amount variable.
; Reads the date information into the dates variable.
status = DC_READ_FREE('sales1.dat', amount, dates, /Col, $
Delim = [" "], Get_Columns = [9, 10], NSkip = 2)
; Plots data as shown in
; Figure 8-9: Yearly Sales Plot over Four Years.
PLOT, dates, amount, XType=2, Start_Level=7