compare#

geobricks.compare(data1, data2, *, mode='absolute difference', reprojection='finest', force_time=False, crs1=None, crs2=None)[source]#

Compare two spatio-temporal maps by returning a spatio-temporal map of the difference data2 - data1 (absolute or relative, via mode argument). The 2 input maps can be heterogeneous (different space and time extents and resolutions, different variable names).

If the 2 input maps have different resolutions (and CRS), the finest, coarsest, last or first resolution will be used, depending on reprojection argument.

If both data have a time axis, the time intersection is kept. If one data is not tepmporal, its values are broadcasted against the time axis of the other data.

Parameters#

data1path (str or pathlib.Path), or variable (xarray.Dataset or xarray.DataArray)

First dataset, that will be compared to data2.

data2path (str or pathlib.Path), or variable (xarray.Dataset, xarray.DataArray)

Second dataset, that will be the reference to which data1 will be compared.

mode{‘difference’ (or ‘absolute difference’ or ‘absdif’), ‘relative difference’ (or ‘reldif’) or ‘ratio’}, default ‘difference’

Method of comparison:

  • ‘absolute difference’: data2 - data1

  • ‘relative difference’: (data2 - data1) / data1

reprojection{‘finest’ (or ‘downscale’), ‘coarsest’ (or ‘upscale’), ‘last’, or ‘first’}, default ‘finest’

If the two datasets have different resolutions, reprojection defines how they will be reprojected.

force_timebool, optional, default False

If True, the two datasets will be compared even if the dates do not match (the first time of data1 will be compared to the first time of data1 and so on).

crs1int or str or rasterio.crs.CRS, optional

Coordinate reference system of the first dataset (data1), that will be embedded in the data1. When passed as an integer, crs1 refers to the EPSG code. When passed as a string, crs1 can be OGC WKT string or Proj.4 string.

crs2int or str or rasterio.crs.CRS, optional

Coordinate reference system of the second dataset (data2), that will be embedded in the data2. When passed as an integer, crs2 refers to the EPSG code. When passed as a string, crs2 can be OGC WKT string or Proj.4 string.

Returns#

xarray.Dataset