Skip to content

Commit 915c00f

Browse files
committedApr 19, 2025
attempt to config schism output from yaml files
1 parent c9fb7f1 commit 915c00f

File tree

1 file changed

+40
-8
lines changed

1 file changed

+40
-8
lines changed
 

‎pydelmod/schismui.py

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ def get_map_marker_columns(self):
173173

174174

175175
import click
176+
import yaml
176177

177178

178179
@click.command()
@@ -195,6 +196,7 @@ def get_map_marker_columns(self):
195196
)
196197
@click.option("--flux_out", default="flux.out", help="Path to the flux.out file")
197198
@click.option("--reftime", default="2020-01-01", help="Reference time")
199+
@click.option("--yaml_file", default=None, help="Path to the yaml file")
198200
def show_schism_output_ui(
199201
schism_dir=".",
200202
flux_xsect_file="flow_station_xsects.yaml",
@@ -203,19 +205,49 @@ def show_schism_output_ui(
203205
reftime="2020-01-01",
204206
repo_dir="screened",
205207
inventory_file="inventory_datasets.csv",
208+
yaml_file=None,
206209
):
207-
study = schismstudy.SchismStudy(
208-
schism_dir,
209-
flux_xsect_file=flux_xsect_file,
210-
station_in_file=station_in_file,
211-
flux_out=flux_out,
212-
reftime=reftime,
213-
)
210+
if yaml_file:
211+
# Load the YAML file and create multiple studies
212+
with open(yaml_file, "r") as file:
213+
yaml_data = yaml.safe_load(file)
214+
215+
studies = []
216+
for study_config in yaml_data.get("schism_studies", []):
217+
studies.append(
218+
schismstudy.SchismStudy(
219+
base_dir=study_config["base_dir"],
220+
flux_xsect_file=study_config.get(
221+
"flux_xsect_file", "flow_station_xsects.yaml"
222+
),
223+
station_in_file=study_config.get("station_in_file", "station.in"),
224+
flux_out=study_config.get("flux_out", "flux.out"),
225+
reftime=study_config.get("reftime", "2020-01-01"),
226+
**study_config.get("additional_parameters", {}),
227+
)
228+
)
229+
else:
230+
# Create a single study if no YAML file is provided
231+
studies = [
232+
schismstudy.SchismStudy(
233+
schism_dir,
234+
flux_xsect_file=flux_xsect_file,
235+
station_in_file=station_in_file,
236+
flux_out=flux_out,
237+
reftime=reftime,
238+
)
239+
]
240+
241+
# Create the datastore
214242
ds = datastore.StationDatastore(repo_dir=repo_dir, inventory_file=inventory_file)
243+
244+
# Define the time range
215245
time_range = (pd.Timestamp(reftime), pd.Timestamp(reftime) + pd.Timedelta(days=250))
246+
247+
# Create the UI
216248
ui = DataUI(
217249
SchismOutputUIDataManager(
218-
study,
250+
*studies,
219251
datastore=ds,
220252
time_range=time_range,
221253
),

0 commit comments

Comments
 (0)