# Geostationary satellite imagery

LLMS index: [llms.txt](/docs/llms.txt)

---

In the viewer: [`/himawari`](https://xue.ringsaturn.me/himawari), [`/himawarijp`](https://xue.ringsaturn.me/himawarijp), [`/goeseast`](https://xue.ringsaturn.me/goeseast), [`/goeswest`](https://xue.ringsaturn.me/goeswest) and [`/meteosat`](https://xue.ringsaturn.me/meteosat); a composite through `?type=`, e.g. [`/himawari?type=dustrgb`](https://xue.ringsaturn.me/himawari?type=dustrgb).

How a geostationary imager's channels become Xue bundles: the `himawari`,
`goeseast`, `goeswest` and `meteosat` sources, the `himawarijp` box over
Japan, their Dust RGB and true colour composites and dust confidences, and the seams a further satellite, a second
channel and another composite product go through. The bundle format is
unchanged (`bundle.md`); what this document fixes is the fetch stage,
`xuebuild/satellite/`, and the metadata a satellite variable carries.

## Shape

A satellite source is a `series_file` observation source, the shape of
the JMA nowcast and the CMA mosaic: the fetch stage writes one NetCDF
series per window on a regular latitude/longitude grid, and the converter
downstream — cropping, quantization, temporal grouping, the container,
the Zarr store, the manifest — is the observation path unchanged in both
encoders. What the fetch stage does is:

1. list the scan's files on the agency's public bucket or data store (a
   *slot*: one scan of one channel);
2. fetch them when the slot is complete (every tile has landed);
3. open them as one GDAL dataset on the geostationary projection;
4. warp that dataset onto the published grid, once, into a cached frame;
5. run each producer on the slot's warped channels, once, into cached
   frames of its own;
6. stack the window's frames into one series per variable.

The geostationary projection is implemented once, in GDAL, on the fetch
side. Neither encoder learns the sweep angle or the ellipsoid; the native
encoder reads the series the Python stage wrote, and
`tests/test_native.py` holds the two byte-identical from there.

## The platform registry

`xuebuild/satellite/platforms.py` is one row per spacecraft at an orbital
slot:

| Field | Himawari-9 | GOES-19 | GOES-18 | Meteosat-12 | Meteosat-9 |
|---|---|---|---|---|---|
| `role` (the source id) | `himawari` | `goeseast` | `goeswest` | `meteosat` | `meteosatiodc` |
| `spacecraft` | Himawari-9 | GOES-19 | GOES-18 | Meteosat-12 (MTG-I1) | Meteosat-9 (MSG2) |
| `satellite_number` (WMO C-5) | 174 | 273 | 272 | 71 | 56 |
| `instrument` / `instrument_type` (WMO C-8) | AHI / 297 | ABI / 617 | ABI / 617 | FCI / 210 | SEVIRI / 207 |
| `sub_longitude` | 140.7 | −75.2 | −137.0 | 0.0 | 45.5 |
| `sweep_axis` | `y` | `x` | `x` | `y` | `y` |
| `channels` | the sixteen AHI bands | the sixteen ABI channels | the sixteen ABI channels | the sixteen FCI channels | the twelve SEVIRI channels |
| `reader` | `isatss` | `cmipf` | `cmipf` | `fci` | `seviri` (none) |
| `bucket` / `prefix` | `noaa-himawari9` / `AHI-L2-FLDK-ISatSS` | `noaa-goes19` / `ABI-L2-CMIPF` | `noaa-goes18` / `ABI-L2-CMIPF` | `api.eumetsat.int` / `EO:EUM:DAT:0662` | `api.eumetsat.int` / `EO:EUM:DAT:MSG:HRSEVIRI-IODC` |
| `tile_count` | 88 | 1 | 1 | 40 | 1 |
| `cadence_seconds` (the scans') | 600 | 600 | 600 | 600 | 900 |
| `region` (west … east) | 80.7 … 200.7 | −135.2 … −15.2 | 163 … 283 | −60 … 60 | −14.5 … 105.5 |

A source is named by the **orbital role**, never by the spacecraft: the
pointer (`latest-himawari.json`, `latest-goeseast.json`,
`latest-meteosat.json`), the run directories (`himawari.<run>/`) and the
manifest `model` (`HIMAWARI`, `GOES-EAST`, `GOES-WEST`, `METEOSAT`)
outlive a handover. When Himawari-10 takes the slot, or GOES-19 hands
East to its successor, the platform row changes (`spacecraft`,
`satellite_number`, `bucket`) and nothing published does; the spacecraft
is in each file, as the `band` block below. The `reference_channel`
(`ir104`, which every imager here has) is the one a listing walks to find
a bucket's slots. `bucket` and `prefix` name where the files are in the
terms of the reader: a public bucket and a key prefix, or a data store's
host and a collection id. Meteosat-9 at 45.5°E (the Indian Ocean service)
is a row and nothing more: its SEVIRI Level 1.5 native file has no reader
yet (GDAL's `MSGN` driver gives radiances and the brightness temperatures
would be a Planck fit per channel, as for FCI below), and no source names
it.

`Platform.region` is 60° either side of the sub-satellite longitude and
±60° of latitude. A disk that crosses the antimeridian is spelled with the
west edge inside −180 … 180 and the east edge past 180 — Himawari's 80.7 …
200.7, GOES-West's 163 … 283 — the one shape the encoders' `crop_grid` and
the shell's viewport arithmetic take; GOES-East stays on negative
longitudes like the regional radar grids; Meteosat's −60 … 60 sits on
the prime meridian. The four sources publish the same core variables
(`ir104`, `ir039` and `dustrgb`; the ABI composite takes the Quick Guide's
stretches, FCI has no 11.2 µm window and its green gun reads the 10.5 µm
one) and the true colour composite, the three NOAA-hosted ones the dust
confidences besides, and every seam below is
shared: what differs between
them is the platform row and the reader — and, for Meteosat, the cadence
the source publishes at, which the data policy sets (§"Rounds").

A **channel** is a bundle. Its id is the nominal wavelength,
instrument-neutral: `ir104` is AHI band 13 and ABI channel 13 alike, an
infrared window at 10.4 µm; the exact central wave number is in the
`band` block. The registry carries every channel the instrument has;
`sources.py` says which a source publishes (`bundle_scalar_ids`) and
carries their `band` blocks (`bands`, from `Platform.bands`). The three
NOAA-hosted sources fetch six infrared windows and the solar bands (four
on AHI, three on ABI) and publish `ir104`, `ir039`, the Dust RGB, the
dust confidences and the true colour; Meteosat fetches four windows and
the four solar channels and publishes `ir104`, `ir039`, the Dust RGB and
the true colour (§"The dust confidences" says why not the confidences).

| id | wavelength | AHI | ABI | FCI | quantity | codebook |
|---|---|---|---|---|---|---|
| `ir104` | 10.4 µm (FCI 10.5) | 13 | 13 | 14 (IR 10.5) | brightness temperature, K (the shell reads it in °C) | 180–331.8 at 0.6 |
| `ir086`, `ir112`, `ir123` | 8.6, 11.2, 12.3 µm (FCI 8.7, —, 12.3) | 11, 14, 15 | 11, 14, 15 | 12, —, 15 | brightness temperature; fetched for the Dust RGB (and, but for 11.2 µm, for the dust confidence), registered variables, not published by any source | 180–331.8 at 0.6 |
| `ir039` | 3.9 µm (FCI 3.8) | 7 | 7 | 9 | brightness temperature, published to show fires (§"The 3.9 µm window"); also read by the dust confidence's cloud mask and the true colour's night side | 180–407.7 at 0.9 |
| `wv062` | 6.2 µm (FCI 6.3) | 8 | 8 | 10 | brightness temperature; fetched for the dust confidence's cloud mask, a registered variable, not published by any source | 180–331.8 at 0.6 |
| `vis047`, `vis051`, `vis064`, `nir086` | 0.47, 0.51, 0.64, 0.86 µm (FCI 0.44, 0.51, 0.64, 0.87) | 1, 2, 3, 4 | 1, —, 2, 3 | 1, 2, 3, 4 | top-of-atmosphere reflectance factor, 0–1 (the product's, not yet divided by the cosine of the solar zenith); fetched for the true colour composite, registered variables (GRIB2 3/0/1, the satellite-image albedo, with the band block), not published by any source | −0.01–1.255 at 0.005 |
| `ir096`, `ir133` | 9.6, 13.3 µm | 12, 16 | 12, 16 | 13, 16 | brightness temperature | registered on the platform; not yet a variable |
| `wv069`, `wv073` | 6.9, 7.3 µm | 9, 10 | 9, 10 | —, 11 | brightness temperature | same |
| `nir161`, `nir226`, … | 1.61, 2.26 µm | 5, 6 | 5, 6 | 7, 8 | reflectance | same |

An FCI channel takes the id of the window it is nearest to (IR 10.5 is
`ir104`, IR 8.7 `ir086`; the exact wave number is in the band block, and
the shell classifies by it), so the Dust RGB's inputs keep their ids
across the three imagers.

Adding a channel is: a `VariableSpec` in `variables.py` and its entry in
the registry document (parameter block, codebook, label), the id in the
source's `input_variable_ids` and `bundle_scalar_ids`, the regenerated
registry snapshots (`xue registry --output rust/xue/registry.json --shell
web/src/data/registry.ts`), and a row of the shell's variable table with a
palette. Nothing in the fetch
stage, the converter or the format changes: the fetch warps every channel
a source lists, and the ingest reads one series file per variable. A
channel is warped by its kind (`fetch.resampling_for`): a brightness
temperature bilinearly, a reflectance — delivered at 0.5 or 1 km, four
to eight times finer than the grid — as the block mean, so a cloud edge
is the mean the eye sees from orbit and not a speckle of the four source
pixels a bilinear sample would pick out of sixty-four. The frame's
record says which.

### The 3.9 µm window

`ir039` is published to show where it burns. A fire is a few hundred
metres across and lifts one 2 km pixel tens of kelvin above its
neighbours, up to AHI band 7's saturation near 400 K; three choices keep
that pixel in the bundle:

- **Its own codebook**, 180–407.7 K at 0.9 K (compact: to 406.8 K at
  1.8 K), where the other windows stop at 331.8 K. Linear like theirs, so
  no reader learns a new codebook type; a hot spot is tens of kelvin, and
  the coarser step costs it nothing.
- **A peak frame.** The published series is warped with GDAL's `max`
  (`fetch.PEAK_RESAMPLING`) — the warmest source pixel under each 0.04°
  cell — instead of the bilinear sample, which spreads a 2 km hot spot
  over four cells and loses most of its contrast. The composites read the
  channel as a radiance field and keep the bilinear frame: a source that
  publishes `ir039` (`fetch.PEAK_CHANNEL_IDS` ∩ `bundle_scalar_ids`)
  warps the slot's downloaded tiles twice and caches the second frame
  beside the first as the variable `ir039peak`, and only the series is
  stacked from it. The composites' inputs, and so their bytes, are what
  they were.
- **A peak-keeping ladder.** The reduced tiers keep, at each decimated
  site, the largest code within `factor / 2` rows and columns of it
  (`ladder.decimate_peak_codes`, mirrored in `ladder.rs`), not the
  site's own: a one-cell hot spot lies on a kept row and column one time
  in four at the half. The windows overlap by a row and a column, so
  every cell reaches a site and a peak moves at most half a reduced cell.
  The other variables keep the plain decimation.

Which pixel is a fire is the shell's decision, not the encoder's: it has
`ir039` and `ir104` on one grid and compares them per cell.

### The Dust RGB

`dustrgb` is the classic Dust RGB (Lensky and Rosenfeld 2008, as
EUMeTrain's recipe compilation and the GOES-R Quick Guide fix it): three
stretches of the infrared windows, no ancillary data, no cloud mask —
lofted mineral dust reads pink to magenta over dark blue-green surfaces,
day and night; thick ice cloud dark red, thin cirrus near black, mid-level
cloud ochre.

| gun | recipe | stretch (AHI and FCI: the SEVIRI set) | stretch (ABI: the Quick Guide's) |
|---|---|---|---|
| `dustr` | BT 12.3 − BT 10.4 µm | −4 … +2 K, γ 1 | −6.7 … +2.6 K |
| `dustg` | BT 11.2 − BT 8.6 µm (FCI: BT 10.5 − BT 8.7, the imager has no 11.2 µm window; the original SEVIRI `IR10.8 − IR8.7`) | 0 … +15 K, γ 2.5 | −0.5 … +20 K, γ 2.5 |
| `dustb` | BT 10.4 µm | 261 … 289 K, γ 1 | 261.2 … 288.7 K |

Which channels a platform feeds the recipe is `Producer.inputs_for`
(`DustRGBProducer`: the four windows, or three where 11.2 µm is missing
and 10.4 µm stands in for it); `bundle_input_ids` asks it for the
source's platform, so a `--bundles dustrgb` build and the workflow fetch
what that imager has.

Each gun is a number in 0–1 and the three are one bundle, variables 1, 2
and 3 in that order (`bundles.COMPOSITE_BUNDLES`,
`SourceSpec.bundle_composite_ids`). A composite has no GRIB2 parameter:
each gun takes a local-use one — discipline 3 (space products), category
192, parameter number 1, 2 or 3, on surface 8 — that means nothing
without the `producer` block beside it, `{"id": "shachen", "version":
…}`. The id is registered on the variable (`VariableSpec.producer_id`,
in the registry document); the version is whatever ran, stamped
on the series by the fetch stage and copied into the metadata by
whichever encoder converts, so a shachen upgrade changes the files it
produces and no registry.

The codebook is one for every profile: linear, offset −0.004, step
0.004, codes 0–251, so code 1 is 0.0, code 251 is 1.0 and **code 0 —
one step below zero — is "no data"**: a cell the disk does not cover, or
one an input channel lacked, is code 0 in all three guns at once, and
black (0, 0, 0) stays a value at code 1. The shell paints nothing where
any gun is code 0 and otherwise shows the three guns straight as the
pixel's colour; there is no palette. The composite has no poster; it has the reduced-resolution variants and the Zarr store
(three arrays) like a vector bundle. A satellite source publishes two
rungs where most sources publish one (`SourceSpec.variant_factors`
`(2, 4)`): `.half` and `.quarter` (1500 and 750 cells a side, tiles 32
and 16), each decimated from the full plane — every f-th row and column
from the origin, the poster's own sampling — because the half of a
3000 × 3000 disk is still twice a full GFS plane and a shell with a frame
budget needs a rung it can hold. There is no `.eighth`: it was a quarter of
a disk's objects on the bucket, and the trade is that the coarsest zoom
(and a constrained connection) now downloads the quarter, four times the
bytes of the eighth. The shell reads whichever tiers a manifest lists, so
a window published with an eighth plays to the end of its life.

### The true colour

`truecolor` is one picture by day and by night: the visible picture —
the 0.64, 0.51 and 0.47 µm reflectances of a slot as red, green and
blue — where the sun is up, white cloud from two infrared windows over a
dark ground where it is down, blended across the terminator. It is this
pipeline's own recipe (`TrueColorProducer`, no package behind it), in a
fixed order that the tests hold step by step:

1. every input reflectance clipped at 0 from below (the products carry
   small negative values in the dark);
2. the cosine of the solar zenith on every cell at the slot's start
   (pyorbital, on the grid's own coordinates), and the zenith θ from it;
3. each reflectance divided by `max(cos θ, cos 85°)` — the products are
   the reflectance *factor*, not yet normalised for the sun, and the floor
   keeps the last degrees of a day from amplifying noise;
3a. the molecular sky taken out of each reflectance at its band's own
   wavelength λ (`rayleigh_corrected`): `(ρ − ρ_R) / T`, with the single
   scattering path reflectance over a black surface, lifted for the light
   scattered more than once,
   `ρ_R = 0.75 (1 + cos² Θ) / (4 (μs + μv)) × (1 − exp(−τ m)) × (1 + 0.25 τ m)`, the air
   mass `m = 1/μs + 1/μv`, the optical depth
   `τ = f × 0.008569 λ⁻⁴ (1 + 0.0113 λ⁻² + 0.00013 λ⁻⁴)`
   (Hansen and Travis 1974; 0.19 at 0.47 µm, 0.05 at 0.64 µm) times the
   share `f` of the column above the cell
   (`rayleigh_column_fraction`): 1 up to a sun-normalised 0.64 µm
   reflectance of 0.2, 0 from 1.0, linear between, since a cloud top
   hides the air beneath it (pyspectral's red-band reduction). The
   attenuated form saturates where the slant path is optically thick;
   the thin limit `τ P / (4 μs μv)` takes out several times the sky near
   the terminator and the limb and strips cloud of its blue, and single
   scattering alone leaves a blue haze; the lift of 0.25 keeps the sea
   navy and the cloud white to the limb. The
   scattering angle is `cos Θ = −μs μv − sin θs sin θv cos(φs − φv)` from the
   sun and the satellite as seen from the cell (pyorbital; the satellite
   over the platform's sub-satellite longitude at 35 786 km), and the
   two-way transmittance is `T = exp(−τ m / 2)`, both cosines
   floored at 85°; faded out linearly between 70° and 88° of the larger of
   the two zeniths, where single scattering overestimates the sky and the
   picture falls back to the uncorrected reflectance;
4. the green: `0.93 × 0.51 µm + 0.07 × 0.86 µm` on an imager with a green
   band (AHI, FCI; the hybrid green that lifts vegetation to the colour
   the eye expects, Miller et al. 2016), or `0.45 × 0.47 µm + 0.45 ×
   0.64 µm + 0.10 × 0.86 µm` on the ABI, which has no green band (the
   CIMSS blend);
5. the day guns: red, green and blue through one brightness curve —
   reflectance 0–1.1 spread over 0–255, knots 0, 30, 60, 120, 190, 255 to
   0, 110, 160, 210, 240, 255, linear between, NASA Worldview's
   corrected-reflectance stretch — clamped to 0–1;
6. the night guns: `ground + (1 − ground) × w` on each, with the ground
   `(0.03, 0.035, 0.05)` and the cloud whiteness `w = max(w_ir, w_low)`:
   `w_ir = clip((280 K − T₁₀.₄) / 60 K, 0, 1)^0.75` and
   `w_low = 0.7 × clip((T₁₀.₄ − T₃.₉ − 2 K) / 5 K, 0, 1)`;
7. `a × day + (1 − a) × night`, with the day weight
   `a = clip((90° − θ) / 10°, 0, 1)` — 1 to a zenith of 80°, 0 from 90°,
   linear between — clamped to 0–1;
8. no data in all three guns wherever a side that carries weight lacked
   an input: a reflectance where `a > 0`, the 10.4 or 3.9 µm window where
   `a < 1`.

| gun | day, AHI and FCI | day, ABI | night |
|---|---|---|---|
| `truer` | 0.64 µm | 0.64 µm | 0.03 + 0.97 w |
| `trueg` | 0.93 × 0.51 µm + 0.07 × 0.86 µm | 0.45 × 0.47 µm + 0.45 × 0.64 µm + 0.10 × 0.86 µm | 0.035 + 0.965 w |
| `trueb` | 0.47 µm | 0.47 µm | 0.05 + 0.95 w |

The night constants are named in `producers.py` and are one set for
every imager, so the disks of the `geo` mosaic meet without a seam after
dark (AHI, ABI and FCI read their own 10.4/10.3/10.5 and 3.9/3.9/3.8 µm
channels under the family ids `ir104` and `ir039`); only the day side's
green differs by imager:

| constant | value | why |
|---|---|---|
| `TRUE_COLOR_TERMINATOR_DEG` | 80°, 90° | the day picture alone to 80°, the night alone once the sun is down; about the span GeoColor fades its layers over |
| `TRUE_COLOR_NIGHT_GROUND` | 0.03, 0.035, 0.05 | near black with a faint cool cast: a clear night reads as night, not as missing data (code 0), and cloud stands out on it |
| `TRUE_COLOR_CLOUD_TEMPERATURE_K` | 280 K → 0, 220 K → 1 | warmer than 280 K is the ground or the warmest low cloud, colder than 220 K a deep or high top; about the range of GeoColor's night-side infrared cloud |
| `TRUE_COLOR_CLOUD_EXPONENT` | 0.75 | below 1, so mid-level cloud is already light grey and high cloud white rather than a flat linear grey |
| `TRUE_COLOR_LOW_CLOUD_DIFFERENCE_K` | 2 K → 0, 7 K → 1 | small droplets emit poorly at 3.9 µm, so fog and stratus, as warm as the ground and invisible at 10.4 µm alone, read several kelvin colder there; clear sea and vegetated land stay under 2 K (the fog products' threshold) |
| `TRUE_COLOR_LOW_CLOUD_WHITE` | 0.7 | low cloud a softer grey than high cloud, so the two stay apart as on GeoColor's night side |

The missing-input rule follows the weight: on the full day side
(`a = 1`) a missing infrared window costs nothing and the day picture
stays; on the full night side (`a = 0`) the reflectances are not read; in
the terminator band both sides' inputs must be there. Outside the disk
every input is missing, so code 0 there as before.

The Rayleigh correction is what makes the ground readable. Under a
morning sun near backscatter the sky's own path reflectance at 0.47 µm
is 0.15–0.18, most of what a forest or the sea returns at the top of
the atmosphere; left in, every surface sits under the same blue-grey
veil and a city barely parts from the fields around it. Taken out, sea
and vegetation sit at a few per cent and a city at ten to fifteen, which
is why the brightness curve has a steep foot (a cloud-oriented curve
such as CIRA's leaves that range near black). The correction is
analytic, not a lookup table, so no package or downloaded table stands
behind the recipe; inside the fade it is within a few thousandths of
reflectance of the tabulated corrections, below what the curve resolves.
Aerosol is not corrected: a hazy day stays hazy. The night side reads the infrared alone, so it has known
failures it does not try to fix: a cold clear surface (a winter
continent, the ice sheets near the disk's edge) is colder than 280 K and
reads as thin grey cloud; a desert at night, whose quartz emits poorly
at 3.9 µm, can show a 10.4 − 3.9 µm difference of several kelvin and a
grey low-cloud veil; and the 3.9 µm window's noise over very cold tops
is hidden by the infrared ramp, which is already white there. Which
channels a platform feeds the recipe is `TrueColorProducer.inputs_for`
(the four solar bands, or three without the 0.51 µm one, then `ir039`
and `ir104`), mirrored by `convert.rs::composite_input_ids` the way the
Dust RGB's missing 11.2 µm window is.

The guns are the Dust RGB's shape: three variables of one composite
bundle, local-use parameters 3 / 192 / **7, 8, 9** on surface 8, the
guns' codebook (code 0 no data, 0.0 at code 1, 1.0 at code 251), no
poster, the three-rung ladder. The `producer` block beside each
is `{"id": "xue", "version": "5"}`: the id names this pipeline, and the
version is the recipe's (`producers.TRUE_COLOR_VERSION`), bumped when a
constant above changes and never with the package, since a cached slot is
recomposed when the version it was composed under differs. Numbers 10,
11 and 12 under `xue` are left unused: earlier windows carried a night
microphysics composite (`nightmicro`) there, which readers now treat as
an unknown bundle.

What it costs: the solar bands are the big ones. An AHI slot's 0.5 km red
band is 390 MB of tiles by day and 230 at night, the three 1 km bands 100
MB each; an ABI slot's 0.5 km red file is 430 MB by day and 200 at night,
the two 1 km ones 100 MB. A Himawari round therefore downloads some 700 MB
of tiles against the windows' 140, a GOES round some 630 against 140,
warps the 0.5 km band (22 000 × 22 000 cells) once, and caches the frames
like any channel's. The night side reads two windows every source already
fetches, so it costs no download. On Meteosat the solar channels cost no
download (an FCI chunk carries every channel); the reader turns their
radiances into the same reflectance factor the NOAA products carry, `π L
d² / E_sun` (§"The FCI reader"), FCI's own 0.51 µm band takes the AHI's
hybrid green, and the hourly 24-hour window holds some twelve sunlit
frames. FCI's blue band is 0.444 µm, bluer than the AHI's 0.47, under
the family id `vis047` (the `band` block carries its wave number); the recipe is not changed for it.

### The dust confidences

`dustcf` is DEBRA (Miller et al. 2017, doi:10.1002/2017JD027365 — the
Dynamic Enhancement Background Reduction Algorithm for dust), Eqs. 1–22
as the `shachen` package implements them: an infrared cloud mask, three
dust tests against a clear-sky background, and a confidence factor in
0–1 blended across the terminator, which reads high where lofted mineral
dust is likely and 0 where nothing suggests it. `zhouye` is ZHOUYE (昼夜,
"day and night"), the diurnally consistent scheme the same package
builds on that chain (§"The ZHOUYE scheme" below): the same confidence
by day, and at night a reading that stays at the day's level instead of
fading. They are two products — two bundles of one variable each — from
one pass of the producer seam (`DebraProducer`), computed per slot in
the fetch stage like the guns and brought into these stores as scalar
fields the shell paints with one ramp.

| input | what it feeds |
|---|---|
| `ir039`, `wv062` | the cloud mask's night thin-cirrus and deep-convection tests (Eqs. 4, 6) |
| `ir086`, `ir104`, `ir123` | the mask's split-window tests and restorals, the dust tests DT1 (12.3 − 10.4 µm) and DT2 (8.6 − 10.4 µm) against the background, the thermal contrast DT3 |
| a skin temperature | CM1 and DT3 (how cold the window reads against the ground), and the Planck curve of the background |
| an infrared emissivity | the background: `BT_bg = B⁻¹(ε · B(T_skin))` per window, whose differences are what DT1 and DT2 measure against |

**The ZHOUYE scheme.** DEBRA's three confidence sums (Eqs. 16–18, day,
terminator and night) are normalized (Eq. 19) and blended by solar
zenith (Eqs. 20–22). ZHOUYE (`shachen.constants.ZHOUYE`,
`shachen.pipeline.run_zhouye`) changes three things, all in the
terminator and night sums and none in the daytime one: DT2 is read on a
fixed (−0.5, +1.5) K interval of the 8.6 − 10.4 µm difference instead of
Eq. 14's dynamic one, so the clear-sky side of the signal that Eq. 14
clips away — where most of the night-time ranking lives — is kept; the
thermal-contrast test DT3 needs corroboration from a split-window test,
so a cell lit by DT3 alone (mid-level cloud, or a skin-temperature
error, far more often than dust) contributes nothing; and the two sums'
Eq. 19 intervals are fitted so that lit dust reads at night and across
the terminator as it does by day. The daytime sum and its interval are
DEBRA's ABI retune, on every imager. Below a solar zenith of 75° the
Eq. 20 weight is 1 and the two confidences are one, bit for bit; the
scheme is a night-side extension that blends into DEBRA across 75–90°,
built so that one dust reads one confidence around the clock — no
fading at dusk, no brightening after dark. What it costs, on 30 no-dust
days: the night false-alarm rate at confidence 0.2 doubles (0.0029 →
0.0054); over quartz sand seas it is on the miss side. The numbers and
the ground truth are shachen's, and the paper in preparation that
describes them. The two are kept as separate products because they are
different claims: `dustcf` is the published algorithm as retuned, with
a known night; `zhouye` is a new scheme whose night is its own.

The two ancillary fields are not what the algorithm was built against
(MERRA-2 skin temperature, which lands weeks late, and the CAMEL
climatology behind Earthdata credentials), so `ancillary.py` takes two
stand-ins, in the same shape:

- **Skin temperature** is GFS `TMP:surface`, the one record of NOAA's
  0.25° file nearest the slot's whole hour, located through the file's
  `.idx` and fetched by byte range (a megabyte) from the newest cycle
  that reaches the hour, walking back over the cycles the bucket does
  not have yet (a cycle lands some four hours after its analysis, so
  the walk back is the normal path). Cached under
  `data/raw/ancillary/gfs/gfs_tmpsfc_<cycle>_f<hhh>.grib2`; a later slot
  of the same hour asks nothing. Read through GDAL with the unit left in
  kelvin (`GRIB_NORMALIZE_UNITS=NO`; GDAL would hand the field back in
  Celsius) and the raster shifted onto −180 … 180 as GDAL does itself.
- **Emissivity** is the CAMEL monthly climatology (CAM5K30EM V003),
  staged on this bucket by `xuebuild/satellite/staging.py` (§"Staging
  the emissivity"): one NetCDF per region and operational month,
  already interpolated to the DEBRA band centres (`emis_tir_86` …
  `emis_tir_123`), cropped to the region's box with a degree of margin,
  named for the month it serves (the record ends in 2023; the file's
  `source_month` says which year's same calendar month it carries).
  `make pull-r2-ancillary` mirrors that prefix whole into
  `data/raw/ancillary/camel/<region>/<YYYYMM>.nc` (the rounds script
  does it before the first build under `ANCILLARY=true`); a round
  touches neither Earthdata nor the staging prefix. A region with no
  file for the slot's month is served by its newest staged month with a
  warning — the product is a climatology, and a region dropping out at
  a month's turn would be the worse failure; a region with nothing
  staged is not a region; nothing staged at all is an error, since the
  confidence over water alone is not the product.

Both are put on the target grid by one bilinear interpolation
(`ancillary.regrid`) done in the grid's own copy of the world: a global
field is re-based column by column onto a grid that runs past 180° and
wrapped (its first column repeated a turn later), a regional file is
moved whole by the turn that lays it over the grid, and nothing is
extrapolated. The chain is composed here from shachen's per-equation
modules (`background_signals`, `cloud_mask`, `dust_tests`, `confidence`,
`blend_confidence`) rather than through `shachen.pipeline.run_debra` /
`run_zhouye`, because those entry points take a pyresample area and do
the regrid, the sun and the land mask themselves; on these grids those
three are this module's (the regrid above, pyorbital's zenith on the
grid's own coordinates, the land mask on wrapped ones), and
`tests/test_debra.py` holds the composition equal to both pipelines on
a plate carrée area cell for cell. The background, the mask and the
tests are computed once per slot and both confidences read them (the
ZHOUYE dust-test constants differ from the ABI retune's only by the
second DT2 reading they add, which DEBRA's sums are not shown); the
constants are shachen's ABI retune on every imager (the Eq. 19 daytime
floor at 0.40 rather than the printed 0.25, which keeps clear-sky DT3
noise over vegetation from colouring, and the night branch on an
interval of its own), as the former operational pipeline ran both AHI
and ABI.

**Where the confidence is defined.** A cell is computed wherever every
input channel and the skin temperature have data and the ground is
either water — DEBRA takes the water surface's emissivity as unity and
needs no climatology there — or inside the extent of a staged CAMEL
file. Land no staged file reaches is no data (code 0), never a
confidence computed against an emissivity that was never read: staging a
region is what extends the product over it, and a whole-disk staging
would fill the disk with no code change. Today the staged regions are
three — the Gobi and Taklamakan through the North China Plain to Japan
(Himawari), the Chihuahuan Desert and the US Southwest (GOES-East and
GOES-West both see it), and the Saharan transport corridor from the
Cape Verde longitudes to the Caribbean and the Gulf (GOES-East) — plus
every sea the three disks cover. Meteosat publishes no confidence: no
staged region lies on its disk, the Sahara itself is exactly what a
climatology is for, and its window is hourly besides.

**The gate.** What is published as `dustcf` is `cf_comb` with the
split-window gate applied (`producers.split_window_gate`): a cell where
neither split-window test responded (`dt1 = dt2 = 0`) reads 0, since
cloud has no split-window signal and dust nearly always does. The
failure it removes is mid-level cloud too warm for CM1 and too thin for
CM3, which the thermal-contrast test alone reads as dust; on 42 dust
days of East Asian station data it costs a daytime detection rate at
confidence 0.1 of 0.411 → 0.373 for a false-alarm ratio of 0.422 → 0.23.
It is not part of DEBRA (Eqs. 1–29) and not in shachen. `zhouye` takes
the same gate on its normalized day factor alone, then shachen's Eq. 22
blend again (Eq. 19 maps a zero sum to 0 on the day interval, so gating
the factor is gating the sum): ZHOUYE's own corroboration rule already
acts on the terminator and night sums with its DT2 reading, and gating
the blended ZHOUYE on Eq. 14's DT2 — which is 0 over nearly all clear
ground at night — would erase the night it was built for. A second gate
on the 0.64 µm reflectance is not applied to either: it would cost a
0.5 km visible channel per slot for a false-alarm ratio of 0.23 → 0.21,
and there is no reflectance at night.

The result is two bundles of one variable each, `dustcf` and `zhouye`,
on the channel's axis and grid: *composite* bundles in the encoders'
terms (`bundles.COMPOSITE_BUNDLES`, `SourceSpec.bundle_composite_ids`)
— produced in the fetch stage, read off the series with their producer
stamp, never derived by a converter — whose one component is the bundle
itself.
Their identity is the guns' pattern: a local-use parameter, discipline
3, category 192, **number 4** for `dustcf` and **number 6** for
`zhouye`, on surface 8, meaningful only with the `producer` block beside
it (`{"id": "shachen", "version": …}`, the id registered on the
variable, the version whatever ran), no band. Their codebook is the
guns' (linear, offset −0.004, step 0.004, codes 0–251, code 0 no data,
0.0 at code 1, 1.0 at code 251), the same ladder, no poster. A produced frame's record names, beside the
producer and the input frames, the ancillary it was computed against
(the staged directory and the GFS record by name, whose name is the
cycle and forecast hour). Like every produced frame it is composed once:
a slot's confidence is the first computation's, and a GFS cycle landing
later for the same hour does not recompute a cached slot.

### Staging the emissivity

`xuebuild/satellite/staging.py` writes the CAMEL months §"The dust
confidence" reads, and `stage-ancillary.yml` is the one job that holds
Earthdata credentials: at 03:00 UTC on the 25th it stages the month in
progress and the next for every region in the module's table (the 1st
is the retry), and pushes them with `make push-r2-ancillary` (a
`--size-only` sync, so an unchanged file costs nothing). A month is cut
from the granule `shachen.io.emissivity.fetch_emissivity` serves for it
— the record ends in 2023-12, so the same calendar month of the newest
year that has one, never a different month — interpolated to the DEBRA
band centres by `load_band_emissivity`, sorted ascending on both
coordinates (CAMEL stores latitude north to south, and a slice against
a descending coordinate selects nothing, silently), cropped to the
region's box plus `MARGIN_DEG` (1°, so the bilinear regrid never
extrapolates at the box's edge), cast back to float32 and written
zlib-compressed with the attributes the reader keys on (`region`,
`month`, `source_month`, `source`, `bbox`, `margin_deg`). An empty crop
is an error; an existing file is overwritten, since restaging is how a
bad subset is fixed. The regions are a table (a key, a box, a
description) rather than a derivation from the disks, because staging a
region is a decision about where the product is defined over land. The
table holds one row, `global`, the whole granule: the confidence is
defined over every disk's land, and the reader wraps a global field
across the antimeridian itself. A margin past the granule's edge
selects nothing extra. Locally, `make stage-ancillary MONTHS="2026-11"
REGIONS="global"` does
the same against your own `~/.netrc` (the `staging` dependency group;
no GDAL), and `tests/test_staging.py` holds the crop, the month
resolution and a staged file's read-back through `ancillary.py` on a
synthetic granule, never the network.

## Regional boxes

A disk at 0.04° (4.4 km at the equator) is limited by the grid, not the
sensor: AHI samples 0.64 µm at 0.5 km, the other solar bands at 1 km and
the infrared at 2 km at the sub-satellite point, some 0.7–1 km and 2.8 km
effective over Japan at its 42° viewing angle. The whole disk at 0.01°
would be 144 M cells a plane; a box is a few million. So a finer grid is a
**source of its own** on the same platform — a regional source, the way
`hrrr` sits beside `gfs` — and not a finer rung of the disk's ladder,
since a variant is the same extent decimated.

`SourceSpec.region` is the box as `(west, south, east, north)`, edges on
whole cells of `grid_step`; the fetch warps onto it instead of
`Platform.region`, and `production_grid` must be the box at the step.
`himawarijp` is the one such source today:

| | `himawarijp` |
|---|---|
| platform | `himawari` (the same files, band blocks and producers) |
| box | 24–46°N, 122–148°E (whole degrees: the JMA nowcast's 0.005° cells nest 2:1) |
| grid | 0.01°, 2600 × 2200, tile 64 × 64 (0.64°, 1435 a plane), ladder 0.02 / 0.04 / 0.08° |
| fetched | `ir039`, `ir086`, `ir104`, `ir112`, `ir123`, `vis047`, `vis051`, `vis064`, `nir086` |
| published | `ir104`, `ir039`, `dustrgb`, `truecolor` (no confidences: their CAMEL months are staged on the disk grids) |
| window | 600 s, 3 h |

The ISatSS reader narrows a slot to the box (`ISatSSReader.tiles_covering`).
A tile's position on the disk's 10 × 10 grid of tiles is a fixed table
(`ISATSS_TILE_ROWS`: rows of 6, 8, 10 × 6, 8, 6 tiles, the twelve corners
that hold no Earth left out; T020 is row 2, column 5, as its own
`tile_row_offset` / `tile_column_offset` say), and its footprint is the
box around a 56 × 56 lattice of its scan angles put through PROJ's
ellipsoidal `geos` inverse (`geostationary_lonlat`), with the tiles'
own projection constants. Over a whole slot of real tiles the footprints
match those computed from each tile's own geotransform to 1e-10°, and
the fixture tiles' corners as GDAL reads them to 0.01°. A tile is needed
when its footprint, widened by 0.1° (more than a 2 km pixel wherever a
box is useful, so a bilinear sample at the edge finds its neighbours),
overlaps the box: for Japan, six of the 88 (T009–T011, T018–T020). Only
those make a slot complete, are downloaded and are mosaicked — some 60
MB a slot over the eight channels other than 3.9 µm by day and 35 MB by
night (2026-10-11 03:00 and 2026-10-10 15:00 UTC), against 870 and 500
MB for the disk's ten; the 3.9 µm window the true colour's night side
reads adds one more 2 km channel's six tiles. A CMIPF slot is one file and an FCI download already crops
its chunks to the disk's rows, so those readers do not narrow
(`tiles_covering` is None).

The frame cache is keyed by the **source**, `<source>-frames`, since the
box and the disk warp the same slot onto two grids; a disk's source id is
its platform's role, so the disks' caches kept their names. A slot of the
box is eighteen frames of 3–7 MB (some 95 MB). Measured on one sunlit
hour (2026-10-11 03:00–04:00 UTC, seven slots, under true colour recipe
1): the stores are 8.4 MB of `ir104`, 35 MB of `dustrgb` and 65 MB of
`truecolor` at full resolution and a third more for the ladder, some
170 MB, near 0.5 GB for a sunlit three-hour round; that is why the
window is three hours and not the disks' six. The true colour's night
side is white cloud over a flat dark ground, smoother than the sunlit
picture, so a night hour costs less than a sunlit one but no longer next
to nothing.

## Metadata

A satellite variable's identity is its `parameter` block, brightness
temperature at the nominal top of the atmosphere (GRIB2 0 / 4 / 4 on
surface 8), which every infrared band of every imager shares, plus the
`band` block beside it (`bundle.md` §"Band, Producer and Aerosol"), template
4.31's five fields:

```json
"band": {
  "satelliteSeries": 0,
  "satelliteNumber": 174,
  "instrumentType": 297,
  "scaleFactorOfCentralWaveNumber": 0,
  "scaledValueOfCentralWaveNumber": 96086
}
```

The shell classifies a channel by the band's central wave number (10–11 µm
is the infrared window, `ir104`), never by the spacecraft, so GOES-19's
10.35 µm channel and Himawari-9's 10.41 µm one draw with one palette. A
brightness temperature with no band, or in a band the shell has no chart
for, renders generically.

Cells the disk never covers arrive as the product's fill (`-32767`) and
become the bottom of the codebook, 180 K — below any cloud top a 10 µm
channel reports — which the shell paints as nothing, the way the radar
mosaics' no-coverage cells are handled. The format carries no bitmap.

## The fetch stage

### Reader

A reader (`readers.py`, `Reader`) lists a platform's slots and a slot's
objects, downloads them, and opens them as **one thing GDAL can open**: a
dataset on the geostationary CRS whose values are the physical quantity or
carry a scale and offset to it. Its responsibility ends there.

`ISatSSReader` is NOAA's ISatSS product: each channel of each scan as 88
Sectorized CMI NetCDF tiles (550 × 550 at 2 km) under
`AHI-L2-FLDK-ISatSS/YYYY/MM/DD/HHMM/`, named
`OR_HFD-<res>-B<bits>-M1C<channel>-T<tile>_GH9_s<start>_c<created>.nc`. The
bit-depth field varies by channel (B11 for most, B12 for channels 10–15,
B14 for channel 7), so the listing prefix spells the channel's own and
never guesses. The tiles are already calibrated (`Sectorized_CMI`, Int16
with `scale_factor` 0.064208984375 and `add_offset` 69, kelvin) on the CF
`geostationary` projection with x/y in microradians; GDAL warns about the
unit and computes the geotransform from them faithfully. The coordinates
themselves are one pixel off: a tile's first pixel centre is written half
a pixel *west* of the edge its `tile_column_offset` names, where it belongs
half a pixel east of it (T020 of the 0.5 km band starts at x = −500 m where
the offset says 0), and half a pixel north of its row edge the same way,
in every band at that band's own pixel. Read as written,
the 0.5, 1 and 2 km bands of one slot land 0.5, 1 and 2 km north-west of
their ground and up to 1.5 km apart from each other (measured on a clear
Korean coast against the coastline: 0.85 grid cells at 0.01° between the
1 km bands and the 0.64 µm band, 2 cells for the infrared), which fringes
every edge of the true colour with cyan and red. The reader moves its
mosaic back one pixel east and one south (`_shift_one_pixel_south_east`),
after which the bands agree to 0.02 cells. A day's slots are
the directory listing (`delimiter=/`), a slot's tiles one listing under
the channel's prefix, a reissued tile the later `c` stamp. The slot opens
as a `gdalbuildvrt` mosaic of the tiles by georeference. For a source with a
region of its own the reader also says which tiles reach into it
(`tiles_covering`, §"Regional boxes"); only those make the slot complete,
are fetched and are mosaicked.

`CMIPFReader` is NOAA's `ABI-L2-CMIPF` product, the GOES-R full disk:
each channel of each scan as **one** netCDF-4 file under
`ABI-L2-CMIPF/YYYY/DDD/HH/` (year, day of year, hour), named
`OR_ABI-L2-CMIPF-M<mode>C<channel>_G<nn>_s<start>_e<end>_c<created>.nc`
with `YYYYDDDHHMMSSs` stamps. `CMI` is unsigned 16-bit, 5424 × 5424 at
2 km for the infrared channels, with the band's own scale and offset to
kelvin (C13: 0.06145332 and 89.62) and 65535 where the disk is not; the
`goes_imager_projection` is the CF `geostationary` mapping with sweep `x`
and x/y in radians, which GDAL turns into a metre geotransform on its own
(its warning about the radian axis unit concerns the SRS's axis, not the
georeference). A scan in mode 6 starts twenty seconds past every ten-minute
mark and its **slot is that mark** (the start floored to the cadence); the
listing accepts any mode digit. A slot is complete once its file is listed
(`tile_count` 1), the file lands some ten minutes after the scan starts,
and a reissue is the later `c` stamp. The slot opens as a one-source VRT
over the `CMI` variable, so the no-data floor is applied the way it is to
a mosaic. Listing is per hour directory: `list_hours` reads a day's hour
prefixes in one request, `list_hour` one hour's files for a channel, and
`recent_slots` walks the hours newest first and stops once it has the few
slots `latest_slot` asks about — two or three requests a round rather
than a whole day's twenty-four. The `DQF` quality flags are not read
(99.9996 % of a sampled disk is flag 0).

`FCIReader` is EUMETSAT's MTG FCI Level 1c full-disk product (FDHSI, the
Data Store collection `EO:EUM:DAT:0662`): one product per ten-minute
repeat cycle, cut into forty netCDF-4 chunk files, each a strip of some
140 rows of the 5568 × 5568 2 km grid carrying **every channel** as
12-bit radiance codes with a scale and offset
(`/data/<channel>/measured/effective_radiance`, mW m⁻² sr⁻¹ (cm⁻¹)⁻¹, fill
65535). Three things stop GDAL opening a chunk as the other readers'
files are opened, and the reader does them itself:

- the chunks are compressed with an HDF5 filter (JPEG-LS, filter 32018)
  a stock GDAL cannot decode: the plugin comes with the `hdf5plugin`
  distribution (the `satellite` dependency group) and is handed to each
  GDAL subprocess the reader runs as `HDF5_PLUGIN_PATH`
  (`hdf5_plugin_environment`; an environment that already names one is
  left alone);
- the values are radiances: the reader reads the channel's codes with
  `gdal_translate`, unpacks them, and converts them by the channel's
  kind. An infrared channel takes its own Planck coefficients, scalar
  variables of its `measured` group read through `gdalmdiminfo` —
  `BT = (c2 ν / ln(1 + c1 ν³ / L) − b) / a`, the conversion the product
  documents — into an Int16 strip in steps of 1/128 K above 100 K
  (`FCI_BT_SCALE` / `FCI_BT_OFFSET`; IR 3.8, which reads past 356 K over a
  sunlit desert, about 200 K instead). A solar channel takes its
  effective solar irradiance at 1 AU (`channel_effective_solar_irradiance`
  in the same group, mW m⁻² (cm⁻¹)⁻¹) and the mean Earth–Sun distance of
  the chunk's rows (`/state/celestial/earth_sun_distance`, km, over
  1.495978707e8 for AU): `reflectance_factor = π L d² / E_sun`, not
  divided by the cosine of the solar zenith (the ISatSS and CMIPF
  reflectances are not either; the true colour producer divides), into
  an Int16 strip in steps of 1/4096 from zero (`FCI_REFL_SCALE`;
  −0.01 … 1.26 is codes −41 … 5161). Either way a raw file and a VRT
  that carries the packing and the unit (`K` or `1`), and the frame's
  record carries the channel's `kind`. The steps are binary
  fractions on purpose: a decimal one such as 0.01 K puts some values an
  ulp either side of a codebook half-step depending on whether a
  platform fuses `code × scale + offset`, and the two encoders then
  disagree by one code on one cell. A solar channel's group carries the
  Planck variables too, holding their fill value, so asking it for
  Planck coefficients is an error ("not an infrared channel?"), as is
  asking an infrared group for a solar irradiance;
- the grid mapping (`/data/mtg_geos_projection`: sweep `y`, height
  35786400 m, WGS84, longitude 0) sits in a parent group GDAL does not
  connect to the variable, so the strip's VRT carries the geostationary
  SRS built from those fields and an extent in scan angles (radians, a
  column or row number packed with a scale and offset) times the height.
  East to west the extent comes from the file's own column packing:
  column i, from 1, is the scan angle `offset + step × i`, and the
  product measures that angle positive towards the **west**, the negative
  of PROJ's geos x (offset +0.156 rad, a negative step, column 1 the
  western limb). Taken at face value, as GDAL's geotransform takes it,
  the disk comes out mirrored about the sub-satellite meridian — every
  Meteosat frame until reader version 3 did, Arabia over the Atlantic.
  North to south GDAL's row origin is the chunk's, its row step checked
  against the grid. The strip is written west to east and north to south
  whichever way the file runs. A frame's record names the reader version
  that placed it (`frameVersion`, 3 for FCI), and a cached frame of
  another version is warped again, its slot's composites recomposed. The
  infrared channels are on a 2 km grid (5568 columns, row step
  5.5887e-5 rad), the solar ones on a 1 km grid (11 136 columns, half the
  step, the same disk); a chunk is a fortieth of the rows of either. The
  reader checks the packing of the rows and columns and the grid's width against the
  constants of the grid the channel's `resolution_km` names (`FCI_GRIDS`),
  and plans chunks with them, so a product change is an error.

The strips of a channel are mosaicked with `gdalbuildvrt`; the projector
warps that. A chunk carries every channel, so a slot's files are shared
by its channels (`Reader.files_per_channel` is false: `fetch_frame` puts
them under the slot's directory rather than a channel's, and the window
removes the directory once the slot's channels are done), and only the
chunks whose rows reach into ±60° of latitude are downloaded
(`needed_chunks`: 60° on the sub-satellite meridian is seen 0.1402 rad up
from the disk's centre, against the disk's 0.1556, so the outermost two
chunks at either end — 2 through 39 remain — are never fetched, some
900 MB a cycle). A slot is complete when the product lists all forty
chunks; a cycle's slot is its sensing start floored to the ten-minute
cadence (15:20:07 is 15:20).

The store is `eumetsat.py`: `search` is the anonymous OpenSearch query
(`…/search-products/1.0.0/os?format=json&pi=<collection>&dtstart=…&dtend=…`,
each product's `date` interval, `updated` stamp and `sip-entries` — one
link per file, `entry?name=<file>`), `list_slots` one search over a day,
`recent_slots` one search back over six hours, `list_slot` one over the
cycle. `download_bytes` fetches one file with a bearer token minted by
`POST https://api.eumetsat.int/token` from a registered account's
consumer key and secret — `EUMETSAT_CONSUMER_KEY` /
`EUMETSAT_CONSUMER_SECRET` in the environment, the workflow's secrets of
the same names — renewing it when the store refuses it, waiting out a
rate limit as the store's `retryAfter` asks (capped at two minutes), and
failing by name when the two variables are unset, so a build without an
account stops at the first download. The listing gives no file sizes; a
file present on disk at all is taken as complete, since a download lands
under a `.part` name until it is.

A further reader would be `HSDReader`, for the raw Himawari Standard
Data segments should the ISatSS product ever stop, or `SEVIRIReader` for
Meteosat-9's Level 1.5 native file.

### Projector

A projector (`projector.py`, `Projector`) writes the reader's dataset
resampled onto a `TargetGrid` — edges and step, cell centres half a step
inside, longitudes allowed past 180 — as an Int16 GeoTIFF with the
source's nodata, scale and offset on the band. `GdalWarpProjector` is
`gdalwarp -t_srs EPSG:4326 -te … -tr … -r bilinear` (`average` for a
reflectance, `max` for a peak frame), deterministic for one GDAL version,
multithreaded. A NumPy projector with a cached lookup table
(for parallax correction, or exact alignment with a producer's grid) is
the same interface.

The published grid is the platform's region at the source's `grid_step`:
60° either side of the sub-satellite longitude and ±60° of latitude, past
which the view is too oblique to read. For Himawari that is 80.7°E to
200.7°E at 0.04°, 3000 × 3000 cells, first cell centre 80.72°E, 59.98°N —
a grid that crosses the antimeridian, which the encoders' `crop_grid` and
the shell's viewport arithmetic take in the grid's own copy of the world
(a box spelled `-170` is at 190 on it); GOES-West's is 163°E to 283°E the
same way (first cell centre 163.02°E), GOES-East's 135.2°W to 15.2°W
(first cell centre 135.18°W). A scene that lies wholly outside the grid is
refused rather than written blank, since a blank warp is also what a lost
projection produces.

### Frames and the cache

A frame is one slot of one variable on the target grid, at
`data/raw/<source>-frames/<variable>/<variable>_<YYYYMMDDHHMMSS>.tif`
(keyed by the source, since two sources of one platform warp the same
slot onto two grids; a full-disk source's id is its platform's role): a
channel's, warped by the projector, or a produced one, written by
`assemble.write_frame` (Int16 at 1e-4 with the same fill, through an ENVI
header and `gdal_translate`, no raster library). Inside every frame is its
record, one JSON object in the GeoTIFF's `XUE_FRAME` metadata item (GDAL's
default domain, the `GDAL_METADATA` tag) — the scale, offset and unit the
frame's codes mean, read off the source tile before the warp for a
channel, the tiles and reader version it came from, and for a produced
frame also the producer's id and version and its inputs — so a frame is
one object on the bucket. `gdalwarp` takes no metadata option, so the
projector warps to an uncompressed scratch file and `gdal_translate`
writes the frame from it with the item. Frames cached before the record
moved inside carry it in a `<variable>_<YYYYMMDDHHMMSS>.json` sidecar;
`assemble.frame_record` reads the embedded item first and the sidecar
only when there is none, so both kinds meet in one window until the old
ones are pruned. A slot is warped once and
composed once: the rounds script pulls the window's hours of frames from
the bucket before the first build and pushes new ones after every upload
(`make pull-r2-frames` / `push-r2-frames` / `prune-r2-frames`, `MODEL=himawari`;
the targets take every variable directory), so a round downloads one
slot's tiles (26 MB per channel) and runs the producers on one slot
whatever the window's length. A channel's frame is a pure function of its
tiles and the GDAL version, a produced one of its input frames, its
ancillary and the producer's version (`produce_frames` recomposes a
cached slot whose record names another version); a GDAL upgrade may
resample the next frame differently, and the cached older frames stay as
they are, each under its own `?v=` once published. A producer's ancillary
fields live beside the frames under `data/raw/ancillary/` (the staged
CAMEL months, mirrored from the bucket by `make pull-r2-ancillary`; the
GFS records the dust confidence producer fetches per slot, never mirrored), which
`_fetch_satellite_run` hands to `fetch_window` as the ancillary root.

### The series

`assemble.write_series` stacks one variable's frames into its series
file of the window, `<stem>.<variable>.nc` (`himawari.2026091703.ir104.nc`,
`….dustr.nc`, …): a VRT over the frames carrying the netCDF driver's
extra-dimension metadata (`NETCDF_DIM_EXTRA={time}`,
`NETCDF_DIM_time_DEF`, `NETCDF_DIM_time_VALUES`, one `NETCDF_DIM_time`
per band, `NETCDF_VARNAME=<variable>`), translated with
`gdal_translate -of netCDF` into `<variable>(time, lat, lon)`, packed
Int16 with the frames' own scale and offset and fill, `time` in seconds
since the run, `units` the registry's (`K`, or `1` for a gun), and on a
produced variable the `producer_id` and `producer_version` attributes
(the band metadata keys of the VRT become the variable's attributes).
One file per variable because the netCDF driver stacks a VRT's bands into
one extra-dimensioned variable only when the bands are exactly that axis;
given two variables' bands it writes one variable per band instead. Every
series of a window carries the same axis: a slot is in the window only
when every channel landed whole, and every producer's outputs exist
exactly when its inputs do. The reference pipeline needs no NetCDF
library; GDAL writes the file, and the same GDAL reads it back through
`xuebuild/observation.py` (`series_files` resolves a run directory to a
file per variable, or to the one file the radar sources write;
`inspect_observation` reads each variable with its own packing and fill,
holds the axes equal, returns the producer stamps), which snaps each time
to its 600 s slot and takes the first slot's hour as the run. The
converter reads only the variables the requested bundles carry: the five
unpublished channels are never quantized.

### Rounds

`fetch.fetch_window` walks every slot from the run's hour through `hours`
past it at the source's cadence: a cached frame is read back, a complete
slot on the bucket is fetched and warped, an incomplete or absent slot is
left out (the axis allows the gap, and the next round takes it if it
lands). The live window's end is the newest slot whose tiles have all
landed (`latest_slot`: the reader's `recent_slots` — a day's slot
directories at once for ISatSS, the newest hour directory for CMIPF, one
search for FCI, yesterday's as well around midnight — then the newest
three slots asked for their tiles, the rest trusted). `resolve_run("latest")`
is the six whole hours (`window_hours`) ending with that slot's hour, as
for MRMS and JMA with their own lengths.

**Meteosat is hourly.** The imager scans every ten minutes and the store
lists every cycle, but the `meteosat` source's `cadence_seconds` is 3600
against the platform's 600, its window 24 hours (25 frames), and
`window_slots` and `latest_slot` keep the slots on the source's cadence:
the cycle on each hour alone. The reason is the EUMETSAT data policy
(2025): the Level 1 repeat cycle referenced to each clock hour is Core
data, released under CC-BY-4.0 and redistributable at any latency; the
cycles between are licensed data whose operational use within an hour of
sensing is not free and whose numbers may not be redistributed after it.
A store with hourly frames is what that policy allows this site to
publish. The attribution it requires ("Contains modified EUMETSAT
Meteosat data [year of publication or distribution]") is in the shell's
credit, the year stamped at render time, and in the catalog prose, the
year of the run's first frame filled in when the Collection is written. The tiles of a Himawari scan are generated about eight
minutes after it starts and listed some fifteen after, a GOES file lands
some ten minutes after its scan starts; a round is a listing, one scan's
files, one warp per channel, one composition, one stack per variable and
a conversion, three to four minutes, so the live window ends fifteen to
twenty minutes behind real time; an FCI cycle is in the store some five
minutes after its sensing ends, and its round downloads 900 MB and
converts 38 strips per channel for eight channels — the four solar ones
on the 1 km grid, which read no slower than an infrared one, since a
strip's time is opening the chunk — some ten to fifteen minutes once an
hour.
`.github/workflows/publish-himawari.yml`, `publish-goeseast.yml`,
`publish-goeswest.yml` and `publish-meteosat.yml` each run one round per
job on a half-hour cron (a round fetches every slot its frame cache lacks,
so the window keeps its ten-minute step) and install `gdal-bin` whichever encoder
converts, since the wheel's GDAL is a library with no GeoTIFF driver; the
three NOAA ones pull the staged CAMEL months before the first build
(`ANCILLARY=true` in the rounds script, `make pull-r2-ancillary`); the
Meteosat one also proves the runner's GDAL loads the JPEG-LS plugin on the
fixture chunk before a round spends a download, and warns and builds
nothing when the two `EUMETSAT_*` secrets are absent.

## Producers

A composite product (a dust index, a split-window difference, an RGB) is
a `Producer` (`producers.py`): its input is one slot's channels, already
warped — float planes in the channel's unit with NaN where no data — plus
the ancillary fields it names (`ancillaries`, resolved and fetched per
slot by `ancillary_for(platform, slot, root)` under the fetch's
ancillary root), the slot and the grid, its output one or more new
planes on the same grid, each written as a frame of its own and cached
beside the channels' (`fetch.produce_frames`), so a round composes the
slot it warped and reads the rest back. It never touches quantization, the
container, the store or the manifest: its outputs are stacked into series
like channels and the converter reads them as the components of one
composite bundle. Two kinds share the interface: an in-process NumPy
function with a fixed operation order, which can be held to a golden, and
an external one that runs elsewhere and writes to the shared bucket, read
back the way the CMA archive is. A produced variable's identity is a
local-use GRIB2 parameter with the `producer` block beside it, the id
registered on the variable, the version taken from the frames the
producer wrote.

`DustRGBProducer` is the first: `id` `shachen`, `bundle_id` `dustrgb`,
inputs `ir086`, `ir104`, `ir112`, `ir123` (`inputs_for(platform)`: the
three without `ir112` on an imager that lacks it), outputs `dustr`,
`dustg`, `dustb`, no ancillaries, `version` the installed shachen
distribution's. It builds an xarray scene of the planes (the 10.4 µm one
standing in for 11.2 µm where there is none) and calls
`shachen.dustrgb.dust_rgb` with the stretch set the platform's instrument
takes (`DUST_RGB` for AHI and FCI, `DUST_RGB_ABI` for ABI — the rule
shachen applies by satpy reader, made here by `Platform.instrument`), then
marks every cell any input lacked as no data in all three guns.

`DebraProducer` is the second (§"The dust confidences"): `id` `shachen`,
`bundle_ids` `dustcf` and `zhouye` (`bundle_id` is the first, what the
logs name it by), inputs `ir039`, `wv062`, `ir086`, `ir104`, `ir123`
(all five required; no stand-in), outputs `dustcf` and `zhouye` in that
order, ancillaries `camel` (the staged months' directory) and `skin`
(the slot's GFS record, fetched by `ancillary_for` when not cached),
`version` shachen's. `run` regrids the two fields, finds the sun and the
ground, composes shachen's per-equation modules once, takes the DEBRA
confidence gated and the ZHOUYE confidence with its day factor gated and
re-blended, and leaves NaN wherever the confidence is not defined. A
producer's outputs may be the components of more than one bundle:
`PRODUCERS` lists it under each, the fetch runs it once for all of them
(`dict.fromkeys` over the source's listed composites) and caches every
output frame, so a source listing one of its bundles still composes
both. `PRODUCERS` is keyed by the
bundle produced; `SourceSpec.bundle_composite_ids` lists what a source
publishes, and `_fetch_satellite_run` runs every listed producer whose
channels the window fetches (asked for the Dust RGB's four alone, it
composes that and not the confidence). `TrueColorProducer` is this
pipeline's own (`id` `xue`, the version the recipe's constant): §"The
true colour". shachen is the `satellite`
dependency group (`uv sync --group satellite`), imported inside the
producers and nowhere else.

## Fixtures and tests

`tests/fixtures/himawari/` is forty real tiles — T020 and T021 of two
consecutive scans in bands 7, 8, 11, 13, 14 and 15, untouched, and the
same tiles in bands 1–4 cut to their north-west corner
(`tests/prepare_himawari_fixture.py`: a sixteenth of each, since a 1 km
tile is 1.3 MB and the 0.5 km one 4.7) — and `tests/test_satellite.py`
runs them through the whole stage — listing, completeness, download,
mosaic, warp (the solar bands as block means, the record saying so),
cache, the producers (the Dust RGB held cell for cell to
`shachen.dustrgb.dust_rgb` called directly, the true colour's day side to
its recipe written out step by step, its night side to the night recipe
on the fixture's windows — ground and white cloud, never no data, a cold
top whiter than a warm one, fog lit by the 10.4 − 3.9 µm difference —
and the terminator blend held monotone and continuous with the
missing-input rule on each side), series, ingest, conversion on the production grid with every
composite bundle, a crop past the antimeridian, a `--bundles` build that
reads one series alone — against a stand-in for the bucket, then through
both encoders. `tests/fixtures/debra/` is two crops of a staged CAMEL month
(the Gobi, land; a box of water south of Japan inside the tiles' grid)
and four crops of one cached GFS record, and `tests/test_debra.py` holds
the ancillary readers, the regrid across 180°, the GFS candidate walk and
byte-range fetch against fakes, the composed chain equal to
`shachen.pipeline.run_debra` and `run_zhouye` on the same grid (and the
two confidences one by day), the definition and gate rules, and the producer in the fetch stage (composed once, the record
naming its ancillary); the satellite and GOES suites stage the same
fixtures under the raw root (`stage_ancillary`) so no test reaches the
GFS bucket.
The registry document (`rust/xue/registry.json`, and its trimmed shell
copy `web/src/data/registry.ts`) holds each channel's and gun's label, unit,
parameter block, band block or producer id and codebooks, and each
composite's components in order, identical across the Python encoder,
the Rust encoder and the shell (`docs/registry.md`).

`tests/fixtures/goes/` is eighteen windows cut from real GOES-19 CMIPF
files (`tests/prepare_goes_fixture.py`: the six dust channels and the
three solar bands of two consecutive scans, 220 × 220 cells at 2 km and
the same ground at each band's own resolution, cut with `gdal_translate
-of netCDF -srcwin`, which keeps the `geostationary` mapping, the band's
packing and fill — the Venezuelan coast and Trinidad, 66–62°W, 7–11°N),
and `tests/test_goes.py` runs them the same way under the `goeseast`
source: the hour-directory listing and its request count, the slot rule,
the reissue rule, the single-file download, the warp, the Dust RGB with
the ABI stretches (and that they differ from the SEVIRI set on the
scene), the true colour with the synthetic green, the series, the ingest,
the conversion on the East disk with the ABI band block, and the native
encoder byte for byte. GOES-West is the same reader on its own
bucket and grid; its tests are the registry's.

`tests/fixtures/meteosat/` is one real FCI chunk (chunk 20 of a
full-disk cycle from EUMETSAT's public MTG test data, the spectrally
representative FDHSI cycle of May 2022: simulated 2017 radiances in the
operational format, rows 2645–2784 of the grid, the strip from the
equator to 2.5°S) and a trimmed real search response, and
`tests/test_meteosat.py` runs them under the `meteosat` source with the
chunk standing for every chunk of every slot (the reader's
`needed_chunks` narrowed to it): the store's own response parsed, the
token minted, refused and renewed and a rate limit waited out against a
fake opener, the chunk names, the cycle's slot, the needed chunks and
the elevation angle behind them, the Planck conversion against the
formula, the strip's footprint and its numbers read back through GDAL's
own unscaling, the vis_06 strip on the 1 km grid held to
`π L d² / E_sun` off the file's own constants cell for cell (the algorithm, not
the 2017 test product's absolute values), the solar frames and the true
colour composed from them by day, the IR 3.8 strip in kelvin and the true
colour's night side composed from it and IR 10.5, the producer with
three inputs held to `dust_rgb` with the 10.5 µm plane as the green
minuend, the hourly slots against a store that lists ten-minute cycles,
the series, the ingest, the conversion with the FCI band block and the
hourly axis, and the native encoder byte for byte when the wheel knows
the source. The GDAL-backed cases skip without `hdf5plugin`.

---

Part of the Xue specification, licensed under [CC BY 4.0](../LICENSE-CC-BY).
