Changeset 2295 in lmdz_wrf for trunk/tools
- Timestamp:
- Jan 28, 2019, 10:49:39 PM (6 years ago)
- Location:
- trunk/tools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/module_scientific.f90
r2294 r2295 5263 5263 ! Local 5264 5264 INTEGER :: iv, ix, iy 5265 INTEGER :: Nvertex 5265 INTEGER :: Nvertex, Nptin 5266 5266 INTEGER, ALLOCATABLE, DIMENSION(:,:) :: poinsin 5267 5267 CHARACTER(len=20) :: IS … … 5316 5316 END DO 5317 5317 5318 Nptin = Ngridsin(ix,iy) 5318 5319 CALL grid_spacepercen_within_reg(Nvertex, vertexgrid, dxB, dyB, NBvertexmax, xBBvals, & 5319 yBBvals, Ngridsin(ix,iy), poinsin, strict, pareas, percentages(ix,iy,1: dxyB))5320 yBBvals, Ngridsin(ix,iy), poinsin, strict, pareas, percentages(ix,iy,1:Nptin)) 5320 5321 5321 5322 ! Filling areas -
trunk/tools/nc_var_tools.py
r2294 r2295 28231 28231 else: 28232 28232 dn = varn + '' 28233 varslcv = slicesinf[dn] 28234 Nslices = varslcv[0] 28235 ovardims = varslcv[1] 28236 slcvar = varslcv[2] 28237 lcvalsc = varslcv[3] 28238 slcvals = varslcv[4] 28239 28233 28240 dv = np.zeros((1,Nslices), dtype=int) 28234 28241 # Here is only done by 1D variables !!! … … 28236 28243 print ' ' + fname + ": slicing variable '" + dn + "' without bounds !!" 28237 28244 print ' directly using grid point values' 28238 28239 #if len(varv.shape) > 1: 28240 # print errormsg 28241 # print ' ' + fname + ": wrong shape for slicing vriable '" + varn + "' !!" 28242 # print ' function only ready to slice 1D varables and it has:', \ 28243 # varv.shape 28244 # quit(-1) 28245 print ' remaining dimensions:', rmdims 28246 28247 refblon1D = np.zeros((Nslices,4), dtype=np.float) 28248 for iv in range(Nslices): 28249 slcvv = slcvals[iv] 28250 refblon1D[iv,0] = slcvv[0] 28251 refblon1D[iv,1] = slcvv[1] 28252 refblon1D[iv,2] = slcvv[1] 28253 refblon1D[iv,3] = slcvv[0] 28254 refblat1D = np.zeros((1,4), dtype=np.float) 28255 refblat1D[0,:] = np.array([-1,1,1,-1]) 28256 28257 # Getting boundaries to compute area of the slices 28258 iid = 0 28259 for dimn in rmdims: 28260 if slicebndsdim.has_key(dimn): 28261 print " bounded dimension '" + dimn + "' by '" + slicebndsdim[dimn] + "' !!" 28262 if iid == 0: 28263 ogetblat = onc.variables[slicebndsdim[dimn]] 28264 # Removing undesired dimensions from bounds slicing variable 28265 if sliceremovedim is not None: 28266 getblat, rmd, rms = ovar_reducedims(ogetblat, sliceremovedim) 28267 else: 28268 getblat = ogetblat[:] 28269 rmd = ogetblat.dimensions 28270 rms = list(ogetblat.shape) 28271 elif iid == 1: 28272 ogetblon = onc.variables[slicebndsdim[dimn]] 28273 # Removing undesired dimensions from bounds slicing variable 28274 if sliceremovedim is not None: 28275 getblon, rmd, rms = ovar_reducedims(ogetblon, sliceremovedim) 28276 else: 28277 getblon = ogetblon[:] 28278 rmd = ogetblon.dimensions 28279 rms = list(ogetblon.shape) 28280 iid = iid + 1 28281 xdimvarbnds2D = getblon 28282 ydimvarbnds2D = getblat 28245 28283 28246 28284 Ngridsin = np.zeros((1,Nslices), dtype=int) … … 28253 28291 areas = np.ones(tuple(varfinalshape), dtype=np.float) 28254 28292 percens = np.zeros((Ngridsinmax,1,Nslices), dtype=np.float) 28293 28255 28294 for islc in range(Nslices): 28256 28295 unmasked = slcvar[islc,] … … 28283 28322 # Remenber we are in C-like ... 28284 28323 ainds = ainds - 1 28324 28285 28325 if Ngridsin[0,islc] > 0: 28286 28326 gridsin[0,0:Nt,0,islc] = ainds[0,0:Nt] … … 28397 28437 for i in range(dxref): 28398 28438 apolygon = np.zeros((4,2), dtype=np.float) 28399 apolygon[0,0] = refblon1D[i,0]28400 apolygon[1,0] = refblon1D[i,1]28401 apolygon[2,0] = refblon1D[i,1]28402 apolygon[3,0] = refblon1D[i,0]28403 apolygon[0,1] = refblat1D[j,1]28404 apolygon[1,1] = refblat1D[j,1]28405 apolygon[2,1] = refblat1D[j,0]28406 apolygon[3,1] = refblat1D[j,0]28407 ap = np.abs(fsci.module_scientific.shoelace_area_polygon(nvertex=4, poly=apolygon))28439 #apolygon[0,0] = refblon1D[i,0] 28440 #apolygon[1,0] = refblon1D[i,1] 28441 #apolygon[2,0] = refblon1D[i,1] 28442 #apolygon[3,0] = refblon1D[i,0] 28443 #apolygon[0,1] = refblat1D[j,1] 28444 #apolygon[1,1] = refblat1D[j,1] 28445 #apolygon[2,1] = refblat1D[j,0] 28446 #apolygon[3,1] = refblat1D[j,0] 28447 #ap = np.abs(fsci.module_scientific.shoelace_area_polygon(nvertex=4, poly=apolygon)) 28408 28448 innewvar[:,0:Ngridsin[j,i],j,i] = \ 28409 28449 gridsin[:,0:Ngridsin[j,i],j,i] … … 28418 28458 apolygon[:,1] = ydimvarbnds2D[:,iy,ix] 28419 28459 ag = np.abs(fsci.module_scientific.shoelace_area_polygon(nvertex=4, poly=apolygon)) 28420 print ' lluis iv:', iv, ':', iy, ix, 'ag:', ag, 'areas:', areas[iy,ix], 'percens:', percens[iv,j,i] 28421 slicearea = slicearea + areas[iy,ix]*percens[iv,j,i] 28460 if varn == 'HGT': 28461 print 'Lluis ref dy:', dyref, 'dx:', dxref 28462 print ' lluis iv:', iv, ':', iy, ix, '<>', apolygon[1:3,0],'x',apolygon[2:4,1],'ag:', ag, 'areas:', areas[iy,ix], 'percens:', percens[iv,j,i] 28463 slicearea = slicearea + ag*percens[iv,j,i] 28422 28464 aa = aa + areas[iy,ix] 28423 28465 pp = pp + percens[iv,j,i] 28424 28466 aanewvar[j,i]= slicearea 28425 print ' areas Lluis =', refblon1D[i,:], 'x', refblat1D[j,:], \ 28426 'j i:', j,i, 'ap', ap, 'aanewvar:', slicearea, 'aa:', aa, 'pp:', pp 28427 if slicearea > ap: quit() 28467 #print ' areas Lluis =', refblon1D[i,:], 'x', refblat1D[j,:], \ 28468 # 'j i:', j,i, 'ap', ap, 'aanewvar:', slicearea, 'aa:', aa, 'pp:', pp 28469 if varn == 'HGT': 28470 print ' areas Lluis =', refblon1D[i,:], 'x', refblat1D[j,:], \ 28471 'j i:', j,i, 'aanewvar:', slicearea, 'aa:', aa, 'pp:', pp 28472 #if slicearea > ap: quit() 28428 28473 28429 28474 onewnc.sync()
Note: See TracChangeset
for help on using the changeset viewer.