Skip to content

Commit 64257b4

Browse files
sbryngelsonclaude
andcommitted
viz: limit rendering/slice CLI opts to --png/--mp4 only
TUI and interactive modes have their own UI controls for colormap, vmin/vmax, log scale, and slice position, so those CLI flags are only needed for batch rendering. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent d1ccb3d commit 64257b4

2 files changed

Lines changed: 39 additions & 39 deletions

File tree

toolchain/mfc/cli/commands.py

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -935,7 +935,7 @@
935935
),
936936
Argument(
937937
name="cmap",
938-
help="Matplotlib colormap name (--interactive, --png, --mp4).",
938+
help="Matplotlib colormap name (--png, --mp4 only).",
939939
type=str,
940940
default='viridis',
941941
metavar="CMAP",
@@ -967,14 +967,14 @@
967967
),
968968
Argument(
969969
name="vmin",
970-
help="Minimum value for color scale (--interactive, --png, --mp4).",
970+
help="Minimum value for color scale (--png, --mp4 only).",
971971
type=float,
972972
default=None,
973973
metavar="VMIN",
974974
),
975975
Argument(
976976
name="vmax",
977-
help="Maximum value for color scale (--interactive, --png, --mp4).",
977+
help="Maximum value for color scale (--png, --mp4 only).",
978978
type=float,
979979
default=None,
980980
metavar="VMAX",
@@ -988,7 +988,7 @@
988988
),
989989
Argument(
990990
name="slice-axis",
991-
help="Axis for 3D slice (--interactive, --png, --mp4).",
991+
help="Axis for 3D slice (--png, --mp4 only).",
992992
type=str,
993993
default='z',
994994
choices=["x", "y", "z"],
@@ -997,15 +997,15 @@
997997
),
998998
Argument(
999999
name="slice-value",
1000-
help="Coordinate value at which to take the 3D slice (--interactive, --png, --mp4).",
1000+
help="Coordinate value at which to take the 3D slice (--png, --mp4 only).",
10011001
type=float,
10021002
default=None,
10031003
dest="slice_value",
10041004
metavar="VAL",
10051005
),
10061006
Argument(
10071007
name="slice-index",
1008-
help="Array index at which to take the 3D slice (--interactive, --png, --mp4).",
1008+
help="Array index at which to take the 3D slice (--png, --mp4 only).",
10091009
type=int,
10101010
default=None,
10111011
dest="slice_index",
@@ -1040,7 +1040,7 @@
10401040
),
10411041
Argument(
10421042
name="log-scale",
1043-
help="Logarithmic color/y scale (--interactive, --png, --mp4).",
1043+
help="Logarithmic color/y scale (--png, --mp4 only).",
10441044
action=ArgAction.STORE_TRUE,
10451045
default=False,
10461046
dest="log_scale",
@@ -1102,20 +1102,21 @@
11021102
("--interactive / -i", "Dash web UI (1D/2D/3D, needs browser or SSH tunnel)"),
11031103
("--png", "Save PNG image(s) to case_dir/viz/"),
11041104
("--mp4", "Encode frames into an MP4 video"),
1105-
("-- Appearance (--interactive, --png, --mp4) --", ""),
1105+
("-- Rendering (--png, --mp4 only) --", ""),
11061106
("--cmap NAME", "Matplotlib colormap (default: viridis)"),
11071107
("--vmin / --vmax", "Fix color-scale limits"),
11081108
("--log-scale", "Logarithmic color/y axis"),
1109-
("--dpi N", "Image resolution for --png/--mp4 (default: 150)"),
1110-
("-- 3D slicing (--interactive, --png, --mp4) --", ""),
1109+
("--dpi N", "Image resolution (default: 150)"),
1110+
("-o, --output DIR", "Output directory (default: case_dir/viz/)"),
1111+
("-- 3D slicing (--png, --mp4 only) --", ""),
11111112
("--slice-axis x|y|z", "Plane to slice (default: z midplane)"),
11121113
("--slice-value VAL", "Slice at coordinate value"),
11131114
("--slice-index IDX", "Slice at array index"),
1114-
("-- Mode-specific --", ""),
1115-
("-o, --output DIR", "Output directory for --png/--mp4 (default: case_dir/viz/)"),
1116-
("--fps N", "Frames per second for --mp4 (default: 10)"),
1117-
("--port PORT", "Web server port for --interactive (default: 8050)"),
1118-
("--host HOST", "Bind address for --interactive (default: 127.0.0.1)"),
1115+
("-- --mp4 only --", ""),
1116+
("--fps N", "Frames per second (default: 10)"),
1117+
("-- --interactive only --", ""),
1118+
("--port PORT", "Web server port (default: 8050)"),
1119+
("--host HOST", "Bind address (default: 127.0.0.1)"),
11191120
],
11201121
)
11211122

toolchain/mfc/viz/viz.py

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -287,25 +287,6 @@ def viz(): # pylint: disable=too-many-locals,too-many-statements,too-many-branc
287287
f"No matching timesteps for --step {step_arg!r}{detail}. "
288288
f"Available steps: {_steps_hint(steps)}")
289289

290-
# Collect rendering options
291-
render_opts = {
292-
'cmap': ARG('cmap'),
293-
'dpi': ARG('dpi'),
294-
'slice_axis': ARG('slice_axis'),
295-
}
296-
if ARG('vmin') is not None:
297-
render_opts['vmin'] = float(ARG('vmin'))
298-
if ARG('vmax') is not None:
299-
render_opts['vmax'] = float(ARG('vmax'))
300-
if ARG('log_scale'):
301-
render_opts['log_scale'] = True
302-
if ARG('slice_index') is not None and ARG('slice_value') is not None:
303-
raise MFCException("--slice-index and --slice-value are mutually exclusive.")
304-
if ARG('slice_index') is not None:
305-
render_opts['slice_index'] = int(ARG('slice_index'))
306-
if ARG('slice_value') is not None:
307-
render_opts['slice_value'] = float(ARG('slice_value'))
308-
309290
interactive = ARG('interactive')
310291

311292
# Lagrange bubble overlay: auto-detect D/lag_bubble_evol_*.dat files
@@ -364,11 +345,6 @@ def read_step(step):
364345
f"Use --list-vars to see variables at a given step."
365346
)
366347

367-
# Validate colormap early so all modes get a clean error for bad --cmap
368-
cmap_name = ARG('cmap')
369-
if cmap_name:
370-
_validate_cmap(cmap_name)
371-
372348
# TUI mode — launch Textual terminal UI (1D/2D only)
373349
if use_tui:
374350
if test_assembled.ndim == 3:
@@ -394,6 +370,29 @@ def read_step(step):
394370
bubble_func=bubble_func)
395371
return
396372

373+
# --- PNG / MP4 rendering options (not used by TUI or interactive) ---
374+
render_opts = {
375+
'cmap': ARG('cmap'),
376+
'dpi': ARG('dpi'),
377+
'slice_axis': ARG('slice_axis'),
378+
}
379+
if ARG('vmin') is not None:
380+
render_opts['vmin'] = float(ARG('vmin'))
381+
if ARG('vmax') is not None:
382+
render_opts['vmax'] = float(ARG('vmax'))
383+
if ARG('log_scale'):
384+
render_opts['log_scale'] = True
385+
if ARG('slice_index') is not None and ARG('slice_value') is not None:
386+
raise MFCException("--slice-index and --slice-value are mutually exclusive.")
387+
if ARG('slice_index') is not None:
388+
render_opts['slice_index'] = int(ARG('slice_index'))
389+
if ARG('slice_value') is not None:
390+
render_opts['slice_value'] = float(ARG('slice_value'))
391+
392+
cmap_name = ARG('cmap')
393+
if cmap_name:
394+
_validate_cmap(cmap_name)
395+
397396
# Create output directory
398397
output_base = ARG('output')
399398
if output_base is None:

0 commit comments

Comments
 (0)