### Install sentle Python package Source: https://github.com/cmosig/sentle/blob/main/README.md Instructions to install the sentle package using pip or by cloning the GitHub repository for local development. The package is tested with Python 3.12.*. ```Shell pip install sentle ``` ```Shell git clone git@github.com:cmosig/sentle.git cd sentle pip install -e . ``` -------------------------------- ### API Reference for sentle.process function Source: https://github.com/cmosig/sentle/blob/main/README.md Detailed API documentation for the `sentle.process` function, which is the main entry point for retrieving and processing Sentinel data. It outlines all required parameters, their types, and descriptions. ```APIDOC sentle.process: Description: The package contains only one main function for retrieving and processing Sentinel data. Parameters: target_crs: Type: rasterio.crs.CRS or str Description: Specifies the target CRS that all data will be reprojected to. You can provide either a rasterio.crs.CRS object or a string (e.g., "EPSG:32633"). target_resolution: Type: float Description: Determines the resolution that all data is reprojected to in the target_crs. bound_left: Type: float Description: Left bound of area that is supposed to be covered. Unit is in target_crs. bound_bottom: Type: float Description: Bottom bound of area that is supposed to be covered. Unit is in target_crs. bound_right: Type: float Description: Right bound of area that is supposed to be covered. Unit is in target_crs. bound_top: Type: float Description: Top bound of area that is supposed to be covered. Unit is in target_crs. datetime: Type: DatetimeLike Description: Specifies time range of data to be downloaded. This is forwarded to the respective STAC interface. zarr_store: Type: str or zarr.storage.Store Description: Path of where to create the zarr storage. ``` -------------------------------- ### Notes and Constraints for Parameter Usage Source: https://github.com/cmosig/sentle/blob/main/README.md Important considerations and dependencies for various parameters, including conditions for applying snow/cloud masks, handling of empty Sentinel-1 asset lists, and requirements for zarr store chunk sizes. ```APIDOC - If S2_apply_snow_mask is set to True, S2_mask_snow must also be True. - If S2_apply_cloud_mask is set to True, S2_cloud_classification must also be True. - If time_composite_freq is set and neither S2_apply_snow_mask nor S2_apply_cloud_mask is set, a warning will be issued as temporal aggregation may yield useless results for Sentinel-2 data. - When S1_assets is supplied as an empty list, it will be converted to None, meaning no Sentinel-1 data will be downloaded. - The zarr_store_chunk_size dictionary must contain the keys 'time', 'y', and 'x'. - When using cloud or snow masking with temporal composites, the masks will be applied before aggregation. ``` -------------------------------- ### Visualize Sentinel data cube using lexcube Source: https://github.com/cmosig/sentle/blob/main/README.md Illustrates how to visualize a specific band (e.g., B02) of the loaded Sentinel data cube using the lexcube package. This provides an interactive 3D widget for exploring the data, highlighting features like cloud gaps and seasonal coverage. ```Python import lexcube lexcube.Cube3DWidget(da.load().sel(band="B02"), vmin=0, vmax=4000) ``` -------------------------------- ### Process Sentinel-1 and Sentinel-2 data into a Zarr cube Source: https://github.com/cmosig/sentle/blob/main/README.md Demonstrates how to use the `sentle.process` function to download and process Sentinel-1 and Sentinel-2 data for a specified geographic area and time range. It applies cloud/snow masks, selects assets, and performs temporal compositing, saving the results to a Zarr store. The process is parallelized across multiple workers to handle larger-than-memory cubes. ```Python from sentle import sentle sentle.process( zarr_store="mycube.zarr", target_crs="EPSG:32633", bound_left=176000, bound_bottom=5660000, bound_right=216000, bound_top=5700000, datetime="2022-06-17/2023-06-17", target_resolution=10, S2_mask_snow=True, S2_cloud_classification=True, S2_cloud_classification_device="cuda", S1_assets=["vh_asc", "vh_desc", "vv_asc", "vv_desc"], S2_apply_snow_mask=True, S2_apply_cloud_mask=True, time_composite_freq="7d", num_workers=10, ) ``` -------------------------------- ### Scaling Program with num_workers Parameter Source: https://github.com/cmosig/sentle/blob/main/README.md Guidance on how to scale the program by adjusting the `num_workers` parameter when calling `sentle.process`. It also specifies memory requirements per worker based on the default spatial chunk size. ```APIDOC Increase the number of workers using the `num_workers` parameter when calling `sentle.process`. With default spatial chunk size of 4000, specified by `processing_spatial_chunk_size`, you should plan with 2GiB per worker. ``` -------------------------------- ### Optional Parameters for Data Processing Source: https://github.com/cmosig/sentle/blob/main/README.md This section details the optional parameters available for configuring data processing operations, including settings for spatial chunking, Sentinel-1 and Sentinel-2 data handling, cloud and snow masking, and storage options. ```APIDOC Parameter: processing_spatial_chunk_size Type: int Default: 4000 Description: Size of spatial chunks across which parallelization is performed in pixels. Parameter: S1_assets Type: list[str] Default: ["vh_asc", "vh_desc", "vv_asc", "vv_desc"] Description: Specify which bands to download for Sentinel-1. Only "vh_asc", "vh_desc", "vv_asc", "vv_desc" are supported. Empty list will be converted to None (no Sentinel-1 data). Parameter: S2_mask_snow Type: bool Default: False Description: Whether to create a snow mask. Based on https://doi.org/10.1016/j.rse.2011.10.028. Parameter: S2_cloud_classification Type: bool Default: False Description: Whether to create cloud classification layer, where 0=clear sky, 2=thick cloud, 3=thin cloud, 4=shadow. Parameter: S2_cloud_classification_device Type: str Default: "cpu" Description: On which device to run cloud classification. Either "cpu" or "cuda". Parameter: S2_return_cloud_probabilities Type: bool Default: False Description: Whether to return raw cloud probabilities which were used to determine the cloud classes. Parameter: num_workers Type: int Default: 1 Description: Number of cores to scale computation across. Plan 2GiB of RAM per worker. -1 uses all available cores. Parameter: time_composite_freq Type: str Default: None Description: Rounding interval across which data is averaged. Parameter: S2_apply_snow_mask Type: bool Default: False Description: Whether to replace snow with NaN. Parameter: S2_apply_cloud_mask Type: bool Default: False Description: Whether to replace anything that is not clear sky with NaN. Parameter: overwrite Type: bool Default: False Description: Whether to overwrite existing zarr storage. Parameter: zarr_store_chunk_size Type: dict Default: {"time": 50, "x": 100, "y": 100} Description: Chunk sizes for zarr storage. Must contain the keys 'time', 'y', and 'x'. Controls the size of data chunks for efficient storage and retrieval. ``` -------------------------------- ### Load processed Sentinel data from Zarr with xarray Source: https://github.com/cmosig/sentle/blob/main/README.md Shows how to load the processed Sentinel data cube from a Zarr store into an xarray DataArray. This allows for easy access and manipulation of the multi-dimensional data. ```Python import xarray as xr da = xr.open_zarr("mycube.zarr").sentle da ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.