diff --git a/src/python/visclaw/plotpages.py b/src/python/visclaw/plotpages.py index 1048f00..4405035 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] @@ -2960,11 +2959,20 @@ def plotclaw_driver(plotdata, verbose=False, format='ascii'): # Gauges: # ------- if os.path.exists(os.path.join(plotdata.outdir,"gauges.data")): - 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 + 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.gauges_gaugenos = gaugenos plotdata.gauges_fignos = fignos_each_gauge