Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

attemp to add kwards to rc.ObservationData.from_nc #230

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/xhydro/modelling/_ravenpy_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ class RavenpyModel(HydrologicalModel):
meteo_station_properties : dict
The properties of the weather stations providing the meteorological data. Used to adjust weather according to
differences between station and catchment elevations (adiabatic gradients, etc.).
hydro_station_properties : dict
Optional arguments to observation data like station indexes.
workdir : str or os.PathLike
Path to save the .rv files and model outputs.
rain_snow_fraction : str
Expand Down Expand Up @@ -78,6 +80,7 @@ def __init__(
data_type,
alt_names_meteo,
meteo_station_properties,
hydro_station_properties={},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This signature creates a mutable default argument, meaning that multiple instances of the RavenPyModel running in the same script could inherit changes to this argument on prior initialisation. See: https://docs.python-guide.org/writing/gotchas/#mutable-default-arguments

Another way to do this would be

Suggested change
hydro_station_properties={},
hydro_station_properties: dict | None = None,

Followed by:

if hydro_station_properties is None:
    hydro_station_properties = {}

workdir: str | os.PathLike | None = None,
rain_snow_fraction="RAINSNOW_DINGMAN",
evaporation="PET_PRIESTLEY_TAYLOR",
Expand Down Expand Up @@ -106,7 +109,9 @@ def __init__(
StartDate=start_date,
EndDate=end_date,
ObservationData=[
rc.ObservationData.from_nc(qobs_path, alt_names=alt_names_flow)
rc.ObservationData.from_nc(
qobs_path, alt_names=alt_names_flow, **hydro_station_properties
)
],
Gauge=[
rc.Gauge.from_nc(
Expand Down