Changeset 817


Ignore:
Timestamp:
Oct 25, 2012, 11:24:38 PM (12 years ago)
Author:
aslmd
Message:

UTIL PYTHON : improved projections. improved local time ticks. small bug fix with vertical coordinates. added a keyword nocolorb.

Location:
trunk/UTIL/PYTHON
Files:
4 edited

Legend:

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

    r796 r817  
    6565def check_localtime(time):
    6666    a=-1
    67     print time
    6867    for i in range(len(time)-1):
    6968       if (time[i] > time[i+1]): a=i
     
    452451
    453452## Author: AS + TN
    454 def definesubplot ( numplot, fig ):
     453def definesubplot ( numplot, fig, ipreferline=False):
    455454    from matplotlib.pyplot import rcParams
    456455    rcParams['font.size'] = 12. ## default (important for multiple calls)
     
    470469        subh = 1
    471470        fig.subplots_adjust(hspace = 0.5)
     471        if ipreferline: subv = 1 ; subh = 3 ; fig.subplots_adjust(wspace = 0.35)
    472472        rcParams['font.size'] = int( rcParams['font.size'] * 1. / 2. )
    473473    elif numplot == 4:
     
    883883    h = 50.  ## en km
    884884    radius = 3397200.
    885     #print meanlat, meanlon
    886885    if   char == "cyl":     m = Basemap(rsphere=radius,projection='cyl',\
    887886                              llcrnrlat=wlat[0],urcrnrlat=wlat[1],llcrnrlon=wlon[0],urcrnrlon=wlon[1])
     
    900899    elif char == "merc":    m = Basemap(rsphere=radius,projection='merc',lat_ts=0.,\
    901900                              llcrnrlat=wlat[0],urcrnrlat=wlat[1],llcrnrlon=wlon[0],urcrnrlon=wlon[1])
     901    elif char == "geos":    m = Basemap(rsphere=radius,projection='geos',lon_0=meanlon)
     902    elif char == "robin":   m = Basemap(rsphere=radius,projection='robin',lon_0=0)
     903    elif char == "cass":   
     904             if zewidth > 60000.:  ## approx. more than one degree
     905                m = Basemap(rsphere=radius,projection='cass',\
     906                              lon_0=meanlon,lat_0=meanlat,\
     907                              width=zewidth,height=zeheight)
     908             else:
     909                m = Basemap(rsphere=radius,projection='cass',\
     910                              lon_0=meanlon,lat_0=meanlat,\
     911                              llcrnrlat=wlat[0],urcrnrlat=wlat[1],llcrnrlon=wlon[0],urcrnrlon=wlon[1])
     912    else:                   errormess("projection not supported.")
    902913    fontsizemer = int(mpl.rcParams['font.size']*3./4.)
    903     if char in ["cyl","lcc","merc","nsper","laea"]:   step = findstep(wlon)
    904     else:                                             step = 10.
    905     steplon = step*2.
     914    if zewidth > 60000.:
     915        if char in ["cyl","lcc","merc","nsper","laea"]:   step = findstep(wlon)
     916        else:                                             step = 10.
     917        steplon = step*2.
     918    else:
     919        print "very small domain !"
     920        steplon = 0.5
     921        step = 0.5
    906922    zecolor ='grey'
    907923    zelinewidth = 1
    908     zelatmax = 80
    909     if meanlat > 75.: zelatmax = 90. ; step = step/2.
     924    zelatmax = 80.
     925    if meanlat > 75.:  zelatmax = 90. ; step = step/2. ; steplon = steplon*2.
    910926    # to show gcm grid:
    911927    #zecolor = 'r'
     
    914930    #steplon = 360./64.
    915931    #zelatmax = 90. - step/3
    916     if char not in ["moll"]:
     932    if char not in ["moll","robin"]:
    917933        if wlon[1]-wlon[0] < 2.:  ## LOCAL MODE
    918934            m.drawmeridians(np.r_[-1.:1.:0.05], labels=[0,0,0,1], color=zecolor, linewidth=zelinewidth, fontsize=fontsizemer, fmt='%5.2f')
     
    10411057             "TPOT":         "%.0f",\
    10421058             "TSURF":        "%.0f",\
     1059             "TSK":          "%.0f",\
    10431060             "U_OUT1":       "%.0f",\
    10441061             "T_OUT1":       "%.0f",\
     
    10921109             "TPOT":         "Paired",\
    10931110             "TSURF":        "RdBu_r",\
     1111             "TSK":          "RdBu_r",\
    10941112             "QH2O":         "PuBu",\
    10951113             "USTM":         "YlOrRd",\
     
    13501368      else: y = lat
    13511369      count = count+1
    1352    if indexvert is None and ((dim0 == 4) or (y is None)):
     1370   if indexvert is None and len(vert) > 1 and ((dim0 == 4) or (y is None)):
    13531371      print "AXIS is vert"
    13541372      if vertmode == 0: # vertical axis is as is (GCM grid)
  • trunk/UTIL/PYTHON/myscript.py

    r792 r817  
    3131    parser.add_option('-c', '--color',  action='store',dest='clb',       type="string",  default=None,  help='change colormapS (also: nobar,onebar,def)')
    3232    parser.add_option('--trycol',       action='store_true',dest='trycol',               default=False, help='try 9 typical color palette')
     33    parser.add_option('--nocolorb',     action='store_true',dest='nocolorb',             default=False, help='no color bar please')
    3334    parser.add_option('--div',          action='store',dest='ndiv',      type="int",     default=10,    help='number of divisions in colorbar [10]')
    3435    parser.add_option('--title',        action='store',dest='zetitle',   type="string",  default="fill",help='customize the whole title')
  • trunk/UTIL/PYTHON/planetoplot.py

    r792 r817  
    7676           trycol=False,\
    7777           streamflag=False,\
     78           nocolorb=False,\
    7879           analysis=None):
    7980
     
    429430    ### Open a figure and set subplots
    430431    fig = figure()
    431     subv,subh = definesubplot( numplot, fig )
     432    subv,subh = definesubplot( numplot, fig, ipreferline = (mapmode == 1) )
    432433    if ope in ['-','-%','-_histo'] and len(namefiles) ==1 : subv,subh = 2,2
    433434    elif ope in ['-','-%'] and len(namefiles)>1 : subv, subh = len(namefiles), 3
     
    464465       ltst = None
    465466       if typefile in ['meso'] and indextime is not None and len(indextime) < 2: ltst = localtime ( indextime, slon , all_namefile[index_f])
     467
     468
     469       #if mapmode == 0:
     470       # if xlab is None:
     471       #  if indexlon is None:  xlab = "Longitude"
     472       #  elif indexlat is None: xlab = "Latitude"
     473       # if ylab is None:
     474       #  if indexvert is None: ylab = "Altitude"
     475
     476
    466477       print "********** INDEX LON:",indexlon," LAT:",indexlat," VERT:",indexvert," TIME:",indextime
    467478       ##var = nc.variables["phisinit"][:,:]
     
    547558               else:                                                   palette = get_cmap(name=colorb)
    548559               #palette = cm.GMT_split
     560               #palette = cm.GMT_globe
    549561               ##### 1. ELIMINATE 0D or >3D CASES
    550562               if len(what_I_plot.shape) == 0:   
     
    618630                        if indextime is None and axtime is not None and xlab is None:    xlabel(axtime.upper()) ## define the right label
    619631                        if save == 'txt':  writeascii(np.transpose([x,np.transpose(what_I_plot)]),'profile'+str(nplot*1000+imov)+'.txt')
    620 
     632                        if axtime == "lt":
     633                            ax = mpl.pyplot.gca()
     634                            # set ticks where your images will be
     635                            ax.get_xaxis().set_ticks(np.arange(0,48,2))
     636                            # rename tick labels
     637                            ax.get_xaxis().set_ticklabels(["0","2","4","6","8","10","12","14","16","18","20","22",\
     638                                                       "0","2","4","6","8","10","12","14","16","18","20","22"])
     639                            ## rebound everyone
     640                            ax.set_xbound(lower=min(x), upper=max(x))
    621641                    elif which == "xy":
    622642                        if lbls is not None: lbl=lbls[index_f]
     
    707727                            mpl.pyplot.plot([idx],[idy],'+k',mew=0.5,ms=18)
    708728
    709                         if colorb not in ['nobar','onebar']:       
     729                        if not nocolorb:
     730                          if colorb not in ['nobar','onebar']:
    710731                            if (fileref is not None) and ((index_f+1)%3 == 0):   daformat = "%.3f"
    711732                            elif mult != 1:                                        daformat = "%.1f"
  • trunk/UTIL/PYTHON/pp.py

    r792 r817  
    177177                redope=opt.redope,seevar=opt.seevar,xlab=opt.xlab,ylab=opt.ylab,lbls=separatenames(opt.labels),\
    178178                lstyle=separatenames(opt.linestyle),cross=readslices(opt.mark),markdevil=opt.mdevil,facwind=opt.facwind,\
    179                 trycol=opt.trycol,streamflag=opt.stream,analysis=opt.analysis)
     179                trycol=opt.trycol,streamflag=opt.stream,nocolorb=opt.nocolorb,analysis=opt.analysis)
    180180        print 'DONE: '+name
    181181        system("rm -f to_be_erased")
Note: See TracChangeset for help on using the changeset viewer.