diff --git a/notebooks/pnCCD/Correct_pnCCD_NBC.ipynb b/notebooks/pnCCD/Correct_pnCCD_NBC.ipynb index ab838561f5787a39709cc91bc5bc426ed5dc19ab..66db3ffb2b00ab49d9efd42a700d2c2bba9ec6ca 100644 --- a/notebooks/pnCCD/Correct_pnCCD_NBC.ipynb +++ b/notebooks/pnCCD/Correct_pnCCD_NBC.ipynb @@ -400,26 +400,32 @@ " metadata = ConstantMetaData()\n", " relgain = Constants.CCD(DetectorTypes.pnCCD).RelativeGain()\n", " metadata.calibration_constant = relgain\n", - "\n", - " # set the operating condition\n", - " condition = Conditions.Illuminated.CCD(bias_voltage=bias_voltage,\n", - " integration_time=integration_time,\n", - " gain_setting=gain,\n", - " temperature=fix_temperature,\n", - " pixels_x=pixels_x,\n", - " pixels_y=pixels_y, \n", - " photon_energy=photon_energy)\n", - "\n", - " device = Detectors.PnCCD1\n", - " metadata.detector_condition = condition\n", - "\n", - "\n", - " # specify the a version for this constant\n", - " metadata.calibration_constant_version = Versions.Now(device=device)\n", - " metadata.retrieve(cal_db_interface, timeout=cal_db_timeout) \n", - " constants[\"RelativeGain\"] = relgain.data\n", - " print(\"Retrieved RelativeGain constant with creation time:\"\n", - " f\"{metadata.calibration_constant_version.begin_at}\")\n", + " try:\n", + " # set the operating condition\n", + " condition = Conditions.Illuminated.CCD(bias_voltage=bias_voltage,\n", + " integration_time=integration_time,\n", + " gain_setting=gain,\n", + " temperature=fix_temperature,\n", + " pixels_x=pixels_x,\n", + " pixels_y=pixels_y, \n", + " photon_energy=photon_energy)\n", + "\n", + " device = Detectors.PnCCD1\n", + " metadata.detector_condition = condition\n", + "\n", + "\n", + " # specify the a version for this constant\n", + " metadata.calibration_constant_version = Versions.Now(device=device)\n", + " cal_db_interface = get_random_db_interface(cal_db_interface)\n", + " metadata.retrieve(cal_db_interface, timeout=cal_db_timeout) \n", + " constants[\"RelativeGain\"] = relgain.data\n", + " print(\"Retrieved RelativeGain constant with creation time:\"\n", + " f\"{metadata.calibration_constant_version.begin_at}\")\n", + " except Exception as e:\n", + " print(f\"Error: {e}.\\n\")\n", + " if relgain.data is None:\n", + " constants[\"RelativeGain\"] = np.ones((pixels_x, pixels_y))\n", + " print(\"Relative was not retrieved and an empty constant of ones will be used.\")\n", " display(Markdown('### Relative Gain Map Retrieval'))\n", " fig = xana.heatmapPlot(constants[\"RelativeGain\"], figsize=(8, 8), x_label='Columns', y_label='Rows', lut_label='Relative Gain', \n", " aspect=1, x_range=(0, pixels_y), y_range=(0, pixels_x), vmin=0.8, vmax=1.2, \n",