Changeset 191 for trunk/MESOSCALE/PLOT/PYTHON
- Timestamp:
- Jul 4, 2011, 2:40:25 PM (14 years ago)
- Location:
- trunk/MESOSCALE/PLOT/PYTHON
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MESOSCALE/PLOT/PYTHON/mylib/api_g95.sh
r186 r191 1 1 #! /bin/bash 2 2 3 f2py -c -m api ~/Science/MODELES/MESOSCALE/LMD_MM_MARS/SRC/POSTPROC/api.F90 --fcompiler=g95 -L$NETCDF/lib -lnetcdf -lm -I$NETCDF/include --f90flags="-Wall -Wno=112,141,137,155 -fno-second-underscore -ffree-form" > ~/logc 2> ~/loge 3 #NETCDF=/distrib/local/netcdf-4.0.1/g95_4.0.3_64/ 4 #echo $NETCDF 5 6 touch logc 7 touch loge 8 \rm logc 9 \rm loge 10 f2py -c -m api ../../../LMD_MM_MARS/SRC/POSTPROC/api.F90 --fcompiler=g95 -L$NETCDF/lib -lnetcdf -lm -I$NETCDF/include --f90flags="-Wall -Wno=112,141,137,155 -fno-second-underscore -ffree-form" > logc 2> loge -
trunk/MESOSCALE/PLOT/PYTHON/mylib/myplot.py
r188 r191 35 35 return wlon,wlat 36 36 37 #def landers (map) 38 # map.plot(blue_calf_lon,blue_calf_lat, 'gs') 39 # return 40 37 41 def api_onelevel ( path_to_input = None, \ 38 42 input_name = 'wrfout_d0?_????-??-??_??:00:00', \ -
trunk/MESOSCALE/PLOT/PYTHON/scripts/winds.py
r189 r191 1 1 #!/usr/bin/env python 2 2 3 ### A. Spiga -- LMD -- 30/0 5/20113 ### A. Spiga -- LMD -- 30/06/2011 to 04/07/2011 4 4 ### Thanks to A. Colaitis for the parser trick 5 5 … … 16 16 numplot=4,\ 17 17 var=None,\ 18 colorb=None): 18 colorb=None,\ 19 winds=True): 19 20 20 21 ################################# … … 32 33 ### Recognize predefined file types 33 34 if 'controle' in nc.variables: typefile = 'gcm' 34 elif ' Um' in nc.variables:typefile = 'mesoapi'35 elif 'vert' in nc.variables: typefile = 'mesoapi' 35 36 elif 'U' in nc.variables: typefile = 'meso' 36 37 else: 37 38 print "typefile not supported." 39 print nc.variables 38 40 exit() 39 41 … … 74 76 ############################################################################## 75 77 ### Get winds and know if those are meteorological winds (ie. zon, mer) or not 76 if typefile is 'mesoapi': 77 [u,v] = getwinds(nc) 78 metwind = True ## meteorological (zon/mer) 79 elif typefile is 'gcm': 80 [u,v] = getwinds(nc,charu='u',charv='v') 81 metwind = True ## meteorological (zon/mer) 82 elif typefile is 'meso': 83 [u,v] = getwinds(nc,charu='U',charv='V') 84 metwind = False ## geometrical (wrt grid) 85 print "Beware ! Not using meteorological winds. You trust numerical grid as being (x,y)." 86 87 #################################################### 78 if winds: 79 if typefile is 'mesoapi': 80 [u,v] = getwinds(nc) 81 metwind = True ## meteorological (zon/mer) 82 elif typefile is 'gcm': 83 [u,v] = getwinds(nc,charu='u',charv='v') 84 metwind = True ## meteorological (zon/mer) 85 elif typefile is 'meso': 86 [u,v] = getwinds(nc,charu='U',charv='V') 87 metwind = False ## geometrical (wrt grid) 88 print "Beware ! Not using meteorological winds. You trust numerical grid as being (x,y)." 89 90 ##################################################### 88 91 ### Load the chosen variables, whether it is 2D or 3D 89 92 if var: … … 96 99 elif dimension == 3: field = nc.variables[var][:,:,:] 97 100 elif dimension == 4: field = nc.variables[var][:,nvert,:,:] 98 nt = len(u[:,0,0,0]) 101 102 ########################### 103 ### Get length of time axis 104 if winds: nt = len(u[:,0,0,0]) 105 elif var: 106 if dimension == 2: nt = 1 107 else : nt = len(field[:,0,0]) 99 108 100 109 ######################################### 101 110 ### Name for title and graphics save file 102 basename = "WINDS" 111 if winds: basename = "WINDS_" 112 else: basename = "" 103 113 if var: 104 basename = basename + "_" +var114 basename = basename + var 105 115 if typefile is 'meso': stralt = "_lvl" + str(nvert) 106 116 elif typefile is 'mesoapi': … … 187 197 188 198 ### Vector plot 189 if typefile in ['mesoapi','meso']: 190 [vecx,vecy] = [dumpbdy(u[i,nvert,:,:]), dumpbdy(v[i,nvert,:,:])] 191 key = True 192 elif typefile in ['gcm']: 193 [vecx,vecy] = [ u[i,nvert,:,:] , v[i,nvert,:,:] ] 194 key = False 195 if metwind: [vecx,vecy] = m.rotate_vector(vecx, vecy, lon2d, lat2d) 196 if var == None and back == "vishires": colorvec = 'w' 197 else: colorvec = 'k' 198 vectorfield(vecx, vecy,\ 199 if winds: 200 if typefile in ['mesoapi','meso']: 201 [vecx,vecy] = [dumpbdy(u[i,nvert,:,:]), dumpbdy(v[i,nvert,:,:])] 202 key = True 203 elif typefile in ['gcm']: 204 [vecx,vecy] = [ u[i,nvert,:,:] , v[i,nvert,:,:] ] 205 key = False 206 if metwind: [vecx,vecy] = m.rotate_vector(vecx, vecy, lon2d, lat2d) 207 if var == None and back == "vishires": colorvec = 'w' 208 else: colorvec = 'k' 209 vectorfield(vecx, vecy,\ 199 210 x, y, stride=stride, csmooth=stride,\ 200 211 scale=15., factor=300., color=colorvec, key=key) … … 247 258 parser.add_option('-i', action='store', dest='interp', type="int", default=None, help='interpolation method (2: press, 3: z-amr, 4:z-als)') 248 259 parser.add_option('-c', action='store', dest='colorb', type="string", default=None, help='colorbar') 260 parser.add_option('-x', action='store_false', dest='winds', default=True, help='flag: no wind vectors') 249 261 (opt,args) = parser.parse_args() 250 262 if opt.namefile is None: … … 258 270 if opt.interp is not None: 259 271 if opt.nvert is 0 and opt.interp is 4: zelevel = 0.010 260 if opt.var is None : zefields = 'uvmet' 261 else : zefields = 'uvmet,'+opt.var 272 ### winds or no winds 273 if opt.winds : zefields = 'uvmet' 274 else : zefields = '' 275 ### var or no var 276 if opt.var is None : pass 277 elif zefields == '' : zefields = opt.var 278 else : zefields = zefields + "," + opt.var 279 print zefields 262 280 zefile = api_onelevel ( path_to_input = '', \ 263 281 input_name = zefile, \ … … 269 287 270 288 winds (zefile,int(zelevel),\ 271 proj=opt.proj,back=opt.back,target=opt.target,stride=opt.stride,var=opt.var,numplot=opt.numplot,colorb=opt.colorb )289 proj=opt.proj,back=opt.back,target=opt.target,stride=opt.stride,var=opt.var,numplot=opt.numplot,colorb=opt.colorb,winds=opt.winds)
Note: See TracChangeset
for help on using the changeset viewer.