diff --git a/notebooks/AGIPD/Characterize_AGIPD_Gain_FlatFields_Summary.ipynb b/notebooks/AGIPD/Characterize_AGIPD_Gain_FlatFields_Summary.ipynb index e5705d14886ebc5234f282b9a887bead70205329..fca571903e01ac972a3a4a4c1f03c44ead950819 100644 --- a/notebooks/AGIPD/Characterize_AGIPD_Gain_FlatFields_Summary.ipynb +++ b/notebooks/AGIPD/Characterize_AGIPD_Gain_FlatFields_Summary.ipynb @@ -19,12 +19,12 @@ "metadata_folder = \"\" # Directory containing calibration_metadata.yml when run by xfel-calibrate\n", "hist_file_template = \"hists_m{:02d}_sum.h5\"\n", "proc_folder = \"\" # Path to corrected image data used to create histograms and validation plots\n", - "raw_folder = \"/gpfs/exfel/exp/MID/202030/p900137/raw\" # folder of raw data. This is used to save information of source data of generated constants, required\n", - "run = 449 # runs of image data used to create histograms\n", + "raw_folder = \"\" # folder of raw data. This is used to save information of source data of generated constants, required\n", + "run = 38 # runs of image data used to create histograms\n", "\n", - "karabo_id = \"MID_DET_AGIPD1M-1\" # karabo karabo_id\n", + "karabo_id = \"SPB_DET_AGIPD1M-1\" # karabo karabo_id\n", "ctrl_source_template = '{}/MDL/FPGA_COMP' # path to control information\n", - "karabo_id_control = \"MID_EXP_AGIPD1M1\" # karabo-id for control device\n", + "karabo_id_control = \"SPB_IRU_AGIPD1M1\" # karabo-id for control device\n", "\n", "use_dir_creation_date = True # use the creation data of the input dir for database queries\n", "cal_db_interface = \"tcp://max-exfl-cal001:8015#8045\" # the database interface to use\n", @@ -39,7 +39,7 @@ "d0_lim = [10, 70] # hard limits for d0 value (distance between noise and first peak)\n", "gain_lim = [0.80, 1.2] # Threshold on gain in relative number. Contribute to BadPixel bit \"Gain_deviation\"\n", "\n", - "cell_range = [1,5] # range of cell to be considered, [0,0] for all\n", + "cell_range = [0,352] # range of cell to be considered, [0,0] for all\n", "pixel_range = [0,0,512,128] # range of pixels x1,y1,x2,y2 to consider [0,0,512,128] for all\n", "n_peaks_fit = 4 # Number of gaussian peaks to fit including noise peak\n", "\n", @@ -561,17 +561,16 @@ "metadata": {}, "outputs": [], "source": [ - "def get_trains_data(run_folder, source, include, tid=None):\n", + "def get_trains_data(run_data, source, include, tid=None):\n", " \"\"\"\n", " Load single train for all module\n", " \n", - " :param run_folder: Path to folder with data\n", + " :param run_data: Corrcted data to be loaded from\n", " :param source: Data source to be loaded\n", " :param include: Inset of file name to be considered \n", " :param tid: Train Id to be loaded. First train is considered if None is given\n", " \n", " \"\"\"\n", - " run_data = RunDirectory(run_folder, include)\n", " if tid:\n", " tid, data = run_data.select('*/DET/*', source).train_from_id(tid)\n", " return tid, stack_detector_data(data, source, modules=nmods)\n", @@ -580,9 +579,9 @@ " return tid, stack_detector_data(data, source, modules=nmods)\n", " return None, None\n", "\n", - "\n", "include = '*S00000*'\n", - "tid, orig = get_trains_data(f'{proc_folder}/r{run:04d}/', 'image.data', include)\n", + "run_data = RunDirectory(f'{proc_folder}/r{run:04d}/', include)\n", + "tid, orig = get_trains_data(run_data, 'image.data', include)\n", "orig = orig[cell_range[0]:cell_range[1], ...]" ] }, @@ -594,10 +593,19 @@ "source": [ "# FIXME: mask bad pixels from median\n", "# mask = const_data['BadPixelsFF']\n", - "\n", "corrections = const_data['slopesFF'] # (16,shape[0],512,128) shape[0]= cell_range[1]-cell_range[0] /\n", "corrections = np.moveaxis(corrections, 1, 0) # (shape[0],16,512,128)\n", "rel_corr = corrections/np.nanmedian(corrections)\n", + "\n", + "# this is needed if LitFrame is enabled in DAQ to avoid shape mismatch \n", + "# and correction of the right cells\n", + "if np.diff(cell_range)[0] == mem_cells:\n", + " sel = run_data.select(f'{karabo_id}/DET/0CH0:xtdf', 'image.cellId')\n", + " _, cell = sel.train_from_index(0)\n", + " stacked_cells = stack_detector_data(cell, 'image.cellId')[:, 0]\n", + " \n", + " rel_corr = rel_corr[stacked_cells[0]:stacked_cells[-1]+1]\n", + "\n", "corrected = orig / rel_corr" ] }, @@ -817,6 +825,23 @@ "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.11" + }, + "latex_envs": { + "LaTeX_envs_menu_present": true, + "autocomplete": true, + "bibliofile": "biblio.bib", + "cite_by": "apalike", + "current_citInitial": 1, + "eqLabelWithNumbers": true, + "eqNumInitial": 1, + "hotkeys": { + "equation": "Ctrl-E", + "itemize": "Ctrl-I" + }, + "labels_anchors": false, + "latex_user_defs": false, + "report_style_numbering": false, + "user_envs_cfg": false } }, "nbformat": 4,