hypso.io#
Product file I/O: one reader and one writer for every level (io/product.py), file names (io/naming.py), provenance (io/provenance.py), and the CF attribute builders and per-level schema they use.
Submodules#
Classes#
What differs between product levels: product variable name, units, |
Functions#
|
Convert a product file of any supported layout to the current format. |
|
The |
|
Per-band metadata of a product file, without reading pixel data. |
|
Parse a current-style or legacy product file name. |
|
Compose a product name. |
|
Read any supported HYPSO product file into the in-memory model. |
|
Write a product tree in the current file format. |
Package Contents#
- class hypso.io.LevelSchema[source]#
What differs between product levels: product variable name, units, CF standard name, title and whether the level has geometry.
- hypso.io.convert_product(src, out_dir=None)[source]#
Convert a product file of any supported layout to the current format.
- Parameters:
src (str or pathlib.Path)
out_dir (str or pathlib.Path, optional) – Default: next to
src.
- Returns:
The new file, named by
hypso.io.naming. Aconvertstep is recorded; the source file is left untouched.- Return type:
- hypso.io.get_schema(level)[source]#
The
LevelSchemaof a level (“L1A” … “L1C”, “L2A”/”L2”, “L2B”).- Parameters:
level (str)
- Return type:
- hypso.io.list_band_variables(path)[source]#
Per-band metadata of a product file, without reading pixel data.
- hypso.io.parse_product_name(path)[source]#
Parse a current-style or legacy product file name.
- Parameters:
path (str or pathlib.Path) – A file name or path; only the name is used.
- Return type:
- Raises:
ValueError – If the name is not a HYPSO product name.
- hypso.io.product_name(sat_id, time, target, level, ac=None, label=None, grid=None, instrument='HSI', quantity=None)[source]#
Compose a product name.
- Parameters:
sat_id (str) – e.g.
"HYPSO-2".time (datetime.datetime) – Capture start; converted to UTC if timezone-aware.
target (str) – Capture target, e.g.
"aeronetvenice".level (str) –
"L1A"…"L1C","L2A".ac (str, optional) – Atmospheric correction method (L2A) or source (L2B: algorithm or tool); required there, not allowed otherwise.
label (str, optional) – Free-text label for experiments (letters, digits,
_,-).grid (str, optional) – Grid name of a regridded product (
hypso.grid.grid_name()).instrument (str, default "HSI") – Instrument token (
INSTRUMENTS).quantity (str, optional) – L2A quantity token (
QUANTITIES, e.g."RRS", or the product variable"Rrs") or L2B group (L2B_GROUPS, e.g."BGC"); required for L2A and L2B.
- Returns:
product_name(...).filename()gives the file name.- Return type:
- hypso.io.read_product(path, wavelength_range=None, wavelengths=None, indices=None)[source]#
Read any supported HYPSO product file into the in-memory model.
- Parameters:
path (str or pathlib.Path)
wavelength_range (optional) – Read only some bands, selected as in
hypso.processing.bands.select_bands()(at most one of them). Only the selected band variables are read from the file; a file holding the cube as one variable is read whole and then subset.wavelengths (optional) – Read only some bands, selected as in
hypso.processing.bands.select_bands()(at most one of them). Only the selected band variables are read from the file; a file holding the cube as one variable is read whole and then subset.indices (optional) – Read only some bands, selected as in
hypso.processing.bands.select_bands()(at most one of them). Only the selected band variables are read from the file; a file holding the cube as one variable is read whole and then subset.
- Returns:
See the module description.
tree.encoding["source"]holds the path (not written back).- Return type:
- Raises:
ValueError – If no product cube or processing level is found, or the file uses the levels from before format 3.0.
- hypso.io.write_product(tree, path, datacube=False, significant_bits=SIGNIFICANT_BITS)[source]#
Write a product tree in the current file format.
- Parameters:
tree (xarray.DataTree) – In-memory model (see the module description).
path (str or pathlib.Path)
datacube (bool, default False) – Write the cube as one 3D variable instead of one variable per band.
significant_bits (int or None, default 14) – Keep this many significant mantissa bits of the float band variables (L1B-L2A; netCDF BitRound, max relative error
2**-(bits + 1); values stay float32, NaN is kept, readers need nothing special). None writes them lossless. L1A counts, geometry, derived variables and metadata are always lossless. Recorded in theband_quantizationglobal attribute.
- Return type:
None