Skip to content

Commit

Permalink
Merge pull request #5916 from nilsvu/list_obs
Browse files Browse the repository at this point in the history
Print available observations in CLI
  • Loading branch information
knelli2 authored Apr 17, 2024
2 parents 52f20d7 + 1d2e381 commit b7c2426
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/Visualization/Python/OpenVolfiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,13 @@ def decorator(f):
)
+ (" Can be specified multiple times." if multiple_vars else ""),
)
@click.option(
"--list-observations",
"--list-times",
"list_times",
is_flag=True,
help="Print all available observation times and exit.",
)
@click.option(
"--step",
callback=parse_step,
Expand All @@ -140,6 +147,7 @@ def command(
subfile_name,
list_vars,
vars_patterns,
list_times,
step,
time,
**kwargs,
Expand All @@ -166,6 +174,17 @@ def command(
if not subfile_name.startswith("/"):
subfile_name = "/" + subfile_name

# Print available observations/times and exit
if list_times:
import rich.columns

all_obs_ids, all_obs_times = list_observations(
open_volfiles(h5_files, subfile_name)
)
rich.print(
rich.columns.Columns(f"{time:g}" for time in all_obs_times)
)
return
# Select observation
if step is None and time is None:
if obs_id_required:
Expand Down

0 comments on commit b7c2426

Please sign in to comment.