Multidimensional Processing API¶
Convert multidimensional cubes (NetCDF, Zarr) to H3-indexed GeoParquet through GDAL multidimensional reads. The cng-datasets mdim-workflow jobs call these same functions.
N-D cube (time, lat, lon) → H3 hex processing (issue #181).
- class cng_datasets.mdim.CubeSource(paths: Sequence[str], variables: Sequence[str])[source]¶
Bases:
objectA (time, lat, lon) variable — or several sharing a grid — over 1+ files.
- nearest_pixel(lat: ndarray, lon: ndarray)[source]¶
(iy, ix) storage indices of the pixel containing each point, -1 if outside the grid. Points are in [-180, 180] longitude.
- read(variable: str, t0: int, t1: int, y0: int, y1: int, x0: int, x1: int) ndarray[source]¶
Values as float64 (time, lat, lon) in storage lat/lon order, with nodata and values outside the CF valid range as NaN, and CF scale/offset applied. [t0, t1) must lie in one file.
- tiles(window) Iterator[Tuple[int, int, int, int]][source]¶
Split a window into pieces that each lie within one storage block, so every read decodes each chunk it touches exactly once.
- class cng_datasets.mdim.MdimProcessor(inputs: Sequence[str], variables: Sequence[str], output_parquet_path: str, h3_resolution: int, parent_resolutions: List[int] | None = None, chunk_resolution: int = 0, h0_subset: List[int] | None = None, h0_grid_path: str = 's3://public-grids/hex/h0-valid.parquet', hex_resampling: str = 'mean', time_agg: str = 'none', time_start: str | None = None, time_end: str | None = None, placement: str = 'auto', read_budget_bytes: float = 536870912, allow_empty_window: bool = False)[source]¶
Bases:
objectHex one spatial chunk of a (time, lat, lon) cube into H3 cells.
- __init__(inputs: Sequence[str], variables: Sequence[str], output_parquet_path: str, h3_resolution: int, parent_resolutions: List[int] | None = None, chunk_resolution: int = 0, h0_subset: List[int] | None = None, h0_grid_path: str = 's3://public-grids/hex/h0-valid.parquet', hex_resampling: str = 'mean', time_agg: str = 'none', time_start: str | None = None, time_end: str | None = None, placement: str = 'auto', read_budget_bytes: float = 536870912, allow_empty_window: bool = False)[source]¶
- process_chunk(chunk_index: int) str | None[source]¶
Hex chunk chunk_index; returns the parquet written, or None.
- process_region(unit_index: int) str | None[source]¶
Time fan-out (#267): every chunk of the region over this processor’s time range, in one read of the grid.
For sources whose chunks span the whole grid (NEX-GDDP: one global day per chunk), a spatial fan-out makes every pod fetch every chunk. Here a pod owns a slice of time instead, reads each chunk once, and writes one part per h0 partition — part-t{unit}-*.parquet under the staging prefix, which merge-chunks concatenates into data_0.parquet.