Calibration constants¤
The extra.calibration module helps you to find & load detector calibration
constants stored in the Calibration Catalog.
To find constants by conditions for a particular point in time, create a
condition object for the relevant detector type and use
CalibrationData.from_condition:
from extra.calibration import CalibrationData, LPDConditions
lpd_cd = CalibrationData.from_condition(
LPDConditions(memory_cells=200, sensor_bias_voltage=250),
"FXE_DET_LPD1M-1",
event_at="2022-05-22T02:00:00",
)
# Load one constant for all found modules
offset = lpd_cd["Offset"].ndarray()
You can also find a group of constants produced by one characterisation process by specifying a CalCat report, e.g. Report 3757:
In a Jupyter notebook, you can show the selected constants in a table:
| Modules | BadPixelsDark | Noise | Offset | ThresholdsDark |
|---|---|---|---|---|
| 0 | 2023-07-29 19:34 | 2023-07-29 19:34 | 2023-07-29 19:34 | 2023-07-29 19:34 |
| 1 | 2023-07-29 19:34 | 2023-07-29 19:34 | 2023-07-29 19:34 | 2023-07-29 19:34 |
| 2 | 2023-07-29 19:34 | 2023-07-29 19:34 | 2023-07-29 19:34 | 2023-07-29 19:34 |
| ... | ||||
| 14 | 2023-07-29 19:34 | 2023-07-29 19:34 | 2023-07-29 19:34 | 2023-07-29 19:34 |
| 15 | 2023-07-29 19:34 | 2023-07-29 19:34 | 2023-07-29 19:34 | 2023-07-29 19:34 |
Found constants¤
extra.calibration.CalibrationData ¤
Bases: Mapping
Collected constants for a given detector
This can represent multiple constant types (offset, gain, bad pixels, etc.)
across multiple modules. It works as a mapping keyed by constant type
(e.g. cd["Offset"]), giving you MultiModuleConstant objects.
from_condition
classmethod
¤
from_condition(condition: ConditionsBase, detector_name, calibrations=None, client=None, event_at=None, pdu_snapshot_at=None, begin_at_strategy='closest')
Look up constants for the given detector conditions & timestamp.
condition should be a conditions object for the relevant detector type,
e.g. DSSCConditions.
from_report
classmethod
¤
Look up constants by a report ID or path.
Constants produced together in the same characterisation are grouped in CalCat by their report. This method accepts either the integer report ID or the full filesystem path of the report.
aggregator_names
property
¤
Data aggregator names for modules. May include missing modules.
pdu_names
property
¤
Names of the specific detector units making up the detector.
May include missing modules.
require_calibrations ¤
Drop any modules missing the specified constant types
select_modules ¤
Return a new CalibrationData object with only the selected modules
One of module_nums, aggregator_names or qm_names must be specified.
select_calibrations ¤
Return a new CalibrationData object with only the selected constant types
merge ¤
Combine two or more CalibrationData objects for the same detector.
Where the inputs have different constant types or different modules, the output will include all of them (set union). Where they overlap, later inputs override earlier ones.
summary_table ¤
Make a table overview of the constants found.
Columns are calibration types, rows are modules. If there are >4 calibrations, the table will be split up into several pieces with up to 4 calibrations in each.
The table(s) returned should be rendered within Jupyter notebooks, including when converting them to Latex & PDF.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
module_naming
|
str
|
modnum, aggregator or qm, to change how the modules are labelled in the table. Defaults to modnum. |
'modnum'
|
markdown_table ¤
Make a markdown table overview of the constants found.
Columns are calibration types, rows are modules. If there are >4 calibrations, the table will be split up into several pieces with up to 4 calibrations in each.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
module_naming
|
str
|
modnum, aggregator or qm, to change how the modules are labelled in the table. Defaults to modnum. |
'modnum'
|
display_markdown_table ¤
Display a table of the constants found (in a Jupyter notebook).
Columns are calibration types, rows are modules. If there are >4 calibrations, the table will be split up into several pieces with up to 4 calibrations in each.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
module_naming
|
str
|
modnum, aggregator or qm, to change how the modules are labelled in the table. Defaults to modnum. |
'modnum'
|
extra.calibration.MultiModuleConstant
dataclass
¤
MultiModuleConstant(constants: Dict[str, SingleConstant], module_details: List[Dict], detector_name: str, calibration_name: str)
Bases: Mapping
A group of similar constants for several modules of one detector.
This works as a mapping holding SingleConstant objects.
Keys can be module numbers (offset[0]), data aggregator names
(offset['LPD00']), QxMy names (offset['Q1M1']) or Physical Detector Unit
(PDU) names.
aggregator_names
property
¤
Data aggregator names for the modules where we have this constant
qm_names
property
¤
Names like Q1M3 for the modules where we have this constant, if applicable
pdu_names
property
¤
Names of the specific detector units making up the detector.
Only includes modules where we have this constant.
select_modules ¤
Return a new MultiModuleConstant object with only the selected modules
One of module_nums, aggregator_names or qm_names must be specified.
ndarray ¤
Load this constant as a Numpy array.
If parallel is specified, the per-module constants are loaded in
parallel using N worker processes.
xarray ¤
Load this constant as an xarray DataArray.
module_naming may be "modnum", "aggregator" or "qm" to use different
styles of labelling for the modules dimension.
If parallel is specified, the per-module constants are loaded in
parallel using N worker processes.
extra.calibration.SingleConstant
dataclass
¤
SingleConstant(path: Path, dataset: str, ccv_id: Optional[int], pdu_name: Optional[str], _metadata: dict = dict(), _have_calcat_metadata: bool = False)
A calibration constant for one detector module
CalCat calls this a calibration constant version (CCV).
Conditions objects¤
extra.calibration.AGIPDConditions
dataclass
¤
AGIPDConditions(sensor_bias_voltage: float, memory_cells: int, acquisition_rate: float, gain_setting: Optional[int], gain_mode: Optional[int], source_energy: float, integration_time: int = 12, pixels_x: int = 512, pixels_y: int = 128)
Bases: ConditionsBase
Conditions for AGIPD detectors
extra.calibration.DSSCConditions
dataclass
¤
DSSCConditions(sensor_bias_voltage: float, memory_cells: int, pulse_id_checksum: Optional[float] = None, acquisition_rate: Optional[float] = None, target_gain: Optional[int] = None, encoded_gain: Optional[int] = None, pixels_x: int = 512, pixels_y: int = 128)
Bases: ConditionsBase
Conditions for DSSC detectors
extra.calibration.JUNGFRAUConditions
dataclass
¤
JUNGFRAUConditions(sensor_bias_voltage: float, memory_cells: int, integration_time: float, gain_setting: int, gain_mode: Optional[int] = None, exposure_timeout: int = 25, sensor_temperature: float = 291, pixels_x: int = 1024, pixels_y: int = 512)
Bases: ConditionsBase
Conditions for JUNGFRAU detectors
extra.calibration.LPDConditions
dataclass
¤
LPDConditions(sensor_bias_voltage: float = 250.0, memory_cells: int = 512, memory_cell_order: Optional[str] = None, feedback_capacitor: float = 5.0, source_energy: float = 9.3, category: int = 0, pixels_x: int = 256, pixels_y: int = 256, parallel_gain: bool = False)
Bases: ConditionsBase
extra.calibration.ShimadzuHPVX2Conditions
dataclass
¤
Bases: ConditionsBase
Bad pixel values¤
The calibration pipeline produces masks along with corrected data, in keys
called image.mask or data.mask depending on the detector. Zeros in the mask
represent normal, good pixels, while any other value indicates one or more
reasons why the data may be atypical.
Most of these values indicate different kinds of 'bad' data. But it also
includes values like NON_STANDARD_SIZE for pixels, usually at sensor edges,
which are intentionally larger than most, and thus capture more photons.