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:
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,
)
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.
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,
_gain_parameters=[
"Sensor Bias Voltage",
"Pixels X",
"Pixels Y",
"Memory cells",
"Acquisition rate",
"Gain setting",
"Integration time",
],
_other_dark_parameters=_gain_parameters + ["Gain mode"],
_illuminated_parameters=_gain_parameters
+ ["Source energy"],
calibration_types={
"Offset": _other_dark_parameters,
"Noise": _other_dark_parameters,
"ThresholdsDark": _other_dark_parameters,
"BadPixelsDark": _other_dark_parameters,
"BadPixelsPC": _gain_parameters,
"SlopesPC": _gain_parameters,
"BadPixelsFF": _illuminated_parameters,
"SlopesFF": _illuminated_parameters,
},
)
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,
_params=[
"Sensor Bias Voltage",
"Memory cells",
"Pixels X",
"Pixels Y",
"Pulse id checksum",
"Acquisition rate",
"Target gain",
"Encoded gain",
],
calibration_types={"Offset": _params, "Noise": _params},
)
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,
sensor_temperature: float = 291,
pixels_x: int = 1024,
pixels_y: int = 512,
_params=[
"Sensor Bias Voltage",
"Memory Cells",
"Pixels X",
"Pixels Y",
"Integration Time",
"Sensor temperature",
"Gain Setting",
"Gain mode",
],
calibration_types={
"Offset10Hz": _params,
"Noise10Hz": _params,
"BadPixelsDark10Hz": _params,
"RelativeGain10Hz": _params,
"BadPixelsFF10Hz": _params,
},
)
Bases: ConditionsBase
Conditions for JUNGFRAU detectors
extra.calibration.LPDConditions
dataclass
¤
LPDConditions(
sensor_bias_voltage: float,
memory_cells: int,
memory_cell_order: Optional[str] = None,
feedback_capacitor: float = 5.0,
source_energy: float = 9.2,
category: int = 1,
pixels_x: int = 256,
pixels_y: int = 256,
_base_params=[
"Sensor Bias Voltage",
"Memory cells",
"Pixels X",
"Pixels Y",
"Feedback capacitor",
],
_dark_parameters=_base_params + ["Memory cell order"],
_illuminated_parameters=_base_params
+ ["Source Energy", "category"],
calibration_types={
"Offset": _dark_parameters,
"Noise": _dark_parameters,
"BadPixelsDark": _dark_parameters,
"RelativeGain": _illuminated_parameters,
"GainAmpMap": _illuminated_parameters,
"FFMap": _illuminated_parameters,
"BadPixelsFF": _illuminated_parameters,
},
)
Bases: ConditionsBase
Conditions for LPD detectors
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.