Changeset 917 for trunk/UTIL/PYTHON


Ignore:
Timestamp:
Mar 27, 2013, 11:14:53 PM (12 years ago)
Author:
aslmd
Message:

UTIL PYTHON planetoplot_v2. Fixed bounding box problems when using Basemap and saving this in png,pdf,etc...

Location:
trunk/UTIL/PYTHON/planetoplot_v2
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/UTIL/PYTHON/planetoplot_v2/pp_reload.py

    r910 r917  
    99# -----------------------------------------------------------------------
    1010parser = OptionParser()
    11 parser.add_option('-o',action='store',dest='out',type="string",default="gui",help='Specify a new output format')
     11parser.add_option('-O','--out',action='store',dest='out',type="string",default="gui",help='Specify a new output format')
     12parser.add_option('-P','--proj',action='store',dest='proj',type="string",default=None,help='Define a new map projection')
    1213(opt,args) = parser.parse_args()
    1314# -----------------------------------------------------------------------
     
    1617    yeah.defineplot(loadfile=files)
    1718    yeah.out = opt.out
     19    if opt.proj is not None:
     20      for plot in yeah.p:
     21        plot.proj = opt.proj
    1822    yeah.makeplot()
    1923
  • TabularUnified trunk/UTIL/PYTHON/planetoplot_v2/ppclass.py

    r916 r917  
    725725            self.subv,self.subh = ppplot.definesubplot(self.howmanyplots,self.fig)
    726726            self.n = 0
     727            ## adapted space for labels etc
     728            ## ... except for ortho because there is no label anyway
     729            customplot = self.p[0].field.ndim == 2 \
     730                        and self.p[0].mapmode == True \
     731                        and self.p[0].proj not in ["ortho"]
     732            if customplot:
     733                margin = 0.07
     734                self.fig.subplots_adjust(left=margin,right=1-margin,bottom=margin,top=1-margin)
    727735        else:
    728736            # start from an existing figure.
     
    765773            self.n = self.n+1
    766774        # once completed show the plot (cannot show intermediate plotin)
     775        # ... added a fix (customplot=True) for the label problem in basemap
    767776        print "**** Done step: makeplot"
    768         if (self.n == self.howmanyplots): ppplot.save(mode=self.out,filename=self.filename,folder=self.folder)
     777        if (self.n == self.howmanyplots):
     778            ppplot.save(mode=self.out,filename=self.filename,folder=self.folder,custom=customplot)
    769779        # SAVE A PICKLE FILE WITH THE self.p ARRAY OF OBJECTS
    770780        if self.verbose: print "**** Saving session in "+self.filename + ".ppobj"
  • TabularUnified trunk/UTIL/PYTHON/planetoplot_v2/ppplot.py

    r910 r917  
    218218# a generic function to show (GUI) or save a plot (PNG,EPS,PDF,...)
    219219# -------------------------------
    220 def save(mode="gui",filename="plot",folder="./",includedate=True,res=150):
     220def save(mode="gui",filename="plot",folder="./",includedate=True,res=150,custom=False):
    221221    # a few settings
    222222    possiblesave = ['eps','ps','svg','png','jpg','pdf']
     
    233233        ## save file
    234234        print "**** Saving file in "+mode+" format... Please wait."
    235         mpl.savefig(name,dpi=res,bbox_inches='tight',pad_inches=pad_inches_value)
     235        if not custom:
     236            # ... regular plots
     237            mpl.savefig(name,dpi=res,pad_inches=pad_inches_value,bbox_inches='tight')
     238        else:
     239            # ... mapping mode, adapted space for labels etc...
     240            mpl.savefig(name,dpi=res)
    236241    else:
    237242        print "!! ERROR !! File format not supported. Supported: ",possiblesave
     
    538543            # ... cyl is good for global and regional
    539544            if self.proj == "cyl":
    540                 pass
     545                format = '%.0f'
    541546            # ... global projections
    542547            elif self.proj in ["ortho","moll","robin"]:
     
    603608        if self.trans > 0.:
    604609            ## draw colorbar. settings are different with projections. or if not mapmode.
    605             if not self.mapmode: orientation=zeorientation ; frac = 0.075
    606             elif self.proj in ['moll']: orientation="horizontal" ; frac = 0.075
    607             elif self.proj in ['cyl']: orientation="vertical" ; frac = 0.023
    608             else: orientation = zeorientation ; frac = zefrac
     610            if not self.mapmode: orientation=zeorientation ; frac = 0.075 ; pad = 0.03
     611            elif self.proj in ['moll']: orientation="horizontal" ; frac = 0.075 ; pad = 0.03
     612            elif self.proj in ['cyl']: orientation="vertical" ; frac = 0.023 ; pad = 0.03
     613            else: orientation = zeorientation ; frac = zefrac ; pad = 0.03
    609614            zelevpal = np.linspace(zevmin,zevmax,num=min([ticks/2+1,21]))
    610             zecb = mpl.colorbar(fraction=frac,pad=0.03,\
     615            zecb = mpl.colorbar(fraction=frac,pad=pad,\
    611616                                format=self.fmt,orientation=orientation,\
    612617                                ticks=zelevpal,\
     
    629634                              scale=zescale*reducevec,width=widthvec )
    630635                # make vector key. default is on upper left corner.
    631                 p = mpl.quiverkey(q,-0.06,0.98,\
     636                p = mpl.quiverkey(q,-0.03,1.08,\
    632637                                  zescale,str(int(zescale)),\
    633638                                  color='black',labelpos='S',labelsep = 0.07)
     639        #### streamplot!!! avec basemap
  • TabularUnified trunk/UTIL/PYTHON/planetoplot_v2/set_multiplot.txt

    r910 r917  
    44############################################
    551 ; 1 ; 1 ; 0.0 ; 0.0 ; 22
    6 2 ; 1 ; 2 ; 0.5 ; 0.0 ; 20
     62 ; 1 ; 2 ; 0.35 ; 0.0 ; 20
    77#3 ; 3 ; 1 ; 0.0 ; 1.0 ; 18
    8 3 ; 1 ; 3 ; 0.7 ; 0.0 ; 18
     83 ; 1 ; 3 ; 0.35 ; 0.0 ; 18
    994 ; 2 ; 2 ; 0.8 ; 0.6 ; 18
    10106 ; 3 ; 2 ; 0.6 ; 1.0 ; 18
Note: See TracChangeset for help on using the changeset viewer.