eoio.readers.gistda_theos.data_io module#
eoio.readers.gistda_theos.data_io - data reading functionality for THEOS meas vars.
- eoio.readers.gistda_theos.data_io.georeference_from_gcps(img: DataArray) tuple[DataArray, Any, str][source]#
Attach a real affine transform + CRS to img from its own embedded ground control points (GISTDA THEOS ships no GDAL geotransform – only GCPs – so
rxr.open_rasteriootherwise leavesimg’s x/y as bare pixel indices with no CRS at all: verified directly against a real product’s IMAGERY.TIF).Fits one affine transform across every GCP (
rasterio.transform.from_gcps(), a least-squares fit from >= 3 points) – appropriate for a geometrically-corrected Level-1 scene like this, where a single overall rotation/scale (THEOS’s own SCENE_ORIENTATION in METADATA.DIM) explains the corners, not a per-pixel nonlinear distortion; THEOS provides exactly the 4 scene corners, so the fit is over-determined by 2 equations and therefore self-consistency-checked.- Parameters:
img – DataArray from
rxr.open_rasterio– GCPs read via rioxarray’s own.rio.get_gcps()/.rio.crs(which read a GeoTIFF’s embedded GDAL GCP tags directly), not reader-specific parsing.- Returns:
(img, transform, gcp_crs)– img with CRS/transform written in place (sorioxarray.raster_array.RasterArray.clip(), and any other rioxarray spatial op, can use them), the fitted affine transform and its CRS (forlonlat_grid_from_gcps()to reuse without refitting).- Raises:
GISTDATHEOSDataIOError – img has no usable ground control points.
- eoio.readers.gistda_theos.data_io.get_var_geometry() str[source]#
Get the variable geometry
- Returns:
string of geometry
- eoio.readers.gistda_theos.data_io.get_var_resolution() str[source]#
Get the variable resolution
- Returns:
string of resolution
- eoio.readers.gistda_theos.data_io.lonlat_grid_from_gcps(transform: Any, *, width: int, height: int) tuple[ndarray, ndarray][source]#
Full-resolution
(height, width)longitude/latitude grids from transform (seegeoreference_from_gcps()) – a real 2-D(row, col) -> (lon, lat)mapping.Deliberately not row/col treated as independent 1-D axes (wrong whenever the transform has any rotation term, which GISTDA THEOS scenes generally do – see SCENE_ORIENTATION in METADATA.DIM: verified on a real product with ~10 deg of rotation that independent axes mislabel most pixels by ~0.2 deg / ~20 km).
- Parameters:
transform – affine transform from
georeference_from_gcps().width – image width in pixels.
height – image height in pixels.
- Returns:
(lon, lat), each shape(height, width).
- eoio.readers.gistda_theos.data_io.read_bands_into_dataset(*, ds: Dataset, layout: GISTDATHEOSLayout, meas: list[str], subset: ResolvedROISubset | None, mtd: GISTDATHEOSMetadataExtractor, chunks: dict[str, int] | None = None, use_chunks: bool = False) Dataset[source]#
Read THEOS image bands into an xarray dataset.