diff --git a/notebooks/Jungfrau/Jungfrau_dark_analysis_all_gains_burst_mode_NBC.ipynb b/notebooks/Jungfrau/Jungfrau_dark_analysis_all_gains_burst_mode_NBC.ipynb index 6a777b117c25e928aa8f8f802b85e2b1d9ce83cd..9c74953bf1c7d8c59deb87dbec87994eab300fe8 100644 --- a/notebooks/Jungfrau/Jungfrau_dark_analysis_all_gains_burst_mode_NBC.ipynb +++ b/notebooks/Jungfrau/Jungfrau_dark_analysis_all_gains_burst_mode_NBC.ipynb @@ -45,15 +45,14 @@ "control_id = \"CONTROL\" # inset for control devices\n", "db_module = \"Jungfrau_M260\" # ID of module in calibration database\n", "use_dir_creation_date = True # use dir creation date\n", - "manual_slow_data = False # if true, use manually entered bias_voltage and integration_time values" + "manual_slow_data = False # if true, use manually entered bias_voltage and integration_time values\n", + "time_limits = 0.5 # to find calibration constants later on, the integration time is allowed to vary by 0.5 us" ] }, { "cell_type": "code", "execution_count": 90, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -114,6 +113,16 @@ "os.makedirs(out_folder, exist_ok=True)" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "proposal = list(filter(None, in_folder.strip('/').split('/')))[-2]\n", + "file_loc = 'proposal:{} runs:{} {} {}'.format(proposal, run_high, run_med, run_low)" + ] + }, { "cell_type": "code", "execution_count": 83, @@ -138,9 +147,7 @@ { "cell_type": "code", "execution_count": 84, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -326,7 +333,6 @@ "cell_type": "code", "execution_count": 86, "metadata": { - "collapsed": false, "scrolled": false }, "outputs": [ @@ -522,9 +528,7 @@ { "cell_type": "code", "execution_count": 87, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -549,7 +553,6 @@ "cell_type": "code", "execution_count": 88, "metadata": { - "collapsed": false, "scrolled": false }, "outputs": [ @@ -618,9 +621,7 @@ { "cell_type": "code", "execution_count": 89, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "ename": "RuntimeError", @@ -636,78 +637,40 @@ } ], "source": [ - "## offset\n", - "\n", - "metadata = ConstantMetaData()\n", - "offset = Constants.jungfrau.Offset()\n", - "offset.data = np.moveaxis(offset_map, 0, 1)\n", - "metadata.calibration_constant = offset\n", - "\n", - "# set the operating condition\n", - "condition = Conditions.Dark.jungfrau(memory_cells=memoryCells, bias_voltage=bias_voltage,\n", - " integration_time=integration_time)\n", - "device = getattr(Detectors, db_module)\n", + "constants = {'Offset': np.moveaxis(offset_map, 0, 1),\n", + " 'Noise': np.moveaxis(noise_map, 0, 1), \n", + " 'BadPixelsDark': np.moveaxis(bad_pixels_map, 0, 1)}\n", "\n", + "for key, const_data in constants.items():\n", "\n", - "metadata.detector_condition = condition\n", + " metadata = ConstantMetaData()\n", + " const = getattr(Constants.jungfrau, key)()\n", + " const.data = const_data\n", + " metadata.calibration_constant = const\n", "\n", - "# specify the version for this constant\n", - "if creation_time is None:\n", - " metadata.calibration_constant_version = Versions.Now(device=device)\n", - " metadata.retrieve(cal_db_interface)\n", - "else:\n", - " metadata.calibration_constant_version = Versions.Timespan(device=device,\n", - " start=creation_time)\n", - "metadata.send(cal_db_interface)\n", - "\n", - "## noise\n", - "\n", - "metadata = ConstantMetaData()\n", - "noise = Constants.jungfrau.Noise()\n", - "noise.data = np.moveaxis(noise_map, 0, 1)\n", - "metadata.calibration_constant = noise\n", - "\n", - "# set the operating condition\n", - "condition = Conditions.Dark.jungfrau(memory_cells=memoryCells, bias_voltage=bias_voltage,\n", - " integration_time=integration_time)\n", - "\n", - "\n", - "\n", - "metadata.detector_condition = condition\n", - "\n", - "# specify the version for this constant\n", - "if creation_time is None:\n", - " metadata.calibration_constant_version = Versions.Now(device=device)\n", - " metadata.retrieve(cal_db_interface)\n", - "else:\n", - " metadata.calibration_constant_version = Versions.Timespan(device=device,\n", - " start=creation_time)\n", - "metadata.send(cal_db_interface)\n", - "\n", - "\n", - "## bad pixels \n", - "\n", - "metadata = ConstantMetaData()\n", - "bpix = Constants.jungfrau.BadPixelsDark()\n", - "bpix.data = np.moveaxis(bad_pixels_map, 0, 1)\n", - "metadata.calibration_constant = bpix\n", - "\n", - "# set the operating condition\n", - "condition = Conditions.Dark.jungfrau(memory_cells=memoryCells, bias_voltage=bias_voltage,\n", - " integration_time=integration_time)\n", - "\n", - "\n", - "\n", - "metadata.detector_condition = condition\n", + " # set the operating condition\n", + " condition = Conditions.Dark.jungfrau(memory_cells=memoryCells, bias_voltage=bias_voltage,\n", + " integration_time=integration_time)\n", + " \n", + " for parm in condition.parameters:\n", + " if parm.name == \"Integration Time\":\n", + " parm.lower_deviation = time_limits\n", + " parm.upper_deviation = time_limits\n", + " \n", + " device = getattr(Detectors, db_module)\n", + " metadata.detector_condition = condition\n", "\n", - "# specify the version for this constant\n", - "if creation_time is None:\n", + " # specify the version for this constant\n", + " if creation_time is None:\n", " metadata.calibration_constant_version = Versions.Now(device=device)\n", - " metadata.retrieve(cal_db_interface)\n", - "else:\n", - " metadata.calibration_constant_version = Versions.Timespan(device=device,\n", - " start=creation_time)\n", - "metadata.send(cal_db_interface)" + " else:\n", + " metadata.calibration_constant_version = Versions.Timespan(device=device,\n", + " start=creation_time)\n", + " \n", + " metadata.calibration_constant_version.raw_data_location = file_loc\n", + " metadata.send(cal_db_interface)\n", + " print('Constants {} is sent to the data base'.format(key))\n", + "\n" ] }, { @@ -736,7 +699,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.6" + "version": "3.6.7" } }, "nbformat": 4,