Skip to content
Snippets Groups Projects

[AGIPD] [DARK] Add support for AGIPD mini half in dark calibration

Merged Cyril Danilevski requested to merge feat/AGIPD_mini_half_darks into master

Description

In this MR, I've made modifications regarding the way the acquisition rate is calculated, as part of the Mini Half epic (calibration-workshop issue #177

How Has This Been Tested?

It's been tested by running the notebook against DETLAB data. Jola approved the resulting report resulting from this script:

xfel-calibrate AGIPD DARK \
    --slurm-mem 750 \
    --slurm-name darks_mini_half \
    --report-to /gpfs/exfel/data/scratch/danilevc/out/mini_half_test \
    --receiver-id {}CH0 \
    --karabo-id-control HED_EXP_AGIPD500K2G \
    --karabo-da-control DA01 \
    --h5path-ctrl /CONTROL/{}/MDL/FPGA_COMP \
    --in-folder /gpfs/exfel/exp/DETLAB/202031/p900172/raw \
    --out-folder /gpfs/exfel/data/scratch/danilevc/out/mini_half_test \
    --karabo-id DETLAB_DET_AGIPD500K2G \
    --run-high 73 \
    --run-med 71 \
    --run-low 72

It's also been tested against breaking changes on AGIPD1M1 detectors with the following script:

xfel-calibrate AGIPD DARK \
    --slurm-mem 750 \
    --slurm-name darks_modif_checks \
    --report-to /gpfs/exfel/data/scratch/danilevc/out/darks_modif_checks \
    --receiver-id {}CH0 \
    --karabo-id-control SPB_IRU_AGIPD1M1 \
    --karabo-da-control AGIPD1MCTRL00\
    --h5path-ctrl /CONTROL/{}/MDL/FPGA_COMP_TEST \
    --in-folder /gpfs/exfel/exp/SPB/202030/p900138/raw \
    --out-folder /gpfs/exfel/data/scratch/danilevc/out/darks_modif_checks \
    --karabo-id SPB_DET_AGIPD1M-1 \
    --run-high 167 \
    --run-med 168 \
    --run-low 169

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

In cal_tools.cal_tools.tools.agipdlib, I extensively modified get_acq_rate to be able to get the acquisition rate from slow data, the MDL FPGA_COMP device.

I've updated the interface such that it first tries to get the information from slow data, if possible, or then resorts to calculating it from fast data.

As such, all AGIPD notebooks have to have be updated. Which I will do once the report has been approved.

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

Having talked offline with @ahmedk , we discussed the usage of type hinting.
We're thinking of trialling it, as a number of functions have cryptic parameters.

@kamile

Edited by Cyril Danilevski

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
43 :param fast_paths: in which module file and h5 path to look for pulses.
44 The first string is the filename with complete path,
45 the second string is the module device name `karabo_id`,
46 the third parameter is the module number, used to navigate
47 through the h5 file structure.
48
49 :return acq_rate: the acquisition rate. If not found in either files, return None.
50 """
51 # Attempt to look for acquisition rate in slow data
52 slow_data_file, karabo_id_control = slow_paths
53 slow_data_file = Path(slow_data_file)
54 if slow_data_file.is_file():
55 slow_data_path = f'CONTROL/{karabo_id_control}/MDL/FPGA_COMP/bunchStructure/repetitionRate/value' # noqa
56 with h5py.File(slow_data_file, "r") as fin:
57 if slow_data_path in fin:
58 return fin[slow_data_path][3]
  • Ebad Kamil
    Ebad Kamil @kamile started a thread on the diff
  • 52 slow_data_file, karabo_id_control = slow_paths
    53 slow_data_file = Path(slow_data_file)
    54 if slow_data_file.is_file():
    55 slow_data_path = f'CONTROL/{karabo_id_control}/MDL/FPGA_COMP/bunchStructure/repetitionRate/value' # noqa
    56 with h5py.File(slow_data_file, "r") as fin:
    57 if slow_data_path in fin:
    58 return fin[slow_data_path][3]
    59
    60 # Compute acquisition rate from fast data
    61 fast_data_file, karabo_id, module = fast_paths
    62 fast_data_file = Path(fast_data_file)
    63 if fast_data_file.is_file():
    64 fast_data_path = f'INSTRUMENT/{karabo_id}/DET/{module}CH0:xtdf/image/pulseId' # noqa
    65 with h5py.File(fast_data_file) as fin:
    66 if fast_data_path in fin:
    67 pulses = np.squeeze(fin[fast_data_path][1:3])
  • 22 25 return options[np.argmin(dists)]
    23 26
    24 27
    25 def get_acq_rate(fname, loc, module):
    26 with h5py.File(fname, "r") as f:
    27 try:
    28 pulses = \
    29 np.squeeze(f[f"INSTRUMENT/{loc}/DET/{module}CH0:xtdf/image/pulseId"][:2]) # noqa
    30 diff = pulses[1] - pulses[0]
    31 except:
    32 diff = 0
    33 options = {8: 0.5, 4: 1.1, 2: 2.2, 1: 4.5}
    34 return options.get(diff, None)
    28 def get_acq_rate(slow_paths: Tuple[str, str],
  • Karim Ahmed
  • Karim Ahmed
  • Cyril Danilevski added 2 commits

    added 2 commits

    • 28e0e5f0 - Clarify documentation in agipdlib
    • d88b9162 - Update agipd get_acq_rate signature

    Compare with previous version

  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Please register or sign in to reply
    Loading