The following code analyzes a set of dark images taken with the AGIPD detector to deduce detector offsets , noise, bad-pixel maps and thresholding. All four types of constants are evaluated per-pixel and per-memory cell. Data for the detector's three gain stages needs to be present, separated into separate runs.
The following code analyzes a set of dark images taken with the AGIPD detector to deduce detector offsets , noise, bad-pixel maps and thresholding. All four types of constants are evaluated per-pixel and per-memory cell. Data for the detector's three gain stages needs to be present, separated into separate runs.
The evaluated calibration constants are stored locally and injected in the calibration data base.
The evaluated calibration constants are stored locally and injected in the calibration data base.
%% Cell type:code id: tags:
%% Cell type:code id: tags:
``` python
``` python
in_folder="/gpfs/exfel/d/raw/CALLAB/202031/p900113"# path to input data, required
in_folder="/gpfs/exfel/d/raw/CALLAB/202031/p900113"# path to input data, required
out_folder="/gpfs/exfel/data/scratch/hammerd/agipd-fixed-gain"# path to output to, required
out_folder="/gpfs/exfel/data/scratch/hammerd/agipd-fixed-gain"# path to output to, required
sequences=[0]# sequence files to evaluate.
sequences=[0]# sequence files to evaluate.
modules=[-1]# list of modules to evaluate, RANGE ALLOWED
modules=[-1]# list of modules to evaluate, RANGE ALLOWED
run_high=9985# run number in which high gain data was recorded, required
run_high=9985# run number in which high gain data was recorded, required
run_med=9984# run number in which medium gain data was recorded, required
run_med=9984# run number in which medium gain data was recorded, required
run_low=9983# run number in which low gain data was recorded, required
run_low=9983# run number in which low gain data was recorded, required
operation_mode="ADAPTIVE_GAIN"# Detector operation mode, optional (defaults to "ADAPTIVE_GAIN")
operation_mode="ADAPTIVE_GAIN"# Detector operation mode, optional (defaults to "ADAPTIVE_GAIN")
karabo_id="HED_DET_AGIPD500K2G"# karabo karabo_id
karabo_id="HED_DET_AGIPD500K2G"# karabo karabo_id
karabo_da=['-1']# a list of data aggregators names, Default [-1] for selecting all data aggregators
karabo_da=['-1']# a list of data aggregators names, Default [-1] for selecting all data aggregators
receiver_id="{}CH0"# inset for receiver devices
receiver_id="{}CH0"# inset for receiver devices
path_template='RAW-R{:04d}-{}-S{:05d}.h5'# the template to use to access data
path_template='RAW-R{:04d}-{}-S{:05d}.h5'# the template to use to access data
h5path='/INSTRUMENT/{}/DET/{}:xtdf/image'# path in the HDF5 file to images
h5path='/INSTRUMENT/{}/DET/{}:xtdf/image'# path in the HDF5 file to images
h5path_idx='/INDEX/{}/DET/{}:xtdf/image'# path in the HDF5 file to images
h5path_idx='/INDEX/{}/DET/{}:xtdf/image'# path in the HDF5 file to images
h5path_ctrl='/CONTROL/{}/MDL/FPGA_COMP'# path to control information
h5path_ctrl='/CONTROL/{}/MDL/FPGA_COMP'# path to control information
karabo_id_control="HED_EXP_AGIPD500K2G"# karabo-id for control device '
karabo_id_control="HED_EXP_AGIPD500K2G"# karabo-id for control device '
karabo_da_control="AGIPD500K2G00"# karabo DA for control infromation
karabo_da_control="AGIPD500K2G00"# karabo DA for control infromation
use_dir_creation_date=True# use dir creation date as data production reference date
use_dir_creation_date=True# use dir creation date as data production reference date
cal_db_interface="tcp://max-exfl016:8020"# the database interface to use
cal_db_interface="tcp://max-exfl016:8020"# the database interface to use
cal_db_timeout=3000000# timeout on caldb requests"
cal_db_timeout=3000000# timeout on caldb requests"
local_output=True# output constants locally
local_output=True# output constants locally
db_output=False# output constants to database
db_output=False# output constants to database
mem_cells=0# number of memory cells used, set to 0 to automatically infer
mem_cells=0# number of memory cells used, set to 0 to automatically infer
bias_voltage=0# detector bias voltage
bias_voltage=0# detector bias voltage
gain_setting=0.1# the gain setting, use 0.1 to try to auto-determine
gain_setting=0.1# the gain setting, use 0.1 to try to auto-determine
acq_rate=0.# the detector acquisition rate, use 0 to try to auto-determine
acq_rate=0.# the detector acquisition rate, use 0 to try to auto-determine
interlaced=False# assume interlaced data format, for data prior to Dec. 2017
interlaced=False# assume interlaced data format, for data prior to Dec. 2017
rawversion=2# RAW file format version
rawversion=2# RAW file format version
thresholds_offset_sigma=3.# offset sigma thresholds for offset deduced bad pixels
thresholds_offset_sigma=3.# offset sigma thresholds for offset deduced bad pixels
thresholds_offset_hard=[0,0]# For setting the same threshold offset for the 3 gains. Left for backcompatability. Default [0, 0] to take the following parameters.
thresholds_offset_hard=[0,0]# For setting the same threshold offset for the 3 gains. Left for backcompatability. Default [0, 0] to take the following parameters.
thresholds_offset_hard_hg=[3000,7000]# High-gain thresholds in absolute ADU terms for offset deduced bad pixels
thresholds_offset_hard_hg=[3000,7000]# High-gain thresholds in absolute ADU terms for offset deduced bad pixels
thresholds_offset_hard_mg=[6000,10000]# Medium-gain thresholds in absolute ADU terms for offset deduced bad pixels
thresholds_offset_hard_mg=[6000,10000]# Medium-gain thresholds in absolute ADU terms for offset deduced bad pixels
thresholds_offset_hard_lg=[6000,10000]# Low-gain thresholds in absolute ADU terms for offset deduced bad pixels
thresholds_offset_hard_lg=[6000,10000]# Low-gain thresholds in absolute ADU terms for offset deduced bad pixels
thresholds_offset_hard_hg_fixed=[3500,6500]# Same as thresholds_offset_hard_hg, but for fixed gain operation
thresholds_offset_hard_hg_fixed=[3500,6500]# Same as thresholds_offset_hard_hg, but for fixed gain operation
thresholds_offset_hard_mg_fixed=[3500,6500]# Same as thresholds_offset_hard_mg, but for fixed gain operation
thresholds_offset_hard_mg_fixed=[3500,6500]# Same as thresholds_offset_hard_mg, but for fixed gain operation
thresholds_offset_hard_lg_fixed=[3500,6500]# Same as thresholds_offset_hard_lg, but for fixed gain operation
thresholds_offset_hard_lg_fixed=[3500,6500]# Same as thresholds_offset_hard_lg, but for fixed gain operation
thresholds_noise_sigma=5.# noise sigma thresholds for offset deduced bad pixels
thresholds_noise_sigma=5.# noise sigma thresholds for offset deduced bad pixels
thresholds_noise_hard=[0,0]# For setting the same threshold noise for the 3 gains. Left for backcompatability. Default [0, 0] to take the following parameters.
thresholds_noise_hard=[0,0]# For setting the same threshold noise for the 3 gains. Left for backcompatability. Default [0, 0] to take the following parameters.
thresholds_noise_hard_hg=[4,20]# High-gain thresholds in absolute ADU terms for offset deduced bad pixels
thresholds_noise_hard_hg=[4,20]# High-gain thresholds in absolute ADU terms for offset deduced bad pixels
thresholds_noise_hard_mg=[4,20]# Medium-gain thresholds in absolute ADU terms for offset deduced bad pixels
thresholds_noise_hard_mg=[4,20]# Medium-gain thresholds in absolute ADU terms for offset deduced bad pixels
thresholds_noise_hard_lg=[4,20]# Low-gain thresholds in absolute ADU terms for offset deduced bad pixels
thresholds_noise_hard_lg=[4,20]# Low-gain thresholds in absolute ADU terms for offset deduced bad pixels
thresholds_gain_sigma=5.# Gain separation sigma threshold
thresholds_gain_sigma=5.# Gain separation sigma threshold
high_res_badpix_3d=False# set this to True if you need high-resolution 3d bad pixel plots. ~7mins extra time for 64 memory cells
high_res_badpix_3d=False# set this to True if you need high-resolution 3d bad pixel plots. ~7mins extra time for 64 memory cells
print(f"Will process a total of {total_sequences} files.")
print(f"Will process a total of {total_sequences} files.")
```
```
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
## Calculate Offsets, Noise and Thresholds ##
## Calculate Offsets, Noise and Thresholds ##
The calculation is performed per-pixel and per-memory-cell. Offsets are simply the median value for a set of dark data taken at a given gain, noise the standard deviation, and gain-bit values the medians of the gain array.
The calculation is performed per-pixel and per-memory-cell. Offsets are simply the median value for a set of dark data taken at a given gain, noise the standard deviation, and gain-bit values the medians of the gain array.
%% Cell type:code id: tags:
%% Cell type:code id: tags:
``` python
``` python
ifthresholds_offset_hard!=[0,0]:
ifthresholds_offset_hard!=[0,0]:
# if set, this will override the individual parameters
# if set, this will override the individual parameters
thresholds_offset_hard=[thresholds_offset_hard]*3
thresholds_offset_hard=[thresholds_offset_hard]*3
eliffixed_gain_mode:
eliffixed_gain_mode:
thresholds_offset_hard=[
thresholds_offset_hard=[
thresholds_offset_hard_hg_fixed,
thresholds_offset_hard_hg_fixed,
thresholds_offset_hard_mg_fixed,
thresholds_offset_hard_mg_fixed,
thresholds_offset_hard_lg_fixed,
thresholds_offset_hard_lg_fixed,
]
]
else:
else:
thresholds_offset_hard=[
thresholds_offset_hard=[
thresholds_offset_hard_hg,
thresholds_offset_hard_hg,
thresholds_offset_hard_mg,
thresholds_offset_hard_mg,
thresholds_offset_hard_lg,
thresholds_offset_hard_lg,
]
]
print(f"Will use the following hard offset thresholds")
print(f"Will use the following hard offset thresholds")
The thresholds for gain switching are then defined as the mean value between in individual gain bit levels. Note that these thresholds need to be refined with charge induced thresholds, as the two are not the same.
The thresholds for gain switching are then defined as the mean value between in individual gain bit levels. Note that these thresholds need to be refined with charge induced thresholds, as the two are not the same.
Single cell overviews allow to identify potential effects on all memory cells, e.g. on sensor level. Additionally, they should serve as a first sanity check on expected behaviour, e.g. if structuring on the ASIC level is visible in the offsets, but otherwise no immediate artifacts are visible.
Single cell overviews allow to identify potential effects on all memory cells, e.g. on sensor level. Additionally, they should serve as a first sanity check on expected behaviour, e.g. if structuring on the ASIC level is visible in the offsets, but otherwise no immediate artifacts are visible.
The following tables show summary information for the evaluated module. Values for currently evaluated constants are compared with values for pre-existing constants retrieved from the calibration database.
The following tables show summary information for the evaluated module. Values for currently evaluated constants are compared with values for pre-existing constants retrieved from the calibration database.