This commit is contained in:
root
2022-08-15 15:11:24 +02:00
parent ec92902990
commit 1cf100baa9
16 changed files with 82 additions and 59 deletions
@@ -18,7 +18,7 @@ nus = 299792458 / (lambdas * 10**-9) # frequency space, uneven
nus_new = np.linspace(nus[0], nus[-1], num=2048, endpoint=True) # frequency space, even
filters = {
"YAG": np.concatenate((np.ones(20),signal.tukey(40)[20:40], np.zeros(2008), np.zeros(2048))), # back timetool YAG
"SiN": np.concatenate((signal.tukey(40)[25:40], np.zeros(2033), np.zeros(2048))) # SiN
"SiN": np.concatenate((signal.tukey(40)[25:40], np.zeros(2033), np.zeros(2048))) # back timetool SiN
}
# Functions for image analysis and spectral encoding processing
@@ -90,6 +90,7 @@ def process_image(image, pulse_id, timestamp, x_axis, y_axis, parameters, bsdata
background_mode = parameters.get("image_background_enable")
roi_signal = parameters.get("roi_signal")
project_axis = parameters.get("project_axis", 0)
#events = data[parameters["events"]] # added 2022-07-19
# maintain the structure of processing_parameters
background_shape = None
@@ -102,7 +103,7 @@ def process_image(image, pulse_id, timestamp, x_axis, y_axis, parameters, bsdata
if roi_signal is not None:
projection_background = get_roi_projection(background, roi_signal, project_axis)
projection_signal = get_roi_projection(image, roi_signal, project_axis)
peak_pos, peak_amp, sig_deriv, sig_uninterp = edge("SiN", projection_background, projection_signal, 0)
peak_pos, peak_amp, sig_deriv, sig_uninterp = edge("YAG", projection_background, projection_signal, 0)
except Exception as e:
lineno = sys.exc_info()[2].tb_lineno
@@ -116,6 +117,7 @@ def process_image(image, pulse_id, timestamp, x_axis, y_axis, parameters, bsdata
"status": status,
"background_name": background_name,
"roi_signal": roi_signal
#"events": events[21]
}
processing_parameters = json.dumps(processing_parameters)
@@ -1,6 +1,8 @@
from cam_server.pipeline.data_processing import functions, processor
import json
import scipy.signal
import numpy as np
from collections import deque
from logging import getLogger
@@ -11,6 +13,7 @@ background = deque(maxlen=4)
DEFAULT_ROI_SIGNAL = None
DEFAULT_ROI_BACKGROUND = None
um_per_px = 2.28 # calibrated xxxx-yy-zz
def get_roi_projection(image, roi, axis):
x_start, x_stop, y_start, y_stop = roi
@@ -18,15 +21,38 @@ def get_roi_projection(image, roi, axis):
project = cropped.mean(axis=axis)
return project
def find_spacing(py, extend=5):
"finds the spacing of a (laser or x-ray induced) ladder on a high viscosity jet from the microscope images"
py -= py.mean()
if extend > 1:
py = np.concatenate((py, np.zeros(len(py) * extend)))
spectrum = np.abs(np.fft.fft(py))
freq = np.fft.fftfreq(len(spectrum))
which = (freq > 0.005)
spectrum = spectrum[which]
freq = freq[which]
index_peaks = scipy.signal.find_peaks(spectrum)[0]
peaks_pos = freq[index_peaks]
peak_height = spectrum[index_peaks]
cut_freq = peaks_pos[np.argmax(peak_height)]
return freq, spectrum, cut_freq
def process_image(image, pulse_id, timestamp, x_axis, y_axis, parameters, bsdata=None):
processed_data = dict()
if bsdata is not None:
processed_data.update(bsdata)
event = processed_data.get("SAR-CVME-TIFALL4:EvtSet", None)
event = processed_data.get("SAR-CVME-TIFALL4:EvtSet", None)
image = image.astype("int64")
image_property_name = parameters["camera_name"]
roi_signal = parameters.get("roi_signal", DEFAULT_ROI_SIGNAL)
@@ -38,4 +64,8 @@ def process_image(image, pulse_id, timestamp, x_axis, y_axis, parameters, bsdata
jet_width = get_roi_projection(image, roi_signal, 0)
processed_data[image_property_name + ".jet_width"] = jet_width
freq, spectrum, cut_freq = find_spacing(jet_projection, extend=10)
jet_spacing = um_per_px / cut_freq
processed_data[image_property_name + ".jet_spacing"] = jet_spacing
return processed_data
+1 -1
View File
@@ -161,7 +161,7 @@ def process(data, pulse_id, timestamp, params):
output[f"{device}:INTENSITY_UJ"] = intensity_uJ
output[xpos_ch_name] = xpos
output[ypos_ch_name] = ypos
intensity_pv, xpos_pv, ypos_pv = create_thread_pvs([intensity_ch_name, xpos_ch_name, ypos_ch_name])
if epics_lock.acquire(False):
try:
+1
View File
@@ -9,4 +9,5 @@ def process_image(image, pulse_id, timestamp, x_axis, y_axis, parameters, bsdata
prefix = parameters["camera_name"]
for c in channels:
ret[prefix+":"+c] = r[c]
ret['input_pulse_id'] = pulse_id
return ret