Skip to content

Fix reshaping

Julia Garriga Ferrer requested to merge fix_reshaping into master

The data that we work with at ID06 is obtained by moving a motor while fixing the others, then moving them and moving the first motor again. For example, suppose we have two motors: the first moves in 5 steps from 0.1 to 0.5, and the other in 2 steps from 0 to 1. Our data will then be 10 images with these motors positions:

i1 i2 i3 i4 i5 i6 i7 i8 i9 i10
diffry 0.1 0.2 0.3 0.4 0.5 0.1 0.2 0.3 0.4 0.5
obpitch 0 0 0 0 0 1 1 1 1 1

With the previous reshaping of the data what we had was:

>>> x = np.arange(1, 11)
>>> diffry_dim = 5
>>> obpitch_dim = 2
>>> x = x.reshape((diffry_dim, obpitch_dim))
>>> x
array([[ 1,  2],
       [ 3,  4],
       [ 5,  6],
       [ 7,  8],
       [ 9, 10]])

But, as we can see with this shape if we take the first value of diffry (0.1) by doing:

>>> x[0, :]
array([1, 2])

The images we have are not 1 and 6 (which correspond to the ones with diffry position 0.1, but 1 and 2. Same happend with obpitch:

>>> x[:, 0]
array([1, 3, 5, 7, 9])

In this MR, the axes are maintained so its easier for the users, meaning that the faster the motor the lower the axis. But the reshape is done by transposing the axes of the dimensions, so we'll have:

>>> x = np.arange(1, 11)
>>> x = x.reshape((obpitch_dim, diffry_dim))
>>> x[0, :]
array([1, 2, 3, 4, 5])
>>> x[:, 0]
array([1, 6])

Which is consistent with our data.

Edited by Julia Garriga Ferrer

Merge request reports