Changeset 424 for trunk/UTIL


Ignore:
Timestamp:
Nov 25, 2011, 1:42:00 AM (13 years ago)
Author:
aslmd
Message:

GRAPHICS: deleted and cleaned obsolete strategy to find local time and options -n -F -e. now using --time like everyone. give a negative argument to --time to get local time. not activated for GCM files for the moment.

Location:
trunk/UTIL/PYTHON
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/UTIL/PYTHON/README.PP

    r394 r424  
    6262
    6363Goal: I want to plot results from two simulation files next to one another
    64 pp.py -f diagfired.nc,diagfired.nc -x -v tsurf
     64pp.py -f diagfired.nc,diagfired.nc -v tsurf
     65
     66Goal: I want to plot results for two different times in the file next to one another
     67pp.py -f diagfi.nc -v tsurf --time 4 -- time 7
     68
     69Goal: I want to plot averaged results in the file from one time to another time
     70pp.py -f diagfi.nc -v tsurf --time 4,7
     71
     72--- mesoscale stuff
     73Goal: I want to plot results for two different LOCAL times in the file next to one another
     74pp.py -f wrfout**** -v TSURF --time -4 -- time -7
    6575
    6676***********************************************************************************
  • trunk/UTIL/PYTHON/myscript.py

    r422 r424  
    3636    parser.add_option('-s', '--stride', action='store',dest='ste',       type="int",     default=3,     help='stride vectors [3]')
    3737    parser.add_option('-W', '--winds',  action='store_true',dest='winds',                default=False, help='wind vectors [False]')
    38     parser.add_option('-n', '--num',    action='store',dest='num',       type="int",     default=None,  help='plot number (<0: plot LT -*numplot*) [1]')
    3938    parser.add_option('-z', '--zoom',   action='store',dest='zoom',      type="float",   default=None,  help='zoom factor in %')
    40     parser.add_option('-e', '--itstep', action='store',dest='it',        type="int",     default=None,  help='stride time [4]')
    41     parser.add_option('-F', '--first',  action='store',dest='frt',       type="int",     default=1,     help='first subscript to plot [1]')
    4239    parser.add_option('--blat',         action='store',dest='blat',      type="int",     default=None,  help='bounding latitude for stereographic plots [computed]')
    4340
     
    4744    parser.add_option('--vert',         action='append',dest='svert',  type="string",  default=None, help='slices along vert. 2 comma-separated values: averaging')
    4845    parser.add_option('--column',       action='store_true',dest='column',             default=False,help='changes --vert z1,z2 from MEAN to INTEGRATE along z')
    49     parser.add_option('--time',         action='append',dest='stime',  type="string",  default=None, help='slices along time. 2 comma-separated values: averaging')
     46    parser.add_option('--time',         action='append',dest='stime',  type="string",  default=None, help='slices along time. 2 comma-separated values: averaging. negative: local time [meso].')
    5047    parser.add_option('--xmax',         action='store',dest='xmax',    type="float",   default=None, help='max value for x-axis in contour-plots [max(xaxis)]')
    5148    parser.add_option('--ymax',         action='store',dest='ymax',    type="float",   default=None, help='max value for y-axis in contour-plots [max(yaxis)]')
  • trunk/UTIL/PYTHON/planetoplot.py

    r423 r424  
    1515           target=None,
    1616           stride=3,\
    17            numplot=None,\
    1817           var=None,\
    1918           colorb="def",\
     
    2625           zoom=None,\
    2726           display=True,\
    28            itstep=None,\
    2927           hole=False,\
    3028           save="gui",\
     
    3230           var2=None,\
    3331           ndiv=10,\
    34            first=1,\
    3532           mult=1.,\
    3633           zetitle="fill",\
     
    9390        if svert is None:  svert = readslices(str(level)) ; nvert=1
    9491    zelen = len(namefiles)*len(var)
    95     if numplot is None:  numplot = zelen*nslices
     92    numplot = zelen*nslices
    9693    print "********** FILES, SLICES, VARS, TOTAL PLOTS: ", len(namefiles), nslices, len(var), numplot
    9794    print "********** MAPMODE: ", mapmode
     
    230227    #################################
    231228    ### Time loop for plotting device
    232     found_lct = False;nplot = 1;itime = first;error = False
    233     if itstep is None and numplot > 0: itstep = int(24./numplot)
    234     elif numplot <= 0:                 itstep = 1
     229    nplot = 1;error = False
    235230    print "********************************************"
    236231    while error is False:
    237        print "********** nplot", nplot, "itime",itime,"error",error
     232       print "********** nplot", nplot, "error",error
    238233     
    239        ### Which local time ?
    240        ltst = localtime ( interv[0]+itime*interv[1], 0.5*(wlon[0]+wlon[1]) )
    241 
    242234       ### General plot settings
    243        #print itime, int(ltst), numplot, nplot
    244        if numplot >= 1:
    245            if nplot > numplot: break
    246            if numplot > 1:     
    247                if typefile not in ['geo']:  subplot(subv,subh,nplot)
    248            found_lct = True
    249        ### If only one local time is requested (numplot < 0)
    250        elif numplot <= 0:
    251            if int(ltst) + numplot != 0:
    252                  itime += 1
    253                  if found_lct is True: break     ## because it means LT was found at previous iteration
    254                  else:                 continue  ## continue to iterate to find the correct LT
    255            else:
    256                  found_lct = True
     235       if nplot > numplot: break
     236       if numplot > 1:  subplot(subv,subh,nplot)
    257237
    258238       ### Map projection                   
     
    260240           m = define_proj(proj,wlon,wlat,back=back,blat=blat)
    261241           x, y = m(lon2d, lat2d)
    262 ####################################################################
     242
     243       ####################################################################
    263244       ## get all indexes to be taken into account for this subplot and then reduce field
    264245       ## We plot 1) all lon slices 2) all lat slices 3) all vert slices 4) all time slices and then go to the next slice
     
    272253       else:                            yeah = len(namefiles)*len(var) ; index_f = ((nplot-1)//(nlon*nlat*nvert*ntime))%yeah
    273254       time = all_time[index_f]
    274 
    275        if mapmode == 1 and stime is None:
    276            indextime = itime
    277            if len(var) != 1 or len(namefiles) != 1: indextime = first
    278        else:
    279            indextime = getsindex(stime,((nplot-1)//(nlon*nlat*nvert))%ntime,time)
    280            if typefile in ['mesoapi','meso'] and indextime is not None:  ltst = localtime ( interv[0]+indextime*interv[1], 0.5*(wlon[0]+wlon[1]) ) 
    281 ####################################################################
     255       if stime is not None:
     256           if stime[0][0] < 0:
     257               if typefile in ['mesoapi','meso']:
     258                   for i in range(len(time)):  time[i] = localtime ( interv[0]+time[i]*interv[1], 0.5*(wlon[0]+wlon[1]) )
     259                   stime = -stime ; print "OK... WORKING WITH LOCAL TIMES"
     260               else: errormess("local times not supported for GCM files. not too hard to modify the code though.")
     261       if mapmode == 1 and stime is None:   indextime = 1
     262       else:                                indextime = getsindex(stime,((nplot-1)//(nlon*nlat*nvert))%ntime,time)
     263       if typefile in ['mesoapi','meso'] and indextime is not None:  ltst = localtime ( interv[0]+indextime*interv[1], 0.5*(wlon[0]+wlon[1]) ) 
     264       ####################################################################
    282265
    283266       ticks = ndiv + 1
     
    418401#       if indextime is not None:     plottitle = plottitle + " time: " + str(min(time[indextime])) +" "+ str(max(time[indextime]))
    419402       title( plottitle )
    420        itime += itstep
    421403       if nplot >= numplot: error = True
    422404       nplot += 1
     
    446428       zeplot=outputname
    447429
    448     if found_lct:     
    449         pad_inches_value = 0.35
    450         print "********** SAVE ", save
    451         if save == 'png':
    452             if display: makeplotres(zeplot,res=100.,pad_inches_value=pad_inches_value) #,erase=True)  ## a miniature
    453             makeplotres(zeplot,res=resolution,pad_inches_value=pad_inches_value,disp=False)
    454         elif save in ['eps','svg','pdf']:     makeplotres(zeplot,pad_inches_value=pad_inches_value,disp=False,ext=save)
    455         elif save == 'gui':                   show()
    456         elif save == 'txt':                   print "Saved results in txt file."
    457         else:
    458             print "INFO: save mode not supported. using gui instead."
    459             show()
    460     else:   print "!!! Local time not found"
     430    pad_inches_value = 0.35
     431    print "********** SAVE ", save
     432    if save == 'png':
     433        if display: makeplotres(zeplot,res=100.,pad_inches_value=pad_inches_value) #,erase=True)  ## a miniature
     434        makeplotres(zeplot,res=resolution,pad_inches_value=pad_inches_value,disp=False)
     435    elif save in ['eps','svg','pdf']:     makeplotres(zeplot,pad_inches_value=pad_inches_value,disp=False,ext=save)
     436    elif save == 'gui':                   show()
     437    elif save == 'txt':                   print "Saved results in txt file."
     438    else:
     439         print "INFO: save mode not supported. using gui instead."
     440         show()
    461441
    462442    ###############
  • trunk/UTIL/PYTHON/pp.py

    r419 r424  
    125125        name = planetoplot (zefiles,level=int(zelevel),vertmode=opt.itp,\
    126126                proj=opt.proj,back=opt.back,target=opt.tgt,stride=opt.ste,var=zevars,\
    127                 numplot=opt.num,colorb=opt.clb,winds=opt.winds,\
     127                colorb=opt.clb,winds=opt.winds,\
    128128                addchar=lschar,interv=[zehour,zehourin],vmin=zevmin,vmax=zevmax,\
    129129                tile=opt.tile,zoom=opt.zoom,display=opt.display,\
    130                 itstep=opt.it,hole=opt.hole,save=opt.save,\
    131                 anomaly=opt.anomaly,var2=opt.var2,ndiv=opt.ndiv,first=opt.frt,\
     130                hole=opt.hole,save=opt.save,\
     131                anomaly=opt.anomaly,var2=opt.var2,ndiv=opt.ndiv,\
    132132                mult=opt.mult,zetitle=opt.zetitle,\
    133133                slon=zeslon,slat=zeslat,svert=zesvert,stime=zestime,\
     
    143143    command = "" 
    144144    for arg in sys.argv: command = command + arg + ' '
    145     if typefile not in ["meso","mesoapi"]: name = 'pycommand'
     145    #if typefile not in ["meso","mesoapi"]: name = 'pycommand'
     146    if opt.save is "gui": name = 'pycommand'
    146147    f = open(name+'.sh', 'w')
    147148    f.write(command)
Note: See TracChangeset for help on using the changeset viewer.