Class index
object --+
|
index
index(filename, *args)
returns grib index object given GRIB filename indexed by keys given in
*args. The select or __call__ method can then be used to selected grib
messages based on specified values of indexed keys. Unlike open.select,
containers or callables cannot be used to select multiple key values.
However, using index.select is much faster than open.select.
If no key are given (i.e. *args is empty), it is assumed the filename
represents a previously saved index (created using the
grib_index_build
tool or index.write)
instead of a GRIB file.
Example usage:
>>> import pygrib
>>> grbindx=pygrib.index('sampledata/gfs.grb','shortName','typeOfLevel','level')
>>> selected_grbs=grbindx.select(shortName='gh',typeOfLevel='isobaricInhPa',level=500)
>>> for grb in selected_grbs:
>>> grb
1:Geopotential height:gpm (instant):regular_ll:isobaricInhPa:level 500 Pa:fcst time 72 hrs:from 200412091200:lo res cntl fcst
>>>
>>> selected_grbs=grbindx(shortName='u',typeOfLevel='isobaricInhPa',level=250)
>>> for grb in selected_grbs:
>>> grb
1:u-component of wind:m s**-1 (instant):regular_ll:isobaricInhPa:level 250 Pa:fcst time 72 hrs:from 200412091200:lo res cntl fcst
>>> grbindx.write('gfs.grb.idx')
>>> grbindx.close()
>>> grbindx = pygrib.index('gfs.grb.idx')
>>> for grb in selected_grbs:
>>> grb
1:u-component of wind:m s**-1 (instant):regular_ll:isobaricInhPa:level 250 Pa:fcst time 72 hrs:from 200412091200:lo res cntl fcst
|
|
|
__init__(filename,
*args)
x.__init__(...) initializes x; see help(type(x)) for signature |
|
|
a new object with type S, a subtype of T
|
|
|
close()
deallocate C structures associated with class instance |
|
|
|
select(**kwargs)
return a list of gribmessage instances from grib index object
corresponding to specific values of indexed keys (given by kwargs). |
|
|
|
write(filename)
save grib index to file |
|
|
Inherited from object :
__delattr__ ,
__format__ ,
__getattribute__ ,
__hash__ ,
__reduce__ ,
__reduce_ex__ ,
__repr__ ,
__setattr__ ,
__sizeof__ ,
__str__ ,
__subclasshook__
|
|
keys
list of strings containing keys used in the index.
|
|
types
if keys are typed, this list contains the type declarations
(l , s or d ).
|
|
name
|
Inherited from object :
__class__
|
__init__(filename,
*args)
(Constructor)
|
|
x.__init__(...) initializes x; see help(type(x)) for signature
- Overrides:
object.__init__
|
- Returns: a new object with type S, a subtype of T
- Overrides:
object.__new__
|
return a list of gribmessage instances from grib index object
corresponding to specific values of indexed keys (given by kwargs).
Unlike open.select, containers or callables cannot be used to
select multiple key values. However, using index.select is
much faster than open.select.
Example usage:
>>> import pygrib
>>> grbindx=pygrib.index('sampledata/gfs.grb','shortName','typeOfLevel','level')
>>> selected_grbs=grbindx.select(shortName='gh',typeOfLevel='isobaricInhPa',level=500)
>>> for grb in selected_grbs:
>>> grb
1:Geopotential height:gpm (instant):regular_ll:isobaricInhPa:level 500 Pa:fcst time 72 hrs:from 200412091200:lo res cntl fcst
>>>
>>> selected_grbs=grbindx(shortName='u',typeOfLevel='isobaricInhPa',level=250)
>>> for grb in selected_grbs:
>>> grb
1:u-component of wind:m s**-1 (instant):regular_ll:isobaricInhPa:level 250 Pa:fcst time 72 hrs:from 200412091200:lo res cntl fcst
>>> grbindx.close()
|
types
if keys are typed, this list contains the type declarations
(l , s or d ). Type declarations are
specified by appending to the key name (i.e. level:l will
search for values of level that are longs).
|