Ignore:
Timestamp:
Dec 21, 2011, 3:22:19 PM (13 years ago)
Author:
aslmd
Message:

UTIL PYTHON : 1) no more negative values for --time but use --axtime lt ; this actually fix a stupid bug with negative lat lon. 2) use of -l is now possible with GCM files, try it with -i 2. 3) now correct handling of sol/ls in mesoscale files 4) for mesoscale files with chosen lat+lon now shows a topo map with a cross on it.

File:
1 edited

Legend:

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

    r485 r489  
    7474    from mymath import deg,max,min,mean,get_tsat,writeascii,fig2data,fig2img
    7575    import matplotlib as mpl
    76     from matplotlib.pyplot import contour,contourf, subplot, figure, rcParams, savefig, colorbar, pcolor, show, plot, clabel, title, close, legend, xlabel
     76    from matplotlib.pyplot import contour,contourf, subplot, figure, rcParams, savefig, colorbar, pcolor, show, plot, clabel, title, close, legend, xlabel, axis
    7777    from matplotlib.cm import get_cmap
    7878    import numpy as np
     
    147147      if ((proj == None) and (typefile not in ['mesoideal'])):   proj = getproj(nc)                 
    148148
    149 ##########################################################
     149      if firstfile:
     150         ##########################
     151         ### Define plot boundaries
     152         ### todo: possible areas in latinterv in argument (ex: "Far_South_Pole")
     153         if proj in ["npstere","spstere"]: [wlon,wlat] = polarinterv(lon2d,lat2d)
     154         elif proj in ["lcc","laea"]:      [wlon,wlat] = wrfinterv(lon2d,lat2d)
     155         else:                             [wlon,wlat] = simplinterv(lon2d,lat2d)
     156         if zoom:                          [wlon,wlat] = zoomset(wlon,wlat,zoom)
     157         elif zarea is not None: [wlon,wlat] = latinterv(area=zarea)
     158
     159########################################################## LOAD 4D DIMENSIONS : x, y, z, t
    150160      if typefile == "gcm":
    151161          lat = nc.variables["latitude"][:] ; lon = nc.variables["longitude"][:]
     
    158168          ### the following lines are kind of dirty... not possible to ask for several lats and lons
    159169          if vlon is not None or vlat is not None:   
    160               indices = bidimfind(lon2d,lat2d,vlon,vlat) #,file=nc)  #placer un point sur carte
     170              if firstfile:  iwantawhereplot = nc
     171              else:          iwantawhereplot = None
     172              indices = bidimfind(lon2d,lat2d,vlon,vlat,file=iwantawhereplot)  #placer un point sur carte
    161173              lonp,latp = ( lon2d[indices[0],indices[1]] , lat2d[indices[0],indices[1]] )
    162174          if typefile in ['mesoapi','meso'] and mapmode == 1: lon2d = dumpbdy(lon2d,6) ; lat2d = dumpbdy(lat2d,6)  ### important to do that now and not before
     
    183195              elif "Time" in nc.variables:  time = count + np.arange(0,len(nc.variables["Time"]),1)
    184196              else:                         time = count + np.arange(0,1,1)
    185               count = time[-1] + 1  ## so that a cat is possible with simple subscripts
     197              if nnn > 0:  count = time[-1] + 1  ## so that a cat is possible with simple subscripts
     198              else:        count = 0
     199          if axtime in ["lt"]:
     200              for i in range(len(time)):  time[i] = localtime ( interv[0]+time[i]*interv[1], 0.5*(wlon[0]+wlon[1]) )
     201              print "LOCAL TIMES.... ", time
    186202          ###
    187203          if typefile in ['geo']:   vert = [0.] ; stime = readslices(str(0))
     
    198214       ## Faire d'autre checks sur les compatibilites entre fichiers!!
    199215##########################################################
    200 
    201       if firstfile:
    202          ##########################
    203          ### Define plot boundaries
    204          ### todo: possible areas in latinterv in argument (ex: "Far_South_Pole")
    205          if proj in ["npstere","spstere"]: [wlon,wlat] = polarinterv(lon2d,lat2d)
    206          elif proj in ["lcc","laea"]:      [wlon,wlat] = wrfinterv(lon2d,lat2d)
    207          else:                             [wlon,wlat] = simplinterv(lon2d,lat2d)
    208          if zoom:                          [wlon,wlat] = zoomset(wlon,wlat,zoom)
    209          elif zarea is not None: [wlon,wlat] = latinterv(area=zarea)
    210216
    211217      all_varname[k] = varname
     
    246252                    if var2: tab2 = np.append(tab2,all_var2[k],axis=0)
    247253                    tabtime = np.append(tabtime,all_time[k]) ; tab = np.append(tab,all_var[k],axis=0) ; k += 1
    248                 #all_time[0] = np.arange(0,len(tab),1) ### AS: time reference is too simplistic, should be better
    249254                all_time[0] = np.array(tabtime) ; all_var[0] = np.array(tab) ; numplot = 1
    250255                if var2: all_var2[0] = np.array(tab2)
     
    287292       else:                            yeah = len(namefiles)*len(var) ; index_f = ((nplot-1)//(nlon*nlat*nvert*ntime))%yeah
    288293       time = all_time[index_f]
    289        if stime is not None:
    290            if stime[0][0] < 0:
    291                if typefile in ['mesoapi','meso']:
    292                    for i in range(len(time)):  time[i] = localtime ( interv[0]+time[i]*interv[1], 0.5*(wlon[0]+wlon[1]) )
    293                    print "OK... WORKING WITH LOCAL TIMES"
    294                else: errormess("local times not supported. not too hard to modify the code though.")
    295294       if mrate is not None:                 indextime = None
    296295       else:                                 indextime = getsindex(stime,((nplot-1)//(nlon*nlat*nvert))%ntime,time)
     
    298297       if typefile in ['mesoapi','meso'] and indextime is not None:  ltst = localtime ( interv[0]+indextime*interv[1], 0.5*(wlon[0]+wlon[1]) ) 
    299298       print "********** INDEX LON:",indexlon," LAT:",indexlat," VERT:",indexvert," TIME:",indextime
     299       #var = nc.variables["phisinit"][:,:]
     300       #contourf(np.transpose(var),30,cmap = get_cmap(name="Greys_r") ) ; axis('off') ; plot(indexlat,indexlon,'mx',mew=4.0,ms=20.0)
     301       #show()
     302       #exit()
    300303       ####################################################################
    301304       ########## REDUCE FIELDS
     
    337340               if colorb in ["def","nobar"]:                           palette = get_cmap(name=defcolorb(fvar.upper()))
    338341               else:                                                   palette = get_cmap(name=colorb)
    339                ##### 1. ELIMINATE >3D CASES
    340                if len(what_I_plot.shape) >= 4:
     342               ##### 1. ELIMINATE 0D or >3D CASES
     343               if len(what_I_plot.shape) == 0:   
     344                 print "VALUE VALUE VALUE VALUE ::: ",what_I_plot
     345                 save = 'donothing'
     346               elif len(what_I_plot.shape) >= 4:
    341347                 print "WARNING!!! ",len(what_I_plot.shape),"-D PLOT NOT SUPPORTED !!! dimensions: ",what_I_plot.shape
    342348                 errormess("Are you sure you did not forget to prescribe a dimension ?")
     
    542548        elif save in ['eps','svg','pdf']:     makeplotres(zeplot,pad_inches_value=pad_inches_value,disp=False,ext=save)
    543549        elif save == 'gui':                   show()
     550        elif save == 'donothing':             pass
    544551        elif save == 'txt':                   print "Saved results in txt file."
    545552        else:
Note: See TracChangeset for help on using the changeset viewer.