Changeset 1968 in lmdz_wrf for trunk/tools/drawing.py
- Timestamp:
- Jul 24, 2018, 6:45:52 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/drawing.py
r1948 r1968 9151 9151 * NOTE: limits of the graph will be computed from the continuous variable 9152 9152 values=[vnamefs]:[dvarxn],[dvaryn]:[dimxyfmt]:[colorbarvals]:[sminv],[smaxv]: 9153 [discvals]:[figt]:[kindfig]:[reverse]:[mapv]:[ close]9153 [discvals]:[figt]:[kindfig]:[reverse]:[mapv]:[plotrange]:[close] 9154 9154 [vnamefs]: Name in the figure of the variable to be shaded 9155 9155 [dvarxn],[dvaryn]: name of the dimensions for the final x-axis and y-axis at … … 9207 9207 * 'h', high 9208 9208 * 'f', full 9209 [plotrange]: range of the plot 9210 'strict': map covers only the minimum and maximum lon,lats from the 9211 locations of the discrtete points 9212 'sponge,'[dlon],[dlat]: map covers an extended [dlon],[dlat] from the 9213 minimum and maximum lon,lats from the locations of the discrtete points 9214 'fullcontinuous': map covers all the shadding area 9209 9215 [close]: Whether figure should be finished or not 9210 9216 """ … … 9217 9223 9218 9224 expectargs = '[vnamefs]:[dvarxn],[dvaryn]:[dimxyfmt]:[colorbarvals]:[sminv],' + \ 9219 '[smaxv]:[discvals]:[figt]:[kindfig]:[reverse]:[mapv]:[ close]'9225 '[smaxv]:[discvals]:[figt]:[kindfig]:[reverse]:[mapv]:[plotrange]:[close]' 9220 9226 9221 9227 drw.check_arguments(fname,values,expectargs,':') … … 9231 9237 revals = values.split(':')[8] 9232 9238 mapvalue = values.split(':')[9] 9233 close = gen.Str_Bool(values.split(':')[10]) 9239 plotrange = values.split(':')[10] 9240 close = gen.Str_Bool(values.split(':')[11]) 9234 9241 9235 9242 ncs = ncfiles.split('@') … … 9266 9273 if not onc.variables.has_key(varn): 9267 9274 print errormsg 9268 print ' ' + fname + ": '" + hfn + "' file '" + ncfile +\9275 print ' ' + fname + ": '" + hfn + "' file '" + ncfilen + \ 9269 9276 "' does not have variable '" + varn + "' !!" 9270 9277 varns = sorted(onc.variables.keys()) … … 9276 9283 vals, dims = drw.slice_variable(ovar, dimvals.replace(',','|')) 9277 9284 9278 # Values have to be 2D (might not be true for disc?)9279 if len(vals.shape) != 2:9285 # Values have to be 2D 9286 if hfn == 'cont' and len(vals.shape) != 2: 9280 9287 print errormsg 9281 9288 print ' ' + fname + ": values have to be 2D !!" … … 9294 9301 if not onc.variables.has_key(vdimxn): 9295 9302 print errormsg 9296 print ' ' + fname + ": '" + hfn + "' file '" + ncfile +\9303 print ' ' + fname + ": '" + hfn + "' file '" + ncfilen + \ 9297 9304 "' does not have x-dimension variable '" + vdimxn + "' !!" 9298 9305 varns = sorted(onc.variables.keys()) … … 9301 9308 if not onc.variables.has_key(vdimyn): 9302 9309 print errormsg 9303 print ' ' + fname + ": '" + hfn + "' file '" + ncfile +\9310 print ' ' + fname + ": '" + hfn + "' file '" + ncfilen + \ 9304 9311 "' does not have y-dimension variable '" + vdimyn + "' !!" 9305 9312 varns = sorted(onc.variables.keys()) … … 9392 9399 absyn = dyn 9393 9400 absyx = dyx 9401 contxynx = [dxn, dxx, dyn, dyx] 9394 9402 9395 9403 else: … … 9403 9411 madiscvarv = vals 9404 9412 9405 # Getting 2D dimensions 9406 [d2Dx, d2Dy] = np.meshgrid(odimxv0, odimyv0) 9407 9408 # Checking for flipping axis? 9409 if d2Dx.shape[0] == vals.shape[1] and d2Dx.shape[1] == vals.shape[0]: 9410 print ' rotating values !' 9411 #madiscvarv = madiscvarv.transpose() 9412 d2Dx = d2Dx.transpose() 9413 d2Dy = d2Dy.transpose() 9414 9415 # vals have to be 2D otherwise... ? 9416 dx = madiscvarv.shape[1] 9417 dy = madiscvarv.shape[0] 9418 for j in range(dy): 9419 for i in range(dx): 9420 if not madiscvarv.mask[j,i]: 9421 discvarv.append(madiscvarv[j,i]) 9422 discx.append(d2Dx[j,i]) 9423 discy.append(d2Dy[j,i]) 9413 if len(vals.shape) == 1: 9414 if type(madiscvarv.mask) == type(np.True_): 9415 discvarv = list(madiscvarv[:]) 9416 discx = list(odimxv0[:]) 9417 discy = list(odimyv0[:]) 9418 else: 9419 for i in range(vals.shape[0]): 9420 if not madiscvarv.mask[i]: 9421 discvarv.append(madiscvarv[i]) 9422 discx.append(odimxv0[i]) 9423 discy.append(odimyv0[i]) 9424 9425 elif len(vals.shape) == 2: 9426 # Getting 2D dimensions 9427 [d2Dx, d2Dy] = np.meshgrid(odimxv0, odimyv0) 9428 9429 # Checking for flipping axis? 9430 if d2Dx.shape[0] == vals.shape[1] and d2Dx.shape[1] == vals.shape[0]: 9431 print ' rotating values !' 9432 #madiscvarv = madiscvarv.transpose() 9433 d2Dx = d2Dx.transpose() 9434 d2Dy = d2Dy.transpose() 9435 9436 # vals have to be 2D otherwise... ? 9437 dx = madiscvarv.shape[1] 9438 dy = madiscvarv.shape[0] 9439 for j in range(dy): 9440 for i in range(dx): 9441 if not madiscvarv.mask[j,i]: 9442 discvarv.append(madiscvarv[j,i]) 9443 discx.append(d2Dx[j,i]) 9444 discy.append(d2Dy[j,i]) 9445 else: 9446 # Values have to be 1D or 2D 9447 print errormsg 9448 print ' ' + fname + ": disc. values have to be 1D or 2D !!" 9449 print ' provided shape:', vals.shape, 'for slice:', dimvals 9450 quit(-1) 9424 9451 9425 9452 Ndiscvals = len(discvarv) … … 9438 9465 onc.close() 9439 9466 9440 graphnx = [absxn, absxx, absyn, absyx] 9441 print 'limits of the graphic:', graphnx 9467 if plotrange[0:6] == 'strict': 9468 graphnx = [absxn, absxx, absyn, absyx] 9469 elif plotrange[0:6] == 'sponge': 9470 dlon = np.float(plotrange.split(',')[1]) 9471 dlat = np.float(plotrange.split(',')[2]) 9472 graphnx = [absxn-dlon, absxx+dlon, absyn-dlat, absyx+dlat] 9473 elif plotrange[0:14] == 'fullcontinuous': 9474 graphnx = contxynx 9475 9476 print " '" + plotrange + "' limits of the graphic:", graphnx 9442 9477 9443 9478 shading_nx = []
Note: See TracChangeset
for help on using the changeset viewer.