Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

MARS Key Mapping

The importer reads the following MARS namespace keys from each GRIB message using ecCodes’ read_key_dynamic API.

Keys Extracted

Identification

GRIB KeyDescriptionExample
classMARS class"od" (operational)
typeData type"an" (analysis), "fc" (forecast)
streamData stream"oper", "enfo"
expverExperiment version"0001"

Parameter

GRIB KeyDescriptionExample
paramParameter ID"2t" (2m temperature)
shortNameShort name"2t"
nameFull name"2 metre temperature"
paramIdNumeric ID167
disciplineWMO discipline0
parameterCategoryWMO category0
parameterNumberWMO number0

Vertical

GRIB KeyDescriptionExample
levelLevel value500
typeOfLevelLevel type"isobaricInhPa"
levtypeMARS level type"pl" (pressure level)

Temporal

GRIB KeyDescriptionExample
date / dataDateReference date20260404
time / dataTimeReference time1200
stepRange / stepForecast step"0", "6", "0-6"
stepUnitsStep units1 (hours)

Spatial

GRIB KeyDescriptionExample
gridTypeGrid type"regular_ll"
Ni, NjGrid dimensions360, 181
numberOfPointsTotal grid points65160
latitudeOfFirstGridPointInDegreesFirst latitude90.0
longitudeOfFirstGridPointInDegreesFirst longitude0.0
latitudeOfLastGridPointInDegreesLast latitude-90.0
longitudeOfLastGridPointInDegreesLast longitude359.0
iDirectionIncrementInDegreesLongitude step1.0
jDirectionIncrementInDegreesLatitude step1.0

Other

GRIB KeyDescriptionExample
bitsPerValuePacking precision16
packingTypeGRIB packing"grid_simple"
centreOriginating centre"ecmf"
subCentreSub-centre0
generatingProcessIdentifierProcess ID148

Storage in Tensogram

Given N GRIB messages in merge-all mode:

  1. Extract all MARS keys from each message using read_key_dynamic
  2. Store ALL keys for each GRIB message in the corresponding base[i]["mars"] entry independently
  3. There is no common/varying partitioning in the output — each base[i] entry is self-contained
graph TD
    A[N GRIB messages] --> B[Extract MARS keys from each]
    B --> C["Store in base[i] independently"]
    C --> D["base[0]: all keys from GRIB msg 0"]
    C --> E["base[1]: all keys from GRIB msg 1"]
    C --> F["base[N-1]: all keys from GRIB msg N-1"]

If you need to extract commonalities after decoding (e.g. for display), use the compute_common() utility in software.

Sentinel Handling

ecCodes uses sentinel values for missing keys:

  • String: "MISSING" or "not_found" → skipped
  • Integer: 2147483647 or -2147483647 → skipped
  • Float: NaN or Inf → skipped