WMO GRIB as a Data Model Gil Ross, UK Met Office 2009-09-14 WMO GRIB • Owned by WMO – maintained by WMO CBS IPET-DR&C • Grib Edition 0 – 1985 – based on WMO GRID and NOAA H-code – Binary – Table driven • Grib Edition 1 - 1990 – single level, single parameter, single time – Still used by aviation • Grib Edition 2 - 1997 – Multi-dimensional, template driven – Failed to converge with NetCDF and HDF in 1990s • Used daily, intensively, by WMO, ICAO, IOC since 1994. WMO GRIB as a Data Model • GRIB is many things: – Exchange container, – Multidimensional data format, – Reference tables, semantics, controlled vocab. – Compression mechanism, – Data model. GRIB as a Container • GRIB container has metadata: – Container metadata – Identification metadata • describing the producer, producing mechanism, • which registry - standard or local/private. – Temporal metadata (potentially 3 temporal dimensions!) – Projection grid metadata (potentially multiple dimensional grids) – Data description metadata • Describing the coverage(s) – Compression metadata – Local metadata GRIB as Multidimensional Format • Data description metadata – 2 D scalar, or 2 D vector (winds on 2 D grid) – Tensor data possible on each grid point – 3rd or more parametric dimension to define coverages (at multiple values of 3rd dimensional grid) – Multiple coverages possible in same container – Missing value masks • Registry table to define coverage (dependent variable) is the same as table to define parametric grid term (independent variable) • This is a major change to ISO 19123 coverages WMO GRIB: some semantics (1) Code Parameter . 052 Relative humidity 053 Humidity mixing ratio 054 Precipitable water 055 Vapour pressure 056 Saturation deficit 057 Evaporation 058 Cloud Ice 059 Precipitation rate 060 Thunderstorm probability 061 Total precipitation 062 Large scale precipitation 063 Convective precipitation 064 Snowfall rate water equiv. 065 Water equiv. accum. Snow 066 Snow depth 067 Mixed layer depth 068 Transient thermocline depth 069 Main thermocline depth 070 Main thermocline anomaly 071 Total cloud cover 072 Convective cloud cover 073 Low cloud cover 074 Medium cloud cover 075 High cloud cover 076 Cloud water . . Units % kg/kg kg/m2 Pa Pa kg/m2 kg/m2 kg/m2/s % kg/m2 kg/m2 kg/m2 kg/m2s kg/m2 m m m m m % % % % % kg/m2 Code Vertical Coordinate (Units) 01 Surface (of the Earth, which includes sea surface) 02 Cloud base level 03 Cloud top level 04 0 deg (C) isotherm level 05 Adiabatic condensation level (parcel lifted from surface) 06 Maximum wind speed level 07 Tropopause level 08 Nominal top of atmosphere 09 Sea bottom 10-99 Reserved 100 Isobaric level (hPa) 101 Layer between two isobaric levels (kPa) 102 Mean sea level 103 Fixed height above MSL (m) 104 Layer between two height levels above MSL 105 Fixed height above ground (m) 106 Layer between two height levels above ground 107 Sigma level, value in 1/10000 108 Layer between two sigma levels 109 Hybrid level (level number) 110 Layer between two hybrid levels 111 Depth below land surface (cm) 112 Layer between two depths below land surface (cm) 113 Isentropic (theta) level (Potential Temperature K) 114 Layer between two isentropic levels . . WMO GRIB: some semantics (2) Code Projection Grid Some settings 0 Latitude/Longitude also called Equidistant Cylindrical or Plate Carrée 1 Mercator 2 Gnomonic 3 Lambert Conformal, secant or tangent, conical or bipolar (normal or oblique) 4 Gaussian Latitude/Longitude 5 Polar Stereographic 0 Earth assumed spherical with radius = 6367.47 km 1 Earth assumed oblate spheroid with size as determined by IAU in 1965: 6378.160 km, 6356.775 km, f = 1/297. 13 Oblique Lambert conformal, secant or tangent, conical or bipolar 50 Spherical Harmonic Coefficients 90 Space view perspective or orthographic 0 u- and v-components of vector quantities resolved relative to easterly and northerly directions 1 u- and v-components of vector quantities resolved relative to the defined grid in the direction of increasing x and y (or i and j) coordinates respectively 0 no bit map 1 bit map present, one bit per data point of grid GRIB as Compression Mechanism • • • • • • • • • Gridded n-dimensional data 2D horizontal geospatial grid originally CRS/projection defined functionally Spherical harmonics option Scaled n-bit integers, difference from minimum Minimum may be for 2D field or row by row Option for 2nd order differences Several scanning patterns JPEG compression added to GRID Ed 2 GRIB as a data model • Temporal metadata – Start time of forecast – Forecast lead time – Start and end lead time of averaging period. • Projection grid metadata – Succinct mathematical definition – Defining projection and rectangular grid within that projection – Spherical Harmonic grid of wavenumbers (space is Fourier transformed rather than the data) – Grid is referenced externally, as standard or irregular grid, defined by array of lat/lon points (deprecated) • Compression Metadata – – – – Either find min and max and defined bit-length to get steps for integer digits Or define precision of steps, find minimum and derive bit length Lossy mechanism, but it loses only irrelevant random floating point precision. Properly used this gives good compression, which e.g. gzip may have difficulty improving (because of the high floating point precision). – Attempts at further compression abandoned as unnecessary, e.g. run-length encoding, boustrophedonic wrapping. GRIB as data model • Same registry table for dependent and independent variable • On a rectangular lat-lon grid • temperature = f(height) or height = f(temperature) – At fixed (independent) heights we can have coverages of (dependent) temperature – OR – At fixed (independent) temperatures we can have coverages of (dependent) height values • cloud amount = f(height) or height = f(cloud amount) – Alternatively, the cloud amount at fixed height – OR – The height at which fixed amount (3/8ths) of cloud is reached • This is not an artificial construct, – it describes the legal height at which aircraft may fly under Visual Flying Rules. GRIB as an ISO model or OGC O&M package • GRIB is a WMO operational standard. • WMO is a Standards body with cross-accreditation with ISO. • WMO and ISO have agreed to cross-adopt each others’ appropriate standards • To be an OGC O&M package – Need to decode metadata in an O&M wrapper with payload as GRIB mime-type – Need to publish WMO registries under ISO Registry mechanism – GRIB to XML converter straightforward • particularly metadata • GRIB data to XML conversion not a normal use case • More usually GRIB data to IEEE numbers – Anything more? • Free Source GRIB decoders available (e.g. NOAA NCEP and ECMWF) – However packages are NOT supported to the level of NetCDF • WMO (or rather the members) needs to implement a GRIB to XML metadata and to create registries