comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » NetCDF: Converting time variable using start time from "units"
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
NetCDF: Converting time variable using start time from "units" [message #91903] Mon, 14 September 2015 13:33 Go to next message
laura.hike is currently offline  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 #91904 is a reply to message #91903] Mon, 14 September 2015 15:29 Go to previous messageGo to next message
Michael Galloy is currently offline  Michael Galloy
Messages: 1114
Registered: April 2006
Senior Member
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 #91916 is a reply to message #91904] Tue, 15 September 2015 08:32 Go to previous messageGo to next message
laura.hike is currently offline  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 #91917 is a reply to message #91916] Tue, 15 September 2015 08:40 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
laura.hike@gmail.com writes:

> 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.")
Re: NetCDF: Converting time variable using start time from "units" [message #91920 is a reply to message #91917] Tue, 15 September 2015 13:52 Go to previous messageGo to next message
laura.hike is currently offline  laura.hike
Messages: 87
Registered: September 2013
Member
COARDS doesn't count?
Re: NetCDF: Converting time variable using start time from "units" [message #91921 is a reply to message #91917] Tue, 15 September 2015 14:17 Go to previous message
laura.hike is currently offline  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.")
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Interpolate
Next Topic: how to write a for loop that skips over things

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 09:19:04 PDT 2025

Total time taken to generate the page: 0.00493 seconds