Changeset 207 for trunk/MESOSCALE_DEV/PLOT/PYTHON
- Timestamp:
- Jul 12, 2011, 11:51:13 AM (13 years ago)
- Location:
- trunk/MESOSCALE_DEV
- Files:
-
- 1 added
- 1 edited
- 4 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/MESOSCALE_DEV/PLOT/PYTHON/mylib/api_wrapper.py
r186 r207 14 14 extrapolate = 0, \ 15 15 unstagger_grid = False, \ 16 onelevel = 0.020 ): 16 onelevel = 0.020, \ 17 nocall = False ): 17 18 import api 18 19 import numpy as np … … 27 28 print input_name, output_name 28 29 29 api.api_main ( path_to_input, input_name, path_to_output, output_name, \ 30 if nocall: pass 31 else: api.api_main ( path_to_input, input_name, path_to_output, output_name, \ 30 32 process, fields, debug, bit64, oldvar, np.arange(299), \ 31 33 interp_method, extrapolate, unstagger_grid, onelevel ) -
trunk/MESOSCALE_DEV/PLOT/PYTHON/mylib/myplot.py
r204 r207 68 68 return prefix 69 69 70 def api_onelevel ( path_to_input = None, \71 input_name = 'wrfout_d0?_????-??-??_??:00:00', \72 path_to_output = None, \73 output_name = 'output.nc', \74 process = 'list', \75 fields = 'tk,W,uvmet,HGT', \76 debug = False, \77 bit64 = False, \78 oldvar = True, \79 interp_method = 4, \80 extrapolate = 0, \81 unstagger_grid = False, \82 onelevel = 0.020 ):83 import api84 import numpy as np85 if not path_to_input: path_to_input = './'86 if not path_to_output: path_to_output = path_to_input87 api.api_main ( path_to_input, input_name, path_to_output, output_name, \88 process, fields, debug, bit64, oldvar, np.arange (299), \89 interp_method, extrapolate, unstagger_grid, onelevel )90 return91 92 70 def getproj (nc): 93 71 map_proj = getattr(nc, 'MAP_PROJ') … … 240 218 elif wlat[0] <= -80.: blat = -40. 241 219 else: blat = wlat[0] 242 h = 2000.220 h = 50. ## en km 243 221 radius = 3397200. 244 222 if char == "cyl": m = Basemap(rsphere=radius,projection='cyl',\ … … 250 228 elif char == "npstere": m = Basemap(rsphere=radius,projection='npstere', boundinglat=blat, lon_0=0.) 251 229 elif char == "spstere": m = Basemap(rsphere=radius,projection='spstere', boundinglat=blat, lon_0=0.) 230 elif char == "nplaea": m = Basemap(rsphere=radius,projection='nplaea', boundinglat=wlat[0], lon_0=meanlon) 231 elif char == "laea": m = Basemap(rsphere=radius,projection='laea',lon_0=meanlon,lat_0=meanlat,lat_ts=meanlat,\ 232 llcrnrlat=wlat[0],urcrnrlat=wlat[1],llcrnrlon=wlon[0],urcrnrlon=wlon[1]) 252 233 elif char == "nsper": m = Basemap(rsphere=radius,projection='nsper',lon_0=meanlon,lat_0=meanlat,satellite_height=h*1000.) 253 234 elif char == "merc": m = Basemap(rsphere=radius,projection='merc',lat_ts=0.,\ 254 235 llcrnrlat=wlat[0],urcrnrlat=wlat[1],llcrnrlon=wlon[0],urcrnrlon=wlon[1]) 255 236 fontsizemer = int(mpl.rcParams['font.size']*3./4.) 256 if char in ["cyl","lcc","merc" ]: step = findstep(wlon)257 else: step = 10.237 if char in ["cyl","lcc","merc","nsper","laea"]: step = findstep(wlon) 238 else: step = 10. 258 239 m.drawmeridians(np.r_[-180.:180.:step*2.], labels=[0,0,0,1], color='grey', fontsize=fontsizemer) 259 240 m.drawparallels(np.r_[-90.:90.:step], labels=[1,0,0,0], color='grey', fontsize=fontsizemer) -
trunk/MESOSCALE_DEV/PLOT/PYTHON/scripts/winds.py
r204 r207 71 71 if not var: back = "mola" ## if no var: draw mola 72 72 elif typefile in ['mesoapi','meso'] \ 73 and proj not in ['merc','lcc' ]:back = "molabw" ## if var but meso: draw molabw73 and proj not in ['merc','lcc','nsper','laea']: back = "molabw" ## if var but meso: draw molabw 74 74 else: pass ## else: draw None 75 75 … … 82 82 elif typefile in ['gcm']: 83 83 [lon2d,lat2d] = getcoord2d(nc,nlat="latitude",nlon="longitude",is1d=True) 84 if proj == "npstere": [wlon,wlat] = latinterv("North_Pole")85 elif proj == "lcc": [wlon,wlat] = wrfinterv(lon2d,lat2d)86 else: [wlon,wlat] = simplinterv(lon2d,lat2d)84 if proj == "npstere": [wlon,wlat] = latinterv("North_Pole") 85 elif proj in ["lcc","laea"]: [wlon,wlat] = wrfinterv(lon2d,lat2d) 86 else: [wlon,wlat] = simplinterv(lon2d,lat2d) 87 87 if zoom: 88 88 dlon = abs(wlon[1]-wlon[0])/2. … … 125 125 ### some already defined colormaps 126 126 if colorb is True: colorb = defcolorb(var) 127 else: 128 dimension = 0 127 129 128 130 ########################### … … 139 141 if var: basename = basename + var 140 142 ### 141 if typefile is 'meso': stralt = "_lvl" + str(nvert) 142 elif typefile is 'mesoapi': 143 zelevel = int(nc.variables['vert'][nvert]) 144 if 'altitude' in nc.dimensions: stralt = "_"+str(zelevel)+"m-AMR" 145 elif 'altitude_abg' in nc.dimensions: stralt = "_"+str(zelevel)+"m-ALS" 146 elif 'bottom_top' in nc.dimensions: stralt = "_"+str(zelevel)+"m" 147 elif 'pressure' in nc.dimensions: stralt = "_"+str(zelevel)+"Pa" 148 else: stralt = "" 143 if dimension == 4: 144 if typefile is 'meso': stralt = "_lvl" + str(nvert) 145 elif typefile is 'mesoapi': 146 zelevel = int(nc.variables['vert'][nvert]) 147 if 'altitude' in nc.dimensions: stralt = "_"+str(zelevel)+"m-AMR" 148 elif 'altitude_abg' in nc.dimensions: stralt = "_"+str(zelevel)+"m-ALS" 149 elif 'bottom_top' in nc.dimensions: stralt = "_"+str(zelevel)+"m" 150 elif 'pressure' in nc.dimensions: stralt = "_"+str(zelevel)+"Pa" 151 else: stralt = "" 152 else: 153 stralt = "" 149 154 ### 150 155 basename = basename + stralt … … 175 180 rcParams['font.size'] = int( rcParams['font.size'] * 1. / 2. ) 176 181 elif numplot == 9: 177 sub = 331 182 sub = 331 178 183 fig.subplots_adjust(wspace = 0.3, hspace = 0.3) 179 184 rcParams['font.size'] = int( rcParams['font.size'] * 1. / 2. ) … … 181 186 sub = 99999 182 187 else: 183 print "supported: 1,2,3,4,6,8 "188 print "supported: 1,2,3,4,6,8,9" 184 189 exit() 185 190 ### Prepare time loop … … 306 311 parser.add_option('-i', action='store', dest='interp', type="int", default=None, help='interpolation method (2: press, 3: z-amr, 4:z-als)') 307 312 parser.add_option('-c', action='store', dest='colorb', type="string", default=True, help='change colormap') 308 parser.add_option('-x', action='store_false', dest='winds', default=True, help=' flag:no wind vectors')313 parser.add_option('-x', action='store_false', dest='winds', default=True, help='no wind vectors') 309 314 parser.add_option('-m', action='store', dest='vmin', type="float", default=None, help='bounding minimum value for color plot') 310 315 parser.add_option('-M', action='store', dest='vmax', type="float", default=None, help='bounding maximum value for color plot') 311 316 parser.add_option('-T', action='store_true', dest='tile', default=False, help='draw a tiled plot (no blank zone)') 312 317 parser.add_option('-z', action='store', dest='zoom', type="float", default=None, help='zoom factor in %') 318 parser.add_option('-N', action='store_true', dest='nocall', default=False, help='do not recreate api file') 313 319 #parser.add_option('-V', action='store', dest='comb', type="float", default=None, help='a defined combination of variables') 314 320 (opt,args) = parser.parse_args() … … 339 345 fields = zefields, \ 340 346 interp_method = opt.interp, \ 341 onelevel = zelevel ) 347 onelevel = zelevel, \ 348 nocall = opt.nocall ) 349 print zefile 342 350 zelevel = 0 ## so that zelevel could play again the role of nvert 343 351
Note: See TracChangeset
for help on using the changeset viewer.