This repository has been archived on 2022-02-23. You can view files and clone it, but cannot push or open issues or pull requests.
Deepak 3a73fee801
Some checks failed
gitea-physics/pathfinder/pipeline/head There was a failure building this commit
More tests with variety of dot ideas
2021-09-13 16:44:07 -05:00

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)