Ignore:
Timestamp:
Nov 18, 2011, 8:43:59 PM (13 years ago)
Author:
aslmd
Message:

GRAPHICS: improved the selection of lon,lat with pp.py for mesoscale files

File:
1 edited

Legend:

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

    r398 r399  
    1818           var=None,\
    1919           colorb="def",\
    20            winds=True,\
     20           winds=False,\
    2121           addchar=None,\
    2222           interv=[0,1],\
     
    6464                       fmtvar,definecolorvec,defcolorb,getprefix,putpoints,calculate_bounds,errormess,definesubplot,\
    6565                       zoomset,getcoorddef,getwinddef,whatkindfile,reducefield,bounds,getstralt,getfield,smooth,nolow,\
    66                        getname,localtime,polarinterv,getsindex,define_axis,determineplot,readslices
     66                       getname,localtime,polarinterv,getsindex,define_axis,determineplot,readslices,bidimfind,getlschar
    6767    from mymath import deg,max,min,mean,get_tsat
    6868    import matplotlib as mpl
     
    8686    ################################
    8787    nlon, nlat, nvert, ntime, mapmode, nslices = determineplot(slon, slat, svert, stime)
     88    vlon = None ; vlat = None
     89    if slon is not None: vlon = slon[0][0]
     90    if slat is not None: vlat = slat[0][0]
    8891    if mapmode == 0:       winds=False
    8992    elif mapmode == 1:     
     
    9396    print "********** FILES, SLICES, VARS, TOTAL PLOTS: ", len(namefiles), nslices, len(var), numplot
    9497    print "********** MAPMODE: ", mapmode
    95     if fileref is not None:       all_var  = [[]]*(zelen+2) ;  all_varname = [[]]*(zelen+2)
    96     else:                         all_var  = [[]]*zelen     ;  all_var2  = [[]]*zelen ;  all_title = [[]]*zelen ;  all_varname = [[]]*zelen
     98    if fileref is not None:       all_var  = [[]]*(zelen+2) ;  all_varname = [[]]*(zelen+2)  ;  all_namefile = [[]]*(zelen+2)
     99    else:                         all_var  = [[]]*zelen     ;  all_var2  = [[]]*zelen ;  all_title = [[]]*zelen ;  all_varname = [[]]*zelen ; all_namefile = [[]]*zelen
    97100 
    98101    #################################################################################################
    99102    ### Loop over the files + vars initially separated by commas to be plotted on the same figure ###
    100103    #################################################################################################
    101     k = 0
    102     firstfile = True
     104    k = 0 ; firstfile = True
    103105    for nnn in range(len(namefiles)):
    104106     for vvv in range(len(var)):
     
    127129      if not varname and not winds: errormess("please set at least winds or var",printvar=nc.variables)
    128130      ### ... COORDINATES, could be moved below
    129       [lon2d,lat2d] = getcoorddef(nc)                       
     131      [lon2d,lat2d] = getcoorddef(nc)
    130132      ### ... PROJECTION
    131133      if proj == None:   proj = getproj(nc)                 
     
    144146          vert = nc.variables["altitude"][:]
    145147      elif typefile in ['meso','mesoapi']:
     148          if vlon is not None or vlat is not None:   indices = bidimfind(lon2d,lat2d,vlon,vlat) ; print '********** INDICES: ', indices
     149          if slon is not None: slon[0][0] = indices[0] ; slon[0][1] = indices[0]
     150          if slat is not None: slat[0][0] = indices[1] ; slat[0][1] = indices[1]
    146151          if varname in ['PHTOT','W']:    vertdim='BOTTOM-TOP_PATCH_END_STAG'
    147152          else:                           vertdim='BOTTOM-TOP_PATCH_END_UNSTAG'
     
    173178         else:                             [wlon,wlat] = simplinterv(lon2d,lat2d)
    174179         if zoom:                          [wlon,wlat] = zoomset(wlon,wlat,zoom)
    175          ### ... NAME FOR TITLE and FILE (have to do something for multiple vars...)
    176          basename = getname(var=varname,winds=winds,anomaly=anomaly)
    177          basename = basename + getstralt(nc,level)  ## can be moved elsewhere for a more generic routine
    178180
    179181      ##### SPECIFIC
     
    183185          else:                                 tinput=tt
    184186          all_var[k]=get_tsat(vert,tinput,zlon=lon,zlat=lat,zalt=vert,ztime=time)
    185           all_varname[k] = varname
    186187      else:
    187188      ##### GENERAL STUFF HERE
    188189          all_var[k] = getfield(nc,varname)
    189           all_varname[k] = varname
     190      all_varname[k] = varname
     191      all_namefile[k] = namefile
    190192      if var2: all_var2[k] = getfield(nc,var2)
    191193     
     
    208210                numplot = numplot+2
    209211             elif ope in ["cat"]:
    210                 tab = all_var[0];k = 0
     212                tab = all_var[0];k = 1
    211213                while k != len(namefiles)-1:
    212214                    tab = np.append(tab,all_var[k],axis=0)
     
    276278       #print slon, slat, svert, stime       
    277279       #print index_f
    278        #print "index lon,lat,vert,time", max(indexlon), max(indexlat), max(indexvert), max(indextime)
     280       #print "index lon,lat,vert,time", indexlon, indexlat, indexvert, indextime
    279281       #if varname != all_varname[index_f]:  indextime = first
    280282####################################################################
     
    401403       ### Next subplot
    402404       basename = getname(var=varname,winds=winds,anomaly=anomaly)
     405       basename = basename + getstralt(nc,level) 
    403406       if typefile in ['mesoapi','meso']:
     407            if slon is not None: basename = basename + "_lon_" + str(int(lon2d[indices[1],indices[0]]))
     408            if slat is not None: basename = basename + "_lat_" + str(int(lat2d[indices[1],indices[0]]))
    404409            plottitle = basename
    405             if addchar:  plottitle = plottitle + addchar + "_LT"+str(ltst)
     410            if addchar: 
     411                [addchar,gogol,gogol2] = getlschar ( all_namefile[index_f] )
     412                plottitle = plottitle + addchar + "_LT"+str(ltst)
    406413            else:        plottitle = plottitle + "_LT"+str(ltst)
    407414       else:
Note: See TracChangeset for help on using the changeset viewer.