Ignore:
Timestamp:
Dec 1, 2011, 2:19:47 AM (13 years ago)
Author:
aslmd
Message:

GRAPHICS: make movies work with mapmode=1. very nice animated movies are now possible with cool map projections.

File:
1 edited

Legend:

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

    r435 r436  
    8989    if slon is not None: vlon = slon[0][0]
    9090    if slat is not None: vlat = slat[0][0]
    91     if mrate is not None: mapmode = 0 ### THIS IS DIRTY. MAPMPODE=1 SHOULD WORK WITH MOVIES. WILL BE FIXED.
    9291    if mapmode == 0:       winds=False
    9392    elif mapmode == 1:     
    9493        if svert is None:  svert = readslices(str(level)) ; nvert=1
     94        if stime is None and mrate is None:
     95           stime = readslices(str(0)) ; ntime=1 ## this is a default choice
     96           print "WELL... nothing about time axis. I took default: first time reference stored in file."
    9597    zelen = len(namefiles)*len(var)
    9698    numplot = zelen*nslices
     
    235237    #################################
    236238    ### Time loop for plotting device
    237     nplot = 1;error = False
     239    nplot = 1 ; error = False
    238240    print "********************************************"
    239241    while error is False:
     
    265267                   for i in range(len(time)):  time[i] = localtime ( interv[0]+time[i]*interv[1], 0.5*(wlon[0]+wlon[1]) )
    266268                   print "OK... WORKING WITH LOCAL TIMES"
    267                else: errormess("local times not supported for GCM files. not too hard to modify the code though.")
     269               else: errormess("local times not supported. not too hard to modify the code though.")
    268270       if mrate is not None:                 indextime = None
    269        elif mapmode == 1 and stime is None:  indextime = 1
    270271       else:                                 indextime = getsindex(stime,((nplot-1)//(nlon*nlat*nvert))%ntime,time)
    271272       ltst = None
     
    288289              if mapmode == 0:
    289290                  if typefile in ['mesoideal']:    what_I_plot = dumpbdy(what_I_plot,0,stag='W')
    290                   itime=indextime
    291                   if len(what_I_plot.shape) is 3:itime=[0]
     291                  itime=indextime 
     292                  if len(what_I_plot.shape) is 3: itime=[0]
    292293                  what_I_plot, x, y = define_axis(lon,lat,vert,time,indexlon,indexlat,indexvert,\
    293294                        itime,what_I_plot, len(all_var2[index_f].shape),vertmode)
     
    306307       varname = all_varname[index_f]
    307308       if varname:
    308            what_I_plot, error = reducefield(all_var[index_f], d4=indextime, d1=indexlon, d2=indexlat , d3=indexvert , yint=yintegral, alt=vert, anomaly=anomaly)
     309           what_I_plot, error = reducefield( all_var[index_f], d4=indextime, d1=indexlon, d2=indexlat, d3=indexvert, \
     310                                             yint=yintegral, alt=vert, anomaly=anomaly )
    309311           what_I_plot = what_I_plot*mult
    310312           if not error:
    311313               fvar = varname
    312314               if anomaly: fvar = 'anomaly'
    313                ##### MAPMODE-SPECIFIC SETTINGS #####
    314                if mapmode == 1:
    315                    if typefile in ['mesoapi','meso']:    what_I_plot = dumpbdy(what_I_plot,6)
    316                elif mapmode == 0:
     315               if mapmode == 0:
    317316                   itime=indextime
    318317                   if len(what_I_plot.shape) is 3:itime=[0]
     
    328327               if (fileref is not None) and (index_f is numplot-1):    zevmin, zevmax = calculate_bounds(what_I_plot,vmin=minop,vmax=maxop)
    329328               else:                                                   zevmin, zevmax = calculate_bounds(what_I_plot,vmin=vmin,vmax=vmax)
    330                if colorb in ["def","nobar"]:   palette = get_cmap(name=defcolorb(fvar.upper()))
    331                elif (fileref is not None) and (index_f is numplot-1): palette = get_cmap(name="RdBu_r")
    332                else:                           palette = get_cmap(name=colorb)
     329               if colorb in ["def","nobar"]:                           palette = get_cmap(name=defcolorb(fvar.upper()))
     330               elif (fileref is not None) and (index_f is numplot-1):  palette = get_cmap(name="RdBu_r")
     331               else:                                                   palette = get_cmap(name=colorb)
    333332               ##### simple 2D field and movies of 2D fields
    334333               if len(what_I_plot.shape) >= 2:
    335                  if (len(what_I_plot.shape) is 3 and mrate is None):
    336                      errormess("3D field in input but not rate specified for movie (use --rate RATE or specify --time TIME). Exit.")
     334                 if (len(what_I_plot.shape) is 3 and mrate is None):  errormess("3D field. Use --rate RATE for movie or specify --time TIME. Exit.")
    337335                 istart=0
    338336                 if mrate is not None: iend=len(time)-1
     
    341339                 while imov <= iend:
    342340                    what_I_plot_frame = what_I_plot
    343                     if mrate is not None:      what_I_plot_frame = what_I_plot[imov,:,:] ; print "-> frame ",imov+1
    344                     if hole:                   what_I_plot_frame = hole_bounds(what_I_plot_frame,zevmin,zevmax)
    345                     else:                      what_I_plot_frame = bounds(what_I_plot_frame,zevmin,zevmax)
    346                     if flagnolow:              what_I_plot_frame = nolow(what_I_plot_frame)
     341                    if mrate is not None:     
     342                        what_I_plot_frame = what_I_plot[imov,:,:] ; print "-> frame ",imov+1
     343                        if mapmode == 1:
     344                            m = define_proj(proj,wlon,wlat,back=back,blat=blat)  ## this is dirty, defined above but out of imov loop
     345                            x, y = m(lon2d, lat2d)                               ## this is dirty, defined above but out of imov loop
     346                    if typefile in ['mesoapi','meso'] and mapmode == 1:   what_I_plot_frame = dumpbdy(what_I_plot_frame,6)
     347                    if hole:         what_I_plot_frame = hole_bounds(what_I_plot_frame,zevmin,zevmax)
     348                    else:            what_I_plot_frame = bounds(what_I_plot_frame,zevmin,zevmax)
     349                    if flagnolow:    what_I_plot_frame = nolow(what_I_plot_frame)
    347350                    if not tile:
    348351                        #zelevels = np.linspace(zevmin*(1. + 1.e-7),zevmax*(1. - 1.e-7)) #,num=20)
     
    460463       zeplot=outputname
    461464
    462     pad_inches_value = 0.35
    463     print "********** SAVE ", save
    464     if save == 'png':
    465         if display: makeplotres(zeplot,res=100.,pad_inches_value=pad_inches_value) #,erase=True)  ## a miniature
    466         makeplotres(zeplot,res=resolution,pad_inches_value=pad_inches_value,disp=False)
    467     elif save in ['eps','svg','pdf']:     makeplotres(zeplot,pad_inches_value=pad_inches_value,disp=False,ext=save)
    468     elif save == 'gui':                   show()
    469     elif save == 'txt':                   print "Saved results in txt file."
    470     else:
    471          print "INFO: save mode not supported. using gui instead."
    472          show()
     465    if mrate is None:
     466        pad_inches_value = 0.35
     467        print "********** SAVE ", save
     468        if save == 'png':
     469            if display: makeplotres(zeplot,res=100.,pad_inches_value=pad_inches_value) #,erase=True)  ## a miniature
     470            makeplotres(zeplot,res=resolution,pad_inches_value=pad_inches_value,disp=False)
     471        elif save in ['eps','svg','pdf']:     makeplotres(zeplot,pad_inches_value=pad_inches_value,disp=False,ext=save)
     472        elif save == 'gui':                   show()
     473        elif save == 'txt':                   print "Saved results in txt file."
     474        else:
     475            print "INFO: save mode not supported. using gui instead."
     476            show()
    473477
    474478    ###############
Note: See TracChangeset for help on using the changeset viewer.