sisppeo.utils package¶
Submodules¶
sisppeo.utils.algos module¶
Contains various useful functions used by algorithms.
- sisppeo.utils.algos.load_calib(calibration, default_calibration_file, default_calibration_name)[source]¶
Loads parameters for a given calibration name/file.
- Parameters
calibration – calibration name or path. 1. If ‘calibration’ is a string, it refers to a calibration included in SISPPEO (this calibration name is an entry of the ‘default_calibration_file’). 2. If ‘calibration’ is a path, it refers to a calibration given by the user, embedded in a standalone file (see the docs for the detailed structure of this file).
default_calibration_file – path of the default calibration file (for a given algorithm).
default_calibration_name – name of the default calibration (for a given algorithm).
- Returns
A dict of parameters (model coefficients) and the name of the chosen calibration.
sisppeo.utils.builders module¶
Contains a useful function used in main.py.
sisppeo.utils.cli module¶
Contains various useful functions and classes used in the CLI.
- class sisppeo.utils.cli.Mutex(*args, **kwargs)[source]¶
Bases:
click.core.Option
Mutually exclusive options (with at least one required).
- class sisppeo.utils.cli.Mutin(*args, **kwargs)[source]¶
Bases:
click.core.Option
Mutually inclusive options.
- class sisppeo.utils.cli.PathPath(exists=False, file_okay=True, dir_okay=True, writable=False, readable=True, resolve_path=False, allow_dash=False, path_type=None)[source]¶
Bases:
click.types.Path
A Click path argument that returns a pathlib Path, not a string
- convert(value, param, ctx)[source]¶
Convert the value to the correct type. This is not called if the value is
None
(the missing value).This must accept string values from the command line, as well as values that are already the correct type. It may also convert other compatible types.
The
param
andctx
arguments may beNone
in certain situations, such as when converting prompt input.If the value cannot be converted, call
fail()
with a descriptive message.- Parameters
value – The value to convert.
param – The parameter that is using this type to convert its value. May be
None
.ctx – The current context that arrived at this value. May be
None
.
- name¶
the descriptive name of this type
sisppeo.utils.config module¶
Contains paths and configs used in other parts of the code.
sisppeo.utils.exceptions module¶
Contains custom exceptions used in other parts of the code.
- exception sisppeo.utils.exceptions.GeometryError[source]¶
Bases:
Exception
Exception raised for errors related to geometry objects.
sisppeo.utils.lazy_loader module¶
A LazyLoader class.
Slightly adapted from the one of TensorFlow, see: https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/util/lazy_loader.py
sisppeo.utils.main module¶
Contains various useful functions used in main.py.
sisppeo.utils.naming module¶
Contains various useful functions used for naming products.
- sisppeo.utils.naming.extract_info_from_input_product(input_product, product_type, code_site=None, geom=None)[source]¶
Extracts some information from the given input product.
- sisppeo.utils.naming.generate_l3_filename(l3prod, code_image, source, roi)[source]¶
Returns a filename for a L3 product based on the provided arguments.
- sisppeo.utils.naming.generate_ts_filename(ts, sat, source, roi)[source]¶
Returns a filename for time series based on the provided arguments.
sisppeo.utils.products module¶
Contains useful stuff for products.
- class sisppeo.utils.products.CoordinatesMixin[source]¶
Bases:
object
A Mixin which adds extra properties and methods related to coordinates.
- property bounds¶
(xmin, ymin, xmax, ymax).
- Type
Returns the boundaries of this product
- extract_point(data_var, coordinates, buffer=None, epsg=4326, mode='xy')[source]¶
Returns value(s) at the given coordinates.
- Parameters
data_var – The name of the variable/DataArray of interest (e.g., a band, aCDOM, etc).
coordinates – A tuple of geographic or projected coordinates; see “mode”.
buffer – Optional; The radius (in pixels) of the circle (centered on coordinates) to extract. Defaults to None.
epsg – Optional; The EPSG code. Defaults to 4326.
mode – Optional; Either ‘xy’ or ‘latlon’. Defaults to ‘xy’.
- Returns
An xr.DataArray containing the wanted information.
- extract_points(data_var, lst_coordinates, buffer=None, epsg=4326, mode='xy')[source]¶
Returns value(s) at each tuple of coordinates of the given list.
- Parameters
data_var – The name of the variable/DataArray of interest (e.g., a band, aCDOM, etc).
lst_coordinates – A list of tuples of geographic or projected coordinates; see “mode”.
buffer – Optional; The radius (in pixels) of the circle (centered on coordinates) to extract. Defaults to None.
epsg – Optional; The EPSG code. Defaults to 4326.
mode – Optional; Either ‘xy’ or ‘latlon’. Defaults to ‘xy’.
- Returns
A list of xr.DataArray (one per coordinates tuple) containing the wanted information.
- property res¶
Returns the spatial resolution of this product.
- property x¶
Returns x-coords.
- property y¶
Returns y-coords.
- sisppeo.utils.products.get_grid(n)[source]¶
Gets the number of rows and columns needed according the number of subplots.
- sisppeo.utils.products.normalize_arr(arr, min_, max_, new_max=255)[source]¶
Normalize an array between 0 and new_max.
- Parameters
arr – The input array.
min – The value to consider as being the min of the array.
max – The value to consider as being the min of the array.
new_max – The maximum value of the output array.
sisppeo.utils.readers module¶
Contains various useful functions used by readers.
- sisppeo.utils.readers.decode_data(arr, scale_factor, fill_value, offset=0)[source]¶
Reads and decodes encoded data.
- Parameters
arr – The input encoded array of values.
scale_factor – coefficient.
fill_value (
[type]
) – coefficient.offset – Optional; coefficient.
- Returns
The decoded array.
- sisppeo.utils.readers.get_ij_bbox(subdataset, geom)[source]¶
Clips the subdataset with the geometry.
- Parameters
subdataset – An open rasterio.io DatasetReader.
geom – A shapley geometry object.
- Returns
The corresponding bbox.
- sisppeo.utils.readers.resample_band_array(arr, in_res, out_res, tqdm_=True)[source]¶
Resamples an array.
- Parameters
arr – An array of (radiometric) values.
in_res – The input resolution.
out_res – The output resolution.
tqdm – Optional; True if in a tqdm loop.
- Returns
The resampled array.
- sisppeo.utils.readers.resize_and_resample_band_array(arr, ij_bbox, in_res, out_res, _tqdm=True)[source]¶
Resamples and resizes an array.
- Parameters
arr – An array of (radiometric) values.
ij_bbox – The bbox of the ROI.
in_res – The input resolution.
out_res – The output resolution.
_tqdm – Optional; True if in a tqdm loop.
- Returns
The resampled ROI.
sisppeo.utils.registration module¶
Contains functions related to algorithm&mask registration.
- sisppeo.utils.registration.check_algoconfig()[source]¶
Print a warning message if an algorithm lacks its configuration file.