[Go to Previous] [Go to Next]


Create an Object - Grids

listGridFieldsInFile - Lists the fields in a file brought in with loadGrid. The output is shortname ; longname

Usage: myData = listGridFieldsInFile(keywords)
Keywords - required:
filename= directory path to local gridded file
Example:
listGridFieldsInFile(filename='C:/Users/myUser/gfs.grb')

listGridLevelsInField - Lists the vertical levels included in a field of a loadGrid file

Usage: myData = listGridLevelsInField(keywords)
Keywords - required:
filename= directory path to local gridded file
field= the short name of the field to list levels of. A listing of field short names included in a file can be printed using listGridFieldsInFile
Example:
listGridLevelsInField(filename='C:/Users/myUser/gfs.grb',field='Temperature_Isobaric')

listGridTimesInField - Lists the times included in a field of a loadGrid file

Usage: myData = listGridTimesInField(keywords)
Keywords - required:
filename= directory path to local gridded file
field= the short name of the field to list times of. A listing of field short names included in a file can be printed using listGridFieldsInFile
Example:
listGridTimesInField(filename='C:/Users/myUser/gfs.grb',field='Temperature_Isobaric')

loadGrid - Loads local netCDF, hdf, and grib files.

Usage: myData = loadGrid(keywords)
Keywords - required:
filename= directory path to local gridded file
field= the short name of the field to load. A listing of field short names included in a file can be printed using listGridFieldsInFile.
Keywords - optional:
level= the vertical level and units to load. Default="All". A listing of vertical levels included with a field can be printed using listGridLevelsInField. Example: level="1000 hPa"
time= the time to load. This can be an integer representing the index of time to be loaded (Default=0 for earliest time). A listing of times included with a field can be printed using listGridTimesInField. This can also be set as a date/time text string. Example: time="2014-01-16 18:00:00 UTC"
xStride= integer value to reduce the resolution of display in the x-direction. Default=1 for full resolution. Higher values reduce the resolution.
yStride= integer value to reduce the resolution of display in the y-direction. Default=1 for full resolution. Higher values reduce the resolution.
stride= integer value to reduce the resolution of the display in the x and y-directions. Default=1 for full resolution. Higher values reduce the resolution.
xRange= integer for geographically subsetting by grid indices in the x-direction. By default, no geographical subsetting is done. Example: xRange=(0,80)
yRange= integer for geographically subsetting by grid indices in the y-direction. By default, no geographical subsetting is done. Example: yRange=(0,80)
latLonBounds= geographically subset by lat/lon bounds. By default, no subsetting is done. The expected format is (upper left lat, upper left, lon, lower right lat, lower right lon). Example: latLonBounds=(50,-130,20,-65)
Example:
t850 = loadGrid(filename='C:/Users/myUser/gfs.grb',field='Temperature_Isobaric',level='850 hPa')
The data object returned from loadGrid contains a variety of key:value pairings with information about the data. The list of keys may vary dependent on the type of data, but here is a general list of keys that may be included in the data object returned from loadGrid as well as example values:
Key Example Value
globalAttributes dictionary of all global attributes included with data
level 850.0
description 'Temperature @ Isobaric surface'
units 'K'
dataSourceName file path or URL of data source
times [2016-03-08T06:00:00Z]
filename name of file or URL of data source
field Temperature_isobaric
datatype float
metadataVariables dictionary of all metadata variables included with data
attributes lists all of the attributes of the field/variable loaded
projection projection information about the data
levels [850]
info 'Temperature_isobaric K false Temperature @ Isobaric surface'
variableAttributes lists all of the attributes of the field/variable loaded
These keys and values can be printed as follows:
t850['description']
The keys and values within one of the dictionary keys (globalAttributes or metadataVariables) can be printed as follows:
t850['globalAttributes']
An individual value of one of the keys in globalAttributes or metadataVariables can be printed as follows
t850['globalAttributes']['file_format']
A practical use for these key:value parings would be to apply it to a layer label. This example adds the description key to the layer label along with the %timestamp% macro:
layer.setLayerLabel(t850['description']+' %timestamp%')

[Go to Previous] [Go to Next]