Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Add a product reader

A new sensor or provider gets its own subpackage, geoproducts.<sensor>, with the same small surface as the others. This page is the one home of that layout and of the shared toolkit every reader builds on. What a reader must return is the ProductReader contract.

The subpackage layout

Copy the shape of goes/ or himawari/ (the most complete) or toy_sensor/ (the in-memory reference):

geoproducts/<sensor>/
├── __init__.py          # public surface; its docstring lists every name
├── reader.py            # Reader(ProductReader) — or l1b.py / l2.py per product level
├── aws.py               # list / download from public buckets (via _src/s3.py) — or an API client
├── constants.py         # BANDS table, flag codes, platform constants
├── data/                # packaged calibration tables (loaded via _src/constants.py)
├── recipes.py           # RGB recipes as data (_src/presets.Recipe)
├── presets.py           # geotoolz operators bound to band names ([operators])
└── _src/                # format parsing private to this sensor
SensorReader modulesFinding filesPrivate _src/
goesl1b.py (Reader, QualityReader), l2.py (L2Reader)aws.pybase.py (ABI grid mapping), metadata.py
himawarireader.py (Reader), l2.py (L2Reader)aws.pyhsd.py (the HSD decoder)
carbonmapperimage.py, rasters.py, sources_raster.pyapi_queries.py, download.py—
toy_sensorreader.py (Reader), swath.py (SwathReader, a GeoSwath)——

Write the reader

Subclass geoproducts.ProductReader and implement:

The base class turns these into the geoarray.RasterSource surface (grid, shape, dtype, fill_value, attrs, read_window, load) plus read_from_bounds / read_from_center_coords, every read a geoarray.GeoArray. georeader may serve as an internal engine (window maths, reprojection), converting at the boundary with geoarray.interop.georeader; no GeoTensor / GeoData appears in a reader’s public API, and one passed in is refused with a TypeError (geoproducts._src.carrier.reject_georeader).

import numpy as np
from affine import Affine
from geoarray import GeoArray, PixelWindow

from geoproducts import ProductReader


class Reader(ProductReader):
    """A ``(2, H, W)`` float32 product held in memory."""

    def __init__(self, data: np.ndarray) -> None:
        self._data = data                                # (2, H, W) float32

    _crs = "EPSG:32631"
    _transform = Affine(30.0, 0.0, 500_000.0, 0.0, -30.0, 4_000_000.0)
    _dtype = np.dtype("float32")
    _bands = ("vis", "nir")
    _fill_value = np.nan
    _track = "A"

    @property
    def _shape(self) -> tuple[int, ...]:
        return self._data.shape

    def _read_window(self, window: PixelWindow) -> np.ndarray:
        return self._read_boundless(window, lambda rows, cols: self._data[:, rows, cols])


reader = Reader(np.ones((2, 64, 64), np.float32))
tile: GeoArray = reader.read_window(
    PixelWindow(col_off=-8, row_off=0, width=16, height=16)
)                                                        # (2, 16, 16) float32 · NaN left of the grid

Calibrate with the file’s own coefficients and document the units and equation in the docstring. Register the subpackage in geoproducts/__init__.py.

Data, extras and presets

The shared toolkit (geoproducts._src)

Check here before writing a helper: these are the pieces every reader so far has needed, written once and tested on their own. They are private to the package; if a new sensor needs something the next one will too, add it here first.

ModuleUse it forUsed by
_src.baseProductReader, Track, _read_boundless, _band_attrs, resolve_fill_valueevery reader
_src.carrierreject_georeader / require_source — refuse a georeader GeoTensor / GeoData at a public boundary, naming from_georeader / source_from_georeaderstack, toy_sensor, carbonmapper
_src.hdfPackedGridReader — bands that are CF-packed 2-D variables of one HDF5 / NetCDF-4 file (integer masks, CF flag tables, chunked window reads), from a local path or any URI with ranged reads. The decoding (PackedVariable, attr, scalar, time_attr, unpacked, grid_variables, open_hdf5) is geotoolz-cloud’s geocloud.hdf; call it as hdf.attr(...) so a reader still imports on a base installgoes, himawari.l2
_src.geostationaryFixedGrid — the affine +proj=geos grid from a CF grid mapping and scan angles; geos_crs, scan_angle_transform, on_earthgoes, himawari (MTG, SEVIRI next)
_src.stackgeoproducts.stack — any readers onto one reference gridpublic
_src.presetsRecipe, rgb_recipe, geotoolz_module (the lazy geotoolz import), parallax_correctgoes, himawari recipes and presets
_src.netretrying (one retry loop for raising and response-returning clients), retry_after_seconds (Retry-After or backoff, clamped), stream_to_file (atomic .part writes), bearer_headers_for (a token only ever sent to its own host)carbonmapper, _src.s3
_src.s3anonymous public buckets, unsigned through geocloud.files: list_objects, download_object, object_url (retries come from geotoolz-cloud)goes.aws, himawari.aws
_src.filesatomic_path / atomic_write_text / write_private_json — complete-or-absent writes; private=True is owner-only (0600) from the first bytehimawari.aws, _src.credentials, _src.net
_src.credentialsauth_path(provider) (~/.geoproducts/auth_<provider>.json), read_json_config, write_private_json, jwt_expirycarbonmapper
_src.queryvalidate_lonlat_bbox, as_utc, rfc3339_utc, time_interval (STAC / OGC ranges)carbonmapper, goes.aws, himawari.aws
_src.constantsload_csv / load_json for packaged tables; band_values for one number per band (centre wavelength, FWHM) from a BANDS tabletoy_sensor, goes, himawari
_src.extrasrequire, missing_extra, install_hint for optional dependenciesevery extra-gated feature

Object-store reads go through geotoolz-cloud (geocloud.hdf.open_hdf5, geocloud.files, geocloud.cog), never a client of your own. A provider client keeps only what is specific to it: its URLs and payloads, which statuses it retries, and its credential fields and renewal flow.

Tests and docs