Changeset 440 for trunk/UTIL


Ignore:
Timestamp:
Dec 1, 2011, 11:10:25 AM (13 years ago)
Author:
acolaitis
Message:

PYTHON. Contour plots now working in movies. I had to modify the call_contour (get out the reducefield part, introduce a new variable what_I_plot_contour dedicated to var2) in order to conserve the speed of movie rendering. (otherwise there were calls to reducefield for each frame in call_contour)

Location:
trunk/UTIL/PYTHON
Files:
2 edited

Legend:

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

    r437 r440  
    10341034
    10351035    return nlon, nlat, nvert, ntime, mapmode, nslices
     1036
     1037# Author: AC
     1038# Reduce complexity of main script by moving the contour part here. Also allow to call it from elsewhere
     1039# which can be usefull
     1040
     1041def call_contour(what_I_plot,error,lon,lat,vert,time,vertmode,ze_var2,indextime,indexlon,indexlat,indexvert,yintegral,mapmode,typefile,var2,ticks):
     1042      from matplotlib.pyplot import contour, plot
     1043      import numpy as np
     1044      #what_I_plot = what_I_plot*mult
     1045      if not error:
     1046         if mapmode == 1:
     1047             if typefile in ['mesoapi','meso']:    what_I_plot = dumpbdy(what_I_plot,6)
     1048         zevmin, zevmax = calculate_bounds(what_I_plot)
     1049         zelevels = np.linspace(zevmin,zevmax,ticks) #20)
     1050         if var2 == 'HGT':  zelevels = np.arange(-10000.,30000.,2000.)
     1051         if mapmode == 0:
     1052             #if typefile in ['mesoideal']:    what_I_plot = dumpbdy(what_I_plot,0,stag='W')
     1053             itime=indextime
     1054             if len(what_I_plot.shape) is 3: itime=[0]
     1055             what_I_plot, x, y = define_axis(lon,lat,vert,time,indexlon,indexlat,indexvert,\
     1056                   itime,what_I_plot, len(ze_var2.shape),vertmode)
     1057         ### If we plot a 2-D field
     1058         if len(what_I_plot.shape) is 2:
     1059             #zelevels=[0.2,0.4,0.6,0.8,1.]
     1060             cs = contour(x,y,what_I_plot, zelevels, colors='k', linewidths = 1 ) #0.33 colors='w' )# , alpha=0.5)
     1061             #clabel(cs,zelevels,inline=3,fmt='%1.1f',fontsize=7)
     1062         ### If we plot a 1-D field
     1063         elif len(what_I_plot.shape) is 1:
     1064             plot(what_I_plot,x)
     1065      else:
     1066         errormess("There is an error in reducing field !")
     1067      return error
     1068
  • trunk/UTIL/PYTHON/planetoplot.py

    r439 r440  
    279279
    280280       #### Contour plot -- to be activated with movies
    281        if var2 and mrate is None:
    282            call_contour(lon,lat,vert,time,vertmode,all_var2[index_f],indextime,indexlon,indexlat,indexvert,yintegral,mapmode,typefile, var2, ticks)
     281       if var2:
     282           what_I_plot_contour, error = reducefield(all_var2[index_f], d4=indextime, d1=indexlon, d2=indexlat , d3=indexvert, yint=yintegral, alt=vert)
     283           call_contour(what_I_plot_contour,error,lon,lat,vert,time,vertmode,all_var2[index_f],indextime,indexlon,indexlat,indexvert,yintegral,mapmode,typefile, var2, ticks)
    283284
    284285       #### Shaded plot
     
    329330                    if flagnolow:    what_I_plot_frame = nolow(what_I_plot_frame)
    330331
    331                     # Renew axis directives for movie frames which are not the first one.
    332332                    if imov > 0:
     333                       # Renew axis directives for movie frames which are not the first one.
    333334                       zxmin, zxmax = xaxis ; zymin, zymax = yaxis
    334335                       if zxmin is not None: mpl.pyplot.xlim(xmin=zxmin)
     
    338339                       if invert_y:     lima,limb = mpl.pyplot.ylim() ; mpl.pyplot.ylim(limb,lima)
    339340                       if ylog:         mpl.pyplot.semilogy()
    340                    
     341                       # Renew contours for movie frames which are not the first one
     342                       if var2:
     343                         call_contour(what_I_plot_contour[imov,:,:],error,lon,lat,vert,time,vertmode,all_var2[index_f],imov,indexlon,indexlat,indexvert,yintegral,mapmode,typefile, var2, ticks)
    341344                    if not tile:
    342345                        #zelevels = np.linspace(zevmin*(1. + 1.e-7),zevmax*(1. - 1.e-7)) #,num=20)
Note: See TracChangeset for help on using the changeset viewer.