Changeset 369 for trunk/UTIL/PYTHON


Ignore:
Timestamp:
Nov 9, 2011, 4:52:59 PM (14 years ago)
Author:
acolaitis
Message:

Added possibility to change plotting window for contour plots, through --xmin, --xmax, --ymin, --ymax. When specifying xmin, there is a priori no need to specify xmax (it will use the max of the x_axis). When specifying values for a y-axis with decreasing-with-height values, both ymin and ymax must be specified.

Location:
trunk/UTIL/PYTHON
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/UTIL/PYTHON/gcm.py

    r363 r369  
    5656    parser.add_option('--Mope',         action='store',dest='vmaxope', type="float",   default=0.,  help='bounding maximum value for inter-file operation')
    5757    parser.add_option('--titleref',     action='store',dest='titref',  type="string",  default="fill",  help='title for the reference file. Default: title of figure (1)')
     58    parser.add_option('--xmax',         action='store',dest='xmax',    type="float",   default=None,    help='Maximum value for the y-axis in contour-plots. Default is max(xaxis).')                                                                                                                                   
     59    parser.add_option('--ymax',         action='store',dest='ymax',    type="float",   default=None,    help='Maximum value for the y-axis in contour-plots Default is max(yaxis)')
     60    parser.add_option('--xmin',         action='store',dest='xmin',    type="float",   default=None,    help='Minimum value for the y-axis in contour-plots. Default is min(xaxis).')
     61    parser.add_option('--ymin',         action='store',dest='ymin',    type="float",   default=None,    help='Minimum value for the y-axis in contour-plots Default is min(yaxis)')
    5862    parser.add_option('--inverty',      action='store_true',dest='inverty',             default=False, help='Force matplotlib.pyplot to revert the y-axis. Can be of use when plotting data along pressure levels. (pyplot naturally tend to plot the z-axis with increasing values)')
    5963   
     
    200204        else:
    201205           reffile=opt.fref
     206# Divers ####################################################
     207   
     208        zexaxis=[opt.xmin,opt.xmax]
     209        zeyaxis=[opt.ymin,opt.ymax]
    202210
    203211        #############
     
    214222                outputname=opt.output,resolution=opt.res,\
    215223                ope=opt.operation,fileref=reffile,minop=opt.vminope,maxop=opt.vmaxope,titleref=opt.titref,\
    216                 invert_y=opt.inverty)
     224                invert_y=opt.inverty,xaxis=zexaxis,yaxis=zeyaxis)
    217225        print 'Done: '+name
    218226        system("rm -f to_be_erased")
  • TabularUnified trunk/UTIL/PYTHON/meso.py

    r363 r369  
    4646    parser.add_option('--title',        action='store',dest='zetitle',   type="string",  default="fill",help='customize the whole title')
    4747    parser.add_option('--inverty',      action='store_true',dest='inverty',             default=False, help='Force matplotlib.pyplot to revert the y-axis. Can be of use when plotting data along pressure levels. (pyplot naturally tend to plot the z-axis with increasing values)')
     48    parser.add_option('--xmax',         action='store',dest='xmax',    type="float",   default=None,    help='Maximum value for the y-axis in contour-plots. Default is max(xaxis).')
     49    parser.add_option('--ymax',         action='store',dest='ymax',    type="float",   default=None,    help='Maximum value for the y-axis in contour-plots Default is max(yaxis)')
     50    parser.add_option('--xmin',         action='store',dest='xmin',    type="float",   default=None,    help='Minimum value for the y-axis in contour-plots. Default is min(xaxis).')
     51    parser.add_option('--ymin',         action='store',dest='ymin',    type="float",   default=None,    help='Minimum value for the y-axis in contour-plots Default is min(yaxis)')
    4852    #parser.add_option('-V', action='store', dest='comb',        type="float",   default=None,  help='a defined combination of variables')
    4953
     
    146150                if vmaxtab[jjj] != -999999:  zevmax = vmaxtab[jjj]
    147151                else:                        zevmax = None
     152
     153
     154        zexaxis=[opt.xmin,opt.xmax]
     155        zeyaxis=[opt.ymin,opt.ymax]
     156
     157
    148158            #############
    149159            ### Main call
     
    157167                mult=opt.mult,zetitle=opt.zetitle,\
    158168                slon=zeslon,slat=zeslat,svert=zesvert,stime=zestime,\
    159                 outputname=opt.output,resolution=opt.res,invert_y=opt.inverty)
     169                outputname=opt.output,resolution=opt.res,\
     170                invert_y=opt.inverty,xaxis=zexaxis,yaxis=zeyaxis)
    160171        print 'Done: '+name
    161172        system("rm -f to_be_erased")
  • TabularUnified trunk/UTIL/PYTHON/planetoplot.py

    r364 r369  
    4545           maxop=0.,\
    4646           titleref="fill",\
    47            invert_y=False):
     47           invert_y=False,\
     48           xaxis=[None,None],\
     49           yaxis=[None,None]):
    4850
    4951
     
    312314                     #contourf(what_I_plot, zelevels, cmap = palette )
    313315
    314                      contourf( x, y, what_I_plot, zelevels, cmap = palette )
     316                     contourf( x, y, what_I_plot, zelevels, cmap = palette)
     317
     318                     zxmin, zxmax = xaxis
     319                     zymin, zymax = yaxis
     320                     if zxmin is not None:
     321                        mpl.pyplot.xlim(xmin=zxmin)
     322                     if zxmax is not None:
     323                        mpl.pyplot.xlim(xmax=zxmax)
     324                     if zymin is not None:
     325                        mpl.pyplot.ylim(ymin=zymin)
     326                     if zymax is not None:
     327                        mpl.pyplot.ylim(ymax=zymax)
     328
    315329                     if invert_y:
    316330                        lima,limb = mpl.pyplot.ylim()
Note: See TracChangeset for help on using the changeset viewer.