Changeset 277 in lmdz_wrf for trunk/tools/nc_var_tools.py
- Timestamp:
- Feb 25, 2015, 11:56:25 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/nc_var_tools.py
r276 r277 10076 10076 newdim = objofile.createDimension('time', None) 10077 10077 10078 # var dimensions10079 newvar = objofile.createVariable('trlon', 'f8', ('time'))10080 newattr = basicvardef(newvar,'trlon','trajectory longitude','degrees west_east')10081 newvar[:] = trajvals[:,1]10082 10083 newvar = objofile.createVariable('trlat', 'f8', ('time'))10084 newattr = basicvardef(newvar,'trlat','trajectory latitude','degrees north_south')10085 newvar[:] = trajvals[:,2]10086 10087 newvar = objofile.createVariable('time', 'f8', ('time'))10088 newattr = basicvardef(newvar, 'time', 'time', tunits)10089 newvar[:] = trajvals[:,0]10090 10091 newvar = objofile.createVariable('lon', 'f8', ('time', 'y', 'x'), \10092 fill_value=fillValue)10093 newattr = basicvardef(newvar, 'longitude', 'longitude', 'degrees west_east')10094 newvar[:] = lonvals10095 10096 newvar = objofile.createVariable('lat', 'f8', ('time', 'y', 'x'), \10097 fill_value=fillValue)10098 newattr = basicvardef(newvar, 'latitude', 'latitude', 'degrees north_south')10099 newvar[:] = latvals10100 10101 10078 statnames = ['minbox', 'maxbox', 'meanbox', 'mean2box', 'stdevbox'] 10102 10079 vstlname = ['minimum value within', 'maximum value within', 'mean value within', \ … … 10120 10097 if Nvardims == 4: 10121 10098 # Too optimistic, but at this stage... 10122 dimt = varobj.shape[0]10123 10099 dimz = varobj.shape[1] 10124 10100 … … 10151 10127 10152 10128 varvals = np.ones(tuple([Ttraj,dimz,boxs,boxs]), dtype=np.float) 10153 lonvals = np.ones(tuple([Ttraj,dimz,boxs,boxs]), dtype=np.float)10154 latvals = np.ones(tuple([Ttraj,dimz,boxs,boxs]), dtype=np.float)10155 10129 rvarvals = np.ones(tuple([Ttraj,dimz,Nrad*2+1,Nrad*2+1]), dtype=np.float) 10156 rlonvals = np.ones(tuple([Ttraj,dimz,Nrad*2+1,Nrad*2+1]), dtype=np.float)10157 rlatvals = np.ones(tuple([Ttraj,dimz,Nrad*2+1,Nrad*2+1]), dtype=np.float)10158 10130 10159 10131 statvarvals = np.ones(tuple([Ttraj,6]), dtype=np.float) … … 10194 10166 statvarvals[it,:,3]*statvarvals[it,:,3]) 10195 10167 10196 varvalst[tuple(slice2D)] = lonv[tuple(slicevnoT)]10197 lonvals[it,:,:,:] = varvalst10198 varvalst[tuple(slice2D)] = latv[tuple(slicevnoT)]10199 latvals[it,:,:,:] = varvalst10200 10201 10168 else: 10202 10169 slicev.append(slice(gtrajvals[it,2]-box2, gtrajvals[it,2]+box2+1)) … … 10227 10194 statvarvals[it,:,5] = np.sqrt(statvarvals[it,:,4] - \ 10228 10195 statvarvals[it,:,3]*statvarvals[it,:,3]) 10229 10230 varvalst = lonv[tuple(slicevnoT)]10231 lonvals[it,:,:] = varvalst10232 varvalst = latv[tuple(slicevnoT)]10233 latvals[it,:,:] = varvalst10234 10196 10235 10197 # Circle values … … 10267 10229 rstatvarvals[it,:,3]*rstatvarvals[it,:,3]) 10268 10230 10269 rvarvalst[tuple(cslice2D)] = lonv[tuple(cslicevnoT)]10270 rlonvals[it,:,:,:] = rvarvalst10271 rvarvalst[tuple(cslice2D)] = latv[tuple(cslicevnoT)]10272 rlatvals[it,:,:,:] = rvarvalst10273 10274 10231 else: 10275 10232 slicev.append(slice(gtrajvals[it,2]-Nrad,gtrajvals[it,2]+Nrad+1)) … … 10300 10257 rstatvarvals[it,:,5] = np.sqrt(rstatvarvals[it,4] - \ 10301 10258 rstatvarvals[it,:,3]*rstatvarvals[it,3]) 10302 10303 rvarvalst = lonv[tuple(cslicevnoT)]10304 rlonvals[it,:,:,:] = rvarvalst10305 rvarvalst = latv[tuple(cslicevnoT)]10306 rlatvals[it,:,:,:] = rvarvalst10307 10259 10308 10260 # print 'statistics:',rstatvarvals[it,:] … … 10490 10442 rstatvarvals[it,3]*rstatvarvals[it,3]) 10491 10443 10492 rvarvalst[tuple(cslice2D)] = lonv[tuple(cslicevnoT)]10493 rlonvals[it,:,:] = rvarvalst10494 rvarvalst[tuple(cslice2D)] = latv[tuple(cslicevnoT)]10495 rlatvals[it,:,:] = rvarvalst10496 10497 10444 else: 10498 10445 slicev.append(slice(gtrajvals[it,2]-Nrad,gtrajvals[it,2]+Nrad+1)) … … 10523 10470 rstatvarvals[it,5] = np.sqrt(rstatvarvals[it,4] - \ 10524 10471 rstatvarvals[it,3]*rstatvarvals[it,3]) 10525 10526 rvarvalst = lonv[tuple(cslicevnoT)]10527 rlonvals[it,:,:] = rvarvalst10528 rvarvalst = latv[tuple(cslicevnoT)]10529 rlatvals[it,:,:] = rvarvalst10530 10472 10531 10473 # print 'statistics:',rstatvarvals[it,:] … … 10599 10541 # newattr = set_attributek(newvar,'_FillValue',fillValue,'npfloat') 10600 10542 ist = ist + 1 10543 10544 if not objofile.has_key('trlon') and Nvardims == 3: 10545 # var dimensions 10546 newvar = objofile.createVariable('trlon', 'f8', ('time')) 10547 newattr = basicvardef(newvar,'trlon','trajectory longitude', \ 10548 'degrees west_east') 10549 newvar[:] = trajvals[:,1] 10550 10551 newvar = objofile.createVariable('trlat', 'f8', ('time')) 10552 newattr = basicvardef(newvar,'trlat','trajectory latitude', \ 10553 'degrees north_south') 10554 newvar[:] = trajvals[:,2] 10555 10556 newvar = objofile.createVariable('time', 'f8', ('time')) 10557 newattr = basicvardef(newvar, 'time', 'time', tunits) 10558 newvar[:] = trajvals[:,0] 10559 10560 newvar = objofile.createVariable('lon', 'f8', ('time', 'y', 'x'), \ 10561 fill_value=fillValue) 10562 newattr = basicvardef(newvar, 'longitude', 'longitude', \ 10563 'degrees west_east') 10564 newvar[:] = lonvals 10565 10566 newvar = objofile.createVariable('lat', 'f8', ('time', 'y', 'x'), \ 10567 fill_value=fillValue) 10568 newattr = basicvardef(newvar, 'latitude', 'latitude', \ 10569 'degrees north_south') 10570 newvar[:] = latvals 10571 10572 ivar = ivar + 1 10573 10601 10574 10602 10575 # global attributes
Note: See TracChangeset
for help on using the changeset viewer.