DOE-4 nominal time

Post any questions, ideas, or topics related to Jython and Python scripting.
Post Reply
User avatar
joleenf
Posts: 1123
Joined: Mon Jan 19, 2009 7:16 pm

DOE-4 nominal time

Post by joleenf »

Hi,

What is the proper way to extract the nominal time for a loadGrid object? I have a few options in my notes, but I don't know that either are working:

data=loadGrid(**parms)
print data.getMetadataMap().get('nominal-time')
or Mike had suggested that at some point it would be possible to use

print data['nominal-time']

when the code was finished. Has the nominal-time option been implemented for DOE-4 data? The first option:

print data.getMetadataMap().get('nominal-time') returns None

the second option:

print data.getMetadataMap().get('nominal-time') fails with a key error.

Using the metaDataVariables from loadGrid,

print data['metadataVariables']['t']['value'], the time is printed but not converted to a yyyy-MM-dd time. I thought the conversion had been built into the loadGrid objects.

print data['times'] on DOE-4 data returns []

Thanks,
Joleen
User avatar
bobc
Posts: 990
Joined: Mon Nov 15, 2010 5:57 pm

Re: DOE-4 nominal time

Post by bobc »

Hi Joleen -

I replicated that 'nominal-time' can't be returned from an object returned from loadGrid, be it an ABI DOE-4 file or a grib2 GFS 80km CONUS file. I wrote up adding this functionality as Inquiry 2456.

I did some digging around and before this ABI data worked with loadGrid, Mike H put together a function called loadAbiDoe which looks to be a bare-bones implementation of loadGrid designed specifically for ABI data. In lines 19-20 it looks like there's code to add 'nominal-time' to the metadata map. I'm not sure why this was this wasn't eventually added to loadGrid. This might take some investigation on our end.

When working with ABI DOE-4 data the timestamp is pulled from the time_coverage_start global attribute which you can print out with:

Code: Select all

print data['globalAttributes']['time_coverage_start']

Is this output of time_coverage_start what you are looking for?

Thanks -
Bob Carp
User avatar
joleenf
Posts: 1123
Joined: Mon Jan 19, 2009 7:16 pm

Re: DOE-4 nominal time

Post by joleenf »

Hi Bob,

This is the date/time that I am looking for.

Joleen
User avatar
joleenf
Posts: 1123
Joined: Mon Jan 19, 2009 7:16 pm

Re: DOE-4 nominal time

Post by joleenf »

Hi Bob,

This date also is not the prettiest for conversion using datetime. The code below is what I am currently using to convert this string to a datetime object, I am wondering if there is a better technique.

from datetime import datetime

new1=datetime.strptime((t.replace('T',' ')).replace('Z','UTC'),'%Y-%m-%d %H:%M:%S.%f%Z')

This is probably not the best method. This is just for easy reformatting of the date, creating a dateTime object would work as well for this purpose.

Joleen
User avatar
bobc
Posts: 990
Joined: Mon Nov 15, 2010 5:57 pm

Re: DOE-4 nominal time

Post by bobc »

Hi Joleen -

I've been looking around for a while and I'm not finding a better way to convert the time string. It looks like what you are doing with datetime.strptime is what is most commonly suggested on various forums I'm finding.

- Bob
User avatar
joleenf
Posts: 1123
Joined: Mon Jan 19, 2009 7:16 pm

Re: DOE-4 nominal time

Post by joleenf »

Hi Bob,

I must have had a typo when I was testing this, because the following also works:

newTime=datetime.strptime(t, "%Y-%m-%dT%H:%M:%S.%fZ")

Since the time format in the doe4 and future goes-16 files should be consistent, this is probably the way to set up the conversion in this case.

Joleen
Post Reply