Closed richardarsenault closed 3 months ago
My understanding is that we have a few options here:
I'm not sure it's a good idea to modify the emulator config and keep the same name (1.). Thoughts ?
Example of code that would filter out lake hrus and warn the user:
class HRUs(rc.HRUs):
"""HRUs command for GR4J.
Pydantic is able to automatically detect if an HRU is Land or Lake if `hru_type` is provided.
"""
root: Sequence[LandHRU]
@field_validator("root", mode="before")
@classmethod
def skip_non_land_hrus(cls, values):
"""Filter out non-land HRUs."""
hrus = [hru for hru in values if hru.hru_type == "land"]
if len(hrus) != len(values):
warn("Only land HRUs are supported for this emulator. Other types of HRUs, such as lakes, were "
"filtered out.")
return hrus
I can apply the same logic to all emulators, using introspection to check what values of hru_type are recognized by the emulator. If the HRU values have a hru_type and it doesn't match the model, I would simply skip them from the config with a UserWarning.
I think option 3 is the best way forward. Users know that when using the RavenPy distributed model builder, it comes with a whole bunch of hypotheses and simplifications. A user warning would suffice I think!
In looking through the Raven manual v3.7 I found the following information that might be useful to treat lakes in HBV-EC:
Lakes in HBV By default, the :LakeStorage state variable is SURFACE_WATER. For HBV-EC or HBV light emulation this is modified to SOIL[2]. HBV treats all landscapes as if they have some presence of lakes, but does not explicitly treat LAKE HRUs. If you would like to revise HBV to properly handle precipitation on a lake, an additional command is required in the :HydrologicProcesses block: :Flush RAVEN_DEFAULT [lake storage SV] [SURFACE_WATER] :-->Conditional HRU_TYPE IS LAKE Without this, the precipitation in the ’lake’ storage unit may steadily increase because standard mechanisms for drainage (e.g., baseflow) are disabled for LAKE type HRUs.
In my opinion, skipping lake HRUs when they are small might be fine, but it could be problematic when they are meant to represent larger lakes. Alternatively (less preferable I think), since "HBV treats all landscapes as if they have some presence of lakes" using the :LakeStorage variable, could these lake HRUs be treated as land HRUs by the emulator?
Description
Using notebook "/tutorial-notebooks/hydro/Distributed_hydrological_modelling.ipynb" works flawlessly with the default GR4JCN model setup. Changing to HBVEC (and changing the parameter set to reflect an HBVEC model) fails due to lake HRUs that are not accepted in HBVEC.
What I Did
The resulting block of code within the cell (cell 6) looks like this now:
This fails with the following traceback:
Expected Behavior:
I would expect the model to simply run and return a streamflow object.