ewatercycle._forcings.caravan

Module Contents

ewatercycle._forcings.caravan.COMMON_URL = 'ca13056c-c347-4a27-b320-930c2a4dd207'
ewatercycle._forcings.caravan.OPENDAP_URL
ewatercycle._forcings.caravan.SHAPEFILE_URL
ewatercycle._forcings.caravan.PROPERTY_VARS = ['timezone', 'name', 'country', 'lat', 'lon', 'area', 'p_mean', 'pet_mean', 'aridity',...
ewatercycle._forcings.caravan.RENAME_ERA5
class ewatercycle._forcings.caravan.CaravanForcing

Bases: ewatercycle.base.forcing.DefaultForcing

Retrieves specified part of the caravan dataset from the OpenDAP server. Examples:

The caravan dataset is an already prepared set by Frederik Kratzert, (see https://doi.org/10.1038/s41597-023-01975-w).

This retrieves it from the OpenDAP server of 4TU, (see https://doi.org/10.4121/bf0eaf7c-f2fa-46f6-b8cd-77ad939dd350.v4).

This can be done by specifying the

from pathlib import Path
from rich import print
from ewatercycle.forcing import sources

path = Path.cwd()
forcing_path = path / "Forcing"
experiment_start_date = "1997-08-01T00:00:00Z"
experiment_end_date = "2005-09-01T00:00:00Z"
HRU_id = 1022500

camels_forcing = sources['LumpedCaravanForcing'].retrieve(
                            start_time = experiment_start_date,
                            end_time = experiment_end_date,
                            directory = forcing_path / "Camels",
                            basin_id = f"camels_0{HRU_id}"
                                                        )
which gives somthing like:
LumpedCaravanForcing(
start_time='1997-08-01T00:00:00Z',
end_time='2005-09-01T00:00:00Z',
directory=PosixPath('/home/davidhaasnoot/eWaterCycle-WSL-WIP/Forcing/Camels'),
shape=PosixPath('/home/davidhaasnoot/eWaterCycle-WSL-WIP/Forcing/Camels/shapefiles/camels_01022500.shp'),
filenames={
    'tasmax':
     'camels_01022500_1997-08-01T00:00:00Z_2005-09-01T00:00:00Z_tasmax.nc',
    'tasmin':
    'camels_01022500_1997-08-01T00:00:00Z_2005-09-01T00:00:00Z_tasmin.nc',
    'evspsblpot':
    'camels_01022500_1997-08-01T00:00:00Z_2005-09-01T00:00:00Z_evspsblpot.nc',
    'pr': 'camels_01022500_1997-08-01T00:00:00Z_2005-09-01T00:00:00Z_pr.nc',
    'tas': 'camels_01022500_1997-08-01T00:00:00Z_2005-09-01T00:00:00Z_tas.nc',
    'Q': 'camels_01022500_1997-08-01T00:00:00Z_2005-09-01T00:00:00Z_Q.nc'
}
)

More in depth notebook van be found here: https://gist.github.com/Daafip/ac1b030eb5563a76f4d02175f2716fd7

classmethod get_dataset(dataset: str) xarray.Dataset

Opens specified dataset from data.4tu.nl OPeNDAP server.

Parameters:

dataset (str) – name of dataset, choose from: ‘camels’, ‘camelsaus’, ‘camelsbr’, ‘camelscl’, ‘camelsgb’, ‘hysets’, ‘lamah’

classmethod get_basin_id(dataset: str) list[str]

Gets a list of all the basin ids in provided dataset :param dataset: name of dataset, choose from:

‘camels’, ‘camelsaus’, ‘camelsbr’, ‘camelscl’, ‘camelsgb’, ‘hysets’, ‘lamah’

Note

https://www.ewatercycle.org/caravan-map/ contains online a set of interactive maps which allows exploration of the available catchments and also contains the needed basin_ids. Alternatively, a zip with shapefiles is available at https://doi.org/10.4121/ca13056c-c347-4a27-b320-930c2a4dd207.v1 which also allows exploration of the dataset.

classmethod generate(start_time: str, end_time: str, directory: str, variables: tuple[str, Ellipsis] = (), shape: str | pathlib.Path | None = None, **kwargs) CaravanForcing

Retrieve caravan for a model.

Parameters:
  • start_time – Start time of forcing in UTC and ISO format string e.g. ‘YYYY-MM-DDTHH:MM:SSZ’.

  • end_time – nd time of forcing in UTC and ISO format string e.g. ‘YYYY-MM-DDTHH:MM:SSZ’.

  • directory – Directory in which forcing should be written. If not given will create timestamped directory.

  • variables – Variables which are needed for model, if not specified will default to all.

  • shape – (Optional) Path to a shape file. If none is specified, will be downloaded automatically.

Kwargs:
basin_id: The ID of the desired basin. Data sets can be explored using

CaravanForcing.get_dataset(dataset_name) or CaravanForcing.get_basin_id(dataset_name) where dataset_name is the name of a dataset in Caravan (for example, “camels” or “camelsgb”). For more information do help(CaravanForcing.get_basin_id) or see https://www.ewatercycle.org/caravan-map/.

ewatercycle._forcings.caravan.get_shapefiles(directory: pathlib.Path, basin_id: str) pathlib.Path

Retrieve shapefiles from data 4TU.nl .

ewatercycle._forcings.caravan.extract_basin_shapefile(basin_id: str, combined_shapefile_path: pathlib.Path, shape_path: pathlib.Path) None

Extract single polygon from multipolygon shapefile.

ewatercycle._forcings.caravan.crop_ds(ds: xarray.Dataset, start_time: str, end_time: str) xarray.Dataset

Crops dataset based on time.