- matrix = np.eye(3,3) creates a
3D 3x3 (thanks hv) matrix with 1's in the diagonal and 0 elsewhere.
(or load it from JSON).
- you mentioned points being byte data, np.frombuffer(points, dtype=np.float32) converts it into a list of float32. And then it swaps the bytes - re: little endian etc.
- d.reshape(-1,6) converts above list into a matrix with number of cols = 6 and any number of rows it can fit.
- d[:,2] the 3rd column of matrix d
- pressure = (d[:,2] / pressure_norm) ** pressure_pow create a pressure vector based on d where each item is divided by pressure_norm and then raise to pressure_pow power. (I guess ** is raising to a power)
- points.shape[0] is the number of rows of points (remember it was reshaped to have 6 columns and any number of rows it fits).
- np.ones([points.shape[0],1]), create a vector of 1s (i,e. a matrix of 1 column, that's the '1' in the expression) with as many rows as the reshaped points of the last bullet
- append that vector into points hence increase the number of rows by 1 adding a vector of 1s at the end.
- points @ matrix.T
I guess it transposes points (rows become columns) it is multiplying the matrix 'points' by the transpose of 'matrix' (see NERDVANA's Re: Translating python math to Perl).
- points = points[:, :2] get the 3rd column (0-based indexing) of the current points
my python is very limited so all above with caution. All the above can be done with pure perl but perhaps a dedicated module or PDL can be employed.