Utility functions

Utility module for stmetrics

stmetrics.utils.bdc2xarray(cube_path, list_bands)

This function reads a path with BDC ARD (Brazil Data Cube Analysis Ready Data) and creates an xarray dataset.

Parameters:
  • cube_path (string) – Path of folder with images.
  • list_bands (list) – List of bands that will be available as xarray.
Return cube_dataset:
 

Xarray dataset.

stmetrics.utils.check_input(timeseries)

This function checks the input and raises one exception if it is too short or has the wrong type.

Parameters:timeseries (numpy.ndarray.) – Your time series.
Raises:ValueError – When timeseries is not valid.
stmetrics.utils.create_polygon(timeseries)

This function converts a time series to the polar space.

If the time series has lenght smaller than 3, it can not be properly converted to the polar space.

Parameters:timeseries (numpy.ndarray) – Your time series.
Return polygon:Shapely polygon of time series without spikes.
stmetrics.utils.fixseries(timeseries, nodata=-9999)

This function ajusts the time series to polar transformation.

As some time series may have very significant noises (such as spikes), when coverted to polar space it may produce an inconsistent geometry. To avoid this issue, this function removes this spikes.

Parameters:
  • timeseries (numpy.ndarray) – Your time series.
  • nodata (int) – nodata of the time series. Default is -9999.
Return fixed_timeseries:
 

Numpy array of time series without spikes.

stmetrics.utils.get_list_of_points(timeseries)

This function creates a list of angles based on the time series that is used to convert a time series to a geometry.

Parameters:timeseries (numpy.ndarray) – Your time series.
Return list_of_observations:
 Numpy array of lists of observations after polar transformation.
Return list_of_angles:
 Numpy array of lists of angles after polar transformation.
stmetrics.utils.list_metrics()

This function lists the available metrics in stmetrics.