calcat_interface2: Fix require_calibrations() when none of a given calibration type found
Description
When no offset constants are found for a given detector, .require_calibrations()
was raising a KeyError, when we expect it to deselect all modules and return an empty CalibrationData object. We have seen this for both LPD & JUNGFRAU.
How Has This Been Tested?
xfel-calibrate jungfrau CORRECT \
--karabo-da JNGFR01 --receiver-template JNGFR01 \
--karabo-id MID_EXP_JF500K1 --run 300 \
--in-folder /gpfs/exfel/exp/MID/202302/p004451/raw \
--out-folder /gpfs/exfel/data/scratch/kluyvert/jf-corr-p4451-r300
Now fails with an error from the notebook:
Exception: Could not find offset constants for any modules, will not correct data.
A separate fix is likely needed in the JUNGFRAU correction notebook for the fallback to dynamic gain constants, as it's currently catching the wrong error.
Types of changes
- Bug fix (non-breaking change which fixes an issue)
Checklist:
- My code follows the code style of this project.
Reviewers
Merge request reports
Activity
added 1 commit
- f3cf6d4f - Fix fallback to dynamic gain constants in burst mode
I have also now updated the notebook code to fall back to dynamic gain constants for burst-mode data. The run I'm testing with (p4451 r300) still doesn't find any constants - maybe because it's from last year but has a non-default exposure timeout, which was only added as a condition more recently. But I see the warning message before it errors out with no constants:
WARNING:root:No fixed gain offset constants found. Looking for dynamic gain constant. ... Exception: Could not find offset constants for any modules, will not correct data.
Edited by Thomas Kluyver276 273 " \"\"\"\n", 277 274 " from datetime import datetime\n", 278 275 "\n", 279 " from cal_tools.calcat_interface import CalCatError\n", 280 "\n", 281 " try:\n", 282 " jungfrau_consts = jungfrau_cal_mdata(gm=1)\n", 283 " except CalCatError as e: # TODO: update with CalibrationError class\n", 276 " jungfrau_consts = jungfrau_cal_mdata(gm=1)\n", 277 " if not jungfrau_consts.aggregator_names:\n", changed this line in version 3 of the diff
Good idea. In fact it would already kind of work in a boolean context, because Python falls back to checking
__len__()
, but it would do the wrong thing if we have calibration types present but no constants in them.I haven't tested this again after a33d66a7, since it's quite a small change. That probably guarantees that I've made a silly mistake.
added 1 commit
- a33d66a7 - CalibrationData.__bool__ to check if any constants present
changed milestone to %3.16.0
mentioned in commit ac3a2137
mentioned in merge request !1129 (merged)