Manual Forcing#

Creating your own forcing object is also a possibility. This does mean that you need to have your forcing data uploaded in netCDF format! So the total needs for making your own forcing object:

  • shapefile, and the accompanying files

  • time-window

  • directory, path where you want to save to

  • forcing, a dictionary filled with your forcings

# Ignore user warnings :)
import warnings
warnings.filterwarnings("ignore", category=UserWarning)

import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
from pathlib import Path
import os
import xarray as xr
import rich

# General eWaterCycle
import ewatercycle
import ewatercycle.forcing

Forcing Dictionary#

To use your own forcing in eWaterCycle you need to put the paths that lead to the netCDF files in a dictionary

# The path to the directory you saved your netCDF files for the forcing
path_to_netCDF = Path.home() / "some_path_to_directory"

forcing_dictionary = dict()
forcing_dictionary["pr"] = str(path_to_netCDF / "pr.nc")
forcing_dictionary["rsds"] = str(path_to_netCDF / "rsds.nc")
forcing_dictionary["tas"] = str(path_to_netCDF / "tas.nc")
forcing_dictionary["evspsblpot"] = str(path_to_netCDF / "evspsblpot.nc")

Reminder dictionary:

  • key: value

  • dict[key] = value

Note that the key in the dictionary has to be “pr” in this case, because now we want to make a LumpedMakkinkForcing object, which uses pr for precipitation etc.

Making the forcing object#

forcing = ewatercycle.forcing.sources["LumpedMakkinkForcing"](
    directory=path_to_save,
    start_time=start_date,
    end_time=end_date,
    shape=shape_file,
    filenames=forcing_dictionary,
)