Skip to content
Snippets Groups Projects

[AGIPD][CORRECT] Fixes for correcting AGIPD HIBEF data

Merged Karim Ahmed requested to merge feat/HIBEF_AGIPD_Correction into master

SUMMARY:

Changes are done by Jola and I, for running the correction notebook for AGIPD HIBEF.

  1. New plot changes.
  2. Bugfix for default fillvalue of np.nan from extra-data was not converted to 0.
  3. Changing the method of reading data from h5 file for fixing very slow data reading.

Tests:

  • Raw data calibrated for testing directly running the notebook:
  1. /gpfs/exfel/exp/HED/202031/p900174/raw/r0155
  2. /gpfs/exfel/exp/MID/201901/p002542/raw/r0229
  3. /gpfs/exfel/exp/SPB/202030/p900119/raw/r0098

Testing using xfel-calibrate CLI:

xfel-calibrate AGIPD CORRECT \
--slurm-mem 750 \
--slurm-name cor_HED_900174_r155 \
--karabo-da -1 \
--receiver-id {}CH0 \
--karabo-id-control HED_EXP_AGIPD500K2G \
--karabo-da-control AGIPD500K2G00 \
--h5path-ctrl /CONTROL/{}/MDL/FPGA_COMP \
--overwrite \
--sequences-per-node 1 \
--in-folder /gpfs/exfel/exp/HED/202031/p900174/raw/ \
--out-folder /gpfs/exfel/data/scratch/ahmedk/test/AGIPD_HIBEF \
--karabo-id HED_DET_AGIPD500K2G \
--run 155 \
--force-hg-if-below \
--force-mg-if-below \
--low-medium-gap \
--zero-nans \
--modules 0-7 \
--acq-rate 4.5 \
--bias-voltage 200 \
--gain-setting 0 \
--only-offset \
--sequences 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15\

Details related to the 3rd point:

There was an issue that reading image data for the HIBEF AGIPD was taking too long (> 2000 seconds)

It was found out there are restrictions when reading data using indexing (parameter:firange) as we do in agipdlib.read_file function.

I tested with all three mentioned raw data, which had more than 1000 list of indices while load data. But the issue of reading performance was only with HIBEF. Reading the whole image then indexing later was faster by a big factor.

What differs between the HIBEF and the SPB runs is not the number of list of indices used (SPB is bigger) but the fact that the list of indices used while reading data is not increasing because of the many empty pulses present for HIBEF raw data.

Also, the mentioned run for HIBEF was tested for sequence 16 which had zeros counts of 7 and more that is why 2 was used.

Here https://docs.h5py.org/en/latest/high/dataset.html#fancy-indexing it was mentioned regarding fancy indexing that

The following restrictions exist:

Selection coordinates must be given in increasing order
Duplicate selections are ignored
Very long lists (> 1000 elements) may produce poor performance

Reviewers:

@kluyvert @danilevc

Edited by Karim Ahmed

Merge request reports

Merged by Karim AhmedKarim Ahmed 4 years ago (Nov 30, 2020 9:29am UTC)

Merge details

  • Changes merged into master with c1b942ce (commits were squashed).
  • Deleted the source branch.

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Karim Ahmed resolved all discussions

    resolved all discussions

  • Karim Ahmed added 1 commit

    added 1 commit

    • 51cf0a2f - Apply suggestion to cal_tools/cal_tools/agipdlib.py

    Compare with previous version

  • Karim Ahmed
  • 172 172 "print(f\"Gain setting: {gain_setting}\")\n",
    173 173 "print(f\"Detector in use is {karabo_id}\")\n",
    174 174 "\n",
    175 "\n",
    176 "# Extracting Instrument string\n",
    177 "instrument = karabo_id.split(\"_\")[0]\n",
    178 "# Evaluate detector instance for mapping\n",
    179 "if instrument == \"SPB\":\n",
    180 " dinstance = \"AGIPD1M1\"\n",
    181 " nmods = 16\n",
    182 "elif instrument == \"MID\":\n",
    183 " dinstance = \"AGIPD1M2\"\n",
    184 " nmods = 16\n",
    185 "# TODO: Remove DETLAB\n",
    186 "elif instrument == \"HED\" or instrument == \"DETLAB\":\n",
  • Karim Ahmed
  • Karim Ahmed added 1 commit

    added 1 commit

    • 4e880079 - Apply suggestion to notebooks/AGIPD/AGIPD_Retrieve_Constants_Precorrection.ipynb

    Compare with previous version

  • Karim Ahmed added 1 commit

    added 1 commit

    • 7e565b4f - check firange size and index incrementation

    Compare with previous version

  • Karim Ahmed added 1 commit

    added 1 commit

    • 7e565b4f - check firange size and index incrementation

    Compare with previous version

  • 287 289 group['trainId'][firange])
    288 290 data_dict['moduleIdx'][0] = module_idx
    289 291 data_dict['nImg'][0] = n_img
    290
    291 raw_data = group['data'][firange]
    292 # Avoid very slow performance using fancing indexing,
    293 # if firange was bigger than 1000 and consists of
    294 # non-incrementing indices
    295 if (n_img > 1000 and
    296 all(y-x==1 for x,y in zip(firange, firange[1:]))):
  • Karim Ahmed added 1 commit

    added 1 commit

    • 21fe39b2 - check firange size and index incrementation

    Compare with previous version

  • Karim Ahmed added 1 commit

    added 1 commit

    • ecb6490c - check firange size and index incrementation

    Compare with previous version

  • Karim Ahmed added 1 commit

    added 1 commit

    • ecb6490c - check firange size and index incrementation

    Compare with previous version

  • Karim Ahmed added 1 commit

    added 1 commit

    • 45d7f9e4 - use numpy vectorised operations rather than iterating over pairs of numbers

    Compare with previous version

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