Module pygrib :: Class gribmessage

# type gribmessage

    object --+
             |
            gribmessage

Grib message object.

Each grib message has attributes corresponding to grib message keys for GRIB1 and GRIB2. Parameter names are are given by the `name`, `shortName` and `paramID` keys. pygrib also defines some special attributes which are defined below under the heading Instance Variables.

Instance Methods

__delattr__(...) x.__delattr__('name') <==> del x.name |

__delitem__(x, y) del x[y] |

__getattr__(...) |

__getattribute__(...) x.__getattribute__('name') <==> x.name |

__getitem__(...) access values associated with grib keys. |

__init__(...) x.__init__(...) initializes x; see help(type(x)) for signature |

a new object with type S, a subtype of T

__new__(T, S, ...) |

__repr__(...) prints a short inventory of the grib message |

__setattr__(...) x.__setattr__('name', value) <==> x.name = value |

__setitem__(...) change values associated with existing grib keys. |

data(lat1=None, lat2=None, lon1=None, lon2=None) extract data, lats and lons for a subset region defined by the keywords lat1,lat2,lon1,lon2. |

expand_grid(...) toggle expansion of reduced grids to regular grids |

has_key(key) tests whether a grib message object has a specified key. |

is_missing(key) returns True if value associated with key is equal to grib missing value flag (False otherwise) |

keys() return keys associated with a grib message (a dictionary-like object) |

latlons() compute lats and lons (in degrees) of grid. |

tostring() return coded grib message in a binary string. |

valid_key(key) tests whether a grib message object has a specified key, it is not missing and it has a value that can be read. |

Instance Variables
| analDate A python datetime instance describing the analysis date and time for the forecast.
| expand_reduced If True (default), reduced lat/lon and gaussian grids will be expanded to regular grids when data is accessed via "values" key.
| fcstimeunits A string representing the forecast time units (an empty string if not defined).
| messagenumber The grib message number in the file.
| projparams A dictionary containing proj4 key/value pairs describing the grid.
| validDate A python datetime instance describing the valid date and time for the forecast.

Method Details

### __delattr__(...)

x.__delattr__('name') <==> del x.name

Overrides: object.__delattr__

### __getattribute__(...)

x.__getattribute__('name') <==> x.name

Overrides: object.__getattribute__

### __getitem__(...)
(Indexing operator)

access values associated with grib keys.

The key "values" will return the data associated with the grib message. The data is returned as a numpy array, or if missing values or a bitmap are present, a numpy masked array. Reduced lat/lon or gaussian grid data is automatically expanded to a regular grid using linear interpolation (nearest neighbor if an adjacent grid point is a missing value).

### __init__(...)
(Constructor)

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__

### __new__(T, S, ...)

Returns: a new object with type S, a subtype of T
Overrides: object.__new__

### __repr__(...)
(Representation operator)

prints a short inventory of the grib message

Overrides: object.__repr__

### __setattr__(...)

x.__setattr__('name', value) <==> x.name = value

Overrides: object.__setattr__

### data(lat1=None, lat2=None, lon1=None, lon2=None)

extract data, lats and lons for a subset region defined by the keywords lat1,lat2,lon1,lon2.

The default values of lat1,lat2,lon1,lon2 are None, which means the entire grid is returned.

If the grid type is unprojected lat/lon and a geographic subset is requested (by using the lat1,lat2,lon1,lon2 keywords), then 2-d arrays are returned, otherwise 1-d arrays are returned.

### latlons()

compute lats and lons (in degrees) of grid. Currently handles reg. lat/lon, global gaussian, mercator, stereographic, lambert conformal, albers equal-area, space-view, azimuthal equidistant, reduced gaussian, reduced lat/lon, lambert azimuthal equal-area, rotated lat/lon and rotated gaussian grids.

Returns:
  `lats,lons`, numpy arrays containing latitudes and longitudes of grid (in degrees).

Instance Variable Details

### analDate

A python datetime instance describing the analysis date and time for the forecast. Only set if forecastTime and julianDay keys exist.

### expand_reduced

If True (default), reduced lat/lon and gaussian grids will be expanded to regular grids when data is accessed via "values" key. If False, data is kept on unstructured reduced grid, and is returned in a 1-d array.

### projparams

A dictionary containing proj4 key/value pairs describing the grid. Set to `None` for unsupported grid types.

### validDate

A python datetime instance describing the valid date and time for the forecast. Only set if forecastTime and julianDay keys exist, and fcstimeunits is defined. If forecast time is a range, then `validDate` corresponds to the end of the range.