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_yeartoend_year. In order to fill the added years, the missing years preceeding the input data are filled with an average over the firstsample_years_startyears, and the missing years following the input data are filled with an average over the lastsample_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)
datawill be loaded into a standard GEOP4TH variable:all raster data (ASCII, GeoTIFF) and netCDF will be loaded as a xarray.Dataset
If
datais 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_yearto 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 thedata. When passed as an integer,crsrefers to the EPSG code. When passed as a string,crscan be OGC WKT string or Proj.4 string.- to_filebool or path (str or pathlib.Path), default False
If True and if
datais a path (str or pathlib.Path), the resulting dataset will be exported to the same location asdata, while appending ‘_prolonged’ to its name. Ifto_fileis 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_fileargument is used, the resulting dataset will also be exported to a file.