NetCDF: Converting time variable using start time from "units" [message #91903] |
Mon, 14 September 2015 13:33  |
laura.hike
Messages: 87 Registered: September 2013
|
Member |
|
|
I've been reading and writing NetCDF files using IDL for some time. Now I'm wondering whether there's a better way to convert the values in the "time" variable to real times than by using ncdump to get the units from the attributes and then hard coding the offset into my routines. I can read the units, e.g.,
time:units = "minutes since 2007-01-26 01:30:00"
using ncdf_attget, but don't know of any way IDL can understand this information and automatically apply the offset to the values in "time". I've heard a rumor that this can be done. Any suggestions? Thanks.
|
|
|
|
Re: NetCDF: Converting time variable using start time from "units" [message #91916 is a reply to message #91904] |
Tue, 15 September 2015 08:32   |
laura.hike
Messages: 87 Registered: September 2013
|
Member |
|
|
Thanks! Given that this expression of start time is a standard, you'd think there'd already be an IDL function to read it....
On Monday, September 14, 2015 at 3:29:07 PM UTC-7, Mike Galloy wrote:
> On 9/14/15 2:33 PM, Larry H. wrote:
>> I've been reading and writing NetCDF files using IDL for some time.
>> Now I'm wondering whether there's a better way to convert the values
>> in the "time" variable to real times than by using ncdump to get the
>> units from the attributes and then hard coding the offset into my
>> routines. I can read the units, e.g.,
>>
>> time:units = "minutes since 2007-01-26 01:30:00"
>>
>> using ncdf_attget, but don't know of any way IDL can understand this
>> information and automatically apply the offset to the values in
>> "time". I've heard a rumor that this can be done. Any suggestions?
>> Thanks.
>>
>
> I have a basic routine to do this MG_CF2JULIAN to convert from the CF
> convention in netCDF to Julian time:
>
> https://github.com/mgalloy/mglib/blob/master/src/calendar/mg _cf2julian.pro
>
> This handled my needs, but I think is fairly general. Please let me know
> if there is more you need from it.
>
> Mike
> --
> Michael Galloy
> www.michaelgalloy.com
> Modern IDL: A Guide to IDL Programming (http://modernidl.idldev.com)
|
|
|
|
|
Re: NetCDF: Converting time variable using start time from "units" [message #91921 is a reply to message #91917] |
Tue, 15 September 2015 14:17  |
laura.hike
Messages: 87 Registered: September 2013
|
Member |
|
|
COARDS standards don't count? Anyway, Python handles this seamlessly and there are toolbox functions for Matlab, so it doesn't seem like a lot to ask.
On Tuesday, September 15, 2015 at 8:40:22 AM UTC-7, David Fanning wrote:
>
>> Thanks! Given that this expression of start time is a standard, you'd think there'd already be an IDL function to read it....
>
> Well, there are standards and there are Standards. In my experience,
> netCDF uses the former, not the later. ;-)
>
> Cheers,
>
> David
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
> Sepore ma de ni thue. ("Perhaps thou speakest truth.")
|
|
|