Changeset 202 for trunk/MESOSCALE/PLOT/PYTHON/mylib
- Timestamp:
- Jul 11, 2011, 12:02:13 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MESOSCALE/PLOT/PYTHON/mylib/myplot.py
r201 r202 62 62 return lschar, zehour, zehourin 63 63 64 def getprefix (nc): 65 prefix = 'LMD_MMM_' 66 prefix = prefix + 'd'+str(getattr(nc,'GRID_ID'))+'_' 67 prefix = prefix + str(int(getattr(nc,'DX')/1000.))+'km_' 68 return prefix 69 64 70 def api_onelevel ( path_to_input = None, \ 65 71 input_name = 'wrfout_d0?_????-??-??_??:00:00', \ … … 177 183 return improc 178 184 185 def getwinds (nc,charu='Um',charv='Vm'): 186 import numpy as np 187 u = nc.variables[charu] 188 v = nc.variables[charv] 189 if charu == 'U': u = u[:, :, :, 0:len(u[0,0,0,:])-1] 190 if charv == 'V': v = v[:, :, 0:len(v[0,0,:,0])-1, :] 191 ### ou alors prendre les coordonnees speciales 192 return u,v 193 179 194 def vectorfield (u, v, x, y, stride=3, scale=15., factor=250., color='black', csmooth=1, key=True): 180 195 ## scale regle la reference du vecteur … … 182 197 import matplotlib.pyplot as plt 183 198 import numpy as np 184 #posx = np.max(x) + np.std(x) / 3. ## pb pour les domaines globaux ...185 #posy = np.mean(y)186 #posx = np.min(x)187 #posy = np.max(x)188 #posx = np.max(x) - np.std(x) / 10.189 #posy = np.max(y) + np.std(y) / 10.190 199 posx = np.min(x) - np.std(x) / 10. 191 200 posy = np.min(y) - np.std(y) / 10. … … 199 208 angles='xy',color=color,\ 200 209 scale=factor,width=widthvec ) 201 if color=='white': kcolor='black' 202 elif color=='yellow': kcolor=color 203 else: kcolor=color 210 if color in ['white','yellow']: kcolor='black' 211 else: kcolor=color 204 212 if key: p = plt.quiverkey(q,posx,posy,scale,\ 205 213 str(int(scale)),coordinates='data',color=kcolor,labelpos='S',labelsep = 0.03) … … 233 241 else: blat = wlat[0] 234 242 h = 2000. 235 radius = 3397200 243 radius = 3397200. 236 244 if char == "cyl": m = Basemap(rsphere=radius,projection='cyl',\ 237 245 llcrnrlat=wlat[0],urcrnrlat=wlat[1],llcrnrlon=wlon[0],urcrnrlon=wlon[1]) … … 261 269 "def": "%.1e",\ 262 270 "PTOT": "%.0f",\ 271 "HGT": "%.1e",\ 263 272 "USTM": "%.2f",\ 264 273 } … … 266 275 whichvar = "def" 267 276 return fmtvar[whichvar] 277 278 def defcolorb (whichone="def"): 279 whichcolorb = { \ 280 "def": "spectral",\ 281 "HGT": "spectral",\ 282 "tk": "gist_heat",\ 283 "QH2O": "PuBu",\ 284 } 285 if whichone not in whichcolorb: 286 whichone = "def" 287 return whichcolorb[whichone] 288 289 def definecolorvec (whichone="def"): 290 whichcolor = { \ 291 "def": "black",\ 292 "vis": "yellow",\ 293 "vishires": "yellow",\ 294 "molabw": "yellow",\ 295 "mola": "black",\ 296 "gist_heat": "white",\ 297 "hot": "tk",\ 298 "gist_rainbow": "black",\ 299 "spectral": "black",\ 300 "gray": "red",\ 301 "PuBu": "black",\ 302 } 303 if whichone not in whichcolor: 304 whichone = "def" 305 return whichcolor[whichone] 268 306 269 307 def marsmap (whichone="vishires"):
Note: See TracChangeset
for help on using the changeset viewer.