Skip to content
Snippets Groups Projects
Commit faee68c2 authored by Andrey Samartsev's avatar Andrey Samartsev
Browse files

changes after MR revision

parent 94178854
No related branches found
No related tags found
1 merge request!432Fix/da qoldformat corr
...@@ -76,16 +76,16 @@ def get_dssc_ctrl_data(in_folder, slow_data_pattern, ...@@ -76,16 +76,16 @@ def get_dssc_ctrl_data(in_folder, slow_data_pattern,
ctrlloc = None ctrlloc = None
filename = next(iter(ctrlDataFiles.values())) filename = next(iter(ctrlDataFiles.values()))
ctlrh5file = h5py.File(filename, 'r') with h5py.File(filename, 'r') as ctlrh5file:
if '/METADATA/dataSources/deviceId' in ctlrh5file: if '/METADATA/dataSources/deviceId' in ctlrh5file:
ctrlloc = ctlrh5file['/METADATA/dataSources/deviceId'][0] ctrlloc = ctlrh5file['/METADATA/dataSources/deviceId'][0]
daq_format = ctlrh5file['/METADATA/dataFormatVersion'][0].decode( daq_format = ctlrh5file['/METADATA/dataFormatVersion'][0].decode(
"utf-8") "utf-8")
elif '/METADATA/deviceId' in ctlrh5file: elif '/METADATA/deviceId' in ctlrh5file:
ctrlloc = ctlrh5file['/METADATA/deviceId'][0] ctrlloc = ctlrh5file['/METADATA/deviceId'][0]
else: else:
print("No Slow Control Data found in files!") print("No Slow Control Data found in files!")
return targetGainAll, encodedGainAll, operatingFreqAll return targetGainAll, encodedGainAll, operatingFreqAll
ctrlloc = ctrlloc.decode("utf-8") ctrlloc = ctrlloc.decode("utf-8")
ctrlloc = ctrlloc[:ctrlloc.find('/')] ctrlloc = ctrlloc[:ctrlloc.find('/')]
...@@ -95,43 +95,42 @@ def get_dssc_ctrl_data(in_folder, slow_data_pattern, ...@@ -95,43 +95,42 @@ def get_dssc_ctrl_data(in_folder, slow_data_pattern,
operatingFreqs = {} operatingFreqs = {}
for quadrant, file in ctrlDataFiles.items(): for quadrant, file in ctrlDataFiles.items():
if len(file): if len(file):
h5file = h5py.File(file) with h5py.File(file) as h5file:
if daq_format != '': if not daq_format:
epcConfig = h5file[f'/RUN/{ctrlloc}/FPGA/PPT_Q{quadrant}/epcRegisterFilePath/value'][0]\ tGain[quadrant] = 0.0 # 0.0 is default value for TG
.decode("utf-8") else:
epcConfig = epcConfig[epcConfig.rfind('/') + 1:] epcConfig = h5file[f'/RUN/{ctrlloc}/FPGA/PPT_Q{quadrant}/epcRegisterFilePath/value'][0]\
.decode("utf-8")
print(f"EPC configuration: {epcConfig}") epcConfig = epcConfig[epcConfig.rfind('/') + 1:]
targGain = _extr_gainparam_conffilename(epcConfig)
tGain[quadrant] = float( print(f"EPC configuration: {epcConfig}")
targGain) if targGain is not None else 0.0 targGain = _extr_gainparam_conffilename(epcConfig)
# 0.0 is default value for TG tGain[quadrant] = float(
else: targGain) if targGain is not None else 0.0
tGain[quadrant] = 0.0
gainSettingsMap = {}
gainSettingsMap = {} for coarseParam in ['fcfEnCap', 'csaFbCap', 'csaResistor']:
for coarseParam in ['fcfEnCap', 'csaFbCap', 'csaResistor']: gainSettingsMap[coarseParam] = int(
gainSettingsMap[coarseParam] = int( h5file[f'/RUN/{ctrlloc}/FPGA/PPT_Q{quadrant}/gain/{coarseParam}/value'][0])
h5file[f'/RUN/{ctrlloc}/FPGA/PPT_Q{quadrant}/gain/{coarseParam}/value'][0])
iramp_path = f'/RUN/{ctrlloc}/FPGA/PPT_Q{quadrant}/gain/irampFineTrm/value'
iramp_path = f'/RUN/{ctrlloc}/FPGA/PPT_Q{quadrant}/gain/irampFineTrm/value' if daq_format != '':
if daq_format != '': irampSettings = h5file[iramp_path][0].decode("utf-8")
irampSettings = h5file[iramp_path][0].decode("utf-8") elif iramp_path in h5file:
elif iramp_path in h5file: irampSettings = h5file[iramp_path][0]
irampSettings = h5file[iramp_path][0] else:
else: irampSettings = "Various"
irampSettings = "Various"
gainSettingsMap['trimmed'] = np.int64(
gainSettingsMap['trimmed'] = np.int64( 1) if irampSettings == "Various" else np.int64(0)
1) if irampSettings == "Various" else np.int64(0)
encodedGain[quadrant] = _get_gain_encoded_val(gainSettingsMap)
encodedGain[quadrant] = _get_gain_encoded_val(gainSettingsMap)
opFreq = h5file[f'/RUN/{ctrlloc}/FPGA/PPT_Q{quadrant}/sequencer/cycleLength/value'][0]
opFreq = h5file[f'/RUN/{ctrlloc}/FPGA/PPT_Q{quadrant}/sequencer/cycleLength/value'][0] # The Operating Frequency of the detector should be in MHz.
# The Operating Frequency of the detector should be in MHz. # Here the karabo operation mode is converted to acquisition rate:
# Here the karabo operation mode is converted to acquisition rate: # 22 corresponds to 4.5 MHz, 44 to 2.25 MHz, etc.
# 22 corresponds to 4.5 MHz, 44 to 2.25 MHz, etc. operatingFreqs[quadrant] = 4.5 * (22.0 / opFreq)
operatingFreqs[quadrant] = 4.5 * (22.0 / opFreq)
else: else:
print(f"no slow data for quadrant {quadrant} is found") print(f"no slow data for quadrant {quadrant} is found")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment