Changeset 240 for trunk/MESOSCALE_DEV/PLOT/PYTHON/mylib
- Timestamp:
- Jul 22, 2011, 9:46:21 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MESOSCALE_DEV/PLOT/PYTHON/mylib/myplot.py
r238 r240 100 100 wlon = [-60.,60.] 101 101 elif area == "North_Pole": 102 wlat = [ 60.,90.]102 wlat = [50.,90.] 103 103 wlon = [-180.,180.] 104 104 elif area == "Close_North_Pole": 105 105 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.] 106 112 wlon = [-180.,180.] 107 113 return wlon,wlat … … 244 250 return [wlon,wlat] 245 251 246 def makeplot pngres (filename,res,pad_inches_value=0.25,folder='',disp=True):252 def makeplotres (filename,res=None,pad_inches_value=0.25,folder='',disp=True,ext='png',erase=False): 247 253 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 250 260 if folder != '': name = folder+'/'+name 251 261 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") 253 265 return 254 266 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): 267 def dumpbdy (field,n,stag=None): 261 268 nx = len(field[0,:])-1 262 269 ny = len(field[:,0])-1 263 270 if stag == 'U': nx = nx-1 264 271 if stag == 'V': ny = ny-1 265 return field[ 5:ny-5,5:nx-5]272 return field[n:ny-n,n:nx-n] 266 273 267 274 def getcoorddef ( nc ): … … 270 277 if typefile in ['mesoapi','meso']: 271 278 [lon2d,lat2d] = getcoord2d(nc) 272 lon2d = dumpbdy(lon2d )273 lat2d = dumpbdy(lat2d )279 lon2d = dumpbdy(lon2d,6) 280 lat2d = dumpbdy(lat2d,6) 274 281 elif typefile in ['gcm']: 275 282 [lon2d,lat2d] = getcoord2d(nc,nlat="latitude",nlon="longitude",is1d=True) … … 376 383 import numpy as np 377 384 import matplotlib as mpl 385 from mymath import max 378 386 meanlon = 0.5*(wlon[0]+wlon[1]) 379 387 meanlat = 0.5*(wlat[0]+wlat[1]) 380 388 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 383 392 h = 50. ## en km 384 393 radius = 3397200. … … 482 491 "ICETOT": "%.1e",\ 483 492 "TAU_ICE": "%.2f",\ 493 "anomaly": "%.1f",\ 484 494 } 485 495 if whichvar not in fmtvar: … … 499 509 "ICETOT": "YlGnBu",\ 500 510 "TAU_ICE": "Blues",\ 511 "anomaly": "RdBu_r",\ 501 512 } 513 #spectral BrBG RdBu_r 502 514 if whichone not in whichcolorb: 503 515 whichone = "def"
Note: See TracChangeset
for help on using the changeset viewer.