Changeset 864


Ignore:
Timestamp:
Jan 24, 2013, 12:45:30 PM (13 years ago)
Author:
aslmd
Message:

UTIL PYTHON. Fixed the movie problem when playing in Windows. Added a noproj case for -p for simple 2D plots. Various other small improvements about the aspect of plots (grid, vector width, ...)

Location:
trunk/UTIL/PYTHON
Files:
1 added
4 edited

Legend:

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

    r822 r864  
    549549        ##### strangely enough this does not work for api or ncrcat results!
    550550        zesol = plus_in_month[ int(zetime[5]+zetime[6])-1 ] + int(zetime[8]+zetime[9]) - 1 ##les sols GCM commencent a 0
    551         dals = int( 10. * sol2ls ( zesol ) ) / 10.
     551        dals = int(sol2ls ( zesol )) #int( 10. * sol2ls ( zesol ) ) / 10.
    552552        ###
    553553        zetime2 = nc.variables['Times'][1]
     
    830830    u = smooth(u,csmooth)
    831831    v = smooth(v,csmooth)
    832     widthvec = 0.003 #0.005 #0.003
     832    widthvec = 0.004 #0.003 #0.005 #0.003
    833833    q = plt.quiver( x[::stride,::stride],\
    834834                    y[::stride,::stride],\
     
    912912    else:                   errormess("projection not supported.")
    913913    fontsizemer = int(mpl.rcParams['font.size']*3./4.)
    914     if zewidth > 60000.:
     914    if zewidth > 60000. or char in ["npstere","spstere","ortho"]:
    915915        if char in ["cyl","lcc","merc","nsper","laea"]:   step = findstep(wlon)
    916916        else:                                             step = 10.
     
    935935            m.drawparallels(np.r_[-1.:1.:0.05], labels=[1,0,0,0], color=zecolor, linewidth=zelinewidth, fontsize=fontsizemer, fmt='%5.2f')
    936936        else:  ## GLOBAL OR REGIONAL MODE
    937             m.drawmeridians(np.r_[-180.:180.:steplon], labels=[0,0,0,1], color=zecolor, linewidth=zelinewidth, fontsize=fontsizemer, latmax=zelatmax)
    938             m.drawparallels(np.r_[-90.:90.:step], labels=[1,0,0,0], color=zecolor, linewidth=zelinewidth, fontsize=fontsizemer, latmax=zelatmax)
     937            m.drawmeridians(np.r_[-360.:360.:steplon], labels=[0,0,0,1], color=zecolor, linewidth=zelinewidth, fontsize=fontsizemer, latmax=zelatmax)
     938            m.drawparallels(np.r_[-180.:180.:step], labels=[1,0,0,0], color=zecolor, linewidth=zelinewidth, fontsize=fontsizemer, latmax=zelatmax)
    939939    if back:
    940940      if back not in ["coast","sea"]:   m.warpimage(marsmap(back),scale=0.75)
     
    11541154                "def":          "black",\
    11551155                "vis":          "yellow",\
    1156                 "vishires":     "green",\
     1156                "vishires":     "blue",\
    11571157                "molabw":       "yellow",\
    11581158                "mola":         "black",\
    11591159                "gist_heat":    "white",\
    1160                 "hot":          "tk",\
    11611160                "gist_rainbow": "black",\
    11621161                "spectral":     "black",\
  • trunk/UTIL/PYTHON/planetoplot.py

    r824 r864  
    106106    from itertools import cycle
    107107    import os
     108    from scipy import ndimage
    108109
    109110#########################
     
    133134    nlon, nlat, nvert, ntime, mapmode, nslices = determineplot(slon, slat, svert, stime, redope)
    134135    zelen = len(namefiles)*len(var)
     136### we have a special mode obtained by -p noproj in which lat/lon plots are just flat 2D plots
     137    if proj == "noproj": mapmode = 0
    135138### we correct number of plot fields for possible operation (substract, etc...)
    136139    if ope is not None:
     
    188191      [lon2d,lat2d] = getcoorddef(nc)
    189192    ### we get an adapted map projection if none is provided by the user
    190       if proj == None:   proj = getproj(nc)                
     193      if proj == None:   proj = getproj(nc)   
    191194    ### we define plot boundaries given projection or user choices
    192195      if firstfile:
     
    282285              lonp,latp = ( lon2d[indices[0,0,0],indices[0,0,1]] , lat2d[indices[0,0,0],indices[0,0,1]] )
    283286          ### we get rid of boundary relaxation zone for plots. important to do that now and not before.
    284           if typefile in ['meso'] and mapmode == 1:
     287          if (typefile in ['meso'] and mapmode == 1):
    285288             if '9999' not in getattr(nc,'START_DATE'): lon2d = dumpbdy(lon2d,6) ; lat2d = dumpbdy(lat2d,6) 
    286289          ### we read the keyword for vertical dimension. we take care for vertical staggering.
     
    553556                       # now that the section is determined we can set the real lat
    554557                       # ... or for now, a temptative one.
    555                        if slon is not None: latyeah = lat2d[:,0]
    556                        if slat is not None: lonyeah = lon2d[0,:]
     558                       milieux = int(lat2d.shape[1]/2.)
     559                       milieuy = int(lat2d.shape[0]/2.)
     560                       if slon is not None or proj == "noproj": latyeah = lat2d[:,milieux]
     561                       if slat is not None or proj == "noproj": lonyeah = lon2d[milieuy,:]
    557562                   what_I_plot, x, y = define_axis(lonyeah,latyeah,vert,time,indexlon,indexlat,indexvert,\
    558563                         itime,what_I_plot, len(all_var[index_f].shape),vertmode,redope)
     564               ###
     565               if analysis in ['laplace']: what_I_plot = ndimage.laplace(what_I_plot)
    559566               ###
    560567               if (fileref is not None) and ((index_f+1)%3 == 0):    zevmin, zevmax = calculate_bounds(what_I_plot,vmin=minop,vmax=maxop)
     
    609616                        m = define_proj(proj,wlon,wlat,back=back,blat=blat,blon=blon)  ## this is dirty, defined above but out of imov loop
    610617                        x, y = m(lon2d, lat2d)                                         ## this is dirty, defined above but out of imov loop
    611                     if typefile in ['meso'] and mapmode == 1:
     618                    if (typefile in ['meso'] and mapmode == 1):
    612619                       if '9999' not in getattr(nc,'START_DATE'): what_I_plot_frame = dumpbdy(what_I_plot_frame,6,condition=True)
    613620#                   if typefile in ['mesoideal']:    what_I_plot_frame = dumpbdy(what_I_plot_frame,0,stag='W',condition=dumped_vert_stag)
     
    633640                        if this_is_a_regular_plot:   plot(x,what_I_plot_frame,zeline,label=lbl,marker=zemarker)  ## vertical profile
    634641                        else:                        plot(what_I_plot_frame,x,zeline,label=lbl,marker=zemarker)  ## regular plot
     642                        mpl.pyplot.grid(True)
    635643                        if nplot > 1: legend(loc='best')
    636644                        if indextime is None and axtime is not None and xlab is None:    xlabel(axtime.upper()) ## define the right label
     
    935943    #### Getting more out of this video -- PROBLEMS WITH CREATED VIDEOS
    936944    #
    937     #if mrate is not None:
    938     #    print "Re-encoding movie.. first pass"
    939     #    video.first_pass(filename=moviename,quality=mquality,rate=mrate)
     945    if mrate is not None and save != "html":
     946        print "Re-encoding movie.. first pass"
     947        video.first_pass(filename=zeplot,quality=mquality,rate=mrate)
    940948    #    print "Re-encoding movie.. second pass"
    941949    #    video.second_pass(filename=moviename,quality=mquality,rate=mrate)   
  • trunk/UTIL/PYTHON/pp.py

    r822 r864  
    189189    #if typefile not in ["meso","mesoapi"]: name = 'pycommand'
    190190    if opt.save == "gui":    name = 'pycommand'
    191     elif opt.save == "avi":  system("mv -f movie*.avi "+name+".avi")
    192191    elif opt.save == "html": system("cat $PYTHONPATH/header.html > anim.html ; cat zepics >> anim.html ; cat $PYTHONPATH/body.html >> anim.html ; rm -rf zepics "+name+" ; mkdir "+name+" ; mv anim.html image*png "+name)
    193192    f = open(name+'.sh', 'w')
  • trunk/UTIL/PYTHON/videosink.py

    r448 r864  
    2929             if quality:bitrate="50000"
    3030             cmdstring  = ('mencoder',
    31                      filename+'_raw.avi',
    32                      '-of', 'rawvideo',
     31                     'movie_raw.avi',
     32                     '-of', 'avi',
    3333                     '-nosound',
    3434                     '-ofps',str(rate),
     
    3636                     '-x264encopts', 'subq=1:frameref=1:bitrate='+bitrate+':bframes=1:pass=1',
    3737                     '-vf', 'scale=1280:720',
    38                      '-o', filename+'_first.264'
     38                     '-o', filename+'.avi'
    3939                    )
     40             ## si second_pass '-o', filename+'_first.264'
     41             ## ... et seconde ligne: filename+'_raw.avi'
    4042             subprocess.call(cmdstring,shell=False)
    4143
Note: See TracChangeset for help on using the changeset viewer.