diff --git a/notebooks/Jungfrau/Jungfrau_Gain_Correct_and_Verify_NBC.ipynb b/notebooks/Jungfrau/Jungfrau_Gain_Correct_and_Verify_NBC.ipynb index 2c485c79b17d0a474e0a85d59c2da8407c678218..c4ad3a8426fb44a4eca442004d2f524cc3da567c 100644 --- a/notebooks/Jungfrau/Jungfrau_Gain_Correct_and_Verify_NBC.ipynb +++ b/notebooks/Jungfrau/Jungfrau_Gain_Correct_and_Verify_NBC.ipynb @@ -46,8 +46,7 @@ "manual_slow_data = False # if true, use manually entered bias_voltage and integration_time values\n", "integration_time = 4.96 # integration time in us, will be overwritten by value in file\n", "gain_setting = 0 # 0 for dynamic gain, 1 for dynamic HG0, will be overwritten by value in file\n", - "gain_mode = 0 # 0 for runs with dynamic gain setting, 1 for fixgain. It will be overwritten by value in file, if manual_slow_data is set to True. -", + "gain_mode = 0 # 0 for runs with dynamic gain setting, 1 for fixgain. It will be overwritten by value in file, if manual_slow_data is set to True.\n", "mem_cells = 0 # leave memory cells equal 0, as it is saved in control information starting 2019.\n", "bias_voltage = 180 # will be overwritten by value in file\n", "\n", diff --git a/src/cal_tools/tools.py b/src/cal_tools/tools.py index 962f1a0db3dbd314d010f762a72cfb997e63f0b5..71fdba355ccbe047d958069b6d5567aeb437274a 100644 --- a/src/cal_tools/tools.py +++ b/src/cal_tools/tools.py @@ -786,18 +786,19 @@ class CalibrationMetadata(dict): def __init__(self, output_dir: Union[Path, str], *args, new=False): dict.__init__(self, args) self._yaml_fn = Path(output_dir) / "calibration_metadata.yml" - if (not new) and self._yaml_fn.exists(): - with self._yaml_fn.open("r") as fd: - data = yaml.safe_load(fd) - if isinstance(data, dict): - self.update(data) + if self._yaml_fn.exists(): + if new: + # TODO: update after resolving this discussion + # https://git.xfel.eu/detectors/pycalibration/-/merge_requests/624 # noqa + self.save() else: - print(f"Warning: existing {self._yaml_fn} is malformed, " - "will be overwritten") - else: - # TODO: update after resolving this discussion - # https://git.xfel.eu/detectors/pycalibration/-/merge_requests/624 - self.save() + with self._yaml_fn.open("r") as fd: + data = yaml.safe_load(fd) + if isinstance(data, dict): + self.update(data) + else: + print(f"Warning: existing {self._yaml_fn} is malformed, " + "will be overwritten") def save(self): with self._yaml_fn.open("w") as fd: