Quick start =========== A runnable version of this page, with figures, is the demo in the repository: ``demo/demo_processing.py`` (or ``demo_processing.ipynb``). Open and process ---------------- ``hypso.open`` reads a product file of any level, in the current or an older file layout. Every processing method returns a new, immutable :class:`~hypso.api.Product`; the one it was called on is unchanged. .. code-block:: python import hypso l1a = hypso.open("HYPSO2_HSI.20250304T103805.aeronetvenice.L1A.nc") l1b = l1a.calibrate() # radiometric "abs", V3.1 coefficients l1b = l1b.georeference(latitudes="latitudes_indirectgeoref.dat", longitudes="longitudes_indirectgeoref.dat") l1c = l1b.toa_reflectance() l1a.calibrate().write() # radiance only: an L1B without geolocation (warns) # or: run only the missing steps l1c = l1a.to("L1C", georeference={"latitudes": "latitudes_indirectgeoref.dat", "longitudes": "longitudes_indirectgeoref.dat"}) ``to("L2A")`` continues through atmospheric correction with MACHI, the default method; ``to("L2A", correct_atmosphere={"method": "ocsmart", "config": "ac_tools.yaml"})`` picks another. Calibration and the other steps log what they do through Python's ``logging``; ``logging.basicConfig(level=logging.INFO)`` shows it. Write ----- .. code-block:: python l1c.write() # ./HYPSO2_HSI.20250304T103805.aeronetvenice.L1C.nc l1c.write(out_dir="out", label="test") # ...L1C.test.nc, for experiments l1c.provenance # how it was made, one entry per step Look inside ----------- .. code-block:: python l1c.cube # xarray DataArray (lines, samples, bands) l1c.wavelengths # band centres, nm l1c.geometry # latitude, longitude, angles l1c.flags # {name: boolean mask} from pixel_flags l1c.spectrum(45.3139, 12.5083) # nearest pixel's spectrum l1c.window(45.3139, 12.5083, size=5) # 5x5 window and its statistics l1c.tree # the whole product as an xarray DataTree Masks and derived products -------------------------- .. code-block:: python from hypso.masks import sea_land_cloud_masks # the ground processing's classification, processing-temp/sea-land-cloud.labels slc = sea_land_cloud_masks("sea-land-cloud.labels", l1c.cube.shape[:2]) masked = l1c.with_masks(land=slc["land"], cloud=slc["cloud"]) # or any boolean arrays with_chl = masked.with_variables(chla=chla_array) # written alongside the cube Atmospheric correction ---------------------- .. code-block:: python l2a = l1c.correct_atmosphere() # MACHI, the default l2a = l1c.correct_atmosphere("dps") l2a = l1c.correct_atmosphere("ocsmart", config="ac_tools.yaml", masked=True) l2a.variables # the tool's own 2D products and flags Map grids --------- .. code-block:: python g = l1c.regrid() # capture's UTM zone, nearest neighbour coarse = l1c.regrid(resolution=3000, method="average") other.regrid(g) # onto the same grid