NCL Home> Application examples> Data Analysis || Data files for some examples

Example pages containing: tips | resources | functions/procedures

Time

This page shows some examples of dealing with "time" coordinates. See the time axis labels page for examples of created nice time labels on the X or Y axis.

time_1.ncl: Create an integer time coordinate variable of the type 199801,199802 etc for multiple years.

ispan is used to create an integer array of both years and months.
sprinti is used to convert the year and month arrays to string arrays so that they can be concatenated together.
tointeger then converts the concatenated string back to an integer. You could leave the time coordinate as a string array or create a separate date array that would be a string. This would be useful for later labeling of a plot.

Note that the contributed.ncl function yyyymm_to_yyyyfrac could be used instead of the process described above to create a YYYYMM array of type float of double. See example 3 below.

time_2.ncl: Demonstrates using cd_calendar to convert a mixed Julian/Gregorian date to a UT-referenced date, and then demonstrates using cd_inv_calendar to go from a UT-referenced date to a mixed Julian/Gregorian date.
time_3.ncl: Demonstrates how to use the contributed.ncl function yyyymm_to_yyyyfrac to set up a monthly time array useful for plotting purposes. The top panel shows a random-generated timeseries plotted along an X-axis set up using yyyymm_to_yyyyfrac. The middle plot shows the result of using tmXBPrecision to set up the number of significant digits shown in the bottom X-axis tickmark labels. The bottom panel shows how to include carriage returns in tick mark labels such that the formatting is similar to:
     Jan    Feb
    2000   2000   
    
Carriage returns are created in text strings by utilizing your text function code surrounding a C. (ex. ~C~)