Skip to content

Commit

Permalink
fix linestrings attribute/type behavior (backwards compatible)
Browse files Browse the repository at this point in the history
  • Loading branch information
lily-tomkovic-DWR committed Jan 3, 2024
1 parent e6e6d54 commit c4badb0
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions schimpy/schism_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ def apply_linestring_ops(self,default,linestrings):
name = linestring.get('Name')
npoint = len(line)
attribute = linestring.get("attribute")
#optype = linestring.get("type")
optype = linestring.get("type")
if attribute == 'local_min':
op = np.min
elif attribute == 'local_max':
Expand All @@ -544,6 +544,9 @@ def apply_linestring_ops(self,default,linestrings):
try:
opval=float(attribute)
op = lambda x: opval
# TODO: implement deprecation warning
# if optype is not None:
# raise Warning("Using type min/max for linestring depth enforcement will soon be deprecated. write the logic you'd like in the attribute field.")
except:
ValueError("Linestring attribute was not a known value (e.g. local_min, local_med) or a float")

Expand Down Expand Up @@ -574,7 +577,13 @@ def apply_linestring_ops(self,default,linestrings):
for inode in node_local_nds:
support_nodes = list(node_local_nds[inode])
orig = mesh.nodes[support_nodes,2]
valreplace=op(orig)
# TODO: implement deprecation warning, eventually delete the following if/elseif
if optype == "min":
valreplace=max(opval, mesh.nodes[inode,2])
elif optype == "max":
valreplace=min(opval, mesh.nodes[inode,2])
else:
valreplace=op(orig)
attr[inode]=valreplace
return attr

Expand Down

0 comments on commit c4badb0

Please sign in to comment.