sisppeo.products.TimeSeries

class sisppeo.products.TimeSeries(dataset)[source]

Bases: sisppeo.utils.products.CoordinatesMixin

A ‘L4’ product, made from either L1, L2, or L3 products.

This product contain one or more DataArrays (e.g., one for ndwi, one for each band extracted…). Each DataArrays is a data cube (i.e. 3D: x, y, time). It allows one to study time series of data, and compute and plot statistics over time and/or space.

dataset

A dataset containing one or more 3D-dataarrays.

Type

xarray.core.dataset.Dataset

__init__(dataset)

Methods

__init__(dataset)

compute_stats(filename[, plot])

Computes (and save on disk) statistics about embedded data at each date.

extract_point(data_var, coordinates[, ...])

Returns value(s) at the given coordinates.

extract_points(data_var, lst_coordinates[, ...])

Returns value(s) at each tuple of coordinates of the given list.

from_file(filename)

Load a TimeSeries object from disk.

from_files(paths)

Load and merge a list of L3 products from disk.

from_l3products(lst)

Load and merge a list of L3 products.

get_max_map(var[, plot, filename, save, ...])

Gets the map of (temporal) max values for a given data_var.

get_mean_map(var[, plot, filename, save, ...])

Gets the map of (temporal) mean values for a given data_var.

get_min_map(var[, plot, filename, save, ...])

Gets the map of (temporal) min values for a given data_var.

index(x, y)

Gets (i, j) from (x, y)

plot_1d(lst_coordinates[, data_var, buffer, ...])

Plots time series of data_var(s) for one or more given points.

plot_2d([data_vars, filename, fmt])

Plots timelapse as a mosaic (one per data_var).

plot_hists([data_vars, dates, plot, ...])

Plots an histogram (per data_var, per date).

plot_stats_maps([data_vars, filename, ...])

Plots a figure of stats (temporal mean/min/max) map (one per data_var).

save(filename)

See base class.

timelapse(data_vars, filename[, out_res, ...])

Creates a timelapse and save it on disk (as a GIF file).

xy(i, j)

Gets (x, y) from (i, j).

Attributes

dataset

bounds

(xmin, ymin, xmax, ymax).

data_vars

Returns a list of DataArrays corresponding to variables.

end_date

Return the end date.

res

Returns the spatial resolution of this product.

start_date

Return the start date.

title

Returns the title of the underlying dataset.

x

Returns x-coords.

y

Returns y-coords.

property bounds

(xmin, ymin, xmax, ymax).

Type

Returns the boundaries of this product

compute_stats(filename, plot=True)[source]

Computes (and save on disk) statistics about embedded data at each date.

Parameters
  • filename – The path of the output product (a CSV file).

  • plot – A boolean flag that indicates if computed statistics should be plotted or not.

property data_vars

Returns a list of DataArrays corresponding to variables.

property end_date

Return the end date.

extract_point(data_var, coordinates, buffer=None, epsg=4326, mode='xy')

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')

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.

classmethod from_file(filename)[source]

Load a TimeSeries object from disk.

Parameters

filename – The path of the netCDF file.

Returns

time, x, y).

Return type

A TimeSeries object (i.e. a 3D dataset

classmethod from_files(paths)[source]

Load and merge a list of L3 products from disk.

Parameters

paths – A list of paths (to L3 products saved as netCDF files).

Returns

time, x, y).

Return type

A TimeSeries object (i.e. a 3D dataset

classmethod from_l3products(lst)[source]

Load and merge a list of L3 products.

Parameters

lst – A list of L3 products (loaded in memory).

Returns

time, x, y).

Return type

A TimeSeries object (i.e. a 3D dataset

get_max_map(var, plot=True, filename=None, save=False, savefig=False, fmt='jpeg')[source]

Gets the map of (temporal) max values for a given data_var.

Compute a map (a dataarray of dimension N * M) from a dataarray of dimension t * N * M. Each pixel of this map is the max value of the N * M t-vectors.

Parameters
  • var – The name of the dataarray to use.

  • plot – A boolean flag that indicates if the figure should be plotted or not.

  • filename – Optional; The path of the output product (a figure and/or a netCDF file).

  • save – Optional; A boolean flag that indicates if the mean map should be saved on disk or not.

  • savefig – Optional; A boolean flag that indicates if the figure should be saved or not.

  • fmt – The format of the static image that is saved on disk. Can be either “png”, “jpeg”, “webp”, “svg” or “pdf”.

Returns

A map (a dataarray of dimension N * M) of max values for a given data_var.

get_mean_map(var, plot=True, filename=None, save=False, savefig=False, fmt='jpeg')[source]

Gets the map of (temporal) mean values for a given data_var.

Compute a map (a DataArray of dimension N * M) from a DataArray of dimension t * N * M. Each pixel of this map is the mean value of the N * M t-vectors.

Parameters
  • var – The name of the DataArray to use.

  • plot – A boolean flag that indicates if the figure should be plotted or not.

  • filename – Optional; The path of the output product (a figure and/or a netCDF file).

  • save – Optional; A boolean flag that indicates if the mean map should be saved on disk or not.

  • savefig – Optional; A boolean flag that indicates if the figure should be saved or not.

  • fmt – The format of the static image that is saved on disk. Can be either “png”, “jpeg”, “webp”, “svg” or “pdf”.

Returns

A map (a dataarray of dimension N * M) of mean values for a given data_var.

get_min_map(var, plot=True, filename=None, save=False, savefig=False, fmt='jpeg')[source]

Gets the map of (temporal) min values for a given data_var.

Compute a map (a dataarray of dimension N * M) from a dataarray of dimension t * N * M. Each pixel of this map is the min value of the N * M t-vectors.

Parameters
  • var – The name of the dataarray to use.

  • plot – A boolean flag that indicates if the figure should be plotted or not.

  • filename – Optional; The path of the output product (a figure and/or a netCDF file).

  • save – Optional; A boolean flag that indicates if the mean map should be saved on disk or not.

  • savefig – Optional; A boolean flag that indicates if the figure should be saved or not.

  • fmt – The format of the static image that is saved on disk. Can be either “png”, “jpeg”, “webp”, “svg” or “pdf”.

Returns

A map (a dataarray of dimension N * M) of min values for a given data_var.

index(x, y)

Gets (i, j) from (x, y)

plot_1d(lst_coordinates, data_var='all', buffer=None, epsg=4326, mode='xy', filename=None, fmt='jpeg')[source]

Plots time series of data_var(s) for one or more given points.

Parameters
  • lst_coordinates – A tuple of coordinates (x, y) that locates the point to extract (/a list of tuples of coordinates, locating points of interest).

  • data_var – Optional; A variable (e.g. “aCDOM”) or a list of variables to plot.

  • buffer

  • epsg

  • mode

  • filename – Optional; If a filename is provided, the figure will be saved using this path.

  • fmt – The format of the exported figure. Can be either “png”, “jpeg”, “webp”, “svg” or “pdf”.

plot_2d(data_vars='all', filename=None, fmt='jpeg')[source]

Plots timelapse as a mosaic (one per data_var).

For each data_var, create a figure composed of multiples subplots, each one of them being a image of the given data_var at a given date.

Parameters
  • data_vars – A variable (e.g. “aCDOM”) or a list for variables to plot. If ‘all’, creates a figure for each variable (i.e. DataArray) embedded into this dataset.

  • filename – Optional; If a filename is provided, the figure will be saved using this path.

  • fmt – The format of the exported figure. Can be either “png”, “jpeg”, “webp”, “svg” or “pdf”.

plot_hists(data_vars='all', dates='all', plot=True, filename=None, fmt='jpeg')[source]

Plots an histogram (per data_var, per date).

For each data_var, at each date, plots an histogram using the right array of values.

Parameters
  • data_vars – The name of the dataarray to plot. If ‘all’, create a figure for each dataarray (i.e. for each data_var in data_vars).

  • dates – The wanted date. If ‘all’, create a histogram for each date.

  • plot – A boolean flag that indicates if the figure should be plotted or not.

  • filename – Optional; The path of the output figure.

  • fmt – The format of the static image that is saved on disk. Can be either “png”, “jpeg”, “webp”, “svg” or “pdf”.

plot_stats_maps(data_vars='all', filename=None, savefig=False, fmt='jpeg')[source]

Plots a figure of stats (temporal mean/min/max) map (one per data_var).

For each data_var, create a figure composed of 3 subplots : a mean-, min-, and max-map. See ‘get_mean_map’, ‘get_min_map’, and ‘get_max_map’ for more information about what the so-called maps are.

Parameters
  • data_vars – The name of the dataarray to plot. If ‘all’, create a figure for each dataarray (i.e. for each data_var in data_vars).

  • filename – Optional; The path of the output figure.

  • savefig – Optional; A boolean flag that indicates if the figure should be saved or not.

  • fmt – The format of the static image that is saved on disk. Can be either “png”, “jpeg”, “webp”, “svg” or “pdf”.

property res

Returns the spatial resolution of this product.

save(filename)[source]

See base class.

property start_date

Return the start date.

timelapse(data_vars, filename, out_res=None, write_time=True)[source]

Creates a timelapse and save it on disk (as a GIF file).

Parameters
  • data_vars – The data_var(s) to plot; 1 for a grayscale image, and a list of 3 for a RGB one.

  • filename – The path of the output gif.

  • out_res – The resolution of the timelapse; must be coarser than the one of the time series.

  • write_time – If True, the corresponding date will be written on each frame.

property title

Returns the title of the underlying dataset.

property x

Returns x-coords.

xy(i, j)

Gets (x, y) from (i, j).

property y

Returns y-coords.