Skip to content
Snippets Groups Projects
Commit eddd50c9 authored by Ilaria Carlomagno's avatar Ilaria Carlomagno
Browse files

Updated documentation

parent 1f877502
No related branches found
No related tags found
No related merge requests found
......@@ -9,12 +9,10 @@ import os
import sys
BMS_MIN = 1e-2
PRECISION = 5
PRECISION = 10**5
PATH_SCALAR = "/Measurement/TransientScalarData"
PATH_VECTOR = "/Measurement/TransientVectorData"
NEWNAME_APP = "_cut.h5"
def check_bms(bms):
beam_lost = False
......@@ -35,56 +33,48 @@ def check_bms(bms):
print('Length of bms after the cut: ', len(bms))
return(beam_lost, len(bms))
# gives the shape of the array by counting the numbers of different values
def count_steps(x):
# gives the shape of the array by counting the numbers of different values
step_x = np.round(np.diff(np.unique(x*10**PRECISION)).min())/10**PRECISION
step_x = np.round(np.diff(np.unique(x*PRECISION)).min())/PRECISION
stx = np.round((x-x.min())/step_x).astype(int)
shape_x = stx.max()+1
return(shape_x)
# flipping has to be implemented yet! An idea could be starting from the following
def descending(j):
def _descending(j):
if (j[0]>j[-1]):
to_be_flipped = True
else:
pass
def orientation(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.
def orientation(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
return ver, 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
return l, 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')
return l, 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')
return ver, hor, move_ver_first
# if both motors are moved or if none moves, then the map is somewhat broken.
else:
raise ValueError('Something is wrong with this map. Please check the file!')
def read_positions(filename,PATH_SCALAR):
def _read_positions(filename,PATH_SCALAR):
with h5py.File(filename, 'r') as f:
#ciclo sui run
for run in f.keys():
print ("Run: %s" %run)
x=f[run+PATH_SCALAR+"/X"][...]
y=f[run+PATH_SCALAR+"/Y"][...]
return x,y
return x,y
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment