running changes made by M.Appleby and J.Beale. Mainly to update due to python 3.10
This commit is contained in:
@@ -155,14 +155,14 @@ class AppCfg(QSettings):
|
||||
}))
|
||||
if AppCfg.DAQ_LOC not in keys:
|
||||
dflt.append((AppCfg.DAQ_LOC, {
|
||||
'end_station': "cristallina",
|
||||
'p_group': "p20516",
|
||||
'end_station': 'cristallina',
|
||||
'p_group': 'p20516',
|
||||
'jungfraujoch': False,
|
||||
'event_trigger': 63,
|
||||
'beam_x': 1613.0,
|
||||
'beam_y': 1666.0,
|
||||
'incident_energy_kev': 12.4,
|
||||
'geometry_file_location': "/res/geometry_files/JF17T16V01.geom",
|
||||
'geometry_file_location': '/res/geometry_files/JF17T16V01.geom',
|
||||
}))
|
||||
|
||||
if AppCfg.DAQ_SAMPLE not in keys:
|
||||
@@ -177,6 +177,7 @@ class AppCfg(QSettings):
|
||||
'triggered': False,
|
||||
'laser_delay': '',
|
||||
'laser_pulse_energy': '',
|
||||
'num_of_on_to_1_off': '1',
|
||||
'block_size':1000,
|
||||
}))
|
||||
#if AppCfg.DAQ_BS_CH not in keys:
|
||||
@@ -186,7 +187,7 @@ class AppCfg(QSettings):
|
||||
"SARFE10-PSSS059:SPECT-RMS", "SAROP31-PBPS113:Lnk9Ch0-PP_VAL_PD0", "SAROP31-PBPS113:Lnk9Ch0-PP_VAL_PD1", "SAROP31-PBPS113:Lnk9Ch0-PP_VAL_PD2", "SAROP31-PBPS113:Lnk9Ch0-PP_VAL_PD3", "SAROP31-PBPS113:XPOS",
|
||||
"SAROP31-PBPS113:YPOS", "SAROP31-PBPS113:INTENSITY", "SAROP31-PBPS113:INTENSITY_UJ", "SAROP31-PBPS149:Lnk9Ch0-PP_VAL_PD0", "SAROP31-PBPS149:Lnk9Ch0-PP_VAL_PD1", "SAROP31-PBPS149:Lnk9Ch0-PP_VAL_PD2",
|
||||
"SAROP31-PBPS149:Lnk9Ch0-PP_VAL_PD3", "SAROP31-PBPS149:XPOS", "SAROP31-PBPS149:YPOS", "SAROP31-PBPS149:INTENSITY", "SAROP31-PBPS149:INTENSITY_UJ", "SARES30-LSCP1-FNS:CH7:VAL_GET", "SARES30-LSCP1-FNS:CH6:VAL_GET",
|
||||
"SARES30-LSCP1-FNS:CH5:VAL_GET", "SARES30-LSCP1-FNS:CH4:VAL_GET", "SARES30-LSCP1-FNS:CH3:VAL_GET", "SARES30-LSCP1-FNS:CH2:VAL_GET", "SARES30-LSCP1-FNS:CH1:VAL_GET", "SARES30-LSCP1-FNS:CH0:VAL_GET"))) #list of BS channels
|
||||
"SARES30-LSCP1-FNS:CH5:VAL_GET", "SARES30-LSCP1-FNS:CH4:VAL_GET", "SARES30-LSCP1-FNS:CH3:VAL_GET", "SARES30-LSCP1-FNS:CH2:VAL_GET", "SARES30-LSCP1-FNS:CH1:VAL_GET", "SARES30-LSCP1-FNS:CH0:VAL_GET", "SARES33-GPS:PR1_CH0_VAL_GET")))#list of BS channels
|
||||
#if AppCfg.DAQ_PV_CH not in keys:
|
||||
dflt.append((AppCfg.DAQ_PV_CH, ("SARUN03-UIND030:K_SET.VAL", "SARUN04-UIND030:K_SET.VAL", "SARUN05-UIND030:K_SET.VAL", "SARUN06-UIND030:K_SET.VAL", "SARUN07-UIND030:K_SET.VAL", "SARUN08-UIND030:K_SET.VAL", "SARUN09-UIND030:K_SET.VAL",
|
||||
"SARUN10-UIND030:K_SET.VAL", "SARUN11-UIND030:K_SET.VAL", "SARUN12-UIND030:K_SET.VAL", "SARUN13-UIND030:K_SET.VAL", "SARUN14-UIND030:K_SET.VAL", "SARUN15-UIND030:K_SET.VAL", "SARCL02-MBND100:P-READ",
|
||||
@@ -437,8 +438,8 @@ verbose bits:
|
||||
{'name':'pos_diode','title':'Diode pos', 'value':dft_pos_bklgt.get('pos_diode', 0), 'type':'float','limits':(-31000, 1500), 'step':10, 'decimals':5, 'suffix':'ustep'},
|
||||
]},
|
||||
{'name': AppCfg.DFT_POS_DET, 'title':'detector reference positions', 'type':'group','expanded':False, 'children':[
|
||||
{'name':'pos_in', 'title':'In position', 'value':dft_pos_det.get('pos_in',0), 'type':'float', 'limits':(112, 280),'step':0.1, 'decimals':5, 'suffix':' mm'},
|
||||
{'name':'pos_out','title':'Out position', 'value':dft_pos_det.get('pos_out',0), 'type':'float', 'limits':(112, 280),'step':0.1, 'decimals':5, 'suffix':' mm'},
|
||||
{'name':'pos_in', 'title':'In position', 'value':dft_pos_det.get('pos_in',0), 'type':'float', 'limits':(108, 290),'step':0.1, 'decimals':5, 'suffix':' mm'},
|
||||
{'name':'pos_out','title':'Out position', 'value':dft_pos_det.get('pos_out',0), 'type':'float', 'limits':(108, 290),'step':0.1, 'decimals':5, 'suffix':' mm'},
|
||||
{'name':'set_in', 'title':'use current position as "in"', 'type':'action'},
|
||||
{'name':'set_out', 'title':'use current position as "out"', 'type':'action'},
|
||||
]},
|
||||
@@ -492,19 +493,20 @@ verbose bits:
|
||||
{'name':'p_group', 'value':daq_loc['p_group'], 'type':'str'},
|
||||
{'name':'jungfraujoch', 'value':daq_loc['jungfraujoch'], 'type':'bool'},
|
||||
{'name':'event_trigger', 'value':daq_loc['event_trigger'], 'type':'int', 'limits':(1, 256)},
|
||||
{'name':'beam_x', 'value':daq_loc['beam_x'], 'type':'float','step':0.001, 'decimals':3},
|
||||
{'name':'beam_y', 'value':daq_loc['beam_y'], 'type':'float','step':0.001, 'decimals':3},
|
||||
{'name':'incident_energy_kev', 'value':daq_loc['incident_energy_kev'], 'type':'float','step':0.001, 'decimals':5},
|
||||
{'name':'beam_x', 'value':daq_loc['beam_x'], 'type':'float','step':0.01, 'decimals':2},
|
||||
{'name':'beam_y', 'value':daq_loc['beam_y'], 'type':'float','step':0.01, 'decimals':2},
|
||||
{'name':'incident_energy_kev', 'value':daq_loc['incident_energy_kev'], 'type':'float','step':0.001, 'decimals':3},
|
||||
{'name':'geometry_file_location', 'value':daq_loc['geometry_file_location'], 'type':'str',},
|
||||
]},
|
||||
{'name':AppCfg.DAQ_RUN, 'title':'run paramters', 'type':'group', 'children':[
|
||||
{'name':'prefix', 'value':daq_run['prefix'], 'type':'str'},
|
||||
{'name':'padding', 'value':daq_run['padding'], 'type':'int'}, #at some point move to old_daq_config
|
||||
{'name':'cell_name', 'value':daq_run['cell_name'], 'type':'str'}, #at some point move to old_daq_config
|
||||
{'name':'prefix', 'value':daq_run['prefix'], 'type':'str'},
|
||||
{'name':'padding', 'value':daq_run['padding'], 'type':'int'}, #at some point move to old_daq_config
|
||||
{'name':'cell_name', 'value':daq_run['cell_name'], 'type':'str'}, #at some point move to old_daq_config
|
||||
{'name':'laser_delay', 'value':daq_run['laser_delay'], 'type':'str'},
|
||||
{'name':'laser_pulse_energy', 'value':daq_run['laser_pulse_energy'], 'type':'str'},
|
||||
{'name':'triggered', 'value':daq_run['triggered'], 'type':'bool'},
|
||||
{'name':'block_size', 'value':daq_run['block_size'], 'type':'int'},
|
||||
{'name':'triggered', 'value':daq_run['triggered'], 'type':'bool'},
|
||||
{'name':'num_of_on_to_1_off', 'value':daq_run['num_of_on_to_1_off'], 'type':'int', 'limits':(1, 6)},
|
||||
{'name':'block_size', 'value':daq_run['block_size'], 'type':'int'},
|
||||
]},
|
||||
{'name':AppCfg.DAQ_SAMPLE, 'title':'sample paramters', 'type':'group', 'children':[
|
||||
{'name':'protein', 'value':daq_sample['protein'], 'type':'str',},
|
||||
|
||||
@@ -14,6 +14,9 @@ import numpy as np
|
||||
from tqdm import tqdm
|
||||
from time import time
|
||||
from time import sleep
|
||||
import sys, os
|
||||
|
||||
sys.path.insert(0, os.path.expanduser('/sf/cristallina/applications/slic/slic-package'))
|
||||
|
||||
from slic.core.acquisition import SFAcquisition
|
||||
from slic.core.acquisition.sfacquisition import BSChannels, transpose_dicts, print_response
|
||||
@@ -67,7 +70,7 @@ class CTAAcquisition(SFAcquisition):
|
||||
bschs = BSChannels(*channels)
|
||||
bschs.check()
|
||||
client = self.client
|
||||
print(kwargs)
|
||||
#print(kwargs)
|
||||
client.set_config(n_pulses, filename, detectors=detectors, channels=channels, pvs=pvs, scan_info=scan_info, **kwargs)
|
||||
#print('set client')
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ all = 0xff
|
||||
|
||||
class IlluminationControl(object):
|
||||
|
||||
def __init__(self,hostname: str="129.129.221.84",port: int=1003):
|
||||
def __init__(self,hostname: str="129.129.244.24",port: int=1003):
|
||||
if hostname is None: #simulated mode
|
||||
self._sim={'stat':0}
|
||||
_log.info('simulated mode:{}'.format(self._sim))
|
||||
@@ -136,7 +136,10 @@ if __name__ == "__main__":
|
||||
args = parser.parse_args()
|
||||
_log.info('Arguments:{}'.format(args.__dict__))
|
||||
|
||||
host = "129.129.221.92"
|
||||
#Static IP 129.129.244.24
|
||||
#HOST SAROP31-CINT-SWMX1
|
||||
#MAC: 08:BB:CC.05:89:1A
|
||||
host = "129.129.244.24"
|
||||
port = 1003
|
||||
leds = IlluminationControl(host,port)
|
||||
if args.test:
|
||||
|
||||
236
psi_device.py
236
psi_device.py
@@ -3,22 +3,23 @@ import logging,sys,os,socket
|
||||
from math import ceil
|
||||
_log=logging.getLogger(__name__)
|
||||
|
||||
if __name__ == "__main__":
|
||||
logging.basicConfig(level=logging.DEBUG,format='%(name)s:%(levelname)s:%(module)s:%(lineno)d:%(funcName)s:%(message)s ')
|
||||
logging.getLogger('matplotlib').setLevel(logging.INFO)
|
||||
logging.basicConfig(level=logging.DEBUG,format='%(name)s:%(levelname)s:%(module)s:%(lineno)d:%(funcName)s:%(message)s ')
|
||||
logging.getLogger('matplotlib').setLevel(logging.INFO)
|
||||
|
||||
if socket.gethostname()=='ganymede':
|
||||
base=os.path.abspath(os.path.dirname(__file__))
|
||||
sys.path.insert(0, os.path.abspath(os.path.join(base,'../PBSwissMX/python')))
|
||||
sys.path.insert(0, os.path.abspath(os.path.join(base,'../../PBTools')))
|
||||
else:
|
||||
base=os.path.abspath(os.path.dirname(__file__))
|
||||
sys.path.insert(0, os.path.join(base,'PBTools'))
|
||||
sys.path.insert(0, os.path.join(base,'PBSwissMX/python'))
|
||||
elif socket.gethostname()!='ganymede':
|
||||
print('past logging')
|
||||
|
||||
if socket.gethostname()=='ganymede':
|
||||
base=os.path.abspath(os.path.dirname(__file__))
|
||||
sys.path.insert(0, os.path.abspath(os.path.join(base,'../PBSwissMX/python')))
|
||||
sys.path.insert(0, os.path.abspath(os.path.join(base,'../../PBTools')))
|
||||
else:
|
||||
base=os.path.abspath(os.path.dirname(__file__))
|
||||
sys.path.insert(0, os.path.join(base,'PBTools'))
|
||||
sys.path.insert(0, os.path.join(base,'PBSwissMX/python'))
|
||||
sys.path.insert(0, os.path.expanduser('/sf/cristallina/applications/slic/slic-package'))
|
||||
sys.path.insert(0, os.path.expanduser('/sf/cristallina/applications/mx/swissmx_tools/jfj'))
|
||||
|
||||
|
||||
from PyQt5.QtWidgets import (QApplication,)
|
||||
from app_config import AppCfg #settings, option, toggle_option
|
||||
|
||||
@@ -34,6 +35,7 @@ try:
|
||||
from ctadaq import CTAAcquisition
|
||||
from jfjoch_device import JFJ
|
||||
except ImportError as e:
|
||||
print(f"error {e}")
|
||||
_log.warning(e)
|
||||
|
||||
|
||||
@@ -125,6 +127,9 @@ class Jungfrau:
|
||||
_log.critical(f'Jungfrau not connected: {e}')
|
||||
self.n_pulses_run = None
|
||||
self.bsdata_scalar = 1
|
||||
self.motion_mode = None
|
||||
self.block_size_to_jungfrau = 1000
|
||||
self.block_size_to_slic = 1000
|
||||
|
||||
def config(self,**kwargs):
|
||||
if getattr(self,'_sim',False):
|
||||
@@ -133,7 +138,7 @@ class Jungfrau:
|
||||
app=QApplication.instance() #temproary fix, couldnt access these in function, maybe the bt above needs to be self.detectors ... etc
|
||||
cfg=app._cfg
|
||||
det = cfg.value(AppCfg.DAQ_DET)
|
||||
print("det", repr(det))
|
||||
#print("det", repr(det))
|
||||
detectors = [det] if det.get("name") else None
|
||||
bs_channels = cfg.value(AppCfg.DAQ_BS_CH)
|
||||
pv_channels = cfg.value(AppCfg.DAQ_PV_CH)
|
||||
@@ -144,6 +149,9 @@ class Jungfrau:
|
||||
sync_mode=dt_misc['sync_mode']
|
||||
sync_flag=dt_misc['sync_flag']
|
||||
self.n_pulses_run = None
|
||||
#print(kwargs)
|
||||
motion_mode = kwargs['mode']
|
||||
self.motion_mode = motion_mode
|
||||
if loc['jungfraujoch']:
|
||||
try:
|
||||
#self.jfj = JFJ("http://sf-daq-2:5232") old port
|
||||
@@ -159,70 +167,130 @@ class Jungfrau:
|
||||
self.jfj = None
|
||||
_log.info(f'JungFrauJoch is not in use')
|
||||
print('JungFrauJoch not in use')
|
||||
if sync_flag==0:
|
||||
#if sync_flag==0:
|
||||
if motion_mode == 1 or motion_mode == 3:
|
||||
#grid_cnt=kwargs['grid']['count']
|
||||
repetitions=int(kwargs['points'][:, 0].max())+1 #grid_cnt[0] #'x' or number of columns # if mode = 1 or 3
|
||||
cta_multiplier=int(kwargs['points'][:, 1].max())+1#grid_cnt[1] #'y' or number of appertures in a column/number of rows
|
||||
elif motion_mode == 4 or motion_mode == 5 or motion_mode == 6:
|
||||
grid_cnt=kwargs['grid']['count']
|
||||
repetitions=grid_cnt[0] #'x' or number of columns
|
||||
repetitions=grid_cnt[0] #'x' or number of columns # if mode = 1 or 3
|
||||
cta_multiplier=grid_cnt[1] #'y' or number of appertures in a column/number of rows
|
||||
number_of_appertures = repetitions*cta_multiplier
|
||||
cta=CTASequencer("SAR-CCTA-ESC")
|
||||
cta.cfg.repetitions = repetitions
|
||||
self.images=repetitions*cta_multiplier
|
||||
if code_gen==3:
|
||||
if kwargs['tmove']==0:
|
||||
wait_pulses=0
|
||||
else:
|
||||
wait_pulses=kwargs['twait']//kwargs['tmove']
|
||||
#xray_seq=[0,]*wait_pulses+[1] # multiplier is proportional to wait_time i.e. 10 ms = 1, 20 ms =2, 30 ms =3.
|
||||
#xray_sequence=[0,]*wait_pulses+[1]
|
||||
#cta.seq[200]=xray_sequence*cta_multiplier # x-ray_shutter
|
||||
#cta.seq[214] = [1,] + [0,] * (len(xray_sequence * cta_multiplier) -1)
|
||||
#trigger_sequence = [1,] + [0,] * wait_pulses + [0,] * wait_pulses + [0]
|
||||
#cta.seq[215]=trigger_sequence*(cta_multiplier//2) # laser_shutter
|
||||
#image_label_sequence = [0,] * wait_pulses + [1] + [0,] * wait_pulses + [0]
|
||||
#cta.seq[216]=image_label_sequence*(cta_multiplier//2)
|
||||
#cta.seq[219] = xray_sequence * cta_multiplier
|
||||
|
||||
on_off_ratio = 2 #1 on to 1 off which means 2 in the whole sequence
|
||||
xray_sequence = [0,] * (wait_pulses - 1) + [1,] + [0,]
|
||||
cta.seq[200] = xray_sequence * cta_multiplier # x-ray_shutter
|
||||
cta.seq[214] = [1,] + [0,] * (len(xray_sequence * cta_multiplier) -1) #start motion
|
||||
if run["triggered"]:
|
||||
trigger_on = [0,] * wait_pulses + [1,]
|
||||
trigger_off = [0,] + [0,] * wait_pulses
|
||||
trigger_sequence = trigger_on * (on_off_ratio-1) + trigger_off
|
||||
image_on = [0,] * (wait_pulses - 1) + [1,] + [0,]
|
||||
image_label_sequence = [0,] +[0,] * wait_pulses + image_on * (on_off_ratio-1)
|
||||
cta.seq[215] = trigger_sequence * (cta_multiplier//on_off_ratio) # trigger (laser_shutter or droplet ejector)
|
||||
cta.seq[216] = image_label_sequence * (cta_multiplier//on_off_ratio) # image label (on or off)
|
||||
else:
|
||||
no_trigger_sequence = [0,] * (wait_pulses - 1) + [0,] + [0,]
|
||||
cta.seq[215] = no_trigger_sequence * cta_multiplier # x-ray_shutter # trigger (laser_shutter or droplet ejector)
|
||||
cta.seq[216] = no_trigger_sequence * cta_multiplier # x-ray_shutter # image label (on or off)1
|
||||
cta.seq[219] = xray_sequence * cta_multiplier # detector trigger
|
||||
|
||||
number_of_appertures = repetitions*cta_multiplier
|
||||
cta=CTASequencer("SAR-CCTA-ESC")
|
||||
cta.cfg.repetitions = repetitions
|
||||
self.images=repetitions*cta_multiplier
|
||||
on_off_ratio = int(run['num_of_on_to_1_off'])+1
|
||||
if motion_mode==5:
|
||||
if kwargs['tmove']==0:
|
||||
wait_pulses=0
|
||||
else:
|
||||
print('not code gen 3')
|
||||
# no extra rows 1:1
|
||||
cta.seq[214]=[1,]+[0,]*(cta_multiplier-1) #start motion
|
||||
cta.seq[200]=[1,]*cta_multiplier #uncomment me for normal operation
|
||||
#cta.seq[200]=[1,0,]*(cta_multiplier//2) # x-ray_shutter
|
||||
cta.seq[219]=[1,]*cta_multiplier #trigger detector
|
||||
if run["triggered"]:
|
||||
cta.seq[215]=[1,0,]*(cta_multiplier//2) # Trigger 1:1
|
||||
cta.seq[216]=[1,0,]*(cta_multiplier//2) # Label image light dark 1:1 #change back to 1,0 for normal on off measurements
|
||||
|
||||
wait_pulses=kwargs['twait']//kwargs['tmove']
|
||||
#xray_seq=[0,]*wait_pulses+[1] # multiplier is proportional to wait_time i.e. 10 ms = 1, 20 ms =2, 30 ms =3.
|
||||
#xray_sequence=[0,]*wait_pulses+[1]
|
||||
#cta.seq[200]=xray_sequence*cta_multiplier # x-ray_shutter
|
||||
#cta.seq[214] = [1,] + [0,] * (len(xray_sequence * cta_multiplier) -1)
|
||||
#trigger_sequence = [1,] + [0,] * wait_pulses + [0,] * wait_pulses + [0]
|
||||
#cta.seq[215]=trigger_sequence*(cta_multiplier//2) # laser_shutter
|
||||
#image_label_sequence = [0,] * wait_pulses + [1] + [0,] * wait_pulses + [0]
|
||||
#cta.seq[216]=image_label_sequence*(cta_multiplier//2)
|
||||
#cta.seq[219] = xray_sequence * cta_multiplier
|
||||
#on_off_ratio = 2 #1 on to 1 off which means 2 in the whole sequence
|
||||
xray_sequence = [0,] * wait_pulses + [1,]
|
||||
cta.seq[200] = xray_sequence * cta_multiplier # x-ray_shutter
|
||||
cta.seq[214] = [1,] + [0,] * (len(xray_sequence * cta_multiplier) -1) #start motion
|
||||
if run["triggered"]:
|
||||
trigger_on = [1,] + [0,] * wait_pulses
|
||||
trigger_off = [0,] + [0,] * wait_pulses
|
||||
trigger_sequence = trigger_off + trigger_on * (on_off_ratio-1)
|
||||
image_on = [0,] * wait_pulses + [1,]
|
||||
image_label_sequence = [0,] * wait_pulses + [0,] + image_on * (on_off_ratio-1)
|
||||
cta.seq[215] = trigger_sequence * int(cta_multiplier/on_off_ratio) # trigger (laser_shutter or droplet ejector)
|
||||
cta.seq[216] = image_label_sequence * int(cta_multiplier/on_off_ratio) # image label (on or off)
|
||||
else:
|
||||
no_trigger_sequence = [0,] + [0,] * wait_pulses
|
||||
cta.seq[215] = no_trigger_sequence * cta_multiplier # x-ray_shutter # trigger (laser_shutter or droplet ejector)
|
||||
cta.seq[216] = no_trigger_sequence * cta_multiplier # x-ray_shutter # image label (on or off)1
|
||||
cta.seq[219] = xray_sequence * cta_multiplier # detector trigger
|
||||
self.n_pulses_run = len(cta.seq[200])*repetitions
|
||||
self.bsdata_scalar = self.n_pulses_run/number_of_appertures
|
||||
_log.info(f'The multiplier of the block size is {self.bsdata_scalar}')
|
||||
cta.seq.upload()
|
||||
self._daq=CTAAcquisition(cta, loc['end_station'], loc['p_group'], default_detectors=detectors,
|
||||
default_channels=bs_channels,
|
||||
default_pvs=pv_channels, rate_multiplicator=1, append_user_tag_to_data_dir=True, timeout=30)
|
||||
#print(on_off_ratio,cta_multiplier,int(cta_multiplier/on_off_ratio),len(cta.seq[200]),len(cta.seq[214]),len(cta.seq[215]),len(cta.seq[216]),len(cta.seq[219]))
|
||||
#self.motion_mode = 5
|
||||
elif motion_mode==6:
|
||||
ssz = kwargs['ssz']
|
||||
#smv = kwargs['smv']
|
||||
grid_cnt=kwargs['grid']['count']
|
||||
repetitions=grid_cnt[0] #'x' or number of columns # if mode = 1 or 3
|
||||
cta_multiplier=grid_cnt[1] #'y' or number of appertures in a column/number of rows
|
||||
smv = ssz[0]-1 #max(ssz[0]-1, ssz[1]) commented out for fast camera tests, need a better work around for non-equal jumps in the CTA or motion script, currently avoid!
|
||||
apperture_group_size = ssz[0] * ssz[1]
|
||||
|
||||
#number_of_apperture_groups = number_of_appertures // apperture_group_size
|
||||
number_of_apperture_groups=(repetitions//ssz[0])*(cta_multiplier//ssz[1])
|
||||
print(f"number_of_apperture_groups = {number_of_apperture_groups}")
|
||||
#print(f"actually want 162//8 * {162//7} (or 162//8 * 162//7) which = 460, so 460*8*7=25760")
|
||||
transition_pulses = smv
|
||||
#on_off_ratio = 2 #1 on to 1 off which means 2 in the whole sequence
|
||||
xray_sequence = [0,] * apperture_group_size + [1,] * apperture_group_size + [0,] * (transition_pulses - 1)
|
||||
cta.seq[200] = xray_sequence
|
||||
cta.seq[214] = [1,] + [0,] * (apperture_group_size -1) + [0,] * apperture_group_size + [0,] * (transition_pulses - 1) #start motion
|
||||
if run["triggered"]:
|
||||
if on_off_ratio > apperture_group_size:
|
||||
on_off_ratio = apperture_group_size
|
||||
on_off_sequence = [1,] * (on_off_ratio - 1) + [0,]
|
||||
cta.seq[215] = on_off_sequence * (apperture_group_size//on_off_ratio) + [0,] * apperture_group_size + [0,] * (transition_pulses -1) # Trigger 1:1
|
||||
repeat_sequence_laser_closed = [1, ] + [0,] * (apperture_group_size - 1)
|
||||
repeat_sequence_laser_open = [1,] + [0,] * (apperture_group_size - 1)
|
||||
tranisition_sequence_laser_shut = [0,] * (transition_pulses - 1) #close shutter after final point before starting move...?
|
||||
cta.seq[213] = repeat_sequence_laser_open + repeat_sequence_laser_closed + tranisition_sequence_laser_shut # Trigger 1:1
|
||||
cta.seq[216] = [0,] * apperture_group_size + on_off_sequence * (apperture_group_size//on_off_ratio) + [0,] * (transition_pulses - 1) # Label image light dark 1:1 #change back to 1,0 for normal on off measurements
|
||||
else:
|
||||
cta.seq[215] = [0] * apperture_group_size * 2 + [0,] * (transition_pulses - 1) # trigger (laser_shutter or droplet ejector)
|
||||
cta.seq[216] = [0] * apperture_group_size * 2 + [0,] * (transition_pulses -1) # image label (on or off)1
|
||||
cta.seq[219] = xray_sequence # detector trigger
|
||||
self.n_pulses_run = len(cta.seq[200])*number_of_apperture_groups
|
||||
cta.cfg.repetitions = number_of_apperture_groups # number of repeitions is now number of times we repeat the loop
|
||||
self.images=number_of_apperture_groups*apperture_group_size
|
||||
#self.bsdata_scalar = self.n_pulses_run/number_of_appertures
|
||||
data_collection_block_scaler = round(1000/apperture_group_size)
|
||||
self.block_size_to_jungfrau = data_collection_block_scaler*apperture_group_size
|
||||
self.block_size_to_slic = data_collection_block_scaler*len(cta.seq[200])
|
||||
print(f"length of sequence = {len(cta.seq[200])}")
|
||||
print(f"apperture in group = {apperture_group_size}")
|
||||
print(f"number_of_apperture_groups = {number_of_apperture_groups}")
|
||||
#print(f"n_pulses = {self.n_pulses_run} and n_appertures and images = {number_of_appertures}")
|
||||
#print(f"so a scalar of {self.bsdata_scalar}")
|
||||
print(f"using a data_collection_block_scaler of {data_collection_block_scaler}")
|
||||
print(f"block_size for slic {self.block_size_to_slic}")
|
||||
print(f"block size for jungfrau {self.block_size_to_jungfrau}")
|
||||
|
||||
else:
|
||||
self._daq=SFAcquisition(
|
||||
loc['end_station'], loc['p_group'],
|
||||
default_detectors=detectors, default_channels=bs_channels, default_pvs=pv_channels,
|
||||
rate_multiplicator=1, append_user_tag_to_data_dir=True)
|
||||
_log.info('not mode 5 or 6')
|
||||
#need to add on off ratio
|
||||
# no extra rows 1:1
|
||||
#self.motion_mode = 4
|
||||
|
||||
cta.seq[214]=[1,]+[0,]*(cta_multiplier-1) #start motion
|
||||
cta.seq[200]=[1,]*cta_multiplier #uncomment me for normal operation
|
||||
#cta.seq[200]=[1,0,]*(cta_multiplier//2) # x-ray_shutter
|
||||
cta.seq[219]=[1,]*cta_multiplier #trigger detector
|
||||
if run["triggered"]:
|
||||
#cta.seq[215]=[1,0,]*(cta_multiplier//2) # Trigger 1:1
|
||||
cta.seq[215]=[1,]*cta_multiplier # shutter always open
|
||||
cta.seq[216]=[1,0,]*(cta_multiplier//2) # Label image light dark 1:1 #change back to 1,0 for normal on off measurements
|
||||
self.n_pulses_run = len(cta.seq[200])*repetitions
|
||||
self.bsdata_scalar=1
|
||||
|
||||
|
||||
cta.seq.upload()
|
||||
self._daq=CTAAcquisition(cta, loc['end_station'], loc['p_group'], default_detectors=detectors,
|
||||
default_channels=bs_channels,
|
||||
default_pvs=pv_channels, rate_multiplicator=1, append_user_tag_to_data_dir=True)#, timeout=30)
|
||||
#else:
|
||||
# self._daq=SFAcquisition(
|
||||
# loc['end_station'], loc['p_group'],
|
||||
# default_detectors=detectors, default_channels=bs_channels, default_pvs=pv_channels,
|
||||
# rate_multiplicator=1, append_user_tag_to_data_dir=True)
|
||||
|
||||
def acquire(self, n_pulses, wait=False):
|
||||
if getattr(self,'_sim',False):
|
||||
@@ -292,19 +360,29 @@ class Jungfrau:
|
||||
header_appendix['trigger_event'] = trigger_event
|
||||
header_appendix['laser_pulse_energy'] = trigger_delay
|
||||
header_appendix['file_prefix'] = f'run{run_number:04}-{user_tag}'
|
||||
|
||||
self.jfj.acquire(beam_x_pxl = loc['beam_x'], beam_y_pxl = loc['beam_y'], detector_distance_mm = detector_distance_mm, incident_energy_keV = loc['incident_energy_kev'], transmission = transmission,
|
||||
sample_name = sample_name, run_number = run_number, file_prefix = jfj_file_prefix, experiment_group=pgroup, ntrigger = self.images, images_per_file = images_per_file,
|
||||
unit_cell=unit_cell, space_group_number=daq_uc['space_group_number'],
|
||||
header_appendix=header_appendix
|
||||
)
|
||||
if self.motion_mode == 6:
|
||||
self.jfj.acquire(beam_x_pxl = loc['beam_x'], beam_y_pxl = loc['beam_y'], detector_distance_mm = detector_distance_mm, incident_energy_keV = loc['incident_energy_kev'], transmission = transmission,
|
||||
sample_name = sample_name, run_number = run_number, file_prefix = jfj_file_prefix, experiment_group=pgroup, ntrigger = self.images, images_per_file = self.block_size_to_jungfrau,
|
||||
unit_cell=unit_cell, space_group_number=daq_uc['space_group_number'],
|
||||
header_appendix=header_appendix
|
||||
)
|
||||
else:
|
||||
self.jfj.acquire(beam_x_pxl = loc['beam_x'], beam_y_pxl = loc['beam_y'], detector_distance_mm = detector_distance_mm, incident_energy_keV = loc['incident_energy_kev'], transmission = transmission,
|
||||
sample_name = sample_name, run_number = run_number, file_prefix = jfj_file_prefix, experiment_group=pgroup, ntrigger = self.images, images_per_file = images_per_file,
|
||||
unit_cell=unit_cell, space_group_number=daq_uc['space_group_number'],
|
||||
header_appendix=header_appendix
|
||||
)
|
||||
_log.info('JFJ primed')
|
||||
else:
|
||||
is_scan_step=False
|
||||
block_size = int(run['block_size']*self.bsdata_scalar) #scales block_size for bsdata acquisition only
|
||||
_log.info(f'The multiplier of the block size is {self.bsdata_scalar}, new block size is {block_size}')
|
||||
#_log.info(f'The multiplier of the block size is {self.bsdata_scalar}, new block size is {block_size}')
|
||||
print(f'The multiplier of the block size is {self.bsdata_scalar}, new block size is {block_size}')
|
||||
if type(self._daq) is CTAAcquisition:
|
||||
self._daq.acquire(user_tag, n_pulses=max(n_pulses_run, block_size), n_block_size=block_size, wait=False, cell_name=run['cell_name'], is_scan_step=is_scan_step)
|
||||
if self.motion_mode == 6:
|
||||
self._daq.acquire(user_tag, n_pulses=max(n_pulses_run, self.block_size_to_slic), n_block_size=self.block_size_to_slic, wait=False, cell_name=run['cell_name'], is_scan_step=is_scan_step)
|
||||
else:
|
||||
self._daq.acquire(user_tag, n_pulses=max(n_pulses_run, block_size), n_block_size=block_size, wait=False, cell_name=run['cell_name'], is_scan_step=is_scan_step)
|
||||
else:
|
||||
self._daq.acquire(user_tag, n_pulses=max(n_pulses_run, block_size), n_repeat=ceil(n_pulses_run/block_size), wait=False, cell_name=run['cell_name'], is_scan_step=is_scan_step)
|
||||
cfg.setValue(AppCfg.DAQ_RUN,run)
|
||||
|
||||
Reference in New Issue
Block a user