clawpack / visclaw

Clawpack visualization tools
http://www.clawpack.org
BSD 3-Clause "New" or "Revised" License
29 stars 48 forks source link

The `surface_or_depth` function assumes sea level is at 0 #162

Open mandli opened 9 years ago

mandli commented 9 years ago

GeoClaw has a parameter to adjust the sea_level. I am not sure how to really get this into the function, maybe provide a key word argument for the sea level and default to 0?


def surface_or_depth(current_data, sea_level=0.0):
    ...

I am also not certain what the real effect of this on plotting is and whether there are cases where we could see this.

rjleveque commented 9 years ago

When we run at different tide levels to incorporate tidal uncertainty in PTHA this is an issue and we need to adjust the color scale to be symmetric about the sea_level used. I've done this by adding something like the following to setplot, where clim_ocean was the cmax value to use over the ocean and clim_CC was to use in a different figure where we zoomed in on Crescent City:

    try:
        tsudata = open(plotdata.outdir+'/geoclaw.data').readlines()
        for line in tsudata:
            if 'sea_level' in line:
                sea_level = float(line.split()[0])
                print "sea_level = ",sea_level
    except:
        print "Could not read sea_level, setting to 0."
        sea_level = 0.

    clim_ocean = 0.2
    clim_CC = 0.5

    cmax_ocean = clim_ocean + sea_level
    cmin_ocean = -clim_ocean + sea_level
    cmax_CC = clim_CC + sea_level
    cmin_CC = -clim_CC + sea_level

and then later used via e.g.:

    plotitem.imshow_cmin = cmin_ocean
    plotitem.imshow_cmax = cmax_ocean
mandli commented 9 years ago

I think reading in of the geoclaw.data file should work via the ClawData framework so you could do that. Also, we could replace the function in geoplot in the setplot function to get this working:

import clawpack.geoclaw.data as data
import clawpack.visclaw.geoplot as geoplot

geo_data = data.GeoClawData()
geo_data.read(os.path.join(plotdata.outdir, 'geoclaw.data'))
geoplot.surface_or_depth = lambda cd: geoplot.surface_or_depth(cd, sea_level=geo_data.sea_level)

but this would require adding the key-word argument. This is a bit shorter and allows this to be set once for the entire script but is a bit less scrutable to someone new at Python. If nothing else this does provide an indication that a user may need to be careful about this.