Skip to content

Commit

Permalink
create source/sink type attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
lily-tomkovic-DWR committed Dec 3, 2024
1 parent 391227e commit 907f1bd
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions schimpy/schism_sources_sinks.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,13 +410,14 @@ def yaml2df(source_yaml):
with open(source_yaml, 'r') as file:
source_sink = yaml.safe_load(file)
if {"sources", "sinks"} & source_sink.keys():
sites, x, y = [], [], []
sites, x, y, stype = [], [], [], []
for v in ["sources","sinks"]:
skeys = source_sink[v].keys()
skeys = list(skeys)
sites.extend(skeys)
a = [source_sink[v][k] for k in skeys]
a = np.array(a)
stype.extend([v] * len(skeys))
x.extend(a[:,0])
y.extend(a[:,1])
else:
Expand All @@ -426,7 +427,8 @@ def yaml2df(source_yaml):
a = np.array(a)
x = a[:,0]
y = a[:,1]
return pd.DataFrame({'sites': sites,'x':x,'y':y})
stype = None
return pd.DataFrame({'sites': sites,'x':x,'y':y,'stype':stype})

if __name__ == "__main__":
yaml_fn1 = 'source_sink.yaml'
Expand Down

0 comments on commit 907f1bd

Please sign in to comment.