Skip to content

Commit

Permalink
fix notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeitsperre committed Feb 25, 2025
1 parent 2f58b6a commit ea8fda4
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions docs/notebooks/Comparing_hindcasts_and_ESP_forecasts.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"\n",
"import matplotlib.pyplot as plt\n",
"import xarray as xr\n",
"from clisops.core import average, subset\n",
"from clisops.core import subset\n",
"\n",
"from ravenpy import Emulator\n",
"from ravenpy.config import commands as rc\n",
Expand Down Expand Up @@ -143,7 +143,7 @@
"\n",
"# Build a new model config:\n",
"# Model configuration\n",
"model_config_ESP = emulators.GR4JCN(\n",
"model_config_ESP = GR4JCN(\n",
" params=[0.529, -3.396, 407.29, 1.072, 16.9, 0.947],\n",
" Gauge=[\n",
" rc.Gauge.from_nc(\n",
Expand Down Expand Up @@ -216,9 +216,8 @@
" dim=(\"rlat\", \"rlon\")\n",
" )\n",
"\n",
"ts_subset = ts_subset.resample(time=\"6H\").nearest(\n",
" tolerance=\"1H\"\n",
") # To make the timesteps identical across the entire duration\n",
"# To make the time steps identical across the entire duration\n",
"ts_subset = ts_subset.resample(time=\"6h\").nearest(tolerance=\"1h\")\n",
"\n",
"# We need to write the hindcast data as a file for Raven to be able to access it.\n",
"fname = \"/tmp/hindcast.nc\"\n",
Expand All @@ -236,28 +235,29 @@
"\n",
"# We will need to reuse this for GR4J. Update according to your needs. For example, here we will also pass\n",
"# the catchment latitude and longitude as our CaSPAr data has been averaged at the catchment scale.\n",
"# We also need to tell the model to deaccumulate the precipitation and shift it in time by 6 hours for our\n",
"# We also need to tell the model to de-accumulate the precipitation and shift it in time by 6 hours for our\n",
"# catchment (UTC timezones):\n",
"data_kwds = {\n",
" \"ALL\": {\n",
" \"elevation\": hru[\"elevation\"],\n",
" \"Latitude\": hru[\"latitude\"],\n",
" \"Longitude\": hru[\"longitude\"],\n",
" },\n",
" # Since we are de-accumulating, we need to manually specify scale.\n",
" \"PRECIP\": {\n",
" \"Deaccumulate\": True,\n",
" \"TimeShift\": -0.25,\n",
" \"LinearTransform\": {\n",
" \"scale\": 1000.0\n",
" }, # Since we are deaccumulating, we need to manually specify scale.\n",
" }, # Converting meters to mm (multiply by 1000).\n",
" \"scale\": 1000.0 # Converting meters to mm (multiply by 1000).\n",
" },\n",
" },\n",
" \"TEMP_AVE\": {\n",
" \"TimeShift\": -0.25,\n",
" },\n",
"}\n",
"\n",
"# Model configuration for forecasting, including correct start date and forecast duration\n",
"model_config_fcst = emulators.GR4JCN(\n",
"model_config_forecast = GR4JCN(\n",
" params=[0.529, -3.396, 407.29, 1.072, 16.9, 0.947],\n",
" Gauge=[\n",
" rc.Gauge.from_nc(\n",
Expand All @@ -271,12 +271,12 @@
")\n",
"\n",
"# Update the initial states\n",
"model_config_fcst = model_config_fcst.set_solution(hotstart)\n",
"model_config_forecast = model_config_forecast.set_solution(hotstart)\n",
"\n",
"# Generate the hindcast by providing all necessary information to generate virtual stations representing\n",
"# the forecast members\n",
"hindcast_sims = forecasting.hindcast_from_meteo_forecast(\n",
" model_config_fcst,\n",
" model_config_forecast,\n",
" forecast=fname,\n",
" overwrite=True,\n",
" # We also need to provide the necessary information to create gauges inside the forecasting model:\n",
Expand Down

0 comments on commit ea8fda4

Please sign in to comment.