@@ -73,28 +73,6 @@ def viz(): # pylint: disable=too-many-locals,too-many-statements,too-many-branc
7373
7474 cons .print (f"[bold]Format:[/bold] { fmt } " )
7575
76- # Quick guide when no action is specified
77- no_action = (not ARG ('list_steps' ) and not ARG ('list_vars' )
78- and ARG ('var' ) is None and ARG ('step' ) is None
79- and not ARG ('interactive' ) and not ARG ('tui' ))
80- if no_action :
81- cons .print ()
82- d = case_dir
83- cons .print ("[bold]Quick start:[/bold]" )
84- cons .print (f" [green]./mfc.sh viz { d } --list-steps[/green]"
85- " [dim]see available timesteps[/dim]" )
86- cons .print (f" [green]./mfc.sh viz { d } --list-vars --step 0[/green]"
87- " [dim]see available variables[/dim]" )
88- cons .print (f" [green]./mfc.sh viz { d } --var pres --step last[/green]"
89- " [dim]render a PNG[/dim]" )
90- cons .print (f" [green]./mfc.sh viz { d } --var pres --step all --mp4[/green]"
91- " [dim]render an MP4[/dim]" )
92- cons .print (f" [green]./mfc.sh viz { d } --var pres --step 0 --slice-axis z[/green]"
93- " [dim]3D midplane slice[/dim]" )
94- cons .print ()
95- cons .print ("[dim]Run [bold]./mfc.sh viz --help[/bold] for all options.[/dim]" )
96- return
97-
9876 # Handle --list-steps
9977 if ARG ('list_steps' ):
10078 steps = discover_timesteps (case_dir , fmt )
@@ -155,12 +133,8 @@ def viz(): # pylint: disable=too-many-locals,too-many-statements,too-many-branc
155133 step_arg = ARG ('step' )
156134 tiled = varname is None or varname == 'all'
157135
158- if step_arg is None :
159- if ARG ('interactive' ) or ARG ('tui' ):
160- step_arg = 'all' # default to all steps in interactive/TUI mode
161- else :
162- raise MFCException ("--step is required for rendering. "
163- "Use --list-steps to see available timesteps, or pass --step all." )
136+ if ARG ('interactive' ) or ARG ('tui' ):
137+ step_arg = 'all' # always load all steps in interactive/TUI mode
164138
165139 steps = discover_timesteps (case_dir , fmt )
166140 if not steps :
@@ -174,31 +148,21 @@ def viz(): # pylint: disable=too-many-locals,too-many-statements,too-many-branc
174148 raise MFCException (msg )
175149
176150 # Collect rendering options
177- render_opts = {}
178- cmap = ARG ('cmap' )
179- if cmap :
180- render_opts ['cmap' ] = cmap
181- vmin = ARG ('vmin' )
182- if vmin is not None :
183- render_opts ['vmin' ] = float (vmin )
184- vmax = ARG ('vmax' )
185- if vmax is not None :
186- render_opts ['vmax' ] = float (vmax )
187- dpi = ARG ('dpi' )
188- if dpi is not None :
189- render_opts ['dpi' ] = int (dpi )
151+ render_opts = {
152+ 'cmap' : ARG ('cmap' ),
153+ 'dpi' : ARG ('dpi' ),
154+ 'slice_axis' : ARG ('slice_axis' ),
155+ }
156+ if ARG ('vmin' ) is not None :
157+ render_opts ['vmin' ] = float (ARG ('vmin' ))
158+ if ARG ('vmax' ) is not None :
159+ render_opts ['vmax' ] = float (ARG ('vmax' ))
190160 if ARG ('log_scale' ):
191161 render_opts ['log_scale' ] = True
192-
193- slice_axis = ARG ('slice_axis' )
194- slice_index = ARG ('slice_index' )
195- slice_value = ARG ('slice_value' )
196- if slice_axis :
197- render_opts ['slice_axis' ] = slice_axis
198- if slice_index is not None :
199- render_opts ['slice_index' ] = int (slice_index )
200- if slice_value is not None :
201- render_opts ['slice_value' ] = float (slice_value )
162+ if ARG ('slice_index' ) is not None :
163+ render_opts ['slice_index' ] = int (ARG ('slice_index' ))
164+ if ARG ('slice_value' ) is not None :
165+ render_opts ['slice_value' ] = float (ARG ('slice_value' ))
202166
203167 interactive = ARG ('interactive' )
204168
@@ -222,11 +186,16 @@ def read_step(step):
222186 f"Refusing to load { len (requested_steps )} timesteps for 3D data "
223187 "(limit is 500). Use --step with a range or stride to reduce." )
224188
225- # Tiled mode for non-TUI, non-interactive rendering only works for 1D
189+ # Tiled mode for non-TUI, non-interactive rendering only works for 1D.
190+ # For 2D/3D, auto-select the first available variable.
226191 if tiled and not interactive and not ARG ('tui' ):
227192 if test_assembled .ndim != 1 :
228- raise MFCException ("--var is required for 2D/3D rendering. "
229- "Use --list-vars to see available variables." )
193+ varname = avail [0 ] if avail else None
194+ if varname is None :
195+ raise MFCException ("No variables found in output." )
196+ tiled = False
197+ cons .print (f"[dim]Auto-selected variable: [bold]{ varname } [/bold]"
198+ " (use --var to specify)[/dim]" )
230199
231200 if not tiled and not interactive and not ARG ('tui' ) and varname not in test_assembled .variables :
232201 raise MFCException (f"Variable '{ varname } ' not found. "
@@ -247,7 +216,7 @@ def read_step(step):
247216 # Interactive mode — launch Dash web server
248217 if interactive :
249218 from .interactive import run_interactive # pylint: disable=import-outside-toplevel
250- port = ARG ('port' ) or 8050
219+ port = ARG ('port' )
251220 # Default to first available variable if --var was not specified
252221 init_var = varname if varname in avail else (avail [0 ] if avail else None )
253222 run_interactive (init_var , requested_steps , read_step , port = int (port ))
@@ -261,7 +230,7 @@ def read_step(step):
261230
262231 # MP4 mode
263232 if ARG ('mp4' ):
264- fps = ARG ('fps' ) or 10
233+ fps = ARG ('fps' )
265234 label = 'all' if tiled else varname
266235 mp4_path = os .path .join (output_base , f'{ label } .mp4' )
267236 cons .print (f"[bold]Generating MP4:[/bold] { mp4_path } ({ len (requested_steps )} frames)" )
0 commit comments