Changeset 476 in lmdz_wrf for trunk/tools
- Timestamp:
- Jun 11, 2015, 5:04:24 PM (10 years ago)
- Location:
- trunk/tools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/drawing.py
r472 r476 169 169 odimyu = '-' 170 170 171 if len(objdimx.shape) <= 2: 172 # odimxv = objdimx[valshad.shape] 173 # odimyv = objdimy[valshad.shape] 174 odimxv = objdimx[:] 175 odimyv = objdimy[:] 176 177 elif len(objdimx.shape) == 3: 178 # dimcut = [0, slice(0,valshad.shape[0]), slice(0,valshad.shape[1])] 179 # odimxv = objdimx[tuple(dimcut)] 180 # odimyv = objdimy[tuple(dimcut)] 181 odimxv = objdimx[0,:] 182 odimyv = objdimy[0,:] 183 else: 184 print errormsg 185 print ' ' + fname + ': shape of dimension variable:', objdimx.shape, \ 186 ' not ready!!' 187 quit(-1) 171 odimxv, odimyv = dxdy_lonlatDIMS(objdimx[:], objdimy[:], objdimx.dimensions, \ 172 objdimy.dimensions, dimvals) 173 174 # if len(objdimx.shape) <= 2: 175 ## odimxv = objdimx[valshad.shape] 176 ## odimyv = objdimy[valshad.shape] 177 # odimxv = objdimx[:] 178 # odimyv = objdimy[:] 179 180 # elif len(objdimx.shape) == 3: 181 ## dimcut = [0, slice(0,valshad.shape[0]), slice(0,valshad.shape[1])] 182 ## odimxv = objdimx[tuple(dimcut)] 183 ## odimyv = objdimy[tuple(dimcut)] 184 # odimxv = objdimx[0,:] 185 # odimyv = objdimy[0,:] 186 # else: 187 # print errormsg 188 # print ' ' + fname + ': shape of dimension variable:', objdimx.shape, \ 189 # ' not ready!!' 190 # quit(-1) 188 191 189 192 shading_nx = [] -
trunk/tools/drawing_tools.py
r475 r476 3394 3394 ydims = '0' 3395 3395 3396 lon0, lat0 = dxdy_lonlat(dimxv,dimyv, xdims, ydims)3396 # lon0, lat0 = dxdy_lonlat(dimxv,dimyv, xdims, ydims) 3397 3397 3398 3398 if not mapv is None: … … 4533 4533 return lonv,latv 4534 4534 4535 def dxdy_lonlatDIMS(dxv,dyv,dnx,dny,dd): 4536 """ Function to provide lon/lat 2D lilke-matrices from any sort of dx,dy values for a given 4537 list of values 4538 dxdy_lonlat(dxv,dyv,Lv,lv) 4539 dxv: values for the x 4540 dyv: values for the y 4541 dnx: mnames of the dimensions for values on x 4542 dny: mnames of the dimensions for values on y 4543 dd: list of [dimname]|[val] for the dimensions use 4544 [dimname]: name of the dimension 4545 [val]: value (-1 for all the range) 4546 """ 4547 4548 fname = 'dxdy_lonlatDIMS' 4549 4550 print 'Lluis which dimensions x:',ddx,'y:',ddy 4551 4552 slicex = [] 4553 ipos=0 4554 for dn in dnx: 4555 for idd in range(len(dd)): 4556 dname = dd[idd].split('|')[0] 4557 dvalue = int(dd[idd].split('|')[1]) 4558 if dn == dname: 4559 if dvalue == -1: 4560 slicex.append(slice(0,len(dxv.shape[ipos]))) 4561 else: 4562 slicex.append(dvalue) 4563 break 4564 ipos = ipos + 1 4565 4566 slicey = [] 4567 ipos=0 4568 for dn in dny: 4569 for idd in range(len(dd)): 4570 dname = dd[idd].split('|')[0] 4571 dvalue = int(dd[idd].split('|')[1]) 4572 if dn == dname: 4573 if dvalue == -1: 4574 slicey.append(slice(0,len(dyv.shape[ipos]))) 4575 else: 4576 slicey.append(dvalue) 4577 break 4578 ipos = ipos + 1 4579 4580 4581 if len(dxv.shape) > 1: 4582 for idim in range(len(dxv.shape)): 4583 if idim == ddxx or idim == ddxy: 4584 slicex.append(slice(0,dxv.shape[idim])) 4585 else: 4586 slicex.append(0) 4587 else: 4588 slicex.append(slice(0,len(dxv))) 4589 4590 slicey = [] 4591 if len(dyv.shape) > 1: 4592 for idim in range(len(dyv.shape)): 4593 if idim == ddyx or idim == ddyy: 4594 slicey.append(slice(0,dyv.shape[idim])) 4595 else: 4596 slicey.append(0) 4597 else: 4598 slicey.append(slice(0,len(dyv))) 4599 4600 lonv = dxv[tuple(slicex)] 4601 latv = dyv[tuple(slicey)] 4602 4603 if len(lonv.shape) != len(latv.shape): 4604 print ' ' + fname + ': dimension size on x:', len(lonv.shape), 'and on y:', \ 4605 len(latv.shape),'do not coincide!!' 4606 quit(-1) 4607 4608 return lonv,latv 4609 4535 4610 def plot_2D_shadow_line(varsv,varlv,vnames,vnamel,dimxv,dimyv,dimxu,dimyu,dimn, \ 4536 4611 colorbar,colln,vs,uts,utl,vtit,kfig,reva,mapv,ifclose):
Note: See TracChangeset
for help on using the changeset viewer.