Ignore:
Timestamp:
Jul 22, 2011, 9:46:21 AM (13 years ago)
Author:
aslmd
Message:

MESOSCALE: corrected a bug in the previous commit in makemeso, works now fine. added anomaly calculations in python interface + better treatment for output; default is now GUI where one can zoom etc... and further explore the plotted field

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/MESOSCALE_DEV/PLOT/PYTHON/mylib/myplot.py

    r238 r240  
    100100                wlon = [-60.,60.]
    101101        elif area == "North_Pole":
    102                 wlat = [60.,90.]
     102                wlat = [50.,90.]
    103103                wlon = [-180.,180.]
    104104        elif area == "Close_North_Pole":
    105105                wlat = [75.,90.]
     106                wlon = [-180.,180.]
     107        elif area == "South_Pole":
     108                wlat = [-90.,-50.]
     109                wlon = [-180.,180.]
     110        elif area == "Close_South_Pole":
     111                wlat = [-90.,-75.]
    106112                wlon = [-180.,180.]
    107113        return wlon,wlat
     
    244250    return [wlon,wlat]
    245251
    246 def makeplotpngres (filename,res,pad_inches_value=0.25,folder='',disp=True):
     252def makeplotres (filename,res=None,pad_inches_value=0.25,folder='',disp=True,ext='png',erase=False):
    247253    import  matplotlib.pyplot as plt
    248     res = int(res)
    249     name = filename+"_"+str(res)+".png"
     254    from os import system
     255    addstr = ""
     256    if res is not None:
     257        res = int(res)
     258        addstr = "_"+str(res)
     259    name = filename+addstr+"."+ext
    250260    if folder != '':      name = folder+'/'+name
    251261    plt.savefig(name,dpi=res,bbox_inches='tight',pad_inches=pad_inches_value)
    252     if disp:              display(name)         
     262    if disp:              display(name)
     263    if ext in ['eps','ps','svg']:   system("tar czvf "+name+".tar.gz "+name+" ; rm -f "+name)
     264    if erase:   system("mv "+name+" to_be_erased")             
    253265    return
    254266
    255 def makeplotpng (filename,pad_inches_value=0.25,minres=100.,folder='',disp=True):
    256     makeplotpngres(filename,minres,     pad_inches_value=pad_inches_value,folder=folder,disp=disp)
    257     makeplotpngres(filename,minres+200.,pad_inches_value=pad_inches_value,folder=folder,disp=False)
    258     return
    259 
    260 def dumpbdy (field,stag=None):
     267def dumpbdy (field,n,stag=None):
    261268    nx = len(field[0,:])-1
    262269    ny = len(field[:,0])-1
    263270    if stag == 'U': nx = nx-1
    264271    if stag == 'V': ny = ny-1
    265     return field[5:ny-5,5:nx-5]
     272    return field[n:ny-n,n:nx-n]
    266273
    267274def getcoorddef ( nc ):   
     
    270277    if typefile in ['mesoapi','meso']:
    271278        [lon2d,lat2d] = getcoord2d(nc)
    272         lon2d = dumpbdy(lon2d)
    273         lat2d = dumpbdy(lat2d)
     279        lon2d = dumpbdy(lon2d,6)
     280        lat2d = dumpbdy(lat2d,6)
    274281    elif typefile in ['gcm']:
    275282        [lon2d,lat2d] = getcoord2d(nc,nlat="latitude",nlon="longitude",is1d=True)
     
    376383    import  numpy                           as np
    377384    import  matplotlib                      as mpl
     385    from mymath import max
    378386    meanlon = 0.5*(wlon[0]+wlon[1])
    379387    meanlat = 0.5*(wlat[0]+wlat[1])
    380388    if   wlat[0] >= 80.:   blat =  40.
    381     elif wlat[0] <= -80.:  blat = -40.
    382     else:                  blat = wlat[0]
     389    elif wlat[1] <= -80.:  blat = -40.
     390    else:                  blat = max([wlat[0],wlat[1]])
     391    print blat
    383392    h = 50.  ## en km
    384393    radius = 3397200.
     
    482491             "ICETOT":       "%.1e",\
    483492             "TAU_ICE":      "%.2f",\
     493             "anomaly":      "%.1f",\
    484494                    }
    485495    if whichvar not in fmtvar:
     
    499509             "ICETOT":       "YlGnBu",\
    500510             "TAU_ICE":      "Blues",\
     511             "anomaly":      "RdBu_r",\
    501512                     }
     513#spectral BrBG RdBu_r
    502514    if whichone not in whichcolorb:
    503515        whichone = "def"
Note: See TracChangeset for help on using the changeset viewer.