Module pygrib

Module pygrib

Introduction

Python module for reading and writing GRIB (editions 1 and 2) files. GRIB is the World Meterological Organization standard for distributing gridded data. The module is a python interface to the GRIB API C library from the European Centre for Medium-Range Weather Forecasts (ECMWF).

Required

These dependencies are available via the package management system of most Linux distributions, and on MacOS X using macports. If you build grib_api yourself as a static library on a 64-bit system you may need to set CFLAGS to '-O2 -fPIC' before running the configure script. To use pygrib on Windows, you must use the Cygwin environment, since the grib_api library requires a posix environment. Cygwin installation instructions are available here.

Installation

Example usage

Documentation


Author: Jeffrey Whitaker.

Contact: Jeff Whitaker

Version: 2.0.0

Copyright: copyright 2010 by Jeffrey Whitaker.

License: Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation. THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

Classes
  gribmessage
Grib message object.
  index
index(filename, *args)
  open
open(filename)
Functions
 
datetime_to_julian(date)
convert python datetime instance to Julian day number.
 
fromstring(string)
Create a gribmessage instance from a python bytes object representing a binary grib message (the reverse of gribmessage.tostring).
 
gaulats(nlats)
Returns nlats gaussian latitudes, in degrees, oriented from north to south.
 
julian_to_datetime(julday)
convert Julian day number to python datetime instance.
 
multi_support_off(...)
turn off support for multi-field grib messages
 
multi_support_on(...)
turn on support for multi-field grib messages (default)
 
reload(grb)
Recreate gribmessage object, updating all the keys to be consistent with each other.
 
setdates(grb)
set fcstimeunits, analDate and validDate attributes using julianDay, forecastTime and indicatorOfUnitOfTimeRange.
 
tolerate_badgrib_off(...)
raise an exception when a missing or malformed key is encountered (default behavior).
 
tolerate_badgrib_on(...)
don't raise an exception when a missing or malformed key is encountered.
Variables
  __package__ = None
  __version__ = '2.0.0'
  default_encoding = 'ascii'
  grib_api_version = '1.12.3'
  missingvalue_float = -1e+100
  missingvalue_int = -1
  tolerate_badgrib = False
Function Details

gaulats(nlats)

 

Returns nlats gaussian latitudes, in degrees, oriented from north to south. nlats must be even.

julian_to_datetime(julday)

 

convert Julian day number to python datetime instance.

Used to create validDate and analDate attributes from julianDay and forecastTime keys.

reload(grb)

 

Recreate gribmessage object, updating all the keys to be consistent with each other. For example, if the forecastTime key is changed, recreating the gribmessage object with this function will cause the analDate and verifDate keys to be updated accordingly.

Equivalent to fromstring(grb.tostring())

setdates(grb)

 

set fcstimeunits, analDate and validDate attributes using julianDay, forecastTime and indicatorOfUnitOfTimeRange. Called automatically when gribmessage instance created, but can be called manually to update keys if one of them is modified after instance creation.