# flipping has to be implemented yet! An idea could be starting from the following
defdescending(j):
def_descending(j):
if (j[0]>j[-1]):
to_be_flipped=True
else:
pass
deforientation(l,m):
move_X_first=False
# when l moves first, then columns and rows in the h5 are swapped
# with respect to what PyMCA is expecting
# This means the map needs to be rotated.
# When the vertical motor moves first, the map is collected filling column after column.
# When PyMCA will try to resize the array of XRF data, the correct image will be shown only entering the cols and rows values swapped.
# The map will have the correct position of the pixel with respect to one another, but it will appear rotated by 90deg counterclockwise.
# The function takes the array of the x and y positions, and returns them swapped when the vertical motor is moved first. And it returns a flag used for the 90deg clockwise rotation needed to bring the map orientation back to normal.
deforientation(ver,hor):
move_ver_first=False
if (ver[1]!=ver[0])and(hor[1]==hor[0]):
print('X (VER) moved first: swapped cols and rows')
move_ver_first=True
ver,hor=hor,ver
returnver,hor,move_ver_first
if (l[1]!=l[0])and(m[1]==m[0]):
print('X moved first: swapped cols and rows')
move_X_first=True
l,m=m,l
returnl,m,move_X_first
# when m moves first, rows and columns are in the correct order
elif (m[1]!=m[0])and(l[1]==l[0]):
print('Y moved first: no swapping of rows and cols')
returnl,m,move_X_first
# if both motors are moved or if none moves, then the map is not correct
# when X moves first, in order to see the map on PyMCA, the number of
# columns to enter is the number of rows. The map will appear rotated.
# when the horizontal motor moves first, no need to swap rows and columns
elif (hor[1]!=hor[0])and(ver[1]==ver[0]):
print('Y (HOR) moved first: no swapping of rows and cols')
returnver,hor,move_ver_first
# if both motors are moved or if none moves, then the map is somewhat broken.
else:
raiseValueError('Something is wrong with this map. Please check the file!')