SfincsAdapter
self, model_root: Path) adapter.SfincsAdapter(
Adapter for the SFINCS model.
This class is used to run the SFINCS model and process the results.
Attributes
settings :
SfincsModel
-
The settings for the SFINCS model.
Methods
Name | Description |
---|---|
add_forcing | Get forcing data and add it. |
add_measure | Get measure data and add it. |
add_obs_points | Add observation points provided in the site toml to SFINCS model. |
add_projection | Get forcing data currently in the sfincs model and add the projection it. |
calculate_rp_floodmaps | Calculate flood risk maps from a set of (currently) SFINCS water level outputs using linear interpolation. |
close_files | Close all open files and clean up file handles. |
execute | Run the sfincs executable in the specified path. |
get_bedlevel | Get bed level from model. |
get_mask | Get mask with inactive cells from model. |
get_model_boundary | Get bounding box from model. |
get_model_grid | Get grid from model. |
get_wl_df_from_offshore_his_results | Create a pd.Dataframe with waterlevels from the offshore model at the bnd locations of the overland model. |
has_run | Check if the model has been run. |
plot_wl_obs | Plot water levels at SFINCS observation points as html. |
preprocess | Preprocess the SFINCS model for a given scenario. |
read | Read the sfincs model from the current model root. |
run | Run the whole workflow (Preprocess, process and postprocess) for a given scenario. |
run_completed | Check if the entire model run has been completed successfully by checking if all flood maps exist that are created in postprocess(). |
set_timing | Set model reference times. |
sfincs_completed | Check if the sfincs executable has been run successfully by checking if the output files exist in the simulation folder. |
write | Write the sfincs model configuration to a directory. |
write_floodmap_geotiff | Read simulation results from SFINCS and saves a geotiff with the maximum water levels. |
write_water_level_map | Read simulation results from SFINCS and saves a netcdf with the maximum water levels. |
add_forcing
adapter.SfincsAdapter.add_forcing(forcing: IForcing)
Get forcing data and add it.
add_measure
adapter.SfincsAdapter.add_measure(measure: Measure)
Get measure data and add it.
add_obs_points
adapter.SfincsAdapter.add_obs_points()
Add observation points provided in the site toml to SFINCS model.
add_projection
adapter.SfincsAdapter.add_projection(projection: Projection)
Get forcing data currently in the sfincs model and add the projection it.
calculate_rp_floodmaps
adapter.SfincsAdapter.calculate_rp_floodmaps(scenario: Scenario)
Calculate flood risk maps from a set of (currently) SFINCS water level outputs using linear interpolation.
It would be nice to make it more widely applicable and move the loading of the SFINCS results to self.postprocess_sfincs().
generates return period water level maps in netcdf format to be used by FIAT generates return period water depth maps in geotiff format as product for users
TODO: make this robust and more efficient for bigger datasets.
close_files
adapter.SfincsAdapter.close_files()
Close all open files and clean up file handles.
execute
bool = True) adapter.SfincsAdapter.execute(path: Path, strict:
Run the sfincs executable in the specified path.
Parameters
path :
str
-
Path to the simulation folder. Default is None, in which case the model root is used.
strict :
bool
= True-
True: raise an error if the model fails to run. False: log a warning. Default is True.
Returns
:
bool
-
True if the model ran successfully, False otherwise.
get_bedlevel
adapter.SfincsAdapter.get_bedlevel()
Get bed level from model.
get_mask
adapter.SfincsAdapter.get_mask()
Get mask with inactive cells from model.
get_model_boundary
adapter.SfincsAdapter.get_model_boundary()
Get bounding box from model.
get_model_grid
adapter.SfincsAdapter.get_model_grid()
Get grid from model.
Returns
:
QuadtreeGrid
-
QuadtreeGrid with the model grid
get_wl_df_from_offshore_his_results
adapter.SfincsAdapter.get_wl_df_from_offshore_his_results()
Create a pd.Dataframe with waterlevels from the offshore model at the bnd locations of the overland model.
Returns
wl_df :
pd
.DataFrame
-
time series of water level.
has_run
adapter.SfincsAdapter.has_run(scenario: Scenario)
Check if the model has been run.
plot_wl_obs
adapter.SfincsAdapter.plot_wl_obs(scenario: Scenario)
Plot water levels at SFINCS observation points as html.
Only for single event scenarios, or for a specific simulation path containing the written and processed sfincs model.
preprocess
adapter.SfincsAdapter.preprocess(scenario: Scenario, event: Event)
Preprocess the SFINCS model for a given scenario.
Parameters
read
adapter.SfincsAdapter.read(path: Path)
Read the sfincs model from the current model root.
run
adapter.SfincsAdapter.run(scenario: Scenario)
Run the whole workflow (Preprocess, process and postprocess) for a given scenario.
run_completed
adapter.SfincsAdapter.run_completed(scenario: Scenario)
Check if the entire model run has been completed successfully by checking if all flood maps exist that are created in postprocess().
Returns
bool : True if all flood maps exist, False otherwise.
set_timing
adapter.SfincsAdapter.set_timing(time: TimeFrame)
Set model reference times.
sfincs_completed
adapter.SfincsAdapter.sfincs_completed(sim_path: Path)
Check if the sfincs executable has been run successfully by checking if the output files exist in the simulation folder.
Parameters
sim_path :
Path
-
Path to the simulation folder to check.
Returns
bool : True if the sfincs executable has been run successfully, False otherwise.
write
adapter.SfincsAdapter.write(str, os.PathLike],
path_out: Union[bool = True,
overwrite: )
Write the sfincs model configuration to a directory.
write_floodmap_geotiff
adapter.SfincsAdapter.write_floodmap_geotiff(
scenario: Scenario,= None,
sim_path: Optional[Path] )
Read simulation results from SFINCS and saves a geotiff with the maximum water levels.
Produced floodmap is in the units defined in the sfincs config settings.
Parameters
scenario : Scenario
-
Scenario for which to create the floodmap.
sim_path :
Path
= None-
Path to the simulation folder, by default None.
write_water_level_map
adapter.SfincsAdapter.write_water_level_map(
scenario: Scenario,= None,
sim_path: Optional[Path] )
Read simulation results from SFINCS and saves a netcdf with the maximum water levels.