From 198e352c0425d5a484db4c375536d1fd8d650c9c Mon Sep 17 00:00:00 2001 From: roeldegoede Date: Wed, 28 Feb 2024 15:29:02 +0100 Subject: [PATCH] fixes for #109 (, #110) and #117 --- .../sfincs_hmt/boundary_conditions_dis.py | 158 ++++++++++++---- .../sfincs_hmt/boundary_conditions_wlev.py | 97 ++++++++-- .../config/boundary_conditions_dis.yml | 172 ++++++++++++++++-- .../config/boundary_conditions_wlev.yml | 115 ++++++++++-- .../sfincs_hmt/config/observation_points.yml | 2 +- .../models/sfincs_hmt/sfincs_hmt.py | 13 +- .../config/mask_boundary_cells.yml | 4 +- .../observation_stations.py | 14 ++ 8 files changed, 490 insertions(+), 85 deletions(-) diff --git a/src/delftdashboard/models/sfincs_hmt/boundary_conditions_dis.py b/src/delftdashboard/models/sfincs_hmt/boundary_conditions_dis.py index 4091781e..94f53c09 100644 --- a/src/delftdashboard/models/sfincs_hmt/boundary_conditions_dis.py +++ b/src/delftdashboard/models/sfincs_hmt/boundary_conditions_dis.py @@ -1,6 +1,6 @@ -import shapely -import pandas as pd import geopandas as gpd +import numpy as np +import pandas as pd from delftdashboard.app import app from delftdashboard.operations import map @@ -9,22 +9,43 @@ def select(*args): # Set all layer inactive, except discharge_points map.update() - app.map.layer["sfincs_hmt"].layer["discharge_points"].activate() app.map.layer["sfincs_hmt"].layer["mask"].activate() + app.map.layer["sfincs_hmt"].layer["discharge_points"].activate() update_list() def add_discharge_point(gdf, merge=True): model = app.model["sfincs_hmt"].domain - # add to existing discharge conditions - model.set_forcing_1d(gdf_locs=gdf, name="dis", merge=merge) - + nr_dis = 0 + if "dis" in model.forcing: + nr_dis = len(model.forcing["dis"].index) + try: + # add to existing discharge conditions + model.set_forcing_1d(gdf_locs=gdf, name="dis", merge=merge) + nr_dis_new = len(model.forcing["dis"].index) + if nr_dis_new > nr_dis: + app.gui.window.dialog_info( + text="Added {} discharge points".format(nr_dis_new - nr_dis), + title="Success", + ) + else: + app.gui.window.dialog_info( + text="No new discharge points added", + title="Failed", + ) + except ValueError as e: + app.gui.window.dialog_info( + text=e.args[0], + title="Error", + ) + return + # retrieve all discharge points as gdf from xarray gdf = model.forcing["dis"].vector.to_gdf() # get the last index of the gdf - index = int(gdf.index[-1]) + index = len(gdf.index) - 1 app.map.layer["sfincs_hmt"].layer["discharge_points"].set_data(gdf, index) app.gui.setvar("sfincs_hmt", "active_discharge_point", index) @@ -36,7 +57,6 @@ def add_discharge_point_on_map(*args): def point_clicked(x, y): - # Add point to discharge conditions model = app.model["sfincs_hmt"].domain # create gdf from xy @@ -44,33 +64,48 @@ def point_clicked(x, y): gdf = gpd.GeoDataFrame(geometry=geometry, crs=app.crs) if "dis" in model.forcing: - # make sure new point gets an index that doesnt exist in model.forcing["dis"] + # make sure new point gets an index that doesnt exist in model.forcing["bzs"] index = int(model.forcing["dis"].index[-1]) + 1 # set index of gdf gdf.index = [index] - # add to existing discharge conditions - model.set_forcing_1d(gdf_locs=gdf, name="dis", merge=True) + add_discharge_point(gdf) - # retrieve all discharge points as gdf from xarray - gdf = model.forcing["dis"].vector.to_gdf() +def load_from_file(*args): + """" Load discharge points from file """ + fname = app.gui.window.dialog_open_file( + "Select file with discharge points ...", + filter="*.geojson *.shp", + ) + if fname[0]: + # for .pol files we assume that they are in the coordinate system of the current map + gdf = app.model["sfincs_hmt"].domain.data_catalog.get_geodataframe(fname[0]) + gdf = gdf.to_crs(app.crs) - # get the last index of the gdf - index = int(gdf.index[-1]) - - app.map.layer["sfincs_hmt"].layer["discharge_points"].set_data(gdf, index) - app.gui.setvar("sfincs_hmt", "active_discharge_point", index) - update_list() + add_discharge_point(gdf) def select_discharge_point_from_list(*args): + model = app.model["sfincs_hmt"].domain index = app.gui.getvar("sfincs_hmt", "active_discharge_point") + + # get maximum values of the model + dis = model.forcing["dis"].values[:,index].max() + app.gui.setvar("sfincs_hmt", "bc_dis_value", dis) + app.map.layer["sfincs_hmt"].layer["discharge_points"].select_by_index(index) def select_discharge_point_from_map(*args): + model = app.model["sfincs_hmt"].domain + index = args[0]["id"] app.gui.setvar("sfincs_hmt", "active_discharge_point", index) + + # get maximum values of the model + dis = model.forcing["dis"].values[:,index].max() + app.gui.setvar("sfincs_hmt", "bc_dis_value", dis) + app.gui.window.update() @@ -79,7 +114,7 @@ def delete_point_from_list(*args): index = app.gui.getvar("sfincs_hmt", "active_discharge_point") # delete point from model forcing - model.forcing["dis"] = model.forcing["dis"].drop_sel(index=index) + model.forcing["dis"] = model.forcing["dis"].drop_isel(index=index) if len(model.forcing["dis"].index) == 0: # if no points are left, drop the forcing @@ -109,29 +144,88 @@ def update_list(): gdf = app.map.layer["sfincs_hmt"].layer["discharge_points"].data discharge_point_names = [] - if gdf is None: - index = 0 - else: + nr_points = 0 + if gdf is not None: # Loop through discharge points for index, row in gdf.iterrows(): + nr_points += 1 # Get the name of the discharge point if present - if "name" in row: + if "name" in row and not pd.isna(row["name"]): discharge_point_names.append(row["name"]) else: discharge_point_names.append("Point {}".format(index)) app.gui.setvar("sfincs_hmt", "discharge_point_names", discharge_point_names) - app.gui.setvar("sfincs_hmt", "nr_discharge_points", index) + app.gui.setvar("sfincs_hmt", "nr_discharge_points", nr_points) app.gui.window.update() +## Add timeseries to the boundary points + +def add_constant_discharge(*args): + """Add constant discahrge to the selected point.""" + index = app.gui.getvar("sfincs_hmt", "active_discharge_point") + value = app.gui.getvar("sfincs_hmt", "bc_dis_value") + + # get the model + model = app.model["sfincs_hmt"].domain + # convert start and stop time to seconds + tstart = model.config["tstart"] + tstop = model.config["tstop"] + + # make constant timeseries + duration = (tstop - tstart).total_seconds() + tt = np.arange(0, duration + 1, duration) + # values with same length as tt + ts = value * np.ones(len(tt)) -def go_to_observation_stations(*args): + # get forcing locations in the model + gdf_locs = model.forcing["dis"].vector.to_gdf() + model_index = gdf_locs.index[index] - toolbox_name = "observation_stations" + # convert to pandas dataframe + df_ts = pd.DataFrame({model_index: ts}, index=tt) + + # replace the boundary condition of the selected point + model.set_forcing_1d(df_ts = df_ts, name = "dis") + +def add_synthetical_discharge(*args): + """Add a guassian shaped discharge (based on peak and tstart/tstop) to selected point """ + index = app.gui.getvar("sfincs_hmt", "active_discharge_point") + value = app.gui.getvar("sfincs_hmt", "bc_dis_value") + + # get the model + model = app.model["sfincs_hmt"].domain + # convert start and stop time to seconds + tstart = model.config["tstart"] + tstop = model.config["tstop"] + + # make timeseries with gaussian peak + peak = value + duration = (tstop - tstart).total_seconds() + time_shift = 0.5 * duration # shift the peak to the middle of the duration + # TODO replace with: time_vec = pd.date_range(tstart, periods=duration / 600 + 1, freq="600S") + tt = np.arange(0, duration + 1, 600) + ts = peak * np.exp(-(((tt - time_shift) / (0.25 * duration)) ** 2)) + + # get forcing locations in the model + gdf_locs = model.forcing["dis"].vector.to_gdf() + model_index = gdf_locs.index[index] + + # convert to pandas dataframe + df_ts = pd.DataFrame({model_index: ts}, index=tt) + + # replace the boundary condition of the selected point + model.set_forcing_1d(df_ts = df_ts, name = "dis") + +def copy_to_all(*args): + """Copy the discharges of the selected station and copy to all boundary points.""" + index = app.gui.getvar("sfincs_hmt", "active_discharge_point") + + # get the model + model = app.model["sfincs_hmt"].domain - # switch to observation stations toolbox - app.active_toolbox = app.toolbox[toolbox_name] - app.active_toolbox.select() + # get the boundary conditions of this point + dis = model.forcing["dis"].isel(index=index) - # TODO back to observations model-tab - # app.active_toolbox.select_tab("observations") + # copy the boundary conditions to all other points + model.forcing["dis"][:] = dis diff --git a/src/delftdashboard/models/sfincs_hmt/boundary_conditions_wlev.py b/src/delftdashboard/models/sfincs_hmt/boundary_conditions_wlev.py index 0e8c3d10..3d89f6fd 100644 --- a/src/delftdashboard/models/sfincs_hmt/boundary_conditions_wlev.py +++ b/src/delftdashboard/models/sfincs_hmt/boundary_conditions_wlev.py @@ -8,6 +8,8 @@ from delftdashboard.operations import map from delftdashboard.toolboxes.observation_stations.observation_stations import Toolbox as ObservationStationsToolbox +import cht_observations.observation_stations as cht_station + def select(*args): # Set all layer inactive, except boundary_points map.update() @@ -74,7 +76,7 @@ def add_boundary_point(gdf, merge=True): gdf = model.forcing["bzs"].vector.to_gdf() # get the last index of the gdf - index = int(gdf.index[-1]) + index = len(gdf.index) - 1 app.map.layer["sfincs_hmt"].layer["boundary_points"].set_data(gdf, index) app.gui.setvar("sfincs_hmt", "active_boundary_point", index) @@ -86,7 +88,6 @@ def add_boundary_point_on_map(*args): def point_clicked(x, y): - # Add point to boundary conditions model = app.model["sfincs_hmt"].domain # create gdf from xy @@ -99,18 +100,21 @@ def point_clicked(x, y): # set index of gdf gdf.index = [index] - # add to existing boundary conditions - model.set_forcing_1d(gdf_locs=gdf, name="bzs", merge=True) + add_boundary_point(gdf) - # retrieve all boundary points as gdf from xarray - gdf = model.forcing["bzs"].vector.to_gdf() - # get the last index of the gdf - index = int(gdf.index[-1]) +def load_from_file(*args): + """" Load boundary points from file """ + fname = app.gui.window.dialog_open_file( + "Select file with boundary points ...", + filter="*.geojson *.shp", + ) + if fname[0]: + # for .pol files we assume that they are in the coordinate system of the current map + gdf = app.model["sfincs_hmt"].domain.data_catalog.get_geodataframe(fname[0]) + gdf = gdf.to_crs(app.crs) - app.map.layer["sfincs_hmt"].layer["boundary_points"].set_data(gdf, index) - app.gui.setvar("sfincs_hmt", "active_boundary_point", index) - update_list() + add_boundary_point(gdf) def select_boundary_point_from_list(*args): @@ -143,7 +147,7 @@ def delete_point_from_list(*args): index = app.gui.getvar("sfincs_hmt", "active_boundary_point") # delete point from model forcing - model.forcing["bzs"] = model.forcing["bzs"].drop_sel(index=index) + model.forcing["bzs"] = model.forcing["bzs"].drop_isel(index=index) if len(model.forcing["bzs"].index) == 0: # if no points are left, drop the forcing @@ -175,12 +179,11 @@ def update_list(): nr_points = 0 if gdf is not None: - # Loop through boundary points for index, row in gdf.iterrows(): nr_points += 1 # Get the name of the boundary point if present - if "name" in row: + if "name" in row and not pd.isna(row["name"]): boundary_point_names.append(row["name"]) else: boundary_point_names.append("Point {}".format(index)) @@ -239,7 +242,7 @@ def add_constant_water_level(*args): df_ts = pd.DataFrame({model_index: ts}, index=tt) # replace the boundary condition of the selected point - model.set_forcing_1d(df_ts = df_ts) + model.set_forcing_1d(df_ts = df_ts, name = "bzs") def add_synthetical_water_level(*args): """Add a guassian shaped water level (based on peak and tstart/tstop) to selected point """ @@ -258,7 +261,7 @@ def add_synthetical_water_level(*args): time_shift = 0.5 * duration # shift the peak to the middle of the duration # TODO replace with: time_vec = pd.date_range(tstart, periods=duration / 600 + 1, freq="600S") tt = np.arange(0, duration + 1, 600) - ts = peak * np.exp(-((tt - time_shift / (0.25 * duration)) ** 2)) + ts = peak * np.exp(-(((tt - time_shift) / (0.25 * duration)) ** 2)) # get forcing locations in the model gdf_locs = model.forcing["bzs"].vector.to_gdf() @@ -268,7 +271,7 @@ def add_synthetical_water_level(*args): df_ts = pd.DataFrame({model_index: ts}, index=tt) # replace the boundary condition of the selected point - model.set_forcing_1d(df_ts = df_ts) + model.set_forcing_1d(df_ts = df_ts, name = "bzs") def add_tidal_constituents(): """Retrieve tidal constituents and save them in a .bca-file.""" @@ -276,9 +279,63 @@ def add_tidal_constituents(): # use bca-files to generate tidal water levels pass -def download_water_level(): +def download_water_level(*args): """Download historical water levels from the API (if available) ... """ - pass + index = app.gui.getvar("sfincs_hmt", "active_boundary_point") + + # get the model + model = app.model["sfincs_hmt"].domain + + # get the active station + # get forcing locations in the model + gdf_locs = model.forcing["bzs"].vector.to_gdf() + model_index = gdf_locs.index[index] + + # check if source is available (for now only NOAA) + if "source" in gdf_locs: + source = gdf_locs.source[model_index] + else: + app.gui.window.dialog_info( + text="No API available to retreive timeseries for this boundary point", + title="Error", + ) + return + + if source == "noaa_coops": + # get the station_id + station_id = gdf_locs.id[model_index] + + # convert start and stop time to seconds + tstart = model.config["tstart"] + tstop = model.config["tstop"] + + # Get NOAA data + try: + source = cht_station.source(source) + df = source.get_data(station_id, tstart, tstop) + df = pd.DataFrame(df) # Convert series to dataframe + df_ts = df.rename(columns={"v": model_index}) + + # replace the boundary condition of the selected point + model.set_forcing_1d(df_ts = df_ts, name = "bzs") + + app.gui.window.dialog_info( + text="Downloaded water level timeseries from NOAA for station {}".format(station_id), + title="Success", + ) + return + except Exception as e: + app.gui.window.dialog_info( + text=e.args[0], + title="Error", + ) + return + else: + app.gui.window.dialog_info( + text="No API available to retreive timeseries for this boundary point", + title="Error", + ) + return def copy_to_all(*args): """Copy the water levels of the selected station and copy to all boundary points.""" @@ -288,7 +345,7 @@ def copy_to_all(*args): model = app.model["sfincs_hmt"].domain # get the boundary conditions of this point - bzs = model.forcing["bzs"].sel(index=index) + bzs = model.forcing["bzs"].isel(index=index) # copy the boundary conditions to all other points model.forcing["bzs"][:] = bzs diff --git a/src/delftdashboard/models/sfincs_hmt/config/boundary_conditions_dis.yml b/src/delftdashboard/models/sfincs_hmt/config/boundary_conditions_dis.yml index 3be88bf3..cd000c77 100644 --- a/src/delftdashboard/models/sfincs_hmt/config/boundary_conditions_dis.yml +++ b/src/delftdashboard/models/sfincs_hmt/config/boundary_conditions_dis.yml @@ -80,7 +80,7 @@ element: y: 90 width: 180 height: 20 - method: load_discharge_points_from_file + method: load_from_file tooltip: Load discharge points from file - style: panel title: Add timeseries @@ -97,16 +97,142 @@ element: operator: ge value: 1 element: + - style: popupmenu + position: + x: 10 + y: 90 + width: 180 + height: 20 + select: index + tooltip: Select method to specify timeseries + variable: bc_dis_timeseries_methods_index + option_string: + variable: bc_dis_timeseries_methods + - style: text + text: "Constant discharge (m3/s): " + position: + x: 10 + y: 65 + width: 100 + height: 20 + dependency: + - action: visible + checkfor: any + check: + - variable: bc_dis_timeseries_methods_index + operator: eq + value: 0 - style: edit - text: Constant discharge (m3/s) position: x: -10 - y: 90 - width: 45 + y: 65 + width: 60 + height: 20 + tooltip: Specify constant discharge + variable: bc_dis_value + dependency: + - action: visible + checkfor: any + check: + - variable: bc_dis_timeseries_methods_index + operator: eq + value: 0 + - style: pushbutton + text: Add + position: + x: -10 + y: 40 + width: 60 height: 20 - tooltip: Add constant discharge + method: add_constant_discharge + tooltip: Add timeseries + dependency: + - action: visible + checkfor: any + check: + - variable: bc_dis_timeseries_methods_index + operator: eq + value: 0 + - style: text + text: "Peak discharge (m3/s): " + position: + x: 10 + y: 65 + width: 100 + height: 20 + dependency: + - action: visible + checkfor: any + check: + - variable: bc_dis_timeseries_methods_index + operator: eq + value: 1 + - style: edit + position: + x: -10 + y: 65 + width: 60 + height: 20 + tooltip: Specify peak discharge for Guassian shaped timeseries + variable: bc_dis_value + dependency: + - action: visible + checkfor: any + check: + - variable: bc_dis_timeseries_methods_index + operator: eq + value: 1 + - style: pushbutton + text: Add + position: + x: -10 + y: 40 + width: 60 + height: 20 + method: add_synthetical_discharge + tooltip: Add timeseries + dependency: + - action: visible + checkfor: any + check: + - variable: bc_dis_timeseries_methods_index + operator: eq + value: 1 + - style: pushbutton + position: + x: -10 + y: 10 + width: 85 + height: 20 + text: Copy to All + method: copy_to_all + tooltip: Copy timeseries to all points + dependency: + - action: enable + checkfor: any + check: + - variable: nr_boundary_points + operator: gt + value: 1 + - style: pushbutton + position: + x: 10 + y: 10 + width: 85 + height: 20 + text: Visualize + method: show_timeseries + tooltip: "NOT YET IMPLEMENTED: Visualize timeseries for all points" + enable: False + # dependency: + # - action: enable + # checkfor: any + # check: + # - variable: nr_boundary_points + # operator: gt + # value: 1 - style: text - text: "discharge points: " + text: "Discharge points: " position: x: -10 y: 125 @@ -115,9 +241,9 @@ element: - style: listbox position: x: -10 - y: 40 + y: 45 width: 120 - height: 80 + height: 75 method: select_discharge_point_from_list variable: active_discharge_point select: index @@ -125,10 +251,34 @@ element: variable: discharge_point_names tooltip: Select discharge point - style: pushbutton - text: Delete all + text: Delete All position: x: -10 - y: 10 + y: 5 width: 120 - height: 20 + height: 15 method: delete_all_points_from_list + tooltip: Delete all discharge points + dependency: + - action: enable + checkfor: all + check: + - variable: nr_discharge_points + operator: gt + value: 0 +- style: pushbutton + text: Delete Point + position: + x: -10 + y: 25 + width: 120 + height: 15 + method: delete_point_from_list + tooltip: Delete discharge point from model + dependency: + - action: enable + checkfor: all + check: + - variable: nr_discharge_points + operator: gt + value: 0 \ No newline at end of file diff --git a/src/delftdashboard/models/sfincs_hmt/config/boundary_conditions_wlev.yml b/src/delftdashboard/models/sfincs_hmt/config/boundary_conditions_wlev.yml index cb75dfda..844d9ede 100644 --- a/src/delftdashboard/models/sfincs_hmt/config/boundary_conditions_wlev.yml +++ b/src/delftdashboard/models/sfincs_hmt/config/boundary_conditions_wlev.yml @@ -153,7 +153,7 @@ element: y: 90 width: 180 height: 20 - method: load_boundary_points_from_file + method: load_from_file tooltip: Load boundary points from file - style: panel title: Add timeseries @@ -181,15 +181,27 @@ element: variable: bc_wlev_timeseries_methods_index option_string: variable: bc_wlev_timeseries_methods + - style: text + text: "Constant water level (m+Ref): " + position: + x: 10 + y: 65 + width: 100 + height: 20 + dependency: + - action: visible + checkfor: any + check: + - variable: bc_wlev_timeseries_methods_index + operator: eq + value: 0 - style: edit - text: Constant water level position: x: -10 y: 65 - width: 45 + width: 60 height: 20 tooltip: Specify constant water level - # method: add_constant_water_level variable: bc_wlev_value dependency: - action: visible @@ -203,7 +215,7 @@ element: position: x: -10 y: 40 - width: 45 + width: 60 height: 20 method: add_constant_water_level tooltip: Add timeseries @@ -214,15 +226,27 @@ element: - variable: bc_wlev_timeseries_methods_index operator: eq value: 0 + - style: text + text: "Peak water level (m+Ref): " + position: + x: 10 + y: 65 + width: 100 + height: 20 + dependency: + - action: visible + checkfor: any + check: + - variable: bc_wlev_timeseries_methods_index + operator: eq + value: 1 - style: edit - text: Peak water level position: x: -10 y: 65 - width: 45 + width: 60 height: 20 - tooltip: Specify peak water level - # method: add_constant_water_level + tooltip: Specify peak water level for Guassian shaped timeseries variable: bc_wlev_value dependency: - action: visible @@ -236,7 +260,7 @@ element: position: x: -10 y: 40 - width: 45 + width: 60 height: 20 method: add_synthetical_water_level tooltip: Add timeseries @@ -248,12 +272,28 @@ element: operator: eq value: 1 - style: pushbutton + text: Download position: x: 10 - y: 10 + y: 65 width: 180 height: 20 - text: Copy to all points + tooltip: Download timeseries from database + method: download_water_level + dependency: + - action: visible + checkfor: any + check: + - variable: bc_wlev_timeseries_methods_index + operator: eq + value: 2 + - style: pushbutton + position: + x: -10 + y: 10 + width: 85 + height: 20 + text: Copy to All method: copy_to_all tooltip: Copy timeseries to all points dependency: @@ -263,6 +303,23 @@ element: - variable: nr_boundary_points operator: gt value: 1 + - style: pushbutton + position: + x: 10 + y: 10 + width: 85 + height: 20 + text: Visualize + method: show_timeseries + tooltip: "NOT YET IMPLEMENTED: Visualize timeseries for all points" + enable: False + # dependency: + # - action: enable + # checkfor: any + # check: + # - variable: nr_boundary_points + # operator: gt + # value: 1 - style: text text: "Boundary points: " position: @@ -273,9 +330,9 @@ element: - style: listbox position: x: -10 - y: 40 + y: 45 width: 120 - height: 80 + height: 75 method: select_boundary_point_from_list variable: active_boundary_point select: index @@ -283,10 +340,34 @@ element: variable: boundary_point_names tooltip: Select boundary point - style: pushbutton - text: Delete all + text: Delete All position: x: -10 - y: 10 + y: 5 width: 120 - height: 20 + height: 15 method: delete_all_points_from_list + tooltip: Delete all boundary points + dependency: + - action: enable + checkfor: all + check: + - variable: nr_boundary_points + operator: gt + value: 0 +- style: pushbutton + text: Delete Point + position: + x: -10 + y: 25 + width: 120 + height: 15 + method: delete_point_from_list + tooltip: Delete boundary point from model + dependency: + - action: enable + checkfor: all + check: + - variable: nr_boundary_points + operator: gt + value: 0 \ No newline at end of file diff --git a/src/delftdashboard/models/sfincs_hmt/config/observation_points.yml b/src/delftdashboard/models/sfincs_hmt/config/observation_points.yml index 18f48057..e8ce28f1 100644 --- a/src/delftdashboard/models/sfincs_hmt/config/observation_points.yml +++ b/src/delftdashboard/models/sfincs_hmt/config/observation_points.yml @@ -57,7 +57,7 @@ element: y: 60 width: 130 height: 20 - method: load_observation_points_from_file + method: load tooltip: Load observation points from file dependency: - action: visible diff --git a/src/delftdashboard/models/sfincs_hmt/sfincs_hmt.py b/src/delftdashboard/models/sfincs_hmt/sfincs_hmt.py index d4012bf3..2643ea1e 100644 --- a/src/delftdashboard/models/sfincs_hmt/sfincs_hmt.py +++ b/src/delftdashboard/models/sfincs_hmt/sfincs_hmt.py @@ -211,9 +211,9 @@ def set_gui_variables(self): app.gui.setvar(group, "meteo_forcing_type", "uniform") # Boundary conditions - # methods + # Waterlevel boundary methods bc_wlev_methods = ["Click Points", "Generate along Boundary", "Select from Database", "Load from File"] - bc_wlev_timeseries_methods = ["Constant", "Synthetic", "Download"] + bc_wlev_timeseries_methods = ["Constant timeseries", "Guassian timeseries", "Download from database"] app.gui.setvar(group, "bc_wlev_methods", bc_wlev_methods) app.gui.setvar(group, "bc_wlev_methods_index", 0) app.gui.setvar(group, "bc_wlev_timeseries_methods", bc_wlev_timeseries_methods) @@ -229,10 +229,19 @@ def set_gui_variables(self): app.gui.setvar(group, "nr_boundary_points", 0) app.gui.setvar(group, "active_boundary_point", 0) + # Discharge methods bc_dis_methods = ["Click Points", "Load from File"] + bc_dis_timeseries_methods = ["Constant timeseries", "Guassian timeseries"] app.gui.setvar(group, "bc_dis_methods", bc_dis_methods) app.gui.setvar(group, "bc_dis_methods_index", 0) + app.gui.setvar(group, "bc_dis_timeseries_methods", bc_dis_timeseries_methods) + app.gui.setvar(group, "bc_dis_timeseries_methods_index", 0) + + # values + app.gui.setvar(group, "bc_dis_value", 0.0) app.gui.setvar(group, "merge_bc_dis", True) + + # gui settings app.gui.setvar(group, "discharge_point_names", []) app.gui.setvar(group, "nr_discharge_points", 0) app.gui.setvar(group, "active_discharge_point", 0) diff --git a/src/delftdashboard/toolboxes/modelmaker_sfincs_hmt/config/mask_boundary_cells.yml b/src/delftdashboard/toolboxes/modelmaker_sfincs_hmt/config/mask_boundary_cells.yml index db4af7a4..ddc60262 100644 --- a/src/delftdashboard/toolboxes/modelmaker_sfincs_hmt/config/mask_boundary_cells.yml +++ b/src/delftdashboard/toolboxes/modelmaker_sfincs_hmt/config/mask_boundary_cells.yml @@ -98,7 +98,7 @@ element: y: 90 width: 45 height: 20 - text: "Restrict to cells with a maximum elevation of (in m+MSL): " + text: "Restrict to cells with a maximum elevation of (in m+Ref): " text_position: left variable: wlev_zmax - style: panel @@ -166,7 +166,7 @@ element: y: 90 width: 45 height: 20 - text: "Restrict to cells with a minimum elevation of (in m+MSL): " + text: "Restrict to cells with a minimum elevation of (in m+Ref): " text_position: left variable: outflow_zmin diff --git a/src/delftdashboard/toolboxes/observation_stations/observation_stations.py b/src/delftdashboard/toolboxes/observation_stations/observation_stations.py index 73430262..6b5fe697 100644 --- a/src/delftdashboard/toolboxes/observation_stations/observation_stations.py +++ b/src/delftdashboard/toolboxes/observation_stations/observation_stations.py @@ -110,6 +110,13 @@ def add_stations_to_model(self, model_option="obs"): index = app.gui.getvar("observation_stations", "active_station_index") gdf = self.gdf.iloc[[index]] + # drop index column if it exists + if "index" in gdf.columns: + gdf = gdf.drop(columns=["index"]) + + # add source to gdf + gdf["source"] = list(self.sources.keys())[app.gui.getvar("observation_stations", "active_source_index")] + app.active_model.add_stations(gdf, naming_option=app.gui.getvar("observation_stations", "naming_option"), model_option=model_option) @@ -130,6 +137,13 @@ def add_all_stations_to_model(self, model_option): # only keep stations within model extent gdf = gpd.sjoin(gdf.to_crs(gdf_model.crs), gdf_model, op='within') + # drop index column if it exists + if "index" in gdf.columns: + gdf = gdf.drop(columns=["index"]) + + # add source to gdf + gdf["source"] = list(self.sources.keys())[app.gui.getvar("observation_stations", "active_source_index")] + app.active_model.add_stations(gdf, naming_option=app.gui.getvar("observation_stations", "naming_option"), model_option=model_option)