satellitetools.biophys.biophys
Python implementation of ESA SNAP s2toolbox biophysical processor and computation of vegetation indices. See ATBD at https://step.esa.int/docs/extra/ATBD_S2ToolBox_L2B_V1.1.pdf And java source code at https://github.com/senbox-org/s2tbx/tree/master/s2tbx-biophysical/src/main/java/org/esa/s2tbx/biophysical SNAP auxdata from: https://github.com/senbox-org/s2tbx/tree/master/s2tbx-biophysical/src/main/resources/auxdata/2_1
Caveats Currently changes out of bounds inputs and outputs to nan (or min or max value if output wihtin tolerance). Maybe output flagging information as well ( i.e. diffferent flags input and output out of bounds).
Convex hull input checking currently disabled. It’s computationally slow and not sure of its benefits. Better to filter out bad data based on L2A quality info/classification and hope averaging removes some bad pixels.
- @author: Olli Nevalainen,
Finnish Meteorological Institute)
Attributes
Classes
str(object='') -> str |
|
Enum where members are also (and must be) strings |
|
Enum where members are also (and must be) strings |
|
SNAP Biophysical Processor. |
Functions
|
Create data cube for SNAP biophysical processor. |
|
Compute specified variable using the SNAP algorithm. |
|
Compute NDVI |
|
Compute CI_Red_Edge vegetation index. |
|
Compute GCC vegetation index. |
|
Compute vegetation index. |
Module Contents
- class satellitetools.biophys.biophys.StrEnum[source]
Bases:
str,enum.Enumstr(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.
Initialize self. See help(type(self)) for accurate signature.
- class satellitetools.biophys.biophys.VegetationIndex[source]
Bases:
enum.StrEnumEnum where members are also (and must be) strings
Initialize self. See help(type(self)) for accurate signature.
- class satellitetools.biophys.biophys.BiophysVariable[source]
Bases:
enum.StrEnumEnum where members are also (and must be) strings
Initialize self. See help(type(self)) for accurate signature.
- classmethod get_by_name(name: str) BiophysVariable[source]
Get BiophysVariable by name.
- Parameters:
name (str) – Name of the biophysical variable.
- Returns:
BiophysVariable or raise Valuer error if not found.
- Return type:
Union[None, “BiophysVariable”]
- class satellitetools.biophys.biophys.SNAPBiophysProcessor(data_cube: xarray.DataArray, variable: BiophysVariable)[source]
SNAP Biophysical Processor.
- data_cube[source]
Data cube with Sentinel-2 10-20m bands and observation geometry layers biophysical bands.
- Type:
xr.DataArray
Initialize SNAPBiophysProcessor.
- Parameters:
data_cube (xr.DataArray) – Data cube with Sentinel-2 10-20m bands and observation geometry layers biophysical bands.
variable (BiophysVariable) – Biophysical variable to compute.
- _read_snap_nn_params(variable: BiophysVariable) dict[source]
- satellitetools.biophys.biophys.create_data_cube(ds: xarray.Dataset) xarray.DataArray[source]
Create data cube for SNAP biophysical processor.
- Parameters:
ds (xr.Dataset) – xarray dataset.
- Returns:
Data cube with Sentinel-2 10-20m bands and observation geometry layers biophysical bands.
- Return type:
xr.DataArray
- satellitetools.biophys.biophys.run_snap_biophys(ds: xarray.Dataset, variable: BiophysVariable) xarray.Dataset[source]
Compute specified variable using the SNAP algorithm.
See ATBD at https://step.esa.int/docs/extra/ATBD_S2ToolBox_L2B_V1.1.pdf
- Parameters:
ds (xr dataset) – xarray dataset.
variable (Union[str, BiophysVariable]) – Options ‘FAPAR’, ‘FCOVER’, ‘LAI’, ‘LAI_Cab’ or ‘LAI_Cw’
- Returns:
Adds the specified variable array to the input dataset.
- Return type:
xarray dataset
- satellitetools.biophys.biophys.compute_ndvi(ds: xarray.Dataset) xarray.Dataset[source]
Compute NDVI
- Parameters:
ds (xarray dataset)
- Returns:
Adds ‘ndvi’ xr array to xr dataset.
- Return type:
xarray dataset
- satellitetools.biophys.biophys.compute_ci_red_edge(ds: xarray.Dataset) xarray.Dataset[source]
Compute CI_Red_Edge vegetation index.
- Parameters:
ds (xarray dataset)
- Returns:
Adds ‘ci_red_edge’ xr array to xr dataset.
- Return type:
xarray dataset
- satellitetools.biophys.biophys.compute_gcc(ds: xarray.Dataset) xarray.Dataset[source]
Compute GCC vegetation index.
- Parameters:
ds (xarray dataset)
- Returns:
Adds ‘gcc’ xr array to xr dataset.
- Return type:
xarray dataset
- satellitetools.biophys.biophys.compute_vegetation_index(ds: xarray.Dataset, vi: VegetationIndex) xarray.Dataset[source]
Compute vegetation index.
- Parameters:
ds (xarray dataset)
vi (VegetationIndex) – Vegetation index to compute.
- Returns:
Adds vegetation index array to xr dataset.
- Return type:
xarray dataset