Fix/da qoldformat corr
Merge request reports
Activity
84 97 if len(file): 85 98 h5file = h5py.File(file) 86 if not f'/RUN/{ctrlloc}/FPGA/PPT_Q{quadrant}/epcRegisterFilePath/value' in h5file: 87 print(f"Slow control data file {file} is not usable") 88 continue 89 epcConfig = h5file[f'/RUN/{ctrlloc}/FPGA/PPT_Q{quadrant}/epcRegisterFilePath/value'][0]\ 90 .decode("utf-8") 91 epcConfig = epcConfig[epcConfig.rfind('/') + 1:] 92 93 print(f"EPC configuration: {epcConfig}") 94 95 targGain = _extr_gainparam_conffilename(epcConfig) 96 97 tGain[quadrant] = float(targGain) if targGain is not None else 0.0 98 # 0.0 is default value for TG 99 if daq_format != '': I would have written this bit as
96 for quadrant, file in ctrlDataFiles.items(): 97 if len(file): 98 h5file = h5py.File(file) 99 if daq_format != '': 100 epcConfig = h5file[f'/RUN/{ctrlloc}/FPGA/PPT_Q{quadrant}/epcRegisterFilePath/value'][0]\ 101 .decode("utf-8") 102 epcConfig = epcConfig[epcConfig.rfind('/') + 1:] 103 104 print(f"EPC configuration: {epcConfig}") 105 targGain = _extr_gainparam_conffilename(epcConfig) 106 tGain[quadrant] = float( 107 targGain) if targGain is not None else 0.0 108 # 0.0 is default value for TG 109 else: 110 tGain[quadrant] = 0.0 96 for quadrant, filename in ctrlDataFiles.items(): 97 if filename: 98 if not daq_format: 99 tGain[quadrant] = 0.0 100 else: 101 with h5file.File(filename) as h5file: 102 epcConfig = h5file[f'/RUN/{ctrlloc}/FPGA/PPT_Q{quadrant}/epcRegisterFilePath/value'][0].decode("utf-8") 103 epcConfig = epcConfig[epcConfig.rfind('/') + 1:] 104 105 print(f"EPC configuration: {epcConfig}") 106 targGain = _extr_gainparam_conffilename(epcConfig) 107 tGain[quadrant] = float(targGain) if targGain is not None else 0.0 With this in mind, I'm wondering whether the topmost
if
could beif not daq_formant or not filename:
? Then this block is even simpler so:96 for quadrant, file in ctrlDataFiles.items(): 97 if len(file): 98 h5file = h5py.File(file) 99 if daq_format != '': 100 epcConfig = h5file[f'/RUN/{ctrlloc}/FPGA/PPT_Q{quadrant}/epcRegisterFilePath/value'][0]\ 101 .decode("utf-8") 102 epcConfig = epcConfig[epcConfig.rfind('/') + 1:] 103 104 print(f"EPC configuration: {epcConfig}") 105 targGain = _extr_gainparam_conffilename(epcConfig) 106 tGain[quadrant] = float( 107 targGain) if targGain is not None else 0.0 108 # 0.0 is default value for TG 109 else: 110 tGain[quadrant] = 0.0 96 for quadrant, filename in ctrlDataFiles.items(): 97 if not filename or not daq_format: 98 tGain[quadrant] = 0.0 99 else: 100 with h5file.File(filename) as h5file: 101 epcConfig = h5file[f'/RUN/{ctrlloc}/FPGA/PPT_Q{quadrant}/epcRegisterFilePath/value'][0].decode("utf-8") 102 epcConfig = epcConfig[epcConfig.rfind('/') + 1:] 103 104 print(f"EPC configuration: {epcConfig}") 105 targGain = _extr_gainparam_conffilename(epcConfig) 106 tGain[quadrant] = float(targGain) if targGain is not None else 0.0 Edited by Cyril Danilevskichanged this line in version 2 of the diff
Added exception handling, changed order in branching.
Edited by Andrey Samartsev- Edited by Andrey Samartsev
74 74 75 ctrlloc = h5py.File(next(iter(ctrlDataFiles.values())), 'r')[ 76 '/METADATA/dataSources/deviceId'][0] 75 daq_format = '' 76 77 ctrlloc = None 78 filename = next(iter(ctrlDataFiles.values())) 79 with h5py.File(filename, 'r') as ctlrh5file: 80 if '/METADATA/dataSources/deviceId' in ctlrh5file: 81 ctrlloc = ctlrh5file['/METADATA/dataSources/deviceId'][0] 82 daq_format = ctlrh5file['/METADATA/dataFormatVersion'][0].decode( 83 "utf-8") 84 elif '/METADATA/deviceId' in ctlrh5file: 85 ctrlloc = ctlrh5file['/METADATA/deviceId'][0] 86 else: 87 print("No Slow Control Data found in files!") - Edited by Karim Ahmed
120 irampSettings = h5file[iramp_path][0] 121 else: 122 irampSettings = "Various" 123 124 gainSettingsMap['trimmed'] = np.int64( 125 1) if irampSettings == "Various" else np.int64(0) 126 127 encodedGain[quadrant] = _get_gain_encoded_val(gainSettingsMap) 128 129 opFreq = h5file[f'/RUN/{ctrlloc}/FPGA/PPT_Q{quadrant}/sequencer/cycleLength/value'][0] 130 # The Operating Frequency of the detector should be in MHz. 131 # Here the karabo operation mode is converted to acquisition rate: 132 # 22 corresponds to 4.5 MHz, 44 to 2.25 MHz, etc. 133 operatingFreqs[quadrant] = 4.5 * (22.0 / opFreq) 118 134 else: 119 135 print(f"no slow data for quadrant {quadrant} is found") - Resolved by Karim Ahmed
- Resolved by Karim Ahmed
- Resolved by Karim Ahmed
- Resolved by Karim Ahmed
added 2 commits
Thank you @samartse for taking care of the MR comments and support updated reports.
LGTM but I will have some points as feedback mentioned below.
From what I understand we are not using the past constants anymore for old data which doesn't have the new parameter conditions. is that right?
For later merge requests it will be good to consider PEP 8 style not only in line length but variable names as well. Usually, we are using small letters for variables and functions instead of camelCase (function_name)
Edited by Karim AhmedFrom what I understand we are not using the past constants anymore for old data which doesn't have the new parameter conditions. is that right?
For very old data, some conditions could not be retrieved because no corresponding slow data existed. Later on additional effort have been made for string encoding. This code is obsolete, because relatively soon ITDM implemented strings in hdf files, and I started to use proper strings. For this data still the correct processing is feasible using reduced set of conditions.
mentioned in commit 9ac9c5f4