On 2014-08-12 3:01 PM, James Adams - NOAA Affiliate wrote:
I would like to create a method that takes a NetCDF Variable as an
argument and returns the Variable's start time (or optionally the end
time). I can imagine how I'd cook up such a method by getting the
variable's time dimension, then getting the start (or end) date using
the time dimension's units, etc., but it'll be several lines of code
and I'm hoping that instead someone has done this sort of thing before
that I can reuse, or if not then maybe there's a best practice that I
could follow.
For example, I'd like to create a couple methods with the following
signatures (or something similar):
public Date getInitialDate(Variable variable);
public Date getFinalDate(Variable variable);
or more generally:
public Date getDate(Variable variable, int timeIndex);
Can anyone advise? Thanks in advance for any suggestions.
Those signatures are odd. Only variables that use a time dimension have
a start and an end time. Are you going to throw an exception if there is
no time dimension associated with the variable?
And if the methods are going to all the trouble of figuring out if there
is a associated time dimension, then why not have it return two Dates:
the begin and end dates?
And very few datasets have multiple time dimensions / different time
dimensions for different variables. Doesn't it almost always make sense
to just find the time variable, e.g., time[time] and return the first
and last values as Dates?
And Dates don't deal with different calendars. And a surprising number
of datasets have dates in year 0000 and 0001. Don't you want
GregorianCalendar objects instead?
Yes, it's several lines of code and how it works depends on whether or
not the dataset conforms to CF metadata standard (or some other
standard), but I think that's what you need to do.
There is an ACDD standard that is similar:
see time_coverage_start and time_coverage_end at
https://geo-ide.noaa.gov/wiki/index.php?title=NetCDF_Attribute_Convention_for_Dataset_Discovery
but it is not as widely used as the CF standard.
Perhaps there is a netcdf-java library call that is more suitable.
Someone else may know.
Good luck.
--James
_______________________________________________
netcdf-java mailing list
netcdf-java@xxxxxxxxxxxxxxxx
For list information or to unsubscribe, visit:
http://www.unidata.ucar.edu/mailing_lists/
--
Sincerely,
Bob Simons
IT Specialist
Environmental Research Division
NOAA Southwest Fisheries Science Center
1352 Lighthouse Ave
Pacific Grove, CA 93950-2079
Phone: (831)658-3205
Fax: (831)648-8440
Email: bob.simons@xxxxxxxx
The contents of this message are mine personally and
do not necessarily reflect any position of the
Government or the National Oceanic and Atmospheric
Administration.
<>< <>< <>< <>< <>< <>< <>< <>< <>< <><