analysis.py: fix duplicities in position mapping due to rounding errors
This commit is contained in:
parent
dd0ee9e2d4
commit
d40f1fd004
|
@ -4,7 +4,7 @@ the ../misc directory.
|
|||
|
||||
This needs to be kept in sync with the scripts and qpms/argproc.py.
|
||||
'''
|
||||
|
||||
import math
|
||||
import numpy as np
|
||||
import qpms
|
||||
from qpms.qpms_c import Particle
|
||||
|
@ -79,11 +79,13 @@ class FiniteRectLatModesAnalysis:
|
|||
y += 1
|
||||
iris1.append(iri1)
|
||||
|
||||
# Mapping between ss particles and grid positions;
|
||||
positions = self.ss.positions.astype(np.float32) # cast to eliminate rounding errors
|
||||
# Mapping between ss particles and grid positions
|
||||
positions = self.ss.positions.astype(np.float32)
|
||||
# round to get rid of duplicities due to rounding errors
|
||||
positions = positions.round(7-int(math.log(np.amax(abs(positions)),10)))
|
||||
xpositions = np.unique(positions[:,0])
|
||||
assert(len(xpositions) == Nx)
|
||||
ypositions = np.unique(positions[:,1])
|
||||
assert(len(xpositions) == Nx)
|
||||
assert(len(ypositions == Ny))
|
||||
# particle positions as integer indices
|
||||
posmap = np.empty((positions.shape[0],2), dtype=int)
|
||||
|
|
Loading…
Reference in New Issue