Ignore:
Timestamp:
Jul 16, 2011, 1:06:45 AM (13 years ago)
Author:
aslmd
Message:

MESOSCALE: corrections petits bugs graphiques.

Location:
trunk/MESOSCALE_DEV/PLOT/PYTHON
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/MESOSCALE_DEV/PLOT/PYTHON/mylib/myplot.py

    r228 r232  
    3535        return wlon,wlat
    3636
    37 #def landers (map)
    38 #    map.plot(blue_calf_lon,blue_calf_lat, 'gs')
    39 #    return
    40 
    4137def getlschar ( namefile ):
    4238    #### strangely enough this does not work for api or ncrcat results!
     
    256252    return m
    257253
     254#### test temporaire
     255def putpoints (map,plot):
     256    #### from http://www.scipy.org/Cookbook/Matplotlib/Maps
     257    # lat/lon coordinates of five cities.
     258    lats = [18.4]
     259    lons = [-134.0]
     260    points=['Olympus Mons']
     261    # compute the native map projection coordinates for cities.
     262    x,y = map(lons,lats)
     263    # plot filled circles at the locations of the cities.
     264    map.plot(x,y,'bo')
     265    # plot the names of those five cities.
     266    wherept = 0 #1000 #50000
     267    for name,xpt,ypt in zip(points,x,y):
     268       plot.text(xpt+wherept,ypt+wherept,name)
     269    ## le nom ne s'affiche pas...
     270    return
     271
     272
    258273def fmtvar (whichvar="def"):
    259274    fmtvar    =     { \
     
    265280             "USTM":         "%.2f",\
    266281             "HFX":          "%.0f",\
     282             "ICETOT":       "%.1e",\
    267283                    }
    268284    if whichvar not in fmtvar:
     
    278294             "USTM":         "YlOrRd",\
    279295             "HFX":          "RdYlBu",\
     296             "ICETOT":       "YlGnBu",\
    280297                     }
    281298    if whichone not in whichcolorb:
     
    305322                "vis":          "http://maps.jpl.nasa.gov/pix/mar0kuu2.jpg",\
    306323                "vishires":     "http://dl.dropbox.com/u/11078310/MarsMap_2500x1250.jpg",\
     324                "geolocal":     "http://dl.dropbox.com/u/11078310/geolocal.jpg",\
    307325                "mola":         "http://www.lns.cornell.edu/~seb/celestia/mars-mola-2k.jpg",\
    308326                "molabw":       "http://dl.dropbox.com/u/11078310/MarsElevation_2500x1250.jpg",\
  • trunk/MESOSCALE_DEV/PLOT/PYTHON/scripts/winds.py

    r225 r232  
    3232    from netCDF4 import Dataset
    3333    from myplot import getcoord2d,define_proj,makeplotpng,simplinterv,vectorfield,ptitle,latinterv,getproj,wrfinterv,dumpbdy,\
    34                        fmtvar,definecolorvec,getwinds,defcolorb,getprefix
     34                       fmtvar,definecolorvec,getwinds,defcolorb,getprefix,putpoints
    3535    from mymath import deg,max,min,mean
    3636    from matplotlib.pyplot import contour,contourf, subplot, figure, rcParams, savefig, colorbar, pcolor
     
    124124            elif dimension == 3:   field = nc.variables[var][:,:,:]
    125125            elif dimension == 4:   field = nc.variables[var][:,nvert,:,:] 
    126         dev = np.std(field)*3.0
    127         if vmin is None:  zevmin = mean(field) - dev
     126        fieldcalc = field[ field < 9e+35 ]
     127        dev = np.std(fieldcalc)*2.0
     128        if vmin is None:  zevmin = mean(fieldcalc) - dev
    128129        else:             zevmin = vmin
    129         if vmax is None:  zevmax = mean(field) + dev
     130        if vmax is None:  zevmax = mean(fieldcalc) + dev
    130131        else:             zevmax = vmax
    131132        if vmin == vmax:   
    132                           zevmin = mean(field) - dev  ### for continuity
    133                           zevmax = mean(field) + dev  ### for continuity           
    134         print "field ", min(field), max(field)
     133                          zevmin = mean(fieldcalc) - dev  ### for continuity
     134                          zevmax = mean(fieldcalc) + dev  ### for continuity           
     135        print "field ", min(fieldcalc), max(fieldcalc)
    135136        print "bounds ", zevmin, zevmax
    136137        ### some already defined colormaps
     
    157158        elif typefile is 'mesoapi': 
    158159            zelevel = int(nc.variables['vert'][nvert])
    159             if 'altitude'       in nc.dimensions:   stralt = "_"+str(zelevel)+"m-AMR"
    160             elif 'altitude_abg' in nc.dimensions:   stralt = "_"+str(zelevel)+"m-ALS"
    161             elif 'bottom_top'   in nc.dimensions:   stralt = "_"+str(zelevel)+"m"
     160            if abs(zelevel) < 10000.:   strheight=str(zelevel)+"m"
     161            else:                       strheight=str(int(zelevel/1000.))+"km"
     162            if 'altitude'       in nc.dimensions:   stralt = "_"+strheight+"-AMR"
     163            elif 'altitude_abg' in nc.dimensions:   stralt = "_"+strheight+"-ALS"
     164            elif 'bottom_top'   in nc.dimensions:   stralt = "_"+strheight
    162165            elif 'pressure'     in nc.dimensions:   stralt = "_"+str(zelevel)+"Pa"
    163166        else:                                       stralt = ""         
     
    179182        elif numplot == 2:
    180183            sub = 121
    181             fig.subplots_adjust(wspace = 0.3)
     184            fig.subplots_adjust(wspace = 0.35)
    182185            rcParams['font.size'] = int( rcParams['font.size'] * 3. / 4. )
    183186        elif numplot == 3:
     
    253256           if not tile:
    254257               zelevels = np.linspace(zevmin,zevmax)
    255                what_I_plot[ what_I_plot < zevmin ] = zevmin*(1. + 1.e-7)
    256                what_I_plot[ what_I_plot > zevmax ] = zevmax*(1. - 1.e-7)
     258               hole = True
     259               if not hole:
     260                   what_I_plot[ what_I_plot < zevmin ] = zevmin*(1. + 1.e-7)
     261                   what_I_plot[ what_I_plot > 9e+35  ] = -9e+35
     262                   what_I_plot[ what_I_plot > zevmax ] = zevmax*(1. - 1.e-7)
    257263               contourf( x, y, what_I_plot, 10, cmap = palette, levels = zelevels )
    258264           else:   
    259265               pcolor( x, y, what_I_plot, cmap = palette, vmin=zevmin, vmax=zevmax )
     266           #putpoints(m,fig)
    260267           if var in ['HGT']: pass
    261268           elif colorb:             
Note: See TracChangeset for help on using the changeset viewer.