Changeset 865


Ignore:
Timestamp:
Jan 24, 2013, 1:05:12 PM (12 years ago)
Author:
aslmd
Message:

UTIL PYTHON. Improved redope (also available now with contours). Added --add (same as --mult for an addition). Added colormaps. Tried a different way to put wind vector reference (above colorbar).

Location:
trunk/UTIL/PYTHON
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/UTIL/PYTHON/myplot.py

    r864 r865  
    255255    csmooth = 12 ## a fair amount of grid points (too high results in high computation time)
    256256    if redope is not None:
    257        if   redope == "mint":     input = min(input,axis=0) ; d1 = None
    258        elif redope == "maxt":     input = max(input,axis=0) ; d1 = None
    259        elif redope == "edge_y1":  input = input[:,:,0,:]    ; d2 = None
     257    #   if   redope == "mint":     input = min(input,axis=0) ; d1 = None
     258    #   elif redope == "maxt":     input = max(input,axis=0) ; d1 = None
     259       if redope == "edge_y1":  input = input[:,:,0,:]    ; d2 = None
    260260       elif redope == "edge_y2":  input = input[:,:,-1,:]   ; d2 = None
    261261       elif redope == "edge_x1":  input = input[:,:,:,0]    ; d1 = None
    262262       elif redope == "edge_x2":  input = input[:,:,:,-1]   ; d1 = None
    263        else:                      errormess("not supported. but try lines in reducefield beforehand.")
     263    #   else:                      errormess("not supported. but try lines in reducefield beforehand.")
    264264       #elif redope == "minz":     input = min(input,axis=1) ; d2 = None
    265265       #elif redope == "maxz":     input = max(input,axis=1) ; d2 = None
     
    430430        elif d3 is not None:        output = reduce_zaxis(input[:,d3,:,:],ax=1,yint=yint,vert=alt,indice=d3)
    431431        elif d4 is not None:        output = mean(input[d4,:,:,:],axis=0)
     432
     433    if redope is not None:
     434       if   redope == "mint":     output = min(output,axis=0)
     435       elif redope == "maxt":     output = max(output,axis=0)
     436
    432437    dimension2 = np.array(output).ndim
    433438    shape2 = np.array(output).shape
     
    826831    #posx = np.min(x) - np.std(x) / 10.
    827832    #posy = np.min(y) - np.std(y) / 10.
    828     posx = np.min(x)
    829     posy = np.min(y) - 4.*np.std(y) / 10.
     833    #posx = np.min(x)
     834    #posy = np.min(y) - 4.*np.std(y) / 10.
    830835    u = smooth(u,csmooth)
    831836    v = smooth(v,csmooth)
     
    839844    if color in ['white','yellow']:     kcolor='black'
    840845    else:                               kcolor=color
    841     if key: p = plt.quiverkey(q,posx,posy,scale,\
    842                    str(int(scale)),coordinates='data',color=kcolor,labelpos='S',labelsep = 0.03)
     846    if key: p = plt.quiverkey(q,-0.06,0.98,scale,\
     847                   str(int(scale)),color=kcolor,labelpos='S',labelsep = 0.03)
    843848    return
    844849
     
    11581163                "mola":         "black",\
    11591164                "gist_heat":    "white",\
     1165                "hot":          "white",\
    11601166                "gist_rainbow": "black",\
    11611167                "spectral":     "black",\
     
    12401246        "Sirenum_Crater_small":  [[-36.,-26.],[-168.,-156.]],\
    12411247        "Rupes":                 [[ 72., 90.],[-120.,- 20.]],\
     1248        "Rupes2":                [[ 80., 85.],[- 90.,- 60.]],\
    12421249        "Xanadu":                [[-40., 20.],[  40., 120.]],\
    12431250        "Hyperboreae":           [[ 80., 87.],[- 70.,- 10.]],\
  • trunk/UTIL/PYTHON/myscript.py

    r817 r865  
    1616    parser.add_option('-a', '--anomaly',action='store_true',dest='anomaly',              default=False, help='compute and plot relative anomaly in %')
    1717    parser.add_option('--mult',         action='store',dest='mult',      type="float",   default=1.,    help='multiplicative factor to plotted field (2718=log)')
     18    parser.add_option('--add',          action='store',dest='add',       type="float",   default=0.,    help='additive factor to plotted field')
    1819    parser.add_option('-m', '--min',    action='append',dest='vmin',     type="float",   default=None,  help='bounding minimum value [min]')   
    1920    parser.add_option('-M', '--max',    action='append',dest='vmax',     type="float",   default=None,  help='bounding maximum value [max]')
  • trunk/UTIL/PYTHON/planetoplot.py

    r864 r865  
    3838           ndiv=10,\
    3939           mult=1.,\
     40           add=0.,\
    4041           zetitle=["fill"],\
    4142           slon=None,\
     
    9697                                  subplots_adjust, axes, clabel
    9798    from matplotlib.cm import get_cmap
    98     #from mpl_toolkits.basemap import cm
     99    from mpl_toolkits.basemap import cm
    99100    import numpy as np
    100101    from numpy.core.defchararray import find
     
    107108    import os
    108109    from scipy import ndimage
     110
    109111
    110112#########################
     
    126128    if clb is None:            clb = ["def"]*len(var)
    127129    elif len(clb) < len(var):  clb = [clb[0]]*len(var) ; print "WARNING: less color than vars! setting all to 1st value."
     130    if redope is not None and winds: winds=False ; print "WARNING: no winds with redope. setting winds to False."
    128131### we set option trycol i.e. the user wants to try a set of colorbars
    129132    if trycol: clb = ["Greys","Blues","YlOrRd","jet","spectral","hot","RdBu","RdYlBu","Paired"] ; zetitle = clb ; var = [var[0]]*9
     
    501504           what_I_plot, error = reducefield( all_var[index_f], d4=indextime, d1=indexlon, d2=indexlat, d3=indexvert, \
    502505                                             yint=yintegral, alt=vert, anomaly=anomaly, redope=redope, mesharea=area, unidim=is1d)
     506           if add != 0.:      what_I_plot = what_I_plot + add
    503507           if mult != 2718.:  what_I_plot = what_I_plot*mult
    504508           else:              what_I_plot = np.log10(what_I_plot) ; print "log plot"
    505                  
     509
    506510       if var2:      ### what is contoured.
    507511           what_I_plot_contour, error = reducefield( all_var2[index_f], d4=indextime, d1=indexlon, d2=indexlat , d3=indexvert, \
    508                                                      yint=yintegral, alt=vert )
     512                                                     yint=yintegral, alt=vert, redope=redope )
    509513       if winds:     ### what is plot as vectors.
    510514           vecx, error = reducefield( all_windu[index_f], d4=indextime, d3=indexvert, yint=yintegral, alt=vert)
     
    569573               #if (fileref is not None) and (index_f == numplot-1):    colorb = "RdBu_r"
    570574               if colorb in ["def","nobar","onebar"]:                  palette = get_cmap(name=defcolorb(fvar.upper()))
     575               elif colorb == "relief":                                palette = cm.GMT_relief
     576               elif colorb == "haxby":                                 palette = cm.GMT_haxby
    571577               else:                                                   palette = get_cmap(name=colorb)
    572578               #palette = cm.GMT_split
     
    794800                           
    795801                    elif which == "contour":
     802                        rcParams['contour.negative_linestyle'] = 'solid' # no dashed line for negative values
    796803                        zevminc, zevmaxc = calculate_bounds(what_I_plot_frame, vmin=min(what_I_plot_frame), vmax=max(what_I_plot_frame))
    797804                        zelevels = np.linspace(zevminc,zevmaxc,ticks/2) #20)
    798805                        ### another dirty specific stuff in the wall
    799                         if var2 == 'HGT':        zelevels = np.arange(-10000.,30000.,500.) #1000.)
     806                        if var2 == 'HGT':        zelevels = np.arange(-10000.,30000.,250.) #1000.)
    800807                        elif var2 == 'tpot':     zelevels = np.arange(270,370,5)
    801808                        elif var2 == 'tk':       zelevels = np.arange(150,250,5)
  • trunk/UTIL/PYTHON/pp.py

    r864 r865  
    170170                hole=opt.hole,save=opt.save,\
    171171                anomaly=opt.anomaly,var2=opt.var2,ndiv=opt.ndiv,\
    172                 mult=opt.mult,zetitle=separatenames(opt.zetitle),\
     172                mult=opt.mult,add=opt.add,zetitle=separatenames(opt.zetitle),\
    173173                slon=zeslon,slat=zeslat,svert=zesvert,stime=zestime,\
    174174                outputname=opt.out,resolution=opt.res,\
Note: See TracChangeset for help on using the changeset viewer.