Skip to content
Snippets Groups Projects

Fix/da qoldformat corr

Merged Andrey Samartsev requested to merge fix/DAQoldformatCorr into master
4 unresolved threads
@@ -13,7 +13,7 @@ def get_pulseid_checksum(fname, h5path, h5path_idx):
with h5py.File(fname, "r") as infile:
count = np.squeeze(infile[f"{h5path_idx}/count"])
first = np.squeeze(infile[f"{h5path_idx}/first"])
last_index = int(first[count != 0][-1]+count[count != 0][-1])
last_index = int(first[count != 0][-1] + count[count != 0][-1])
first_index = int(first[count != 0][0])
pulseids = infile[f"{h5path}/pulseId"][first_index:
int(first[count != 0][1])]
@@ -25,7 +25,7 @@ def get_pulseid_checksum(fname, h5path, h5path_idx):
def _extr_gainparam_conffilename(fileName: str) -> Tuple[int]:
"""extracts target gain from config filename, if provided."""
vals = re.search(".*_TG(?P<TG>\d+.?\d+)", fileName)
vals = re.search(".*_TG(?P<TG>\\d+.?\\d+)", fileName)
if vals:
return vals.group('TG')
@@ -54,7 +54,7 @@ def get_dssc_ctrl_data(in_folder, slow_data_pattern,
encodedGainAll = {}
operatingFreqAll = {}
for i in range(16):
qm = 'Q{}M{}'.format(i//4+1, i % 4+1)
qm = 'Q{}M{}'.format(i // 4 + 1, i % 4 + 1)
targetGainAll[qm] = None
encodedGainAll[qm] = None
operatingFreqAll[qm] = None
@@ -66,13 +66,13 @@ def get_dssc_ctrl_data(in_folder, slow_data_pattern,
f = os.path.join(in_folder, quad_sd_pattern)
if os.path.exists(f):
ctrlDataFiles[quadrant+1] = f
ctrlDataFiles[quadrant + 1] = f
if len(ctrlDataFiles) == 0:
print("No Control Slow Data found!")
print("ERROR: no Control Slow Data found!")
return targetGainAll, encodedGainAll, operatingFreqAll
daq_format = ''
daq_format = None
ctrlloc = None
filename = next(iter(ctrlDataFiles.values()))
@@ -93,11 +93,18 @@ def get_dssc_ctrl_data(in_folder, slow_data_pattern,
tGain = {}
encodedGain = {}
operatingFreqs = {}
for quadrant, file in ctrlDataFiles.items():
if len(file):
for quadrant in range(1,5):
if quadrant in ctrlDataFiles.keys():
file = ctrlDataFiles[quadrant]
with h5py.File(file) as h5file:
iramp_path = f"/RUN/{ctrlloc}/FPGA/PPT_Q{quadrant}/gain/irampFineTrm/value"
if not daq_format:
tGain[quadrant] = 0.0 # 0.0 is default value for TG
tGain[quadrant] = 0.0 # 0.0 is default value for TG
if iramp_path in h5file:
irampSettings = h5file[iramp_path][0]
else:
irampSettings = "Various"
else:
epcConfig = h5file[f'/RUN/{ctrlloc}/FPGA/PPT_Q{quadrant}/epcRegisterFilePath/value'][0]\
.decode("utf-8")
@@ -106,21 +113,14 @@ def get_dssc_ctrl_data(in_folder, slow_data_pattern,
print(f"EPC configuration: {epcConfig}")
targGain = _extr_gainparam_conffilename(epcConfig)
tGain[quadrant] = float(
targGain) if targGain is not None else 0.0
targGain) if targGain is not None else 0.0
irampSettings = h5file[iramp_path][0].decode("utf-8")
gainSettingsMap = {}
for coarseParam in ['fcfEnCap', 'csaFbCap', 'csaResistor']:
gainSettingsMap[coarseParam] = int(
h5file[f'/RUN/{ctrlloc}/FPGA/PPT_Q{quadrant}/gain/{coarseParam}/value'][0])
iramp_path = f'/RUN/{ctrlloc}/FPGA/PPT_Q{quadrant}/gain/irampFineTrm/value'
if daq_format != '':
irampSettings = h5file[iramp_path][0].decode("utf-8")
elif iramp_path in h5file:
irampSettings = h5file[iramp_path][0]
else:
irampSettings = "Various"
gainSettingsMap['trimmed'] = np.int64(
1) if irampSettings == "Various" else np.int64(0)
Loading