Changeset 562 for trunk/UTIL


Ignore:
Timestamp:
Mar 6, 2012, 1:49:07 AM (13 years ago)
Author:
aslmd
Message:

UTIL PYTHON added -i -1 i.e. an option to use model-level geopotential height without the need to call api [useful for big files such as LES results where api cannot handle it]. introduced automatic correction in define_axis. other changes are purely cosmetic.

Location:
trunk/UTIL/PYTHON
Files:
4 edited

Legend:

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

    r558 r562  
    684684    dev = np.std(fieldcalc)*3.0
    685685    ###
    686     if vmin is None:
    687         zevmin = mean(fieldcalc) - dev
     686    if vmin is None:  zevmin = mean(fieldcalc) - dev
    688687    else:             zevmin = vmin
    689688    ###
     
    778777             "W":            "%.1f",\
    779778             "WMAX_TH":      "%.1f",\
     779             "WSTAR":        "%.1f",\
    780780             "QSURFICE":     "%.0f",\
    781781             "UM":           "%.0f",\
     
    10801080   print "CHECK SHAPE: what_I_plot, x, y", what_I_plot.shape, x.shape, y.shape
    10811081   if len(shape) == 1:
    1082       if shape[0] != len(x):
    1083          print "WARNING HERE !!!"
    1084          x = y
     1082       if shape[0] != len(x):           print "WARNING: shape[0] != len(x). Correcting." ; what_I_plot = what_I_plot[0:len(x)]
    10851083   elif len(shape) == 2:
    1086       if shape[1] == len(y) and shape[0] == len(x) and shape[0] != shape[1]:
    1087          what_I_plot = swapaxes(what_I_plot,0,1)
    1088          print "INFO: swapaxes", what_I_plot.shape, shape
     1084       if shape[1] == len(y) and shape[0] == len(x) and shape[0] != shape[1]:
     1085           print "INFO: swapaxes: ",what_I_plot.shape,shape ; what_I_plot = swapaxes(what_I_plot,0,1)
     1086       else:
     1087           if shape[0] != len(y):       print "WARNING: shape[0] != len(y). Correcting." ; what_I_plot = what_I_plot[0:len(y),:]
     1088           elif shape[1] != len(x):     print "WARNING: shape[1] != len(x). Correcting." ; what_I_plot = what_I_plot[:,0:len(x)]
     1089   elif len(shape) == 3:
     1090       if vertmode < 0: print "not supported. must check array dimensions at some point. not difficult to implement though."
    10891091   return what_I_plot,x,y
    10901092
  • trunk/UTIL/PYTHON/myscript.py

    r518 r562  
    2424    ### VERTICAL INTERPOLATION
    2525    parser.add_option('-l', '--level',  action='store',dest='lvl',       type="string",  default="0",   help='level / start,stop,step (-i 2: p,Pa)(-i 3,4: z,km) [0]')
    26     parser.add_option('-i', '--interp', action='store',dest='itp',       type="int",     default=None,  help='interpolation (2: p, 3: z-amr, 4:z-als)')
     26    parser.add_option('-i', '--interp', action='store',dest='itp',       type="int",     default=None,  help='interpolation (2: p, 3: z-amr, 4:z-als, -1)')
    2727    parser.add_option('--intas',        action='store',dest='intas',     type="string",  default=None,  help='specify "mcs" or "tes" for gcm P interpolation grid')
    2828    parser.add_option('-N', '--no-api', action='store_true',dest='nocall',               default=False, help='do not recreate api file')
  • trunk/UTIL/PYTHON/planetoplot.py

    r558 r562  
    196196          ###### principle: calculate correct indices then repopulate slon and slat
    197197          if slon is not None or slat is not None:
    198               if firstfile and save == 'png' and typefile == 'meso':   iwantawhereplot = nc     #show a topo map with a cross on the chosen point
    199               else:                                                    iwantawhereplot = None   #do not show anything, just select indices
     198              if firstfile and save == 'png' and typefile == 'meso' and "HGT" in varinfile:   iwantawhereplot = nc     #show a topo map with a cross on the chosen point
     199              else:                                                                           iwantawhereplot = None   #do not show anything, just select indices
    200200              numlon = 1 ; numlat = 1
    201201              if slon is not None:   numlon = slon.shape[0]   
     
    245245              if vertmode is None:  vertmode=0
    246246              if vertmode == 0:     vert = np.arange(0,getattr(nc,vertdim),1)
     247              elif vertmode == -1:  vert = nc.variables["PHTOT"][0,:,0,0]/3.72 ; vert = np.array(vert[0:len(vert)-1]) #; print vert
    247248              else:                 vert = nc.variables["vert"][:]
    248249       #if firstfile:
     
    398399               if mapmode == 0:    ### could this be moved inside imov loop ?
    399400                   itime=indextime
    400                    if len(what_I_plot.shape) is 3:itime=[0]
     401                   if len(what_I_plot.shape) is 3: itime=[0]
    401402                   m = None ; x = None ; y = None
    402403                   what_I_plot, x, y = define_axis(lon,lat,vert,time,indexlon,indexlat,indexvert,\
     
    431432                 elif len(what_I_plot.shape) == 1:
    432433                    which = "unidim"
     434                    if what_I_plot.shape[-1] == 1:      print "VALUE VALUE VALUE VALUE ::: ", what_I_plot[0] ; save = 'donothing'
    433435                 ##### IMOV LOOP #### IMOV LOOP
    434436                 while imov <= iend:
     
    508510                                                              #200.         ## or csmooth=stride
    509511                    elif which == "contour":
    510                         zevminc, zevmaxc = calculate_bounds(what_I_plot_frame)
     512                        zevminc, zevmaxc = calculate_bounds(what_I_plot_frame, vmin=min(what_I_plot_frame), vmax=max(what_I_plot_frame))
    511513                        zelevels = np.linspace(zevminc,zevmaxc,ticks/2) #20)
    512514                        if var2 == 'HGT': zelevels = np.arange(-10000.,30000.,2000.)
  • trunk/UTIL/PYTHON/pp.py

    r507 r562  
    5353
    5454      typefile = whatkindfile(Dataset(zefiles[0])) ; stralt = None
    55       if typefile in ["meso","mesoapi","mesoideal"]:         
     55      if typefile in ["meso"]:         
    5656          [lschar,zehour,zehourin] = getlschar ( zefiles[0] )
    5757          if opt.var is None:  opt.var = ["HGT"] ; opt.clb = "nobar"
     
    9090        #########################################################
    9191        if opt.itp is not None:
     92         if opt.itp > 0:
    9293          #####
    9394          ##### MESOSCALE : written by AS
    9495          #####
    95           if typefile in ["meso","mesoideal"]:
     96          if typefile in ["meso"]:
    9697            if zelevel == 0. and opt.itp == 4:  zelevel = 0.010
    9798            ### winds or no winds
Note: See TracChangeset for help on using the changeset viewer.