Some checks failed
gitea-physics/pathfinder/pipeline/head There was a failure building this commit
20 lines
576 B
Python
20 lines
576 B
Python
import numpy
|
|
import operator
|
|
|
|
|
|
# flips px, py, pz
|
|
SIGN_ARRAY = numpy.array((-1, -1, -1, 1, 1, 1, 1))
|
|
|
|
|
|
def flip_chunk_to_positive_px(pt: numpy.ndarray) -> numpy.ndarray:
|
|
if pt[0] > 0:
|
|
return pt
|
|
else:
|
|
return SIGN_ARRAY * pt
|
|
|
|
|
|
def normalize_oscillating_dipole_list(pts: numpy.ndarray) -> numpy.ndarray:
|
|
pt_length = 7
|
|
chunked_pts = [flip_chunk_to_positive_px(pts[i: i + pt_length]) for i in range(0, len(pts), pt_length)]
|
|
return numpy.concatenate(sorted(chunked_pts, key=lambda x: tuple(round(val, 3) for val in operator.itemgetter(0, 1, 2, 3, 4, 5, 6)(x))), axis=None)
|