From 0cb621c877a705adf08f9b186e7d711ec8e0e6e9 Mon Sep 17 00:00:00 2001 From: Kyle Mandli Date: Thu, 19 Jun 2025 10:06:05 -0400 Subject: [PATCH 1/2] Adds `print_gaugenos = none` as an option rather than failing Does a little bit more where `none` and `all` case does not matter. This was added to make it so that `None` for instance is valid. --- src/python/visclaw/plotpages.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/python/visclaw/plotpages.py b/src/python/visclaw/plotpages.py index 1048f00..f6f672c 100644 --- a/src/python/visclaw/plotpages.py +++ b/src/python/visclaw/plotpages.py @@ -1028,10 +1028,9 @@ def plotclaw2kml(plotdata): # Loop over all gauges for gnum,gauge in enumerate(gauges): gaugeno = int(gauge[0]) - if plotdata.print_gaugenos != 'all': - if gaugeno not in plotdata.print_gaugenos: - #print('+++ skipping gauge %i, not in print_gaugenos' % gaugeno) - continue # to next gauge + if (plotdata.print_gaugenos.lower() != 'all' or + gaugeno not in plotdata.print_gaugenos): + continue t1,t2 = gauge[3:5] x1,y1 = gauge[1:3] if plotdata.kml_map_topo_to_latlong is not None: @@ -1053,7 +1052,7 @@ def plotclaw2kml(plotdata): # there is only one figure number figno for all gauges # If user has set 'gaugeno=[]', gauge files will not be added to the KMLfile. - if plotdata.gauges_fignos is not None: + if not plotdata.gauges_fignos: figno = plotdata.gauges_fignos[0] # use just the first figname = gauge_pngfile[gaugeno,figno] @@ -2618,6 +2617,7 @@ def plotclaw2html(plotdata): html.write('\n') html.write('Plots') html.write('
\n') + breakpoint() html.write('\n

Gauge %i ' % gaugeno) if numfigs > 1: html.write('  ---  %s' % fignames[figno] ) @@ -2960,6 +2960,8 @@ def plotclaw_driver(plotdata, verbose=False, format='ascii'): # Gauges: # ------- if os.path.exists(os.path.join(plotdata.outdir,"gauges.data")): + if plotdata.print_gaugenos.lower() == 'none': + plotdata.print_gaugenos = [] gaugenos = plotdata.print_gaugenos if gaugenos == 'all': # Read gauge numbers from setgauges.data if it exists: From f0f4b5c2b98d4eea1f41a118b369ccf79a521068 Mon Sep 17 00:00:00 2001 From: Kyle Mandli Date: Thu, 19 Jun 2025 10:19:51 -0400 Subject: [PATCH 2/2] Add some more handling of options --- src/python/visclaw/plotpages.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/python/visclaw/plotpages.py b/src/python/visclaw/plotpages.py index f6f672c..4405035 100644 --- a/src/python/visclaw/plotpages.py +++ b/src/python/visclaw/plotpages.py @@ -2617,7 +2617,6 @@ def plotclaw2html(plotdata): html.write('\n') html.write('Plots') html.write('
\n') - breakpoint() html.write('\n

Gauge %i ' % gaugeno) if numfigs > 1: html.write('  ---  %s' % fignames[figno] ) @@ -2960,13 +2959,20 @@ def plotclaw_driver(plotdata, verbose=False, format='ascii'): # Gauges: # ------- if os.path.exists(os.path.join(plotdata.outdir,"gauges.data")): - if plotdata.print_gaugenos.lower() == 'none': + if isinstance(plotdata.print_gaugenos, str): + if plotdata.print_gaugenos.lower() == 'all': + setgauges = gaugetools.read_setgauges(plotdata.outdir) + gaugenos = setgauges.gauge_numbers + elif plotdata.print_gaugenos.lower() == 'none': + plotdata.print_gaugenos = [] + gaugenos = [] + else: + raise ValueError(f"Unknown option {plotdata.print_gaguenos}" + + "given for print_gaugenos.") + elif not plotdata.print_gaugenos: + # Handle None, also handles False, but not True plotdata.print_gaugenos = [] - gaugenos = plotdata.print_gaugenos - if gaugenos == 'all': - # Read gauge numbers from setgauges.data if it exists: - setgauges = gaugetools.read_setgauges(plotdata.outdir) - gaugenos = setgauges.gauge_numbers + gaugenos = [] plotdata.gauges_gaugenos = gaugenos plotdata.gauges_fignos = fignos_each_gauge