diff --git a/notebooks/pnCCD/Correct_pnCCD_NBC.ipynb b/notebooks/pnCCD/Correct_pnCCD_NBC.ipynb index 6fa624889de54e2fc0d38eea0be38b2dec189de7..11d80de46a72a0ee6d8cc315ab6198f3fb20f251 100644 --- a/notebooks/pnCCD/Correct_pnCCD_NBC.ipynb +++ b/notebooks/pnCCD/Correct_pnCCD_NBC.ipynb @@ -324,10 +324,9 @@ " client=rest_cfg.calibration_client(),\n", ")\n", "\n", - "try:\n", - " pnccd_metadata = pnccd_cal.metadata(calibrations=constant_names)\n", - "except CalCatError as e:\n", - " warning(e)\n", + "pnccd_metadata = pnccd_cal.metadata(calibrations=constant_names)\n", + "\n", + "metadata = pnccd_metadata[karabo_da]\n", "\n", "mod_to_pdu = pnccd_cal.mod_to_pdu\n", "ccvs_url = \"https://in.xfel.eu/calibration/calibration_constant_versions/\"\n", @@ -337,34 +336,31 @@ " display(Markdown(\n", " f\"- [{cname}]({ccvs_url}/{c_mdata['ccv_id']}): {c_mdata['begin_validity_at']}\"))\n", "\n", - "constants = pnccd_cal.ndarray_map(metadata=pnccd_metadata).get(karabo_da, {})\n", - "\n", "# Validate the constants availability and raise/warn correspondingly. \n", "missing_dark_constants = set(\n", - " c for c in [\"OffsetCCD\", \"NoiseCCD\", \"BadPixelsDarkCCD\"] if c not in constants.keys())\n", + " c for c in [\"OffsetCCD\", \"NoiseCCD\", \"BadPixelsDarkCCD\"] if c not in metadata.keys())\n", "\n", "if missing_dark_constants:\n", " raise KeyError(\n", " f\"Dark constants {missing_dark_constants} are not available for correction.\")\n", "\n", - "if corr_bools.get('relgain') and \"RelativeGainCCD\" not in constants.keys():\n", - " warning(\"RelativeGainEPix100 is not found in the calibration database.\")\n", + "if corr_bools.get('relgain') and \"RelativeGainCCD\" not in metadata.keys():\n", + " warning(\"RelativeGainEPix100 is not found in the calibration database. \"\n", + " \"Relative gain correction is disabled.\")\n", " corr_bools['relgain'] = False\n", - "step_timer.done_step(\"Constants retrieval\")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ + "\n", "# Record constant details in YAML metadata\n", "write_constants_fragment(\n", " out_folder=(metadata_folder or out_folder),\n", " det_metadata=pnccd_metadata,\n", " caldb_root=pnccd_cal.caldb_root,\n", - " )" + " )\n", + "\n", + "# load constants arrays after storing fragment YAML file\n", + "# and validating constants availability.\n", + "constants = pnccd_cal.ndarray_map(metadata=pnccd_metadata).get(karabo_da, {})\n", + "\n", + "step_timer.done_step(\"Constants retrieval\")" ] }, {