prolong#

geobricks.prolong(data, *, start_year, end_year, sample_years_start=1, sample_years_end=1, crs=None, to_file=False)[source]#

Extend in time, to cover the duration from start_year to end_year. In order to fill the added years, the missing years preceeding the input data are filled with an average over the first sample_years_start years, and the missing years following the input data are filled with an average over the last sample_years_end.

This function is particularly handy to extend in time data that do not fully cover the time extend of CWatM simulation. For instance:

When running CWatM from 2000 to 2030, if withdrawal data only exist between 2005 and 2025, we can assume that the withdrawals during the years 2000-2004 are somehow similar to the average withdrawal over the first 10 available years (2005-2015). In the same way we can assume that the withdrawals during the years 2026-2030 will somehow be consistend with the average withdrawal over the last 5 available years (2020-2025). We can thus quickly run the simulation by preparing the input data with: cwatm.prolong(data, start_year = 2000, end_year = 2030, sample_years_start = 10, sample_years_end = 5, to_file = True).

Parameters#

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

data will be loaded into a standard GEOP4TH variable:

  • all raster data (ASCII, GeoTIFF) and netCDF will be loaded as a xarray.Dataset

If data is already a variable, no operation will be executed.

start_yearint

Lower bound of the new time cover.

end_yearint

Upper bound of the new time cover.

sample_years_startint, optional, default 1

Set the period length at the beginning of the input data time cover that will be used to compute the average values used for filling data from start_year to the beginning of the input data.

sample_years_endint, optional, default 1

Set the period length at the end of the input data time cover that will be used to compute the average values used for filling data from the end of the input data to end_year.

crsint or str or rasterio.crs.CRS, optional

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

to_filebool or path (str or pathlib.Path), default False

If True and if data is a path (str or pathlib.Path), the resulting dataset will be exported to the same location as data, while appending ‘_prolonged’ to its name. If to_file is a path, the resulting dataset will be exported to this specified filepath.

Returns#

Time-expanded xarray.Dataset or geopandas.GeoDataFrame with a standard georeferencement. If to_file argument is used, the resulting dataset will also be exported to a file.