Re: how does NCL (netCDF?) deal with time?

From: Dave Allured <dave.allured_at_nyahnyahspammersnyahnyah>
Date: Thu, 28 Aug 2008 18:23:10 -0600

Leslie,

Your questions span several topics. Here is my two cents.

It sounds like your data is on a regular lat/lon grid, or you want
to put it onto a regular grid. This is useful for map-based spatial
plots.

If you need to do something else spatially, such as irregular grids
or preserving station coordinates, these are special topics and more
description is needed.

For regular grids, I recommend Netcdf-3 "classic" file format for
ease of use with NCL and other software. Use Netcdf type double
(64-bit floats) for all three coordinate variables. Name them lat,
lon, and time. The units attributes for lat and lon should be
degrees_north and degrees_east.

Time should be a simple numeric axis on the real world calendar time
line, as Jonathan Vigh described in his reply. I prefer double
precision to take care of both range and precision issues.

Specify the time base as time_at_units = "seconds since 1970-1-1
0:0:0". You can use seconds, minutes, hours, or days as the time
units. Weeks, months, and years must be avoided. If the data will
be primarily used in a calendar date sense, then I find "days since
..." to be easiest to work with for debugging, even for sub-daily data.

The base date is arbitrary. I suggest a round number date that is
at the start of your data or near but earlier, to avoid negative
time offsets. E.g. 1800-1-1 and 1900-1-1 are common in modern
historical data. For very high time resolutions of sub daily data,
minutes or seconds from the start date of the actual data may be better.

For more on designing Netcdf files, the following is a good
introduction. Caveat, many of the attributes in this reference and
under conventions are not needed for NCL purposes:

http://www.unidata.ucar.edu/software/netcdf/docs/BestPractices.html

Your Q2 is actually about plotting, not file design. Specifically,
NCL and other softwares understand *any* regular numeric time
coordinate axis on the Gregorian calendar real time line, as long as
time_at_units conforms to the simple rules that we have discussed.
However, the current NCL version only knows how to automatically
print pure numbers on plot axes.

For "human-readable" date/time labels on plot axes, it's a two-step
process. NCL plotting programs need a little extra code to
translate the pure numeric time coordinates into character strings
formatted the way you want them. Use the NCL function ut_calendar.
  The documentation contains a good discussion and sample code for
converting time coordinates to readable strings:

http://www.ncl.ucar.edu/Document/Functions/Built-in/ut_calendar.shtml

Then to actually print the formated strings onto your plot axes, use
the method shown in example 2 on this page:

http://www.ncl.ucar.edu/Applications/tickmarks.shtml

I hope this takes care of your main questions.

Dave Allured
CU/CIRES Climate Diagnostics Center (CDC)
http://cires.colorado.edu/science/centers/cdc/
NOAA/ESRL/PSD, Climate Analysis Branch (CAB)
http://www.cdc.noaa.gov/

Leslie Hartten wrote:
> I am just starting to work with both NCL and some new ascii datasets.
> The data have sub-daily resolution (e.g. 2-minute, 30-minute, or
> hourly) and are written with date & time in a decimal day-of-year format
> (e.g. the timestamps from 26 May 2006 are 147.00000, 147.02083,
> 147.04167, 147.06250, etc.). I want to have latitude, longitude, and
> date/time be the coordinate variables for the geophysical data in the
> files. I can very easily reformat the datasets before I start using
> them in NCL; I'm just not sure what form I should put them in. I've
> read every bit of NCL date/time related material I could find (including
> the udunits documentation at unidata) and I'm no less confused. I'm
> hoping someone on the list can help.
>
> Q1: how does NCL store time (date and time of day)?
>
> Q2: is there a date/time format I can use that will enable me to make a
> plot of 1 day's worth of geophysical data and another plot of 2 weeks
> worth, for which NCL will be able to create a human-readable time axis?
> (In other words, labelled with hours in the first case and with
> Gregorian calendar days in the second case.)
>
> Q3: has anybody done anything like this and found it to be an especially
> good or an especially bad solution?
>
> Cheers,
> Leslie
> --
> Dr. Leslie M. Hartten
> CIRES, Univ. of Colorado email: Leslie.M.Hartten_at_noaa.gov
> 216 UCB web: http://cires.colorado.edu/~hartten
> Boulder CO 80309-0216 phone: (303)497-7052 fax: 497-6181
> --
> Disclaimer: The contents of this message are mine personally and do not
> necessarily reflect any position of the Government of the United States
> of America, the National Oceanic and Atmospheric Administration, or the
> University of Colorado.
> _______________________________________________
> ncl-talk mailing list
> ncl-talk_at_ucar.edu
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Aug 28 2008 - 18:23:10 MDT

This archive was generated by hypermail 2.2.0 : Fri Aug 29 2008 - 07:39:21 MDT