Skip to content

Commit

Permalink
MNT: Modify cspad intensity function to take bin number parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
ZryletTC authored and aegger13 committed Jun 29, 2020
1 parent 055789a commit d96dea5
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
4 changes: 3 additions & 1 deletion jet_tracking/jet_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,9 @@ def jet_scan(injector, cspad, gas_det, params):
# get azav from CSPAD
# get CSPAD and wave8
azav, norm = get_azav(cspad) # call azimuthal average function
intensities.append(jt_utils.get_cspad(azav, params.radius.get(), gas_det))
intensities.append(jt_utils.get_cspad(azav, gas_det,
params.bin_low,
params.bin_high))
hi_intensities.append(max(intensities))
best_pos.append(positions[intensities.index(max(intensities))])
# move motor to average of best positions from two sweeps
Expand Down
9 changes: 7 additions & 2 deletions jet_tracking/jettracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def run(self, azav, gas_det):
sleep(2)
continue

# TODO: Fix the bad call of get_cspad()
# check CSPAD
if (jt_utils.get_cspad(self.cspad) < self.params.thresh_lo):
# if CSPAD is below lower threshold, move jet
Expand All @@ -75,12 +76,16 @@ def run(self, azav, gas_det):
# if camera is bypassed or if jet is less than 10 microns away
# from x-rays, scan jet across x-rays to find new maximum
jet_control.scan(self.injector, self.cspad)
intensity = jt_utils.get_cspad(azav, self.params.radius.get(), gas_det)
intensity = jt_utils.get_cspad(azav, gas_det,
self.params.bin_low.get(),
self.params.bin_high.get())
self.params.intensity.put(intensity)
sleep(1) # change to however long it takes for jet to scan

# if CSPAD is still below upper threshold, stop jet tracking
if (jt_utils.get_cspad(azav, self.params.radius.get(), gas_det)
if (jt_utils.get_cspad(azav, gas_det,
self.params.bin_low.get(),
self.params.bin_high.get())
< self.params.thresh_hi):
print('CSPAD below threshold - TRACKING STOPPED')
self.requestInterruption()
Expand Down
15 changes: 10 additions & 5 deletions jet_tracking/jt_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,28 +111,33 @@ def fit_cspad(azav, norm, gas_det):
return center, intensity


def get_cspad(azav, r, gas_det):
def get_cspad(azav, gas_det, bin_low, bin_high):
"""
Get the intensity of the diffraction ring on the CSPAD.
The returned value is normalized to the intensity from the gas detector.
Parameters
----------
azav : ndarray
Azimuthal average calculated from CSPAD.
r : int
Radius of diffraction ring.
gas_det : float
Gas detector intensity.
bin_low : int
The bin number of the lower bound of the intensity integration.
bin_high : int
The bin number of the upper bound of the intensity integration.
Returns
-------
intensity : float
Sum of 5 qbins above and below the center, normalized by gas detector.
"""

intensity = sum(azav[r - 5:r + 5]) / gas_det
intensity = sum(azav[bin_low:bin_high]) / gas_det
return intensity


Expand Down

0 comments on commit d96dea5

Please sign in to comment.