deafrica_tools.temporal

Functions for calculating per-pixel temporal summary statistics on a timeseries stored in a xarray.DataArray.

The key functions are:

xr_phenology

Obtain land surface phenology metrics from an xarray.DataArray containing a timeseries of a vegetation index like NDVI.

temporal_statistics

Calculate various generic summary statistics on any timeseries.

Functions

allNaN_arg(da, dim, stat)

Calculate da.argmax() or da.argmin() while handling all-NaN slices.

temporal_statistics(da, stats)

Calculate various generic summary statistics on any timeseries.

xr_phenology(da[, stats, method_sos, ...])

Obtain land surface phenology metrics from an xarray.DataArray containing a timeseries of a vegetation index like NDVI.

deafrica_tools.temporal.allNaN_arg(da, dim, stat)

Calculate da.argmax() or da.argmin() while handling all-NaN slices. Fills all-NaN locations with an float and then masks the offending cells.

Paramètres
  • da (xarray.DataArray) –

  • dim (str) – Dimension over which to calculate argmax, argmin e.g. “time”

  • stat (str) – The statistic to calculte, either “min” for argmin() or “max” for .argmax()

Renvoie

Type renvoyé

xarray.DataArray

deafrica_tools.temporal.temporal_statistics(da, stats)

Calculate various generic summary statistics on any timeseries.

This function uses the hdstats temporal library: https://github.com/daleroberts/hdstats/blob/master/hdstats/ts.pyx

last modified June 2020

Paramètres
  • da (xarray.DataArray) – DataArray should contain a 3D time series.

  • stats (list) –

    list of temporal statistics to calculate. Options include:

    • ”discordance” =

    • ”f_std” = std of discrete fourier transform coefficients, returns

      three layers: f_std_n1, f_std_n2, f_std_n3

    • ’f_mean” = mean of discrete fourier transform coefficients, returns

      three layers: f_mean_n1, f_mean_n2, f_mean_n3

    • ’f_median” = median of discrete fourier transform coefficients, returns

      three layers: f_median_n1, f_median_n2, f_median_n3

    • ’mean_change” = mean of discrete difference along time dimension

    • ’median_change” = median of discrete difference along time dimension

    • ’abs_change” = mean of absolute discrete difference along time dimension

    • ’complexity” =

    • ”central_diff” =

    • ”num_peaks”The number of peaks in the timeseries, defined with a local

      window of size 10. NOTE: This statistic is very slow

Renvoie

Dataset containing variables for the selected temporal statistics

Type renvoyé

xarray.Dataset

deafrica_tools.temporal.xr_phenology(da, stats=['SOS', 'POS', 'EOS', 'Trough', 'vSOS', 'vPOS', 'vEOS', 'LOS', 'AOS', 'ROG', 'ROS'], method_sos='first', method_eos='last', verbose=True)

Obtain land surface phenology metrics from an xarray.DataArray containing a timeseries of a vegetation index like NDVI.

last modified June 2020

Paramètres
  • da (xarray.DataArray) – DataArray should contain a 2D or 3D time series of a vegetation index like NDVI, EVI

  • stats (list) –

    list of phenological statistics to return. Regardless of the metrics returned, all statistics are calculated due to inter-dependencies between metrics. Options include:

    • SOS = DOY of start of season

    • POS = DOY of peak of season

    • EOS = DOY of end of season

    • vSOS = Value at start of season

    • vPOS = Value at peak of season

    • vEOS = Value at end of season

    • Trough = Minimum value of season

    • LOS = Length of season (DOY)

    • AOS = Amplitude of season (in value units)

    • ROG = Rate of greening

    • ROS = Rate of senescence

  • method_sos (str) – If “first” then vSOS is estimated as the first positive slope on the greening side of the curve. If “median”, then vSOS is estimated as the median value of the postive slopes on the greening side of the curve.

  • method_eos (str) – If “last” then vEOS is estimated as the last negative slope on the senescing side of the curve. If “median”, then vEOS is estimated as the “median” value of the negative slopes on the senescing side of the curve.

Renvoie

Dataset containing variables for the selected phenology statistics

Type renvoyé

xarray.Dataset