@@ -21,7 +21,7 @@ def __init__(self, *studies, datastore=None, time_range=None, **kwargs):
21
21
This is merged with the data catalog to get the station locations.
22
22
"""
23
23
self .studies = studies
24
- self .study_dir_map = {str (s .base_dir ): s for s in self .studies }
24
+ self .study_dir_map = {str (s .output_dir ): s for s in self .studies }
25
25
self .datastore = datastore
26
26
self .catalog = self ._merge_catalogs (self .studies , self .datastore )
27
27
self .catalog ["filename" ] = self .catalog ["filename" ].astype (str )
@@ -195,18 +195,47 @@ def get_map_marker_columns(self):
195
195
"--station_in_file" , default = "station.in" , help = "Path to the station.in file"
196
196
)
197
197
@click .option ("--flux_out" , default = "flux.out" , help = "Path to the flux.out file" )
198
- @click .option ("--reftime" , default = "2020-01-01" , help = "Reference time" )
198
+ @click .option ("--reftime" , default = None , help = "Reference time" )
199
199
@click .option ("--yaml_file" , default = None , help = "Path to the yaml file" )
200
200
def show_schism_output_ui (
201
201
schism_dir = "." ,
202
202
flux_xsect_file = "flow_station_xsects.yaml" ,
203
203
station_in_file = "station.in" ,
204
204
flux_out = "flux.out" ,
205
- reftime = "2020-01-01" ,
205
+ reftime = None ,
206
206
repo_dir = "screened" ,
207
207
inventory_file = "inventory_datasets.csv" ,
208
208
yaml_file = None ,
209
209
):
210
+ """
211
+ Shows Data UI for SCHISM output files.
212
+
213
+ This function creates a Data UI for SCHISM output files, allowing users to visualize and analyze the data.
214
+ It can handle multiple studies and datasets, and provides options for customizing the display.
215
+ The function can be run from the command line or imported as a module.
216
+
217
+ If a YAML file is provided, it will be used to create multiple studies.
218
+ Otherwise, a single study will be created using the provided parameters.
219
+
220
+ Example YAML file::
221
+
222
+ .. code-block:: yaml
223
+ \b
224
+ schism_studies:
225
+ - label: Study1
226
+ base_dir: "study1_directory"
227
+ flux_xsect_file: "study1_flow_station_xsects.yaml"
228
+ station_in_file: "study1_station.in"
229
+ output_dir: "outputs"
230
+ param_nml_file: "param.nml"
231
+ flux_out: "study1_flux.out"
232
+ reftime: "2020-01-01"
233
+ - label: Study2
234
+ base_dir: "study2_directory"
235
+ datastore:
236
+ repo_dir: /repo/continuous/screened
237
+ inventory_file: "inventory_datasets.csv"
238
+ """
210
239
if yaml_file :
211
240
# Load the YAML file and create multiple studies
212
241
with open (yaml_file , "r" ) as file :
@@ -217,15 +246,21 @@ def show_schism_output_ui(
217
246
studies .append (
218
247
schismstudy .SchismStudy (
219
248
base_dir = study_config ["base_dir" ],
249
+ output_dir = study_config .get ("output_dir" , "outputs" ),
250
+ param_nml_file = study_config .get ("param_nml_file" , "param.nml" ),
220
251
flux_xsect_file = study_config .get (
221
252
"flux_xsect_file" , "flow_station_xsects.yaml"
222
253
),
223
254
station_in_file = study_config .get ("station_in_file" , "station.in" ),
224
255
flux_out = study_config .get ("flux_out" , "flux.out" ),
225
- reftime = study_config . get ( " reftime" , "2020-01-01" ) ,
256
+ reftime = reftime ,
226
257
** study_config .get ("additional_parameters" , {}),
227
258
)
228
259
)
260
+
261
+ datastore_config = yaml_data .get ("datastore" , {})
262
+ repo_dir = datastore_config .get ("repo_dir" , repo_dir )
263
+ inventory_file = datastore_config .get ("inventory_file" , inventory_file )
229
264
else :
230
265
# Create a single study if no YAML file is provided
231
266
studies = [
@@ -238,12 +273,17 @@ def show_schism_output_ui(
238
273
)
239
274
]
240
275
276
+ # study.reftime to study.endtime is the range of a single study
277
+ # Initialize the union range
278
+ union_start = min (study .reftime for study in studies )
279
+ union_end = max (study .endtime for study in studies )
280
+
281
+ # Create the union range as a single variable
282
+ time_range = (union_start , union_end )
283
+
241
284
# Create the datastore
242
285
ds = datastore .StationDatastore (repo_dir = repo_dir , inventory_file = inventory_file )
243
286
244
- # Define the time range
245
- time_range = (pd .Timestamp (reftime ), pd .Timestamp (reftime ) + pd .Timedelta (days = 250 ))
246
-
247
287
# Create the UI
248
288
ui = DataUI (
249
289
SchismOutputUIDataManager (
0 commit comments