Skip to content

Xue Bundle Metadata and Codes

A Xue bundle is one or more variables of one forecast run or observation window, quantized to single-byte codes on the source’s native grid (a series store’s widened variables to sixteen-bit ones, “Series codebooks”). This document is normative for what every bundle carries whatever writes it down: the metadata JSON and its schema versions, the quantization codebooks, and the modulo-256 residual arithmetic. The published layout is a Zarr v3 store (zarr-profile.md); the .xue container (format.md) is the legacy layout every decoder keeps reading. Both carry the codes and the metadata specified here unchanged.

The Python encoder (xuebuild/metadata.py, xuebuild/quantize.py, xuebuild/temporal.py) is the reference; the native encoder and the Rust decoder (rust/xue) are held to it by cross-language golden and parity tests.

Conventions

  • Metadata is UTF-8 JSON.
  • All quantization rounding is round-half-up: round(x) = floor(x + 0.5). Every rounded quantity in this format is non-negative, so this equals round-half-away-from-zero. Implementations must not use round-half-even (the behavior of Python’s built-in round and the IEEE 754 default); a mismatch changes codes for values landing exactly on a half step.

Metadata JSON

The shape of a schemaVersion 3 or 4 document is schemas/bundle-metadata.schema.json, which is normative: a document that does not match it is not version 3 or 4 metadata. The sections below give the meaning of each field and the rules across fields that a schema cannot say, which every reader checks after the shape: the lowest version that fits, the one encoding of a time axis, unique numericIds, and the halves of a GRIB2 value that are null together. Versions 1 and 2 have no schema; their rules are this section’s prose alone. tests/test_schemas.py holds the frozen container corpus (tests/fixtures/v1/), the synthetic run’s containers, posters and stores, and the committed stores to it; the shell checks a version 3 document with the validator generated from it (web/src/schema/generated/), and the Rust decoder’s tests tie the fields it reads to the names the schema gives.

Example (a single-variable GFS temperature bundle):

{
  "schemaVersion": 3,
  "model": "GFS",
  "product": "pgrb2.0p25",
  "runTime": "2026-08-15T06:00:00Z",
  "time": {
    "unitSeconds": 3600,
    "firstFrameOffset": 0,
    "frameStep": 1,
    "frameCount": 121
  },
  "grid": {
    "width": 1440,
    "height": 721,
    "layout": "row-major",
    "rowOrder": "north-to-south",
    "columnOrder": "west-to-east",
    "firstLongitude": -180.0,
    "firstLatitude": 90.0,
    "longitudeStep": 0.25,
    "latitudeStep": -0.25,
    "wrapLongitude": true
  },
  "variables": [
    {
      "numericId": 1,
      "id": "tmp2m",
      "label": "2 meter temperature",
      "unit": "°C",
      "parameter": {
        "discipline": 0,
        "parameterCategory": 0,
        "parameterNumber": 0,
        "typeOfFirstFixedSurface": 103,
        "scaleFactorOfFirstFixedSurface": 0,
        "scaledValueOfFirstFixedSurface": 2
      },
      "quantization": {
        "type": "linear",
        "offset": -60.0,
        "scale": 0.5,
        "minimumCode": 0,
        "maximumCode": 220,
        "nodataCode": 255
      }
    }
  ]
}

A bundle may declare more than one variable; the two 10 m wind components ship together in one two-variable wind10m bundle. Every variable’s quantization block must be one of the codebook types below.

numericId is a handle, unique within the bundle and meaningless outside it: the variable’s position in a store’s group document, its variableId in a container’s index (format.md, “variableId is file-local”). The encoders here number the variables 1…n in the order they are listed.

Metadata Schema Version

schemaVersion is the lowest metadata schema a reader must implement to parse the file. It versions the metadata JSON only; the layout that carries it is versioned on its own (a store’s xue_profile, a container’s FixedHeader version).

schemaVersionIntroducesRecognized by
1—a uniform whole-hour time axis declaring stepHours
2Explicitly listed forecast hoursa whole-hour time axis listing hours
3Per-variable GRIB2 identity, and a time axis in units it namesa parameter block on every variable (optionally with band / producer / aerosol / ensemble beside it), and a time block declaring unitSeconds
4A grid on a map projectiona grid.projection block in place of the four regular grid fields; variables and time block as in version 3

An encoder must emit the lowest version that can express the file: the highest version any single feature of the metadata requires, and no higher. For the versions defined so far that is 4 when the grid carries projection, otherwise 3 when the variables carry parameter, otherwise 2 when the axis lists hours, otherwise 1. A schemaVersion 3 file with a uniform axis is still version 3, since the parameter block sets its floor, and a parameter block is invalid below version 3. A file on a regular grid never declares version 4, and a reader that does not implement version 4 refuses a projected file rather than misplacing it.

Decoders enforce both sides of that rule: they must reject a schema version they do not implement, and must reject a declared version higher than the lowest the metadata needs (see Error Handling). Rejecting unknown versions makes an older decoder reject a file it would otherwise misread; rejecting overdeclared versions gives any given metadata exactly one valid encoding. Every already published bundle stays valid and byte-identical under both rules.

Schema version 3 is what the reference encoder writes; versions 1 and 2 remain readable and are published by nothing. Because older decoders reject a version they do not implement, a decoder implementing a new version must be deployed before the first file at that version is published.

Variable Identity

From schemaVersion 3, every variable declares what it is in GRIB2’s own terms, so a reader can recognize a field without matching on id strings. The block is required on every variable of a version 3 file and invalid below it.

The parameter block is a variable’s identity. Neither variableId (a file-local handle) nor the id string carries it; the parameter triple and the fixed surface do, and two files describe the same field exactly when their blocks agree.

FieldGRIB2 originRule
disciplineSection 0, octet 70–255
parameterCategorySection 4, code table 4.10–255
parameterNumberSection 4, code table 4.20–255
typeOfFirstFixedSurfaceSection 4, code table 4.50–255
scaleFactorOfFirstFixedSurfaceSection 4−127…127, or null
scaledValueOfFirstFixedSurfaceSection 40…4294967294, or null
typeOfStatisticalProcessingSection 4, code table 4.100–255, optional

The surface value is scaledValueOfFirstFixedSurface × 10^−scaleFactorOfFirstFixedSurface in that surface’s own unit. A surface that carries no value (“entire atmosphere”, type 10, or a source that encodes the value as missing) writes both halves as null, which is how GRIB2 encodes it; one half alone is invalid. Both keys are always present.

typeOfStatisticalProcessing is absent for an instantaneous field and present when the values are a statistic over the step. It distinguishes a prate bundle whose source carried an instantaneous rate (GFS pgrb2) from one derived by de-accumulating, de-averaging or differencing a window’s total (ECMWF, GFS sflux, WOOF-NAM), which are otherwise the same parameter.

No other keys are allowed; a version 3 decoder must reject an unknown one, so any later addition is a new schema version. GRIB2’s local-use ranges (parameter numbers and surface types 192–254) need no special treatment: a local number is an ordinary number, and several variables below use one.

The identity written is the registered one, whatever record the encoder read. Centres write the same quantity differently (ECMWF encodes its mean sea level pressure as plain pressure on the mean sea level surface, its gust as an interval maximum on the 10 m surface, its skin temperature as a parameter of its own with no surface value), and the encoder’s registry accepts such a record as an alias (another parameter number on the same surface) or an alternate (a whole other identity: surface, value, statistical process, unit) of the variable, so that GFS and ECMWF publish one chart under one parameter block. The table notes each such acceptance; none of them is ever written.

The identities this pipeline produces are below. This is not an admission list: a decoder validates the shape of a parameter block, never its contents against this table, and a file naming a parameter not listed here is a well-formed file. The table says which fields a chart-aware reader (one with a palette, a contour interval or a legend for the quantity) can recognize; anything else it can still decode.

idParameterSurfaceNotes
tmp2m0 / 0 / 0103, 2 m
prate0 / 1 / 71, 0typeOfStatisticalProcessing: 0 when derived (ECMWF, sflux)
ugrd10m0 / 2 / 2103, 10 m
vgrd10m0 / 2 / 3103, 10 m
ugrd100m / vgrd100m0 / 2 / 2, 0 / 2 / 3103, 100 m100 m wind components, the turbine hub height; the wind100m bundle
dswrf0 / 4 / 1921, 0NCEP local parameter
cref0 / 16 / 510, no valueComposite reflectivity, entire atmosphere; observed (the radar mosaic) or forecast (HRRR’s REFC, NCEP-local 0 / 16 / 196, accepted on input and never written)
rqi209 / 8 / 0102, 0 mRadar quality index of the MRMS mosaic, 0–1, unitless. MRMS-local (discipline 209): no WMO parameter carries it, so the local identity is the one written
gust0 / 2 / 221, 0Instantaneous surface wind gust (GFS). ECMWF’s 10fg / 10fg3, the same parameter on the 10 m surface (103, 10 m) as the maximum over the interval ending at the frame, product template 4.8, is accepted on input under this identity and never written; on ECMWF the series starts at the first step
tcdc0 / 6 / 110, no valueTotal cloud cover, entire atmosphere; the instantaneous record, not the interval average. ECMWF’s tcc, the ECMWF-local 0 / 6 / 192 on the ground surface as a 0–1 fraction, is accepted on input, scaled to percent, and never written
cape0 / 7 / 61, 0Surface-based CAPE (not the mixed-layer variants on surface type 108). ECMWF’s mucape, the same parameter departing from surface type 17, the most unstable parcel’s level, is accepted on input and never written
cin0 / 7 / 71, 0Surface-based convective inhibition in J/kg, never positive (not the mixed-layer variants on surface type 108)
lcdc / mcdc / hcdc0 / 6 / 3, 0 / 6 / 4, 0 / 6 / 5214 / 224 / 234, no valueLow / middle / high cloud cover, each its own parameter on its own layer surface; the instantaneous records
vis0 / 19 / 01, 0Surface visibility, quantized in km
dpt2m0 / 0 / 6103, 2 m2 m dew point
aptmp2m0 / 0 / 21103, 2 mNCEP’s 2 m apparent temperature
pwat0 / 1 / 3200, no valuePrecipitable water, the column mass in kg/m² (a millimetre of water); NCEP writes it on its local “entire atmosphere (considered as a single layer)” surface, type 200, which carries no value like the WMO type 10
hpbl0 / 3 / 1961, 0Planetary boundary layer height in metres, NCEP’s local number (the WMO table’s 0 / 3 / 18 is not what pgrb2 carries)
orog0 / 3 / 51, 0Orography in metres, a static one-frame bundle. ECMWF open data’s surface geopotential, 0 / 3 / 4 on the same surface, is accepted on input and divided by g; DWD’s and Météo-France’s geometric height, 0 / 3 / 6 in metres, is accepted as it is
ptype0 / 1 / 191, 0Precipitation type: one categorical field the encoder derives from the four flags below, in WMO code table 4.201’s own values (1 rain, 3 freezing rain, 5 snow, 8 ice pellets, 0 none). Never fetched; the flags are inputs only and reach no bundle
crain / cfrzr / cicep / csnow0 / 1 / 192–1951, 0The four 0/1 categorical precipitation-type flags pgrb2 carries (rain, freezing rain, ice pellets, snow; NCEP-local numbers), input-only, combined into ptype
tmpsfc0 / 0 / 01, 0Surface (skin) temperature, the SST over water. ECMWF’s skt, its own parameter 0 / 0 / 17 with no surface value, is accepted on input and never written
icec10 / 2 / 01, 0Sea ice cover, a 0–1 proportion quantized in percent (GFS only)
icetk10 / 2 / 11, 0Sea ice thickness; ECMWF’s sithick carries no surface value and a bitmap over land (GDAL’s 9999, the bottom of the codebook), and is accepted on input
htsgw10 / 0 / 31, no valueSignificant height of combined wind waves and swell (GFS-Wave, ECMWF swh); WAVEWATCH III writes the surface value as 1 and ECMWF none, so none is declared and any is accepted
perpw10 / 0 / 111, no valuePrimary wave mean period (GFS-Wave); ECMWF’s peak period pp1d, 10 / 0 / 34, is the nearest neighbour and accepted on input under this identity
dirpw10 / 0 / 101, no valuePrimary wave direction, degrees true the waves come from (GFS-Wave); ECMWF’s mean wave direction mwd, 10 / 0 / 14, is accepted the same way; a record’s 360 is reduced to 0
wvhgt / wvper / wvdir10 / 0 / 5, 10 / 0 / 6, 10 / 0 / 41, no valueSignificant height, mean period and direction (degrees true the waves come from) of the wind waves (GFS-Wave); the direction is input-only, reduced like dirpw, and reaches a bundle only inside uwindwave / vwindwave
swhgt / swper / swdir10 / 0 / 8, 10 / 0 / 9, 10 / 0 / 7241, 1Significant height, mean period and direction of the first (strongest) swell partition (GFS-Wave). Type 241 is NCEP’s local “ordered sequence of data” surface, its value the partition’s rank; only rank 1 is matched. The direction is input-only and reaches a bundle only inside uswell / vswell
tsoil<n>2 / 0 / 2106, the layer’s upper bound in mSoil temperature in layer n (1–4) counted from the surface, in °C. The registered surface is GFS’s (Noah layers 0–0.1, 0.1–0.4, 0.4–1 and 1–2 m, so 0, 0.1, 0.4 and 1); ECMWF’s sot, the WMO 2 / 3 / 18 on its soil level surface (151) with layer n at value n − 1 (IFS layers 0–7, 7–28, 28–100 and 100–289 cm), is accepted on input and never written. The id is the layer’s index, not its depth: which depths a layer spans is the source’s (sources.md). Water carries no soil: the record’s bitmap there becomes the bottom of the codebook, code 0, one step below every real value (GFS, which writes the ice’s temperature over sea ice; the IFS writes the model’s value over the sea)
soilw<n>2 / 0 / 192106, the layer’s upper bound in mVolumetric soil moisture in layer n, total (liquid and frozen) water in m³/m³, NCEP’s local SOILW (not the liquid part, SOILL). ECMWF’s vsw, the WMO 2 / 0 / 25 on its soil level surface as for tsoil<n>, is accepted on input and never written. Water is code 0 as for tsoil<n> (GFS, which also masks the sea ice and writes 1 over the ice sheets, and AIFS; the IFS writes 0 over the sea)
uwave / vwave10 / 0 / 250, 10 / 0 / 2511, no valueWave vector components in metres: the significant wave height laid along the direction the waves travel, derived by the encoder from htsgw and dirpw as the wind’s (-h sin θ, -h cos θ); Xue-local parameter numbers
uwindwave / vwindwave10 / 0 / 252, 10 / 0 / 2531, no valueWind-wave vector components, derived from wvhgt and wvdir the way uwave / vwave are; Xue-local parameter numbers
uswell / vswell10 / 0 / 254, 10 / 0 / 255241, 1Swell vector components of the first partition, derived from swhgt and swdir the same way, on their inputs’ surface; Xue-local parameter numbers
prmsl0 / 3 / 1101, no valueMean sea level pressure, the quantity ECMWF calls msl and encodes as 0 / 3 / 0 on this surface, and HRRR writes as its MAPS reduction MSLMA, 0 / 3 / 198; both accepted on input, never written (not NCEP’s MSLET, 0 / 3 / 192)
hgt<level>0 / 3 / 5100, <level> hPa in PaGeopotential height, one variable per isobaric surface
tmp<level>0 / 0 / 0100, <level> hPa in PaTemperature on the isobaric surface
rh<level>0 / 1 / 1100, <level> hPa in PaRelative humidity on the isobaric surface
spfh<level>0 / 1 / 0100, <level> hPa in PaSpecific humidity on the isobaric surface, quantized in g/kg
ugrd<level> / vgrd<level>0 / 2 / 2, 0 / 2 / 3100, <level> hPa in PaWind components on the isobaric surface
uqflx<level> / vqflx<level>0 / 1 / 250, 0 / 1 / 251100, <level> hPa in PaWater vapour flux components, q·V/g in g·cm⁻¹·hPa⁻¹·s⁻¹; Xue-local parameter numbers
vvel<level>0 / 2 / 8100, <level> hPa in PaVertical velocity ω in Pa/s on the isobaric surface
relv<level>0 / 2 / 12100, <level> hPa in PaRelative vorticity in 10⁻⁵ s⁻¹ (the record’s s⁻¹ times 10⁵). Registered on 925, 700, 500 and 250 hPa only
thetae<level>0 / 0 / 3100, <level> hPa in PaEquivalent potential temperature in K, derived by the encoder (Bolton 1980) from the temperature and specific humidity on the surface; GRIB2’s EPOT number
cat<level>0 / 19 / 29100, <level> hPa in PaClear-air turbulence as an eddy dissipation rate in m^(2/3)/s: the Ellrod TI1 index (vertical wind shear times total deformation) derived by the encoder from the wind and height on the surface and the ones bracketing it, projected per source onto the climatological EDR distribution (below); GRIB2’s CAT EDR number. Registered on 300, 250 and 200 hPa only
aod0 / 20 / 10210, no valueAerosol optical thickness at 550 nm, total aerosol (GEFS-Aerosols), dimensionless. An aerosol product (template 4.48): the aerosol block beside the parameter (below) is part of the identity — type 62000, particles smaller than 20 µm, 545–565 nm — and tells it from the other six wavelengths and five species the same parameter carries in one file
aoddust / aodsalt / aodsulf / aodorg / aodbc0 / 20 / 10210, no valueThe same optical thickness for dust, sea salt, sulphate, particulate organic matter and black carbon: the same parameter and intervals, aerosolType 62001 / 62008 / 62006 / 62010 / 62009
pm250 / 13 / 1931, 0PM2.5 surface concentration in µg/m³, NCEP’s local PMTF number; aerosol type 62000, particles smaller than 2.5 µm, no wavelength interval
pm10 / pm10dust0 / 13 / 1921, 0PM10 surface concentration in µg/m³ (NCEP’s local PMTC), total aerosol and dust alone: one parameter, aerosolType 62000 / 62001, particles smaller than 10 µm, no wavelength interval
dustsfc0 / 20 / 01, 0Surface dust concentration in µg/m³ (CMA-CW/DUST), the mass density of dust of every particle size the model carries: aerosolType 62001, no size interval and no wavelength interval (both type 255, limits null), which tells it from pm10dust

The twenty-one registered isobaric surfaces are 1000, 975, 950, 925, 900, 850, 800, 750, 700, 650, 600, 550, 500, 450, 400, 350, 300, 250, 200, 150 and 100 hPa, and every isobaric family but cat and relv is registered on all twenty-one; hgt, tmp, ugrd and vgrd go on to the stratospheric 70, 50, 30, 20 and 10 hPa. Which of them a source publishes is the source’s own list. relv is registered on 925, 700, 500 and 250 hPa. cat is registered on 300, 250 and 200 hPa: its vertical shear is taken across 250–300 hPa for cat300, 200–300 for cat250 and 200–250 for cat200, the deformation on the surface itself.

The cat<level> derivation, in float64, in this order (both encoders): centred differences on the uncropped global plane, before any crop window is cut, with R = 6371000 m, dx = R·cos φ·Δλ per row and dy = R·Δφ, the columns wrapping on a global grid; DST = ∂u/∂x − ∂v/∂y, DSH = ∂v/∂x + ∂u/∂y, DEF = √(DST² + DSH²); VWS = |V_above − V_below| / max(z_above − z_below, 1 m); TI1 = VWS·DEF; then EDR = exp(a + b·ln max(TI1, 10⁻¹²)) with b = 0.5067 / σ_L, a = −2.572 − b·μ_L, the climatological ln EDR mean and standard deviation of Sharman & Pearson (2017) and the source’s own ln TI1 fit (SourceSpec.cat_calibration); then every EDR < 0.10 (ICAO’s nil turbulence) becomes 0, 0.10 itself keeping its code. The first and last rows and every row past 85° latitude are written as 0, the codebook floor.

Within a family the variables differ only in the surface value, written in the surface’s own unit, pascals: hgt500 carries scaleFactorOfFirstFixedSurface: 0, scaledValueOfFirstFixedSurface: 50000.

The water vapour flux is not a GRIB2 field: the encoder derives it on each surface as the specific humidity (g/kg) times the wind component (m/s) over standard gravity (9.80665 m/s²), in g·cm⁻¹·hPa⁻¹·s⁻¹. GRIB2 has no standard parameter for a per-level horizontal vapour flux, so the two components take local-use numbers 250 and 251 in the moisture category, which no centre this pipeline reads from uses.

The precipitation type is derived the same way: the encoder reads pgrb2’s four 0/1 categorical flags — crain, cfrzr, cicep and csnow, its local numbers 0 / 1 / 192–195 on the ground surface — and writes one categorical field under WMO code table 4.201’s own values (0 none, 1 rain, 3 freezing rain, 5 snow, 8 ice pellets). The four are mutually exclusive in the model’s own output, so a chart of ptype never has to resolve a real disagreement; where two were set anyway, the order rain, freezing rain, ice pellets, snow decides, each later flag overriding, and both encoders share that order so the plane stays byte-identical. The four flags are input-only and reach no bundle.

Band, Producer and Aerosol

A parameter block names a quantity on a surface, which is a satellite image’s whole identity only together with the channel it was taken in: brightness temperature at the top of the atmosphere (0 / 4 / 4 on surface 8) is one parameter for every infrared channel of every imager, and a composite computed from several channels has no GRIB2 parameter at all. Nor is it an aerosol product’s whole identity: aerosol optical thickness (0 / 20 / 102 on the entire atmosphere) is one parameter for every species at every wavelength, and GRIB2 puts what tells them apart in the product definition template rather than the parameter. Three optional blocks may sit beside parameter on a variable, at the same level as it and never inside it, to carry what the parameter does not:

  • band: the spectral band and the instrument that measured it, in the fields of GRIB2 product definition templates 4.31 and 4.32 for one contributing band (the templates’ band count is 1 and is not written);
  • producer: the algorithm that derived the field from other variables;
  • aerosol: the aerosol type and the size and wavelength intervals of an aerosol product, in the fields of GRIB2 product definition template 4.48 (of which 4.44 and 4.46 are subsets).
{
  "numericId": 1,
  "id": "ir104",
  "label": "Brightness temperature, 10.4 µm",
  "unit": "K",
  "parameter": {
    "discipline": 0, "parameterCategory": 4, "parameterNumber": 4,
    "typeOfFirstFixedSurface": 8,
    "scaleFactorOfFirstFixedSurface": null, "scaledValueOfFirstFixedSurface": null
  },
  "band": {
    "satelliteSeries": 0,
    "satelliteNumber": 174,
    "instrumentType": 297,
    "scaleFactorOfCentralWaveNumber": 0,
    "scaledValueOfCentralWaveNumber": 96086
  },
  "quantization": { "type": "linear", "offset": 180.0, "scale": 0.6,
                    "minimumCode": 0, "maximumCode": 253, "nodataCode": 255 }
}
band fieldGRIB2 originRule
satelliteSeriesTemplate 4.31, Common Code Table C-50–65535
satelliteNumberTemplate 4.31, Common Code Table C-50–65535
instrumentTypeTemplate 4.31, Common Code Table C-80–65535
scaleFactorOfCentralWaveNumberTemplate 4.31−127…127
scaledValueOfCentralWaveNumberTemplate 4.310…4294967294

The central wave number is scaledValueOfCentralWaveNumber × 10^−scaleFactorOfCentralWaveNumber in m⁻¹. All five keys are required when the block is present and no other key is allowed. parameter stays the identity a reader keys on; band says which channel of which instrument measured it, and a chart-aware reader classifies a channel by its central wave number (an infrared window, a water vapour band), not by the spacecraft: the satellite succeeding at an orbital slot changes satelliteNumber and nothing else.

producer fieldRule
id^[a-z][a-z0-9]*$, the algorithm’s name
versiona non-empty string, the algorithm’s version as it names it

Both keys are required when the block is present and no other key is allowed. A produced field’s parameter uses GRIB2’s local-use ranges (category 192 and above in the discipline that fits); a reader that charts such fields tells them apart by producer.id and the parameter number together, since local numbers mean nothing across producers.

{
  "numericId": 1,
  "id": "aoddust",
  "label": "Dust aerosol optical depth at 550 nm",
  "unit": "1",
  "parameter": {
    "discipline": 0, "parameterCategory": 20, "parameterNumber": 102,
    "typeOfFirstFixedSurface": 10,
    "scaleFactorOfFirstFixedSurface": null, "scaledValueOfFirstFixedSurface": null
  },
  "aerosol": {
    "aerosolType": 62001,
    "typeOfSizeInterval": 0,
    "scaleFactorOfFirstSize": 6, "scaledValueOfFirstSize": 20,
    "scaleFactorOfSecondSize": 0, "scaledValueOfSecondSize": 0,
    "typeOfWavelengthInterval": 7,
    "scaleFactorOfFirstWavelength": 9, "scaledValueOfFirstWavelength": 545,
    "scaleFactorOfSecondWavelength": 9, "scaledValueOfSecondWavelength": 565
  },
  "quantization": { "type": "log1p", "trace": 0.005, "scale": 0.05, "maximum": 5.0,
                    "minimumCode": 1, "maximumCode": 253, "zeroCode": 0,
                    "overflowCode": 254, "nodataCode": 255 }
}
aerosol fieldGRIB2 originRule
aerosolTypeTemplate 4.48 octets 12–13, code table 4.2330–65535
typeOfSizeIntervalOctet 14, code table 4.910–255
scaleFactorOfFirstSize / scaledValueOfFirstSizeOctets 15 / 16–19−127…127 / 0…4294967294, or both null
scaleFactorOfSecondSize / scaledValueOfSecondSizeOctets 20 / 21–24as above
typeOfWavelengthIntervalOctet 25, code table 4.910–255
scaleFactorOfFirstWavelength / scaledValueOfFirstWavelengthOctets 26 / 27–30as above
scaleFactorOfSecondWavelength / scaledValueOfSecondWavelengthOctets 31 / 32–35as above

All eleven keys are required when the block is present and no other key is allowed. A limit is scaledValue × 10^−scaleFactor metres, and each of the four is a pair whose two halves are both integers or both null, the way the parameter’s fixed surface value is. An interval whose type is 255 (missing) carries no limits: its two pairs are null, whatever a record wrote in the octets (NCEP writes zeros there for a particulate matter record, and they never reach the file); an interval of any other type carries all four limits as integers. parameter stays the identity a reader keys on together with this block: two aerosol variables are the same field exactly when both blocks agree, and a reader that charts such fields recognizes a species by aerosolType and a band by the wavelength interval. A record is accepted under a registered aerosol variable only when its template carries this whole identity — the encoder compares every field — and an aerosol variable takes no aliases or alternates.

Each block is optional and any may appear without the others; a file that carries none is unchanged from before they were defined. All three are valid only from schemaVersion 3, like parameter, and none raises the version a file must declare: a version 3 reader that predates them reads the keys it knows on a variable object and ignores the rest, which is what lets them widen version 3 rather than open a version 4. A block that is present must be well formed; a reader that implements this section rejects a malformed one (see Error Handling). A block is present or absent, never null, so a variable has exactly one encoding.

Ensemble

A parameter block names a quantity; a field computed from an ensemble of forecasts of that quantity is not the quantity itself but a statistic of it — the members’ mean, their spread, a percentile of their distribution, or the share of members past a threshold — and GRIB2 says which in the product definition template (4.2 and 4.12 for a derived forecast, 4.6 and 4.10 for a percentile, 4.5 and 4.9 for a probability), not in the parameter. The optional ensemble block, beside parameter like the three above, carries it. A variable without the block is a single forecast (or an observation).

The block has exactly one of three shapes; which keys it carries says which:

"ensemble": { "derivedForecast": 4 }        // templates 4.2 / 4.12
"ensemble": { "percentileValue": 75 }       // templates 4.6 / 4.10
"ensemble": {                               // templates 4.5 / 4.9
  "probabilityType": 3,
  "scaleFactorOfLowerLimit": 2, "scaledValueOfLowerLimit": 1000,
  "scaleFactorOfUpperLimit": null, "scaledValueOfUpperLimit": null
}
ensemble fieldGRIB2 originRule
derivedForecastTemplates 4.2 / 4.12, code table 4.70–255 (0 is the unweighted mean of all members, 4 their spread)
percentileValueTemplates 4.6 / 4.100–100
probabilityTypeTemplates 4.5 / 4.9, code table 4.90–5
scaleFactorOfLowerLimit / scaledValueOfLowerLimitTemplates 4.5 / 4.9−127…127 / 0…4294967294, or both null
scaleFactorOfUpperLimit / scaledValueOfUpperLimitTemplates 4.5 / 4.9as above

A derived forecast carries derivedForecast alone and a percentile percentileValue alone. A probability carries all five of its keys, and which limits are integers is fixed by its type, whatever a record wrote in the octets the type does not use (CMA writes the threshold into both): types 0 (below the lower limit), 3 (above the lower limit) and 5 (equal to the lower limit) carry the lower limit and a null upper one; types 1 (above the upper limit) and 4 (below the upper limit) the upper limit and a null lower one; type 2 (between the limits) both. A limit is scaledValue × 10^−scaleFactor in the GRIB2 unit of the quantity the parameter names (kg m⁻² for a precipitation total, m s⁻¹ for a speed), never the variable’s unit; each limit is a pair whose two halves are both integers or both null, as for the fixed surface value.

A probability’s unit is % and its values the percentage of members past the limit; its parameter is the quantity the limit is on, a total over an interval carrying typeOfStatisticalProcessing 1. A percentile, a mean and a spread keep the quantity’s unit. parameter stays the identity a reader keys on together with this block: two variables are the same field exactly when both agree, so a reader that charts the quantity can draw an ensemble member’s percentile or mean beside a single forecast of it, and tells a spread or a probability from the quantity by the block.

ensemble is optional, valid only from schemaVersion 3, and does not raise the version a file must declare, on the same terms as band, producer and aerosol above. A version 3 reader that predates it would draw a spread or a probability as the quantity itself, so a shell that charts it is deployed before the first file carrying one is published (see contribution/delivery.md).

The ensemble fields this pipeline publishes (CMA GRAPES GEPS, cmageps; the spreads and probabilities of the ECMWF ensemble beside the deterministic run, ecmwf) are below. CMA’s central fields keep the ids of the single-forecast fields they stand in for (tmp2m, prate, prmsl, …) and carry the block that says which statistic they are: {"percentileValue": 50}, or {"derivedForecast": 0} for the 500 hPa height and the sea-level pressure, where the mean is the only statistic CMA exchanges. A field’s identity is the one in the table whichever centre wrote it: ECMWF writes its spread as derivedForecast 2 (the standard deviation with respect to the ensemble mean), its sea-level pressure spread as pressure (0 / 3 / 0) and its precipitation probabilities on the precipitation rate (0 / 1 / 52) with the limit unscaled, and is published under the identities below, as its deterministic msl is under prmsl’s.

idParameter, surfaceensembleNotes
<id>q25 / <id>q75 for tmp2m, prate, gust, tcdc, cape, tmp850as <id>percentileValue 25 / 75The quartiles of the members’ distribution, in the quantity’s unit and codebook; prateq25 / prateq75 are the six-hour totals’ quartiles divided by six, as prate is the median’s
prmslsd / hgt500sd / tmp850sdas prmsl / hgt500 / tmp850derivedForecast 4The members’ spread, in hPa / m / °C (tmp850sd from ECMWF only)
apcp24gt1, apcp24gt5, apcp24gt10, apcp24gt25, apcp24gt50, apcp24gt1000 / 1 / 8, 1, 0, typeOfStatisticalProcessing 1probabilityType 3, the lower limit 1 / 5 / 10 / 25 / 50 / 100 kg m⁻²The percentage of members whose precipitation over the 24 hours ending at the frame exceeds the limit; from the 24th hour, at every frame on cmageps and every 12 hours on ecmwf

Time Axis

The axis is a list of integer frame offsets from runTime, each worth unitSeconds seconds. The frame at offset o is valid at runTime + o × unitSeconds; a frame’s position on the axis is its index in a store’s time dimension, and o is what a container index’s frameOffset field carries.

From schemaVersion 3 the block is:

  • unitSeconds: seconds per offset unit. It must be a whole divisor of 3600, and it must be the coarsest unit that expresses every offset exactly, so an axis has one encoding. Formally, gcd(3600 / unitSeconds, offset₀, offset₁, …) must be 1. Every forecast source is hourly and declares 3600, which leaves its offsets equal to its forecast hours; the radar mosaic declares 360. A long axis is no different in kind: the CFSv2 seasonal run reaches hour 6552 in 1092 six-hourly frames, still in hourly units with frameStep: 6, well inside the [0, 65534] range an offset has.
  • firstFrameOffset and frameCount: always present.
  • Exactly one of frameStep (the axis is uniform, and frame i is at firstFrameOffset + i × frameStep) and frameOffsets (the axis does not hold one step throughout and is listed outright). A forecast run lists its offsets because the source changes cadence partway; an observation series lists them because the archive has gaps where a publication was missed.

No other field may appear in the block.

A mixed axis, hourly then three-hourly:

"time": {
  "unitSeconds": 3600,
  "firstFrameOffset": 0,
  "frameCount": 6,
  "frameOffsets": [0, 1, 2, 3, 6, 9]
}

The production GFS 240-hour axis is the same shape at full length: the 161-element list 0, 1, …, 119, 120, 123, 126, …, 237, 240.

A frameOffsets array must have exactly frameCount elements, must be strictly increasing, must begin with firstFrameOffset, and every element must be in [0, 65534]: the frameOffset field is a u16 and 65535 is the dependencyOffset sentinel. The same upper bound applies to a uniform axis’s last offset, firstFrameOffset + (frameCount − 1) × frameStep. A frameOffsets array whose steps are all equal is invalid, since a uniform axis has exactly one encoding, frameStep; this also rules out arrays of fewer than three elements. Declaring both frameStep and frameOffsets, or neither, makes the file invalid.

Schema versions 1 and 2 describe the same thing in whole hours only: firstForecastHour plus one of stepHours (uniform, version 1) and hours (listed, version 2), with unitSeconds implicitly 3600. Those files remain valid and are read unchanged. The two shapes never mix: a version 1 or 2 block carrying any version 3 field, or a version 3 block carrying any of the hour-named fields, is invalid.

A segment is a maximal run of frames with a constant step. For frames h[0] < h[1] < … < h[n-1] with steps d[i] = h[i+1] - h[i], a segment boundary falls between h[i] and h[i+1] exactly where d[i] != d[i-1]: the last frame of the old cadence closes the earlier segment and the first frame of the new cadence opens the next. A uniform axis is one segment. The GFS 240-hour axis is two: 121 hourly frames f000–f120, then 40 three-hourly frames f123–f240.

Segments are derived, never stored. They bound temporal grouping (see Temporal Prediction), and they are where the physical meaning of a derived field changes: past a step increase, a precipitation rate obtained by de-accumulating or de-averaging its source records is a mean over a longer window, so the field is smoother and its peaks lower on the far side of the boundary. That is a property of the source data; a renderer that labels units should not present the two segments as the same measurement.

A field that does not vary in time — a model’s own terrain height — is an ordinary bundle whose axis holds a single frame: frameCount 1 with frameStep 1 on the declared unit. Nothing in a bundle marks it as static; a producer that knows one (Xue’s registry does, the variable descriptor’s static flag is the fetcher’s and the converter’s, not the file’s) simply fetches and encodes the plane once rather than at every lead time. A reader draws it like any one-frame field, and a viewer that offers playback has nothing to scrub.

The encoder rotates longitude columns so the first column is -180, preserving north-to-south row order. Grids that natively start at Greenwich (the GFS surface-flux Gaussian grid) are rolled by the encoder into the same -180-first layout. A renderer applies inverse Web Mercator, converts longitude and latitude to grid coordinates, and samples this layout directly. The grid’s layout, rowOrder and columnOrder (row-major, north-to-south, west-to-east, each the only value allowed) spell this order out; every encoder writes them, and a reader accepts a document without them, since the schema names them without requiring them.

Regional Grids

A grid need not cover the world. The grid block says what a file covers, and a regional file is an ordinary file whose origin and extent name a window rather than the globe; the layout and every codebook are unchanged. The reference pipeline publishes such files for its historical showcase cases, cut out of a global run.

Two rules follow for readers, both of which a global grid satisfies trivially:

  • wrapLongitude is true only when width x longitudeStep is 360 degrees. A reader must take the horizontal wrap from this field, not from the model: sampling filters may wrap across the antimeridian only when it is true, and must clamp otherwise.
  • The grid coordinate of a longitude is (longitude - firstLongitude) mod 360 / longitudeStep. Taking the offset modulo 360 keeps a window that crosses the antimeridian contiguous: such a window declares a firstLongitude near +180 and runs past it. Coordinates outside [0, width) or [0, height) are outside the file; a renderer must draw nothing there rather than clamp.

The four regular fields are a regular grid’s. A grid carries them or a projection block (Projected Sources), never both and never neither.

Gaussian rows

A regular Gaussian grid is regular in longitude only: its latitudes are the roots of a Legendre polynomial. The regular fields describe it as evenly spaced as GDAL reports it (within 0.014 of a row of the roots on GFS-SFLUX, whose step spans its first row to its last; on CFSv2, at GDAL’s 180°/190 from the first root, drifting to half a row by the southern edge), the optional gaussian block beside them says what its rows really are, and it raises no version floor:

"grid": {
  "width": 3072,
  "height": 1536,
  "firstLongitude": -180.0,
  "firstLatitude": 89.9103,
  "longitudeStep": 0.1171875,
  "latitudeStep": -0.1171469,
  "wrapLongitude": true,
  "gaussian": { "n": 768, "firstRow": 0, "rowStride": 1 }
}
  • n is the number of latitudes per hemisphere (1 to 32768); row r of the file is row firstRow + r × rowStride of the Gaussian grid’s 2n, counted from the north. A crop raises firstRow, a reduced-resolution tier rowStride. The last row must lie on the Gaussian grid. The block has exactly these three integer fields and needs schemaVersion 3.
  • A renderer keeps sampling by the regular fields, and a reader that ignores the block draws what it always drew. The true latitudes are for what names a place: a point read’s nearest row and the cell centre it reports, and a store’s latitude coordinate. Past the edge of a crop a point belongs to the edge row for half a row’s spacing; the first and last rows of the whole Gaussian grid own the polar caps.
  • The latitudes are computed, never stored: docs/zarr-profile.md, “Coordinates”, gives the iteration.

Projected Sources

A model computed on a map projection is published on its own grid. The grid block declares the projection in place of the regular fields, and the file is schemaVersion 4:

"grid": {
  "width": 1799,
  "height": 1059,
  "layout": "row-major",
  "rowOrder": "north-to-south",
  "columnOrder": "west-to-east",
  "wrapLongitude": false,
  "projection": {
    "kind": "lambert-conformal",
    "radius": 6371229.0,
    "standardParallel1": 38.5,
    "standardParallel2": 38.5,
    "latitudeOfOrigin": 38.5,
    "centralMeridian": -97.5,
    "x0": -2697520.143,
    "y0": 1586693.847,
    "dx": 3000.0,
    "dy": -3000.0
  }
}
  • kind is a closed set, today lambert-conformal alone. A reader refuses a kind it does not implement; a new kind is a new value, not a new field.
  • x0 and y0 are the centre of the first cell, the north-west one, in projected metres. Cell (row, column) has its centre at x0 + column × dx, y0 + row × dy. dx is positive, dy negative, and wrapLongitude false. Since GDAL’s geotransform names the first cell’s outer corner and different GDAL builds differ in its last digits, an encoder rounds the corner to three decimal places and adds half a step: x0 = round(gt0, 3) + dx / 2, y0 = round(gt3, 3) + dy / 2.
  • A crop adds column × dx and row × dy to x0 and y0. A reduced-resolution tier doubles dx and dy and keeps x0 and y0, with width = (width + 1) // 2 and likewise height.
  • The formulas are the spherical Lambert conformal conic’s (Snyder 1987, §15): with two equal standard parallels the cone constant is n = sin φ1, otherwise n = ln(cos φ1 / cos φ2) / ln(tan(π/4 + φ2/2) / tan(π/4 + φ1/2)). A longitude is taken to within 180° of centralMeridian before it is projected. Both standard parallels and latitudeOfOrigin lie strictly between the poles, and the two parallels must not sum to zero, which leaves no cone.
  • A grid coordinate is (x − x0) / dx, (y − y0) / dy, with the rule for outside coordinates of Regional Grids. Cells are not regular in longitude or latitude: a reader that maps between them and geography goes through the projection.
  • Vector components are east and north, on this grid as on every other. A model writes its winds along the grid’s axes (GRIB2 resolution and component flags 0x08), and an encoder turns each pair before quantizing it: u_e = cos α × u + sin α × v, v_e = −sin α × u + cos α × v, with α the cone constant times the longitude’s distance from centralMeridian. The speed is the model’s. docs/encoder.md, “Native grids”, gives the arithmetic.

Older files do something else, and a reader keeps reading them. Up to schemaVersion 3 a projected model was resampled by the encoder onto a regular latitude/longitude grid before anything else read it, and the file is an ordinary regional file of that grid. Its target is fixed: the regular grid of the source’s declared step whose origin is a whole multiple of the step and which covers the extremes of longitude and latitude the source’s boundary cell centers reach; each target cell center is projected with the source’s own forward formulas and the source plane is bilinearly interpolated there. A conic domain is a trapezoid on that rectangle. The corners it never covered are neither gaps nor a reserved code (the format has neither) but the nearest source cell continued outwards (the sampling coordinate is clamped to the source grid), so the plane is complete and no filter or contour meets an edge. Those cells are not a forecast: a reader that knows the source’s projection clips to its footprint, and one that does not draws the extension. A reader tells the two apart by the grid block alone, never by the source: one model publishes both.

model and product identify the source dataset. Every encoder writes product, and a reader accepts a document without it: the schema names the field without requiring it. Registered pairs:

modelproductGridSteps publishedNotes
GFSpgrb2.0p251440 × 721, 0.25°1 h to f120, 3 h to f240All series include the analysis frame (f000). prate is an instantaneous rate at every step
ECMWFifs-0p251440 × 721, 0.25°3 h to 144 h, 6 h to 240 hprate is de-accumulated from the run-total tp, so its series has no analysis frame and starts at firstFrameOffset: 3; so does gust, whose record (the maximum over the interval ending at the frame) is empty at the analysis. Its wave fields come from the cycle’s wave stream
GFS-SFLUXsfluxgrb3072 × 1536 Gaussian, ~13 km1 h to f120, 3 h to f240prate is de-averaged from window-cumulative records and starts at firstFrameOffset: 1; the only source shipping dswrf
HRRRwrfsfc1799 × 1059, 3 km Lambert conformal, regional (see “Projected Sources” above)1 h to f18A new cycle every hour. Runs published before schemaVersion 4 are on a regular 2441 × 1051 grid at 0.03° (134.10 W – 60.90 W, 52.62 N – 21.12 N), resampled by the encoder. Its prmsl is the MAPS reduction and its cref the model’s forecast reflectivity
RRFS2dfld.3km.conus1799 × 1059, 3 km Lambert conformal, regional: HRRR’s grid1 h to f84The 00/06/12/18Z cycles. Isobaric records come from the prslev file of each hour. Carries the near-surface smoke and dust of RRFS-SD
WOOF-NAMawphys614 × 428, 12.19 km Lambert conformal, regional: NCEP grid 2181 h to f84The 00/06/12/18Z cycles of WOOF-NAM by Recast, not a NOAA forecast. prate is differenced from totals that restart every 12 hours, so its series has no analysis frame and starts at firstFrameOffset: 1; the core is tmp2m alone
CFSv2time-grib-01384 × 190 Gaussian, 0.9375° (T126)6 h from f6 to f6552The seasonal source: ensemble member 01 of the 00Z and 12Z cycles, thirty-nine weeks of a nine-month run. Its series begin at the first step, so every bundle starts at firstFrameOffset: 6 — the cycle’s analysis is in another file family and is not published. prate, dswrf and tcdc are means over the six hours ending at the frame (typeOfStatisticalProcessing: 0) although the records carry the instantaneous template
CMA-RADARl3-mst-creftile grid, 360/(256·2^z) degrees6 min, as publishedObservations, not a forecast: runTime is the first observation and offsets count from it. The only one whose unitSeconds is not 3600; the axis lists its offsets wherever a publication was missed

How far a run is published is a pipeline choice; the steps above are what each source makes available. A uniform series declares a frameStep; a series that runs to 240 hours crosses a step change on every forecast source above and lists its offsets; an observation series lists them wherever the archive has a gap.

CMA-RADAR is a series of observed analyses, and the metadata describes it with no change: runTime is the first observation in the series and each frame’s frameOffset counts six-minute units from it. A reader that labels the axis should take that from the dataset identity rather than assume every file is a forecast.

Time axes may differ between bundles of one run, in both step and extent. The layout is identical for every model; only the metadata identity, the grid, and the time axis differ. Readers must derive the frame list from time and the grid from grid, never from the model name, and must not assume two bundles of one run share an axis.

Quantization Codebooks

Linear ("type": "linear")

q = round((clamp(x, offset, offset + scale * maximumCode) - offset) / scale)
x = offset + q * scale

Codes 0 through maximumCode are valid; nodataCode marks missing data; codes between maximumCode + 1 and nodataCode - 1 are reserved. The maximum in-range quantization error is scale / 2.

Registered linear codebooks (the quality profile; balanced uses the same values unless noted):

VariableoffsetscalemaximumCodenodataCodeError budget
tmp2m−60 °C0.52202550.25 °C
ugrd10m / vgrd10m / ugrd100m / vgrd100m−63.5 m/s0.52542550.25 m/s
dswrf0 W/m²52542552.5 W/m²
cref0 dBZ0.51602550.25 dB
rqi−0.10.111255none: MRMS publishes tenths; code 0 is outside radar coverage, code 1 an index of 0 (every profile)
gust0 m/s0.52542550.25 m/s
tcdc0 %0.52002550.25 %
cape0 J/kg2525425512.5 J/kg
cin−1016 J/kg42542552 J/kg
lcdc / mcdc / hcdc0 %0.52002550.25 %
pwat0 kg/m²0.52542550.25 kg/m²
hpbl0 m2025425510 m
orog−430 m3725425518.5 m
ptype018255—
vis0 km0.12542550.05 km
dpt2m−70 °C0.52202550.25 °C
aptmp2m−90 °C11502550.5 °C
tmpsfc−60 °C0.52542550.25 °C
icec0 %0.52002550.25 %
icetk0 m0.022542550.01 m
htsgw0 m0.12542550.05 m
perpw0 s0.12542550.05 s
wvhgt / swhgt0 m0.12542550.05 m
wvper / swper0 s0.12542550.05 s
dirpw0°1.52392550.75°
wvdir / swdir0°1.52392550.75°
uwave / vwave−25.4 m0.22542550.1 m
uwindwave / vwindwave, uswell / vswell−25.4 m0.22542550.1 m
tsoil<n>−61 °C0.52542550.25 °C; code 0 is no soil
soilw<n>−0.01 m³/m³0.0052022550.0025 m³/m³; code 0 is no soil
prmsl870.5 hPa12542550.5 hPa
hgt1000−905 m102542555 m
hgt925−249 m62542553 m
hgt850423 m62542553 m
hgt7001911 m62542553 m
hgt5004252 m82542554 m
hgt3007505 m102542555 m
hgt2508598 m122542556 m
hgt20010086 m122542556 m
tmp1000−60 °C0.52402550.25 °C
tmp925−65 °C0.52302550.25 °C
tmp850−70 °C0.52302550.25 °C
tmp700−75 °C0.52202550.25 °C
tmp500−85 °C0.52002550.25 °C
tmp300−95 °C0.51902550.25 °C
tmp250−100 °C0.51902550.25 °C
tmp200−100 °C0.51802550.25 °C
rh<level>0 %0.52002550.25 %
spfh1000 / spfh9250 g/kg0.22542550.1 g/kg
spfh850 / spfh7000 g/kg0.12542550.05 g/kg
spfh5000 g/kg0.022542550.01 g/kg
spfh3000 g/kg0.012542550.005 g/kg
spfh250 / spfh2000 g/kg0.0052542550.0025 g/kg
ugrd<level> / vgrd<level>−127 m/s12542550.5 m/s
uqflx<level> / vqflx<level>−63.5 g·cm⁻¹·hPa⁻¹·s⁻¹0.52542550.25
vvel<level>−6.35 Pa/s0.052542550.025 Pa/s
thetae1000235 K0.52542550.25 K
thetae925232 K0.52542550.25 K
thetae850230 K0.52542550.25 K
thetae700235 K0.52542550.25 K
thetae500250 K0.52542550.25 K
thetae300285 K0.52542550.25 K
thetae250295 K0.52542550.25 K
thetae200305 K0.52542550.25 K
cat<level>0 m^(2/3)/s0.0051272550.0025 m^(2/3)/s

The compact profile doubles each scale (temperature 1.0 → maximumCode 110, wind 1.0 → 127, dswrf 10 → 127, cref 1.0 → 80, gust 1.0 → 127, every cloud cover 1.0 → 100, cape 50 → 127, cin 8 → 127, vis 0.2 → 127, dpt2m 1.0 → 110, aptmp2m 2 → 75, pwat 1.0 → 127, hpbl 40 → 127, orog 74 → 127, tmpsfc 1.0 → 127, icec 1.0 → 100, icetk 0.04 → 127, htsgw, perpw and the wind-wave and swell heights and periods 0.2 → 127, tsoil 1.0 → 127, soilw 0.01 → 101, and every pressure-family and isobaric codebook → half its maximumCode over the same range; cat<level> 0.01 over 0–0.64 → 64). Two codebooks do not keep the same range: dirpw’s compact codebook (and wvdir’s and swdir’s) stops at 357° (3 → 119), because 360 / 3 codes would put 360°, which is 0°, back on the grid; and the wave vectors' stop at ±25.2 m (0.4 → 126) so that 0 stays on the grid, since land is (0, 0) in the pair and the middle code of both. The categorical ptype takes one book in every profile: its integer class codes have no resolution to trade, and the codes between the four types GFS reports are never written. balanced takes the compact icec beside the compact humidity and cloud cover, and the quality book for every other one-sided field (the inhibition, the precipitable water, the boundary layer height), as it does for the aerosol fields.

The wave fields are the first whose records do not cover the grid: GFS-Wave carries a bitmap, and land comes out of GDAL as its nodata value (9999). The encoder maps those points to code 0 (0 m, 0 s, 0°) before quantization, as the radar mosaic’s fill is handled (see “Complete planes” below); the nodataCode is still never written. The soil layers’ records do not cover it either (GFS masks the open water, and the sea ice for the moisture; AIFS the sea for the moisture). Their codebooks start one step below the least real value — −61 °C, −0.01 m³/m³ — so the masked points, filled with that bottom, are code 0 and no real value is: a reader tells “no soil” from a value without a bitmap, and 0 °C and 0 m³/m³ are codes of their own in both profiles.

The isobaric temperature takes its range per level: the low end holds the Antarctic winter at every surface, the high end the below-ground extrapolation the lowest surfaces take under high terrain, and no single 127-degree window covers both 850 hPa in summer and 200 hPa in winter. Specific humidity spans two orders of magnitude between the surface and the upper troposphere, so its step follows the level. Relative humidity is the noisiest field published, so the balanced profile takes its compact codebook (1 %, maximumCode 100), and the cloud covers follow it; those are the departures from quality in that profile besides precipitation. The equivalent potential temperature takes a 127 K window per level at the temperature’s step, placed so the tropical end fits (850 hPa runs to 357 K); only the 850 hPa window is verified against an analysis, the others follow the potential temperature’s rise with height. None of the isobaric fills is contoured, so none carries the half-code rule below.

The pressure family’s offsets are chosen so that every standard contour value lands exactly half a code off: (contour − offset) / scale has fractional part 0.5, for the level’s own interval (4 hPa for prmsl, 30 m up to 700 hPa, 40 m at 500, 120 m above) and for the emphasised lines (every 20 hPa on prmsl; 5840 and 5880 gpm on hgt500). This is an encoder rule, in the same sense as a container’s segment grouping: a decoder must not assume it, and nothing in a bundle records it. It exists because a contour drawn where the code is flat covers a whole plateau instead of a line. The coverage is fixed per variable for all time rather than fitted per run; byte-identical re-encoding, a stable legend, and comparable point series across runs depend on it.

cref code 0 is both “no echo” and “outside the radar network’s coverage”. A reader that must tell them apart reads the mosaic’s rqi beside it, whose code 0 is outside coverage and whose code 1 is covered with an index of 0. A ground mosaic is a regional product on a rectangular grid, and a bundle carries no bitmap, so the bottom of the codebook is what a renderer paints as nothing. It is an ordinary in-range code rather than a reserved one: a renderer that interpolates codes before its palette lookup would otherwise colour the gap between a reserved code and its neighbour with a class the data never reached.

Values outside the range clamp to the range ends before quantization.

Logarithmic ("type": "log1p", precipitation)

Precipitation is sparse and long-tailed, so it uses a logarithmic codebook with parameters trace, scale, maximum:

  • Code zeroCode (0): dry, below trace.
  • Codes minimumCode (1) through maximumCode: positive logarithmic values.
  • Code overflowCode (maximumCode + 1): above maximum.
  • Code nodataCode: missing data.

For trace <= p <= maximum, with span = maximumCode - 1:

lo = ln(1 + trace / scale)
hi = ln(1 + maximum / scale)
u = (ln(1 + p / scale) - lo) / (hi - lo)
q = 1 + round(span * u)

Decode with:

u = (q - 1) / span
p = scale * (exp(lo + u * (hi - lo)) - 1)

Code maximumCode decodes to exactly maximum. The overflow code decodes one codebook step above the maximum (the same formula evaluated at q = maximumCode + 1), extending the logarithmic grid by one step so decoded values remain strictly increasing across all non-nodata codes, and overflow pixels stay distinguishable from the top in-range code in both a palette and scalar inspection.

Registered precipitation codebooks (trace = 0.01 mm/h, scale = 0.05 mm/h, maximum = 128 mm/h in both):

ProfilemaximumCodeoverflowCodenodataCode
quality (256-level)253254255
balanced / compact (128-level)125126127

The 128-level codebook still uses full R8 bytes; the smaller symbol alphabet improves entropy coding, and the GPU needs no bit unpacking.

Series codebooks

A series store (zarr-profile.md, “Series store”) holds some variables as sixteen-bit codes, in place of the profile’s byte codebook: a cell’s series is read as a line, where a byte step shows as a staircase. Each is a linear codebook (the formulas above), one per variable whatever the profile, carried in the registry as the variable’s seriesQuantization (registry.md) and, inside a series store, as that variable’s quantization. Every variable below carries one (quantize.SERIES_CODEBOOKS); any other variable of a series store keeps its byte codes:

VariableoffsetscalemaximumCodenodataCodeError budget
tmp2m / dpt2m−90 °C0.11500655350.05 °C
prmsl850 hPa0.12500655350.05 hPa
ugrd10m / vgrd10m−100 m/s0.12000655350.05 m/s
prate0 mm/h0.0165500655350.005 mm/h
dswrf0 W/m²11500655350.5 W/m²

The rate is linear here, where its byte codebook is logarithmic. A codebook whose nodataCode is above 255 is a sixteen-bit one: its codes are held as uint16 and fit only a uint16 array. Every code key of a quantization block (minimumCode, maximumCode, zeroCode, overflowCode, nodataCode) is an integer from 0 to 65535; that every code fits a byte is checked where the codes sit, by the reader of a uint8 array or of a container, which carry byte codes only. A series code is quantized from the same value as the variable’s byte code, in the same pass, never from the byte code.

Residuals

A predicted variable stores each frame after the first of its run of frames as a residual against an earlier one (a store’s xue.delta codec, a container’s predictors).

Residuals are defined unconditionally as one-byte modulo-256 wrapping differences:

residual = (current - base) mod 256
current  = (residual + base) mod 256

Wrapping subtraction and addition are lossless for every byte pair, so there is no residual range check, no signed interpretation, and no RAW fallback for out-of-range differences. Sixteen-bit codes (a series store’s widened variables) wrap the same way modulo 65536.

Complete planes

A bundle requires complete input planes: every point of every plane carries a code. The forecast grids satisfy that outright, and a source whose product does not cover its whole grid (the radar mosaic) resolves it before quantization by mapping absent points to the bottom of the variable’s codebook, a value rather than a gap. A future missing-data implementation should add a separate bitmap so residual bytes never conflict with the nodata code.

Bundle naming

One bundle per variable per run (tmp2m, prate, dswrf, cref), a vector’s components together (wind10m), and reduced-resolution renditions <bundle>.half, <bundle>.quarter and <bundle>.eighth (decimated by 2, 4 and 8; which rungs a source ships is a registry value, every source at least the half, none the eighth today, though published ones stay valid), structurally identical bundles whose metadata declares the decimated grid. A shared store holds every bundle of one tier (bundles.zarr, bundles.half.zarr; zarr-profile.md, “Layout”); a one-bundle store is <name>.zarr, a container <name>.xue.


Part of the Xue specification, licensed under CC BY 4.0.