diff --git a/notebooks/AGIPD/AGIPD_Correct_and_Verify.ipynb b/notebooks/AGIPD/AGIPD_Correct_and_Verify.ipynb index a9471792d01bca6b8a7742bd104b5613d5c7562b..1ecab067d6accd0ce8f03a72a1d4db86a108b118 100644 --- a/notebooks/AGIPD/AGIPD_Correct_and_Verify.ipynb +++ b/notebooks/AGIPD/AGIPD_Correct_and_Verify.ipynb @@ -33,7 +33,7 @@ "ctrl_source_template = '{}/MDL/FPGA_COMP' # path to control information\n", "karabo_id_control = \"SPB_IRU_AGIPD1M1\" # karabo-id for control device\n", "\n", - "slopes_ff_from_files = \"\" # Path to locally stored SlopesFF and BadPixelsFF constants\n", + "slopes_ff_from_files = \"\" # Path to locally stored SlopesFF and BadPixelsFF constants, loaded in precorrection notebook\n", "\n", "use_dir_creation_date = True # use the creation data of the input dir for database queries\n", "cal_db_interface = \"tcp://max-exfl016:8015#8045\" # the database interface to use\n", @@ -88,11 +88,14 @@ "use_litframe_device = '' # Device ID for a lit frame finder device to only process illuminated frames, empty string to disable\n", "energy_threshold = -1000 # The low limit for the energy (uJ) exposed by frames subject to processing. If -1000, selection by pulse energy is disabled\n", "\n", + "# Output parameters\n", + "compress_fields = ['gain', 'mask'] # Datasets in image group to compress.\n", + "\n", "# Plotting parameters\n", "skip_plots = False # exit after writing corrected files and metadata\n", "cell_id_preview = 1 # cell Id used for preview in single-shot plots\n", "\n", - "# Paralellization parameters\n", + "# Parallelization parameters\n", "chunk_size = 1000 # Size of chunk for image-wise correction\n", "n_cores_correct = 16 # Number of chunks to be processed in parallel\n", "n_cores_files = 4 # Number of files to be processed in parallel\n", @@ -491,7 +494,9 @@ "agipd_corr.cm_dark_fraction = cm_dark_fraction\n", "agipd_corr.cm_n_itr = cm_n_itr\n", "agipd_corr.noisy_adc_threshold = noisy_adc_threshold\n", - "agipd_corr.ff_gain = ff_gain" + "agipd_corr.ff_gain = ff_gain\n", + "\n", + "agipd_corr.compress_fields = compress_fields", ] }, { @@ -668,6 +673,7 @@ "\n", " img_counts = pool.map(agipd_corr.apply_selected_pulses, range(len(file_batch)))\n", " step_timer.done_step(\"Applying selected cells after common mode correction\")\n", + " \n", " # Perform image-wise correction\"\n", " pool.starmap(agipd_corr.gain_correction, imagewise_chunks(img_counts))\n", " step_timer.done_step(\"Gain corrections\")\n", diff --git a/src/cal_tools/agipdlib.py b/src/cal_tools/agipdlib.py index 5f0c1d137502f99df99d018cb68356206fd5b2c3..cf63be6b557a2263230ae0615bdd3495e79bbac4 100644 --- a/src/cal_tools/agipdlib.py +++ b/src/cal_tools/agipdlib.py @@ -343,6 +343,9 @@ class AgipdCorrections: self.noisy_adc_threshold = 0.25 self.ff_gain = 1 + # Output parameters + self.compress_fields = ['gain', 'mask'] + # Shared variables for data and constants self.shared_dict = [] self.offset = {} @@ -474,7 +477,6 @@ class AgipdCorrections: image_fields = [ 'trainId', 'pulseId', 'cellId', 'data', 'gain', 'mask', 'blShift', ] - compress_fields = ['gain', 'mask'] n_img = data_dict['nImg'][0] if n_img == 0: @@ -498,7 +500,7 @@ class AgipdCorrections: # so it's efficient to examine the file structure. for field in image_fields: arr = data_dict[field][:n_img] - if field in compress_fields: + if field in self.compress_fields: # gain/mask compressed with gzip level 1, but not # checksummed as we would have to implement this. kw = dict( @@ -517,7 +519,7 @@ class AgipdCorrections: # Write the corrected data for field in image_fields: - if field in compress_fields: + if field in self.compress_fields: self._write_compressed_frames( image_grp[field], data_dict[field][:n_img], )