python-awips/examples/GetGridTimes.md

64 lines
17 KiB
Markdown
Raw Normal View History

2015-06-29 15:30:33 -06:00
{{{
#!python
import numpy as np
from ufpy.dataaccess import DataAccessLayer
#Initiate a new DataRequest
request = DataAccessLayer.newDataRequest()
#Set the datatype to grid so it knows what plugin to route the request too
request.setDatatype("grid")
#Use setLocationNames to set the model we want data from
request.setLocationNames('RUC130')
#Next we set the variable and level of data we want
request.setParameters("T")
request.setLevels("850MB")
#getAvailableTimes allows us to query what times are available based off of the
#model, parameter, and levels we have previously identified. These are of the type
#dynamicserialize.dstypes.com.raytheon.uf.common.time.DataTime.DataTime.
t = DataAccessLayer.getAvailableTimes(request)
print t
#Loop through each DataTime object in our returned list and print the RefTime and ValidPeriod
#See dynamicserialize.dstypes.com.raytheon.uf.common.time.DataTime.DataTime for methods available
#with this object
for each in t:
print each.getRefTime(),each.getValidPeriod()
}}}
getAvailableTimes() returns a list of !DataTime objects and the print statement above would show something like this:
{{{
[<dynamicserialize.dstypes.com.raytheon.uf.common.time.DataTime.DataTime object at 0x12b3bd0>, <dynamicserialize.dstypes.com.raytheon.uf.common.time.DataTime.DataTime object at 0x12b3cd0>, <dynamicserialize.dstypes.com.raytheon.uf.common.time.DataTime.DataTime object at 0x12b3dd0>, <dynamicserialize.dstypes.com.raytheon.uf.common.time.DataTime.DataTime object at 0x12b3ed0>, <dynamicserialize.dstypes.com.raytheon.uf.common.time.DataTime.DataTime object at 0x12b3fd0>, <dynamicserialize.dstypes.com.raytheon.uf.common.time.DataTime.DataTime object at 0x12b1110>, <dynamicserialize.dstypes.com.raytheon.uf.common.time.DataTime.DataTime object at 0x12b1210>, <dynamicserialize.dstypes.com.raytheon.uf.common.time.DataTime.DataTime object at 0x12b1310>, <dynamicserialize.dstypes.com.raytheon.uf.common.time.DataTime.DataTime object at 0x12b1410>, <dynamicserialize.dstypes.com.raytheon.uf.common.time.DataTime.DataTime object at 0x12b1510>, <dynamicserialize.dstypes.com.raytheon.uf.common.time.DataTime.DataTime object at 0x12b1610>, <dynamicserialize.dstypes.com.raytheon.uf.common.time.DataTime.DataTime object at 0x12b1710>, <dynamicserialize.dstypes.com.raytheon.uf.common.time.DataTime.DataTime object at 0x12b1810>, <dynamicserialize.dstypes.com.raytheon.uf.common.time.DataTime.DataTime object at 0x12b1910>, <dynamicserialize.dstypes.com.raytheon.uf.common.time.DataTime.DataTime object at 0x12b1a10>, <dynamicserialize.dstypes.com.raytheon.uf.common.time.DataTime.DataTime object at 0x12b1b10>, <dynamicserialize.dstypes.com.raytheon.uf.common.time.DataTime.DataTime object at 0x12b1c10>, <dynamicserialize.dstypes.com.raytheon.uf.common.time.DataTime.DataTime object at 0x12b1d10>, <dynamicserialize.dstypes.com.raytheon.uf.common.time.DataTime.DataTime object at 0x12b1e10>, <dynamicserialize.dstypes.com.raytheon.uf.common.time.DataTime.DataTime object at 0x12b1f10>, <dynamicserialize.dstypes.com.raytheon.uf.common.time.DataTime.DataTime object at 0x131a050>, <dynamicserialize.dstypes.com.raytheon.uf.common.time.DataTime.DataTime object at 0x131a150>, <dynamicserialize.dstypes.com.raytheon.uf.common.time.DataTime.DataTime object at 0x12b3790>, <dynamicserialize.dstypes.com.raytheon.uf.common.time.DataTime.DataTime object at 0x131a290>, <dynamicserialize.dstypes.com.raytheon.uf.common.time.DataTime.DataTime object at 0x131a390>, <dynamicserialize.dstypes.com.raytheon.uf.common.time.DataTime.DataTime object at 0x131a490>, <dynamicserialize.dstypes.com.raytheon.uf.common.time.DataTime.DataTime object at 0x131a590>, <dynamicserialize.dstypes.com.raytheon.uf.common.time.DataTime.DataTime object at 0x131a690>, <dynamicserialize.dstypes.com.raytheon.uf.common.time.DataTime.DataTime object at 0x131a790>, <dynamicserialize.dstypes.com.raytheon.uf.common.time.DataTime.DataTime object at 0x131a890>, <dynamicserialize.dstypes.com.raytheon.uf.common.time.DataTime.DataTime object at 0x131a990>, <dynamicserialize.dstypes.com.raytheon.uf.common.time.DataTime.DataTime object at 0x131aa90>, <dynamicserialize.dstypes.com.raytheon.uf.common.time.DataTime.DataTime object at 0x131ab90>, <dynamicserialize.dstypes.com.raytheon.uf.common.time.DataTime.DataTime object at 0x131ac90>, <dynamicserialize.dstypes.com.raytheon.uf.common.time.DataTime.DataTime object at 0x131ad90>, <dynamicserialize.dstypes.com.raytheon.uf.common.time.DataTime.DataTime object at 0x131ae90>, <dynamicserialize.dstypes.com.raytheon.uf.common.time.DataTime.DataTime object at 0x131af90>, <dynamicserialize.dstypes.com.raytheon.uf.common.time.DataTime.DataTime object at 0x131e0d0>, <dynamicserialize.dstypes.com.raytheon.uf.common.time.DataTime.DataTime object at 0x131e1d0>, <dynamicserialize.dstypes.com.raytheon.uf.common.time.DataTime.DataTime object at 0x131e2d0>, <dynamicserialize.dstypes.com.raytheon.uf.common.time.DataTime.DataTime object at 0x131e3d0>, <dynamicserialize.dstypes.com.raytheon.uf.common.time.DataTime.DataTime object at 0x131e4d0>, <dynamicserialize.dstypes.com.raytheon.uf.common.time.DataTime.DataTime object at 0x131e5d0>, <dynamicserialize.dstypes.com.raytheon.uf.common.tim
}}}
There are methods on the !DataTime object to pull out specific information...for example in the loop above we go through each !DataTime object and print out
the !RefTime and !ValidPeriod
{{{
Apr 28 15 07:00:00 GMT (Apr 28 15 07:00:00 , Apr 28 15 07:00:00 )
Apr 28 15 08:00:00 GMT (Apr 28 15 08:00:00 , Apr 28 15 08:00:00 )
Apr 28 15 07:00:00 GMT (Apr 28 15 08:00:00 , Apr 28 15 08:00:00 )
Apr 28 15 09:00:00 GMT (Apr 28 15 09:00:00 , Apr 28 15 09:00:00 )
Apr 28 15 08:00:00 GMT (Apr 28 15 09:00:00 , Apr 28 15 09:00:00 )
Apr 28 15 07:00:00 GMT (Apr 28 15 09:00:00 , Apr 28 15 09:00:00 )
Apr 28 15 10:00:00 GMT (Apr 28 15 10:00:00 , Apr 28 15 10:00:00 )
Apr 28 15 09:00:00 GMT (Apr 28 15 10:00:00 , Apr 28 15 10:00:00 )
Apr 28 15 08:00:00 GMT (Apr 28 15 10:00:00 , Apr 28 15 10:00:00 )
Apr 28 15 07:00:00 GMT (Apr 28 15 10:00:00 , Apr 28 15 10:00:00 )
Apr 28 15 11:00:00 GMT (Apr 28 15 11:00:00 , Apr 28 15 11:00:00 )
Apr 28 15 10:00:00 GMT (Apr 28 15 11:00:00 , Apr 28 15 11:00:00 )
Apr 28 15 09:00:00 GMT (Apr 28 15 11:00:00 , Apr 28 15 11:00:00 )
Apr 28 15 08:00:00 GMT (Apr 28 15 11:00:00 , Apr 28 15 11:00:00 )
Apr 28 15 07:00:00 GMT (Apr 28 15 11:00:00 , Apr 28 15 11:00:00 )
Apr 28 15 12:00:00 GMT (Apr 28 15 12:00:00 , Apr 28 15 12:00:00 )
Apr 28 15 11:00:00 GMT (Apr 28 15 12:00:00 , Apr 28 15 12:00:00 )
Apr 28 15 10:00:00 GMT (Apr 28 15 12:00:00 , Apr 28 15 12:00:00 )
Apr 28 15 09:00:00 GMT (Apr 28 15 12:00:00 , Apr 28 15 12:00:00 )
Apr 28 15 08:00:00 GMT (Apr 28 15 12:00:00 , Apr 28 15 12:00:00 )
Apr 28 15 07:00:00 GMT (Apr 28 15 12:00:00 , Apr 28 15 12:00:00 )
Apr 28 15 13:00:00 GMT (Apr 28 15 13:00:00 , Apr 28 15 13:00:00 )
Apr 28 15 12:00:00 GMT (Apr 28 15 13:00:00 , Apr 28 15 13:00:00 )
...
}}}