- Timestamp:
- Sep 16, 2015, 11:28:35 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/nc_var_tools.py
r628 r629 15201 15201 if maxradii is not None and rad > maxradii: break 15202 15202 Nrad = int(values[2]) 15203 couples = None15203 couples = [] 15204 15204 Nradgood = 0 15205 15205 if Nrad > 1: 15206 15206 Ncouples = 0 15207 couples = []15208 15207 for ic in range(Nrad): 15209 15208 ix = int(values[3 + ic*2]) 15210 15209 iy = int(values[3 + ic*2 + 1]) 15211 15210 if ix <= Npt and iy <= Npt: 15212 couples.append(np.array([ix,iy] , dtype=int))15211 couples.append(np.array([ix,iy])) 15213 15212 Nradgood = Nradgood + 1 15214 15213 elif ix > Npt and iy > Npt: break … … 15217 15216 iy = int(values[4]) 15218 15217 if ix <= Npt and iy <= Npt: 15219 couples = np.array([ix,iy], dtype=int)15218 couples.append(np.array([ix,iy])) 15220 15219 Nradgood = Nradgood + 1 15221 15220 elif ix > Npt and iy > Npt: break … … 15223 15222 if Nradgood > 0: 15224 15223 Nradii[rad] = Nradgood 15225 gridradii[rad] = np.array(couples) 15224 finalcouples = np.zeros((Nradgood,2), dtype=int) 15225 for ic in range(Nradgood): 15226 finalcouples[ic,:] = couples[ic] 15227 gridradii[rad] = finalcouples 15226 15228 15227 15229 # for rad in sorted(gridradii.keys()): … … 15240 15242 gridcomb = [] 15241 15243 gridcomb.append([x,y]) 15242 gridcomb.append([-x,y])15243 gridcomb.append([-x,-y])15244 gridcomb.append([x,-y])15244 if x != 0: gridcomb.append([-x,y]) 15245 if x != 0 and y != 0: gridcomb.append([-x,-y]) 15246 if y != 0: gridcomb.append([x,-y]) 15245 15247 15246 15248 if x != y: 15247 15249 gridcomb.append([y,x]) 15248 gridcomb.append([-y,x])15249 gridcomb.append([-y,-x])15250 gridcomb.append([y,-x])15250 if y != 0: gridcomb.append([-y,x]) 15251 if x != 0 and y != 0: gridcomb.append([-y,-x]) 15252 if x != 0: gridcomb.append([y,-x]) 15251 15253 15252 15254 return gridcomb … … 15260 15262 dx= x size of the domain of values 15261 15263 dy= y size of the domain of values 15264 >>> radpos, SQradpos = radii_points(12,12,1,8,25,25) 15265 radpos: 15266 [[[ 13. 12. ]] 15267 [[ 12.70710678 12.70710678]] 15268 [[ 12. 13. ]] 15269 [[ 11.29289322 12.70710678]] 15270 [[ 11. 12. ]] 15271 [[ 11.29289322 11.29289322]] 15272 [[ 12. 11. ]] 15273 [[ 12.70710678 11.29289322]]] 15274 SQradpos: 15275 {1.0: [[13, 12], [11, 12], [12, 13], [12, 11]], 1.41421356237: [[13, 13], [11, 13], [11, 11], [13, 11]]} 15262 15276 """ 15263 15277 fname = 'radii_points' 15264 15278 15265 radiipos = np.zeros((Nang, Lrad, 2), dtype = int)15279 radiipos = np.zeros((Nang, Lrad, 2), dtype = np.float) 15266 15280 SQradiipos = {} 15267 15281 … … 15287 15301 # Creation of a matrix with all the grid points at each time-step 15288 15302 if iipos >= 0 and iipos < dx-1 and jjpos >= 0 and jjpos < dy-1: 15289 radiipos[ia,ip,0] = iipos15290 radiipos[ia,ip,1] = jjpos15303 radiipos[ia,ip,0] = posangle[ip,0] 15304 radiipos[ia,ip,1] = posangle[ip,1] 15291 15305 15292 15306 # SQ radii values … … 15300 15314 Npairs = len(pairs.flatten())/2 15301 15315 pairsw = [] 15302 print 'Lluis ',SQradii[ir],'pairs:',pairs, type([pairs])15303 15316 for ip in range(Npairs): 15304 15317 if Npairs == 0: 15305 print ' Lluis NO pair:', SQradii[ir],':',pairs15306 15318 break 15307 elif Npairs == 1:15308 print ' Lluis single pair:',pairs[ip*2],pairs[ip*2+1]15309 allpairs = grid_combinations(pairs[ip*2],pairs[ip*2+1])15310 15319 else: 15311 print ip,' Lluis 1 pair:',pairs[ip,0],pairs[ip,1] 15312 allpairs = grid_combinations(pairs[ip,0],pairs[ip,1]) 15313 15320 allpairs = grid_combinations(pairs[ip,0],pairs[ip,1]) 15314 15321 for iap in range(len(allpairs)): 15315 15322 ppos = allpairs[iap] … … 15479 15486 trjradii[it,:,:,:], trjSQradii[it] = radii_points(trajvals[it,0], \ 15480 15487 trajvals[it,1],radii,Nangle,dimx,dimy) 15488 print trjradii[it,:,:,:] 15489 print '-----------' 15490 print trjSQradii[it,:,:,:] 15481 15491 15482 15492 it = it + 1 15483 15493 iline = iline + 1 15494 15484 15495 quit() 15485 15496
Note: See TracChangeset
for help on using the changeset viewer.