Changeset 286 in lmdz_wrf
- Timestamp:
- Feb 25, 2015, 3:28:15 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/nc_var_tools.py
r285 r286 10539 10539 # Too optimistic, but at this stage... 10540 10540 dimz = varobj.shape[1] 10541 10542 if not objofile.dimensions.has_key('z'): 10543 varzobj = objfile.variables[zn] 10544 if len(varzobj.shape) == 1: 10545 dimz = varzobj.shape 10546 zvals = varzobj[:] 10547 elif len(varzobj.shape) == 2: 10548 dimz = varzobj.shape[1] 10549 zvals = varzobj[0,:] 10550 elif len(varzobj.shape) == 3: 10551 dimz = varzobj.shape[2] 10552 zvals = varzobj[0,0,:] 10553 10554 objofile.createDimension('z', dimz) 10555 newvar = objofile.createVariable(zn, 'f4', ('z'),fill_value=fillValue) 10556 if searchInlist(varzobj.ncattrs(),'standard_name'): 10557 vsname = varzobj.getncattr('standard_name') 10558 else: 10559 vsname = variables_values(varn)[1] 10560 if searchInlist(varzobj.ncattrs(),'long_name'): 10561 vlname = varzobj.getncattr('long_name') 10562 else: 10563 vlname = variables_values(varn)[4].replace('|',' ') 10564 if searchInlist(varzobj.ncattrs(),'units'): 10565 vunits = varzobj.getncattr('units') 10566 else: 10567 vunits = variables_values(varn)[5].replace('|',' ') 10568 10569 newattr = basicvardef(newvar, vsname, vlname, vunits) 10570 newvar[:] = zvals 10541 10571 10542 10572 varvals = np.ones(tuple([Ttraj,dimz,boxs,boxs]), dtype=np.float) … … 10558 10588 cslicev = [] 10559 10589 cslice2D = [] 10590 cslice2Dhor = [] 10560 10591 cslicevnoT = [] 10592 cslicevnoThor = [] 10561 10593 10562 10594 slicev.append(gtrajvals[it,0]) … … 10641 10673 cslice2D.append(slice(0,cyrangeslice[it][1]-cyrangeslice[it][0])) 10642 10674 cslice2D.append(slice(0,cxrangeslice[it][1]-cxrangeslice[it][0])) 10675 cslice2Dhor.append(slice(0, cyrangeslice[it][1] - \ 10676 cyrangeslice[it][0])) 10677 cslice2Dhor.append(slice(0, cxrangeslice[it][1] - \ 10678 cxrangeslice[it][0])) 10643 10679 10644 10680 rvarvalst = np.ones((dimz,Nrad*2+1,Nrad*2+1),dtype=np.float)* \ 10645 10681 fillValue 10646 10682 rvarvalst[tuple(cslice2D)] = varobj[tuple(cslicev)] 10647 rvarvalst[tuple(cslice2D)] = np.where(circdist[tuple(cslice2D)]>\ 10648 np.float(Nrad), fillValue, rvarvalst[tuple(cslice2D)]) 10683 for iz in range(dimz): 10684 zslice = [slice(iz)]+cslice2Dhor 10685 rvarvalst[iz,:,:] = np.where(circdist[tuple(cslice2Dhor)] > \ 10686 np.float(Nrad), fillValue, rvarvalst[iz,:,:]) 10649 10687 10650 10688 rvarvals[it,:,:,:] = rvarvalst … … 10663 10701 10664 10702 else: 10665 cslicev.append( 0,dimz)10703 cslicev.append(slice(0,dimz)) 10666 10704 cslicev.append(slice(gtrajvals[it,2]-Nrad,gtrajvals[it,2]+Nrad+1)) 10667 10705 cslicev.append(slice(gtrajvals[it,1]-Nrad,gtrajvals[it,1]+Nrad+1)) 10668 cslicevnoT.append( 0,dimz)10706 cslicevnoT.append(slice(0,dimz)) 10669 10707 cslicevnoT.append(slice(gtrajvals[it,2]-Nrad, gtrajvals[it,2]+ \ 10670 10708 Nrad+1)) 10671 10709 cslicevnoT.append(slice(gtrajvals[it,1]-Nrad, gtrajvals[it,1]+ \ 10672 10710 Nrad+1)) 10673 cslice2D.append(0,dimz) 10711 cslicevnoThor.append(slice(gtrajvals[it,2]-Nrad, gtrajvals[it,2]+ \ 10712 Nrad+1)) 10713 cslicevnoThor.append(slice(gtrajvals[it,1]-Nrad, gtrajvals[it,1]+ \ 10714 Nrad+1)) 10715 cslice2D.append(slice(0,dimz)) 10674 10716 cslice2D.append(slice(gtrajvals[it,2]-Nrad,gtrajvals[it,2]+Nrad+ \ 10675 10717 1)) … … 10678 10720 10679 10721 rvarvalst = varobj[tuple(cslicev)] 10680 cdist = circdist[tuple(cslicevnoT )]10722 cdist = circdist[tuple(cslicevnoThor)] 10681 10723 # circle values 10682 rvarvalst = np.where(cdist > np.float(Nrad),fillValue,rvarvalst) 10724 for iz in range(dimz): 10725 zslice = [slice(iz)]+cslicevnoThor 10726 rvarvalst[iz,:,:] = np.where(circdist[tuple(cslicevnoThor)] >\ 10727 np.float(Nrad), fillValue, rvarvalst[iz,:,:]) 10683 10728 10684 10729 rvarvals[it,:,:,:] = rvarvalst … … 10694 10739 rstatvarvals[it,iz,4] = maskedvals2[iz,:,:].mean() 10695 10740 rstatvarvals[it,iz,5] = np.sqrt(rstatvarvals[it,iz,4] - \ 10696 rstatvarvals[it,iz,3]*rstatvarvals[it, :,3])10741 rstatvarvals[it,iz,3]*rstatvarvals[it,iz,3]) 10697 10742 10698 10743 # print 'statistics:',rstatvarvals[it,:]
Note: See TracChangeset
for help on using the changeset viewer.