MeteoIODoc 20240411.d3bdb3cb

Format and limitations

This plugin reads GRIB ( files as produced by meteorological models. Being based on GRIB API (, it should support both version 1 and 2 of the format (please note that grib_api must be compiled with Position Independent Code ("fPIC" flag)). Fields are read based on their marsParam code (this is built as {grib parameter number}.{grib table number} the table being preferably table 2, the parameter being preferably WMO standardized, as in and levels (levels description is available at Standard COSMO grids are listed at while NCEP are listed at Users with access to CSCS can find the up-to-date parameters description under /oprusers/osm/opr/lib/dictionary_cosmo.txt

Several assumptions/approximations are held/made when reading grids:

  • since models usually use rotated latitude/longitude (see , part I, chapter 3.3), the center of the domain can be approximated by a tangential cartesian coordinate system. We therefore don't re-project the lat/lon grid and use it "as is".
  • however, no correction for grid rotation is currently performed. If a grid rotation is specified on top of the rotated coordinate system, an error message will be given
  • the cell size is computed at the center of the domain. This is performed by retrieving the latitude and longitude increments in the rotated coordinates, computing the point at center+increment in geographic coordinates and computing the equivalent geographic latitude and longitude increment. These increments are then converted to distances along the parallel and meridian at the true center latitude (see
  • the average cell size (ie: average between x and y) is used to move the center point to the lower left corner. This will be returned as lower left corner geolocalization of the grid.

This means that close to the center of the grid, coordinates and distances will work as expected, but the distortion will increase when moving away from the center and can become significant. As examples for domain size, cone can look at the MeteoSwiss domain definition at .

As a side note, when calling read2DGrid(grid, filename), it will returns the first grid that is found. When using the standard call, it will look for the the file within the provided directory that contains the requested timestamp and read the requested field from it. Each file should contain all the fields but only one timestamp per file.


This plugin has been developed primarily for reading GRIB files produced by COSMO ( at MeteoSwiss. COSMO (COnsortium for Small scale MOdelling) represents a non-hydrostatic limited-area atmospheric model, to be used both for operational and for research applications by the members of the consortium. The Consortium has the following members:

  • Germany, DWD, Deutscher Wetterdienst
  • Switzerland, MCH, MeteoSchweiz
  • Italy, USAM, Ufficio Generale Spazio Aereo e Meteorologia
  • Greece, HNMS, Hellenic National Meteorological Service
  • Poland, IMGW, Institute of Meteorology and Water Management
  • Romania, NMA, National Meteorological Administration
  • Russia, RHM, Federal Service for Hydrometeorology and Environmental Monitoring
  • Germany, AGeoBw, Amt für GeoInformationswesen der Bundeswehr
  • Italy, CIRA, Centro Italiano Ricerche Aerospaziali
  • Italy, ARPA-SIMC, ARPA Emilia Romagna Servizio Idro Meteo Clima
  • Italy, ARPA Piemonte, Agenzia Regionale per la Protezione Ambientale Piemonte


As specified by WMO.

Files naming scheme

When a grid is read by providing the filename to open, any file name will obviously work. Otherwise, the file names have to follow the pattern:
{GRID2DPREFIX}{ISO8601 numerical UTC date}{GRID2DEXT}
By default, GRID2DPREFIX is empty and GRID2DEXT is ".grb". This means that by default, a grib file containing data for 2013-10-15T12:00 would be: "201310151200.grb". Since the grid extension contains the ".", it is possible to use it for a file name suffix as well. For example, to read files named like "lfff201310151200_z" one would provide GRID2DPREFIX="lfff" and GRID2DEXT="_z".


This plugin uses the following keywords:

  • COORDSYS: coordinate system (see Coords)
  • COORDPARAM: extra coordinates parameters (see Coords)
  • GRID2DPATH: path where to find the grids
  • GRID2DPREFIX: prefix to append when generating a file name for reading (ie: something like "laf" for Cosmo-Analysis-full domain), optional
  • GRID2DEXT: grib file extension, or none for no file extension (default: ".grb")
  • GRIB_DEM_UPDATE: recompute slope/azimuth from the elevations when reading a DEM (default=false, that is we use the slope and azimuth included in the GRIB file)
  • METEOPATH: path where to find the grids for extracting time series at the given points
  • METEOEXT: file extension, or none for no file extension (default: ".grb")
  • STATION#: coordinates for virtual stations (if using GRIB as METEO plugin). Each station is given by its coordinates and the closest grid point will be chosen. Coordinates are given one one line as "lat lon" or "xcoord ycoord epsg_code". If a point leads to duplicate grid points, it will be removed from the list.
  • STATION#: provide the lat, lon and altitude or easting, northing and altitude for a station to get the data from (see Coords() for the syntax). The altitude will be replaced by the one coming from the DEM, so feel free to use "-1" for example to make it obvious that it will be discarded. Finally, if a point leads to duplicate grid points, it will be removed from the list (mandatory);
  • GRIB_DEBUG: output more information about the grib files in order to help fix potential problems (default: false).
METEOPATH = ./input
STATION1 = xy (779932, 188182, -1) ;WFJ
STATION2 = xy (788889, 192513, -1) ;Kloster
STATION3 = xy (793274, 183770, -1) ;Weisshorn
GRID2DPATH = ./input
GRID2DEXT = none
DEMFILE = ./input/laf2012031001