Changeset 610 for trunk/UTIL


Ignore:
Timestamp:
Mar 31, 2012, 7:33:41 PM (13 years ago)
Author:
aslmd
Message:

UTIL PYTHON : for mesoscale plots 1. improved the case of pressure interpolation -i 1 or 2 ; 2. fixed the mean capabilities e.g. --lat 15.,35. now working fine the problem was the wrong dimension being considered in slon, my bad.

Location:
trunk/UTIL/PYTHON
Files:
4 edited

Legend:

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

    r587 r610  
    288288        subv = 2
    289289        subh = 2
    290         fig.subplots_adjust(wspace = 0.3, hspace = 0.3)
     290        fig.subplots_adjust(wspace = 0.4, hspace = 0.3)
    291291        rcParams['font.size'] = int( rcParams['font.size'] * 2. / 3. )
    292292    elif numplot <= 6:
  • trunk/UTIL/PYTHON/myscript.py

    r569 r610  
    3838    parser.add_option('--xlabel',       action='store',dest='xlab',       type="string",  default=None, help='customize the x-axis label')
    3939    parser.add_option('--ylabel',       action='store',dest='ylab',       type="string",  default=None, help='customize the y-axis label')
    40     parser.add_option('--labels',       action='store',dest='labels',     type="string",  default=None, help='customize 1D curve labels. String separated by commas. [None]')
     40    parser.add_option('--labels',       action='store',dest='labels',     type="string",  default=None, help='customize 1D curve labels. Str comma-separated. [None]')
    4141
    4242    ### SPECIFIC FOR MAPPING [MAPMODE 1]
  • trunk/UTIL/PYTHON/planetoplot.py

    r608 r610  
    173173##########################################################
    174174      if typefile in ["gcm","earthgcm","ecmwf"]:
    175           if slon is not None: sslon = slon  ## a fix of the sslon not initialized. but what is the use of sslon?
    176           if slat is not None: sslat = slat  ## a fix of the sslat not initialized. but what is the use of sslat?
     175          if slon is not None: sslon = slon 
     176          if slat is not None: sslat = slat 
    177177          ### LAT
    178178          if "latitude" in nc.variables:  lat = nc.variables["latitude"][:]
     
    208208              else:                                                                           iwantawhereplot = None   #do not show anything, just select indices
    209209              numlon = 1 ; numlat = 1
    210               if slon is not None:   numlon = slon.shape[0]   
    211               if slat is not None:   numlat = slat.shape[0]
     210              if slon is not None:   numlon = slon.shape[1]   
     211              if slat is not None:   numlat = slat.shape[1]
    212212              indices = np.ones([numlon,numlat,2]) ; vlon = None ; vlat = None
    213213              for iii in range(numlon): 
    214214               for jjj in range(numlat):
    215                  if slon is not None:  vlon = slon[iii][0]  ### note: slon[:][0] does not work
    216                  if slat is not None:  vlat = slat[jjj][0]  ### note: slon[:][0] does not work
     215                 if slon is not None:  vlon = slon[0][iii]  ### note: slon[:][0] does not work
     216                 if slat is not None:  vlat = slat[0][jjj]  ### note: slon[:][0] does not work
    217217                 indices[iii,jjj,:] = bidimfind(lon2d,lat2d,vlon,vlat,file=iwantawhereplot) 
    218218                 lonp,latp = ( lon2d[indices[iii,jjj,0],indices[iii,jjj,1]] , lat2d[indices[iii,jjj,0],indices[iii,jjj,1]] )
     
    220220              for iii in range(numlon):
    221221               for jjj in range(numlat):
    222                  if slon is not None: sslon[iii][0] = indices[iii,0,1] ; sslon[iii][1] = indices[iii,0,1] #...this is idx
    223                  if slat is not None: sslat[jjj][0] = indices[0,jjj,0] ; sslat[jjj][1] = indices[0,jjj,0] #...this is idy
     222                 if slon is not None: sslon[0][iii] = indices[iii,0,1] #...this is idx
     223                 if slat is not None: sslat[0][jjj] = indices[0,jjj,0] #...this is idy
    224224              lonp,latp = ( lon2d[indices[0,0,0],indices[0,0,1]] , lat2d[indices[0,0,0],indices[0,0,1]] )
    225225          ######
     
    262262              if vertmode == 0:     vert = np.arange(0,getattr(nc,vertdim),1)
    263263              elif vertmode == -1:  vert = nc.variables["PHTOT"][0,:,0,0]/3.72 ; vert = np.array(vert[0:len(vert)-1]) #; print vert
    264               else:                 vert = nc.variables["vert"][:]
     264              elif vertmode == 1 or vertmode == 2:  vert = nc.variables["vert"][:]        ## pressure in Pa
     265              else:                                 vert = nc.variables["vert"][:]/1000.  ## altitude in km
    265266       #if firstfile:
    266267       #   lat0 = lat
  • trunk/UTIL/PYTHON/pp.py

    r578 r610  
    7979            zelevel = float(inputnvert[0])
    8080            ze_interp_levels = [-9999.]
    81         elif np.array(inputnvert).size == 2:
     81        elif np.array(inputnvert).size > 2:
    8282            zelevel = -99.
    83             ze_interp_levels = np.linspace(float(inputnvert[0]),float(inputnvert[1]),20)
    84         else:
    85             zelevel = -99.
    86             ze_interp_levels = np.linspace(float(inputnvert[0]),float(inputnvert[1]),float(inputnvert[2]))
     83            start = float(inputnvert[0])
     84            stop = float(inputnvert[1])
     85            if np.array(inputnvert).size == 2:  numsample = 20
     86            else:                               numsample = float(inputnvert[2])
     87            if stop > start:   
     88               ## altitude coordinates
     89               ze_interp_levels = np.linspace(start,stop,numsample)
     90            else:
     91               ## pressure coordinates
     92               ze_interp_levels = np.logspace(np.log10(start),np.log10(stop),numsample)
    8793
    8894        #########################################################
Note: See TracChangeset for help on using the changeset viewer.