Basic metrics

Module for computing basic metrics, including sum of values, average value, amplitude (max - min), and so on. We provide a function to compute all metrics in a single call (ts_basics).

stmetrics.basics.abs_sum_ts(timeseries, nodata=-9999)

Sum of absolute values of the time series. All values are converted to absolute (positive) values, and are summed.

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

Sum of absolute values of the time series.

stmetrics.basics.amd_ts(timeseries, nodata=-9999)

Computes the mean of the absolute derivative of time series.

Regarding to vegetation it provides information on the growth rate of vegetation, allowing discrimination of natural cycles from crop cycles.

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

The mean of the absolute derivative of time series.

stmetrics.basics.amplitude_ts(timeseries, nodata=-9999)

The difference between the maximum and minimum values of the time series.

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

Amplitude of values of time series.

stmetrics.basics.fqr_ts(timeseries, nodata=-9999)

Computes the first quartile of a time series.

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

The first quartile of the time series.

stmetrics.basics.fslope_ts(timeseries, nodata=-9999)

Maximum value of the first slope of the time series. It indicates when some abrupt change happened in the time series.

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

The maximum value of the first slope of time series.

stmetrics.basics.iqr_ts(timeseries, nodata=-9999)

Computes the interquaritle range of the time series.

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

The interquaritle range of the time series.

stmetrics.basics.max_ts(timeseries, nodata=-9999)

Maximum value of the time series.

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

Maximum value of time series.

stmetrics.basics.mean_ts(timeseries, nodata=-9999)

Average value (mean) of the time series, considering only valid values. When nodata is found, it is not included in N value (for all functions).

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

Mean value of time series.

stmetrics.basics.min_ts(timeseries, nodata=-9999)

Minimum value of the time series.

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

Minimum value of time series.

stmetrics.basics.mse_ts(timeseries, nodata=-9999)

Computes mean spectral energy of a time series.

Mean spectral energy density computes the energy of the time series that is distributed with frequency. High frequency time series usually have lower spectral energy.

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

The mean spectral energy of the time series.

stmetrics.basics.skew_ts(timeseries, nodata=-9999)

Measures the asymmetry of the time series.

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

The asymmetry of time series.

stmetrics.basics.sqr_ts(timeseries, nodata=-9999)

Computes the second quartile of the time series.

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

The second quartile of the time series.

stmetrics.basics.std_ts(timeseries, nodata=-9999)

Standard deviation of the time series.

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

Standard deviation of time series.

stmetrics.basics.sum_ts(timeseries, nodata=-9999)

Sum of values of the time series.

When dealing with vegetation analysis, this value can be a proxy of the annual production of vegetation.

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

Sum of values of time series.

stmetrics.basics.tqr_ts(timeseries, nodata=-9999)

Computes the third quartile of a time series.

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

The third quartile of the time series.

stmetrics.basics.ts_basics(timeseries, funcs=['all'], nodata=-9999)
This function compute all basic metrics in a single call, returning a dictionary:
  • “Max” - Maximum value of the time series.
  • “Min” - Minimum value of the time series.
  • “Mean” - Average value of the time series.
  • “Std” - Standard deviation of the time series.
  • “Sum” - Sum of values over a cycle. Usually is an indicator of the annual production of vegetation.
  • “Amplitude” - The difference between the time series’s maximum and minimum values.
  • “MSE” - Mean Spectral Energy.
  • “First_slope” - Maximum value of the first slope of the cycle.
  • “Skew” - Measures the asymmetry of the time series.
  • “AMD” - Absolute mean derivative (AMD).
  • “AbsSum” - Absolute Sum of values over of the time series.
  • “IQR” - Interquaritle range (IQR) of the time series.
  • “FQR” - First quartile of the time series.
  • “SQR” - Second quartile of the time series.
  • “TQR” - Third quaritle of the time series.
Parameters:
  • timeseries (numpy.ndarray) – Time series.
  • nodata (real number) – nodata of the time series. Default is -9999.
Returns:

Dictionary of basic metrics