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

added vertical datum to metadata #165

Open
wants to merge 1 commit into
base: FloodAdapt_ModelBuilders
Choose a base branch
from
Open
Show file tree
Hide file tree
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
24 changes: 24 additions & 0 deletions src/delftdashboard/toolboxes/modelmaker_sfincs_hmt/bathymetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,17 +134,30 @@ def add_dataset(*args):
if not src.nodata:
app.gui.window.dialog_warning("File does not have a nodata value")
return

if not src.crs:
app.gui.window.dialog_warning("File does not have a valid CRS")
return
else:
epsg = src.crs.to_epsg()

# Check if the vertical datum is explicitly mentioned in the files metadata
if src.tags().get('VERTICAL_CS'):
vdatum = src.tags()['VERTICAL_CS']
else:
vdatum, okay = app.gui.window.dialog_string("Provide a vertical datum for the dataset", "MSL")
if not okay:
# Cancel was clicked
return
Comment on lines +148 to +151
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we allow people to enter anything and validate that its an actual vdatum or maybe only select from a list of allowed vdatums?

Not sure about a solution, which ones to allow / how to get them. But allowing any str and not validating might break the app / data catalog when that dataset is used?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@roeldegoede is this an issue or should I just merge?


# ask for a name for the dataset
name, okay = app.gui.window.dialog_string("Provide a name for the dataset", "New dataset")
if not okay:
# Cancel was clicked
return

#TODO add nodata, crs, vertical_datum and name to single pop-up, where everything that is already known is filled in

# check whether the name already exists in the data catalog
while name in app.data_catalog.sources.keys():
name, okay = app.gui.window.dialog_string("Dataset name already exists. Provide a different name", "New dataset")
Expand All @@ -162,6 +175,7 @@ def add_dataset(*args):
meta:
category: topography
source: User
vertical_datum: {vdatum}
"""

# check if my_data_catalog.yml exists
Expand Down Expand Up @@ -316,6 +330,15 @@ def update():
app.gui.setvar(group, "selected_bathymetry_dataset_zmin", dataset["zmin"])
app.gui.setvar(group, "selected_bathymetry_dataset_zmax", dataset["zmax"])
app.gui.setvar(group, "selected_bathymetry_dataset_offset", dataset["offset"])

# set vdatum of the model
name = selected_names[0]
meta = app.data_catalog[name].meta

# check if vertical datum is defined in the metadata
if "vertical_datum" in meta:
value = meta["vertical_datum"]
app.gui.setvar(group, "selected_bathymetry_vdatum", value)
else:
app.gui.setvar(group, "selected_bathymetry_dataset_names", [])
app.gui.setvar(group, "selected_bathymetry_dataset_index", 0)
Expand All @@ -325,5 +348,6 @@ def update():
app.gui.setvar(group, "nr_selected_bathymetry_datasets", nrd)



def generate_bathymetry(*args):
app.toolbox["modelmaker_sfincs_hmt"].generate_bathymetry()
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ def __init__(self, name):

self.setup_dict = {}

# create "meta" entry in the setup_dict, this is not used in the model but can be used to store additional information
self.setup_dict["meta"] = {}

# Set GUI variable
group = "modelmaker_sfincs_hmt"

Expand Down Expand Up @@ -128,6 +131,7 @@ def __init__(self, name):
app.gui.setvar(group, "bathymetry_dataset_names", dataset_names)
app.gui.setvar(group, "bathymetry_dataset_index", 0)
app.gui.setvar(group, "selected_bathymetry_dataset_names", [])
app.gui.setvar(group, "selected_bathymetry_vdatum", "MSL")
app.gui.setvar(group, "selected_bathymetry_dataset_index", 0)
app.gui.setvar(group, "selected_bathymetry_dataset_meta", "")
app.gui.setvar(group, "selected_bathymetry_dataset_zmin", -99999.0)
Expand Down Expand Up @@ -448,6 +452,9 @@ def generate_bathymetry(self):
return
self.setup_dict.update({"setup_dep": setup_dep})

# add the vdatum to the metadata
self.setup_dict["meta"]["vertical_datum"] = app.gui.getvar(group, "selected_bathymetry_vdatum")

# show merged bathymetry on map
app.map.layer["sfincs_hmt"].layer["bed_levels"].update()

Expand Down