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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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    ###############
Note: See TracChangeset for help on using the changeset viewer.