Skip to content
Snippets Groups Projects
Commit 27215b74 authored by Loïc Le Guyader's avatar Loïc Le Guyader
Browse files

linear slope estimation

parent 616428fb
No related branches found
No related tags found
1 merge request!36Knife edge
...@@ -46,7 +46,10 @@ def knife_edge(nrun, axisKey='scannerX', signalKey='FastADC4peaks', p0=None, ful ...@@ -46,7 +46,10 @@ def knife_edge(nrun, axisKey='scannerX', signalKey='FastADC4peaks', p0=None, ful
sortIdx = np.argsort(positions) sortIdx = np.argsort(positions)
positions = positions[sortIdx] positions = positions[sortIdx]
intensities = nrun[signalKey].values.flatten()[sortIdx] intensities = nrun[signalKey].values.flatten()[sortIdx]
if intensities[0] > intensities[-1]:
# estimate a linear slope fitting the data to determine which function to fit
slope = np.cov(positions, intensities)[0][1]/np.var(positions)
if slope < 0:
func = integPowerDown func = integPowerDown
funcStr = 'a*erfc(np.sqrt(2)*(x-x0)/w0)' funcStr = 'a*erfc(np.sqrt(2)*(x-x0)/w0)'
else: else:
...@@ -76,4 +79,4 @@ def knife_edge(nrun, axisKey='scannerX', signalKey='FastADC4peaks', p0=None, ful ...@@ -76,4 +79,4 @@ def knife_edge(nrun, axisKey='scannerX', signalKey='FastADC4peaks', p0=None, ful
if full: if full:
return popt, pcov return popt, pcov
else: else:
return np.array([popt[1], pcov[1,1]**0.5]) return np.array([popt[1], pcov[1,1]**0.5])
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment