Skip to content

Commit

Permalink
fix run scenario
Browse files Browse the repository at this point in the history
  • Loading branch information
WOTrompDeltares committed Sep 17, 2024
1 parent 3bdd317 commit 10298b7
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 28 deletions.
8 changes: 3 additions & 5 deletions DT_flood/workflows/pyscripts/init_fa_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
from DT_flood.utils.fa_scenario_utils import init_scenario, create_scenario
from shutil import copytree, rmtree

# print("Make extra copies of input folders")
# print(f"{Path(argv[1])/'input'/'projections'}")
# print(f"{Path(argv[1])/'input'/'Projections'}")
# copytree(Path(argv[1])/'input'/"projections", Path(argv[1])/'input'/"Projections", dirs_exist_ok=True)
# copytree(Path(argv[1])/"input"/"strategies", Path(argv[1])/"input"/"Strategies", dirs_exist_ok=True)
print("Make extra copies of input folders")
copytree(Path(argv[1])/'input'/"projections", Path(argv[1])/'input'/"Projections", dirs_exist_ok=True)
copytree(Path(argv[1])/"input"/"strategies", Path(argv[1])/"input"/"Strategies", dirs_exist_ok=True)

database, scenario = init_scenario(Path(argv[1]), (argv[2]+"_toplevel.toml"))

Expand Down
17 changes: 9 additions & 8 deletions DT_flood/workflows/pyscripts/update_sfincs.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
from shutil import copytree

from hydromt.log import setuplog
from hydromt.exceptions import NoDataException
from hydromt_wflow import WflowModel
from hydromt_sfincs import SfincsModel
from hydromt_sfincs.sfincs_input import SfincsInput
from DT_flood.utils.fa_scenario_utils import init_scenario

database, scenario = init_scenario(argv[1], (argv[2]+"_toplevel.toml"))

# wflow_path = database.output_path / "Scenarios" / argv[2] / "Flooding" / "simulations" / "wflow_event"
sfincs_out_path = database.output_path / "Scenarios" / argv[2] / "Flooding" / "simulations" / "overland"

sfincs_path = database.static_path / "templates" / database.site.attrs.sfincs.overland_model
Expand All @@ -30,7 +30,6 @@
data_libs=scenario['event']['data_catalogues']
)
sf.read()
# sf.set_root(sfincs_out_path, mode='w+')

print("Set SFINCS timing and forcing")
sf.setup_config(
Expand All @@ -43,14 +42,16 @@

sf.setup_waterlevel_forcing(geodataset=scenario['event']['sfincs_forcing']['waterlevel'],buffer=2000)

print(sf.get_model_time())
print(sf.region)
print(scenario['event']['sfincs_forcing']['meteo'])
meteo = sf.data_catalog.get_rasterdataset(scenario['event']['sfincs_forcing']['meteo'],geom=sf.region,time_tuple=sf.get_model_time())
try:
meteo = sf.data_catalog.get_rasterdataset(scenario['event']['sfincs_forcing']['meteo'],geom=sf.region.to_crs(4326),time_tuple=sf.get_model_time())
except NoDataException:
meteo = sf.data_catalog.get_rasterdataset(scenario['event']['sfincs_forcing']['meteo'],geom=sf.region.to_crs(4326),time_tuple=sf.get_model_time(), buffer=1)
except:
print("Failed to get SFINCS Meteo data")



sf.setup_precip_forcing_from_grid(precip=meteo['precip'], aggregate=False)
# sf.setup_wind_forcing_from_grid(wind=meteo.rename({"wind10_u": "wind_u", "wind10_v": "wind_v"}))
# sf.setup_pressure_forcing_from_grid(press=meteo['press_msl'])

print("Write SFINCS to output folder")
sf.write_forcing()
Expand Down
15 changes: 4 additions & 11 deletions Notebooks/ConfigureFullScenario.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@
"outputs": [],
"source": [
"# Path to the FloodAdapt database for which we are configuring scenarios\n",
"fa_database = Path(r\"/mnt/c/Users/santjer/OneDrive - Stichting Deltares/Documents/DestinE/Technical/01_FloodAdapt/scheveningen\")\n",
"fa_database = Path(\"/home/wotromp/DE372/scheveningen\")\n",
"\n",
"# Path to data folder. If (relative) file paths are used when specifying data sets, it will be looked for in this folder.\n",
"# data_folder = Path(\"/home/wotromp/InterTwin/Data\")\n",
"\n",
"# OPTIONAL: HydroMT data catalogue from which to fetch data. The order matters here, as datasets are looked for in a catalogue in order from first catalogue name in list to last.\n",
"data_catalogues = [Path(r\"/mnt/c/Users/santjer/OneDrive - Stichting Deltares/Documents/DestinE/Technical/01_FloodAdapt/deltares_data_wsl.yml\")]"
"data_catalogues = [Path(\"/home/wotromp/DE372/deltares_data_wsl.yml\")]"
]
},
{
Expand Down Expand Up @@ -308,7 +308,7 @@
"metadata": {},
"outputs": [],
"source": [
"database_fn = Path(r\"/mnt/c/Users/santjer/OneDrive - Stichting Deltares/Documents/DestinE/Technical/01_FloodAdapt/scheveningen\")\n",
"database_fn = Path(\"/home/wotromp/DE372/scheveningen\")\n",
"scenario_name = 'test_scenario'"
]
},
Expand All @@ -329,13 +329,6 @@
"source": [
"run_fa_scenario_workflow(database_fn, scenario_name)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand All @@ -354,7 +347,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.9"
"version": "3.11.10"
}
},
"nbformat": 4,
Expand Down
4 changes: 3 additions & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ channels:
dependencies:
- cartopy
- cwltool
- dask=2024.6.0
- ipykernel
- hydromt_wflow
- pandas>2.0.0
- python<3.12
- pip
- pip:
- jupyter
# - git+https://github.com/Deltares-research/FloodAdapt.git@6a18711
- git+https://github.com/Deltares-research/FloodAdapt.git@6a18711
- gwwapi
4 changes: 1 addition & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,4 @@ authors = [
description = "Digital Twin for flooding developed for the InterTwin project"
readme = "README.md"
license = {file = "LICENSE"}
dependencies = [
"hydromt_fiat @ git+https://github.com/Deltares/hydromt_fiat.git@hotfixes",
]
dependencies = []

0 comments on commit 10298b7

Please sign in to comment.