52 lines
1.4 KiB
Python
52 lines
1.4 KiB
Python
#!/usr/bin/env python3
|
|
|
|
# authors M.Appleby T. Mason J Beale M. Kepla
|
|
|
|
"""
|
|
# aim
|
|
Calculate FWHM of x-ray beam from an edge scan
|
|
|
|
# protocol
|
|
complete edge scan
|
|
## IMPORTANT ##
|
|
- save data as .txt file
|
|
|
|
# usage
|
|
python convert-scan-for-pyfai.py -j <jugfrau-name> -s <path to scan file> -n <name of output file>
|
|
|
|
# output
|
|
creates a .png of fit including FWHM title
|
|
"""
|
|
|
|
import numpy as np
|
|
import pandas as pd
|
|
import matplotlib.pyplot as plt
|
|
from scipy import stats
|
|
from scipy.optimize import curve_fit
|
|
from scipy.signal import peak_widths, find_peaks
|
|
from scipy import asarray as ar,exp
|
|
from math import sqrt, pi
|
|
import argparse
|
|
|
|
def loadData(directory): # for data taken by slic
|
|
num_of_acqs=len([name for name in os.listdir(os.path.join(directory,'data'))])
|
|
print(num_of_acqs)
|
|
bkg_estimate_data = []
|
|
for acquisition in range(1,num_of_acqs+1):
|
|
with SFDataFiles(os.path.join(directory,'data','acq{:04}.BSDATA.h5'.format(acquisition))) as data:
|
|
bkg_estimate = data["JF17T16V01j:bkg_estimate"].data
|
|
#diode = diode.mean()
|
|
bkg_estimate_data.append(bkg_estimate)
|
|
scan = SFScanInfo(os.path.join(directory,'meta','scan.json'))
|
|
motor_positions = scan.readbacks
|
|
print(motor_positions)
|
|
print(len(bkg_estimate_data), len(motor_positions))
|
|
return motor_positions, bkg_estimate_data
|
|
|
|
directory="path/to/dir"
|
|
load_data(directory)
|
|
|
|
|
|
|
|
|