35 lines
905 B
Python
35 lines
905 B
Python
from cam_server.pipeline.data_processing import functions
|
|
import numpy as np
|
|
from epics import PV
|
|
from collections import deque
|
|
|
|
id_ca = PV('SLAAR21-LTIM01-EVR0:RX-PULSEID')
|
|
Nbg = 5
|
|
bg_code = 20
|
|
bg_dq = None
|
|
|
|
def process(data, pulse_id, timestamp, parameters):
|
|
global bg_dq
|
|
evtset = data["SAR-CVME-TIFALL5:EvtSet"]
|
|
profile = data["SARES20-CAMS142-M5.roi_signal_x_profile"]
|
|
bunchok = data["SIN-CVME-TIFGUN-EVR0:BUNCH-1-OK"]
|
|
data["bg"] = np.zeros(1,profile.dtype)
|
|
data["profile"] = np.zeros(1,profile.dtype)
|
|
|
|
is_bg = evtset[bg_code]==1
|
|
if is_bg:
|
|
if not bg_dq:
|
|
bg_dq = deque(profile,Nbg)
|
|
else:
|
|
bg_dq.append(profile)
|
|
|
|
if bg_dq:
|
|
data["bg"] = np.mean(bg_dq,axis=0)
|
|
if not is_bg :
|
|
data["profile"] = profile / data["bg"]
|
|
data["pid_offset"] = int(id_ca.get()-pulse_id)
|
|
return data
|
|
|
|
|
|
|