Ignore:
Timestamp:
Nov 8, 2011, 2:38:15 PM (13 years ago)
Author:
acolaitis
Message:

PYTHON.
Added resolution and output filename choices.

--res X to choose X instead of 200 for png outputs
-O or --output to choose filename of the output

Added possibility to do operations between 2 files.
The plot consists of:

  • a main plot, given by the regular options corresponding to the choice of -var and -f.
  • a reference plot, given by the option --fref, in a similar way as the first plot (same var, same min/max, etc...)
  • a plot on which the operation between file 1 and ref file is done.

--operation to choose the operation. For now, there is + and -. It is really simple to add more.
--mope --Mope to choose min and maximum of the colorbar for the operation. Without specifying it, it is computed.
--titleref to change the title of the reference plot. To use in combination with --title for the title of the first plot.

Future work:

  • Add possibility to compare multiple files to the same reference file.
  • Add mesoscale support. (adding the options in meso.py is straightforward but some modif might have to be done in planetoplot.)


File:
1 edited

Legend:

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

    r357 r359  
    4747    #parser.add_option('-V', action='store', dest='comb',        type="float",   default=None,  help='a defined combination of variables')
    4848
     49    parser.add_option('-O','--output',  action='store',dest='output',    type="string",  default=None,  help='Output file name')
     50    parser.add_option('--res',          action='store',dest='res',       type="float",   default=200.,  help='Resolution for png outputs. --save png must be specified. (def=200.)')
     51    parser.add_option('--operation',    action='store',dest='operation', type="string",  default=None,  help='Basic operation to perform between input file and a specified reference file. Available: addition "+", soustraction "-". Operation is done as: file1 +or- fileref. The reference file must be specified using -fref option')
     52    parser.add_option('--fref',         action='store',dest='fref',     type="string",  default=None,  help='Reference namefile for the --operation option.')
     53    parser.add_option('--mope',         action='store',dest='vminope', type="float",   default=0.,  help='bounding minimum value for inter-file operation')
     54    parser.add_option('--Mope',         action='store',dest='vmaxope', type="float",   default=0.,  help='bounding maximum value for inter-file operation')
     55    parser.add_option('--titleref',     action='store',dest='titref',  type="string",  default="fill",  help='title for the reference file. Default: title of figure (1)')
     56
    4957    ############# T.N. changes
    5058    #parser.add_option('-o','--operation',action='store',dest='operation',type="string",   default=None ,help='matrix of operations between files (for now see code, sorry)')
     
    5361    parser.add_option('--vert',         action='append',dest='svert',type="string",   default=None, help='slices along vertical axis. One value, or two values separated by comas for averaging') # quelles coordonnees ?
    5462    parser.add_option('--time',         action='append',dest='stime',type="string",   default=None, help='slices along time. One value, or two values separated by comas for averaging') # quelles coordonnees ?
    55 
    5663
    5764    (opt,args) = parser.parse_args()
     
    7683    #    vmintab = adjust_length (opt.vmin, zelen) 
    7784    #    vmaxtab = adjust_length (opt.vmax, zelen)
     85
     86
     87    ################################
     88    ### General check
     89 
     90    if opt.fref is not None:
     91       if opt.operation is None:
     92          print "you must specify an operation when using a reference file"
     93          exit()
     94    if opt.operation is not None:
     95       if opt.fref is None:
     96          print "you must specifiy a reference file when using inter-file operations"
     97          exit()
     98
     99    ################################
     100
    78101
    79102    print "namefile, length", opt.namefile, len(opt.namefile)
     
    158181                anomaly=opt.anomaly,var2=opt.var2,ndiv=opt.ndiv,first=opt.first,\
    159182                mult=opt.mult,zetitle=opt.zetitle,\
    160                 slon=zeslon,slat=zeslat,svert=zesvert,stime=zestime)
     183                slon=zeslon,slat=zeslat,svert=zesvert,stime=zestime,\
     184                outputname=opt.output,resolution=opt.res,\
     185                ope=opt.operation,fileref=opt.fref,minop=opt.vminope,maxop=opt.vmaxope,titleref=opt.titref)
    161186        print 'Done: '+name
    162187        system("rm -f to_be_erased")
Note: See TracChangeset for help on using the changeset viewer.