55 lines
1.9 KiB
Python
55 lines
1.9 KiB
Python
#from cam_server.pipeline.data_processing import functions, processor
|
|
|
|
#def process_image(image, pulse_id, timestamp, x_axis, y_axis, parameters, bsdata=None):
|
|
# ret = processor.process_image(image, pulse_id, timestamp, x_axis, y_axis, parameters, bsdata)
|
|
# return ret
|
|
|
|
import numpy as np
|
|
from collections import OrderedDict
|
|
from cam_server.pipeline.data_processing import functions
|
|
from logging import getLogger
|
|
#import copy
|
|
|
|
_logger = getLogger(__name__)
|
|
|
|
|
|
def process_image(image, pulse_id, timestamp, x_axis, y_axis, parameters, bsdata):
|
|
|
|
#image = (image < 15) * (image - 15)
|
|
ret = OrderedDict()
|
|
prefix = parameters["camera_name"]
|
|
(x_profile, y_profile) = functions.get_x_y_profile(image)
|
|
_, _, x_fit_amplitude, x_fit_mean, x_fit_standard_deviation, _, _ = functions.gauss_fit(x_profile, x_axis)
|
|
_, _, y_fit_amplitude, y_fit_mean, y_fit_standard_deviation, _, _ = functions.gauss_fit(y_profile, y_axis)
|
|
x_fwhm = functions.get_fw(x_axis,x_profile)
|
|
y_fwhm = functions.get_fw(y_axis,y_profile)
|
|
intensity = x_profile.sum()
|
|
|
|
|
|
h = image.shape[0]
|
|
w = image.shape[1]
|
|
hh = int(h/2)
|
|
wh = int(w/2)
|
|
Q1=float(np.sum(image[0:hh, 0:wh])) #TL
|
|
Q2=float(np.sum(image[0:hh, wh:w])) #TR
|
|
Q3=float(np.sum(image[hh:h, wh:w])) #BR
|
|
Q4=float(np.sum(image[hh:h, 0:wh])) #BL
|
|
I = float(Q1+Q2+Q3+Q4)
|
|
dx = ((Q1+Q4) - (Q2+Q3))/I
|
|
dy = ((Q1+Q2) - (Q3+Q4))/I
|
|
dxcal = dx/1.6014*x_fit_standard_deviation/2.355
|
|
dycal = dy/1.6014*y_fit_standard_deviation/2.355
|
|
|
|
ret[prefix+":intensity"] = intensity
|
|
ret[prefix+":x_fit_mean"] = x_fit_mean
|
|
ret[prefix+":y_fit_mean"] = y_fit_mean
|
|
ret[prefix+":x_fwhm"] = x_fwhm
|
|
ret[prefix+":y_fwhm"] = y_fwhm
|
|
ret[prefix+":x_fit_amplitude"] = x_fit_amplitude
|
|
ret[prefix+":y_fit_amplitude"] = y_fit_amplitude
|
|
ret[prefix+":4qdx"], ret[prefix+":4qdy"] = dxcal, dycal #virtual_4QD(image, 2.355,2.355) #x_fit_standard_deviation, y_fit_standard_deviation
|
|
|
|
|
|
|
|
return ret
|