Grating¤
extra.applications.Grating1DCalibration ¤
Grating1DCalibration(offset: Optional[int] = None, min_pixel: int = 0, max_pixel: int = 1280, sigma: float = 2.0)
Bases: SerializableMixin
Calibrate a 1D grating spectrometer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
offset
|
Optional[int]
|
Offset of the first pulse. |
None
|
sigma
|
float
|
Smoothing factor to apply to data to reduce noise in pixels. |
2.0
|
Example:
bkg_run = open_run(proposal=900485, run=590)
calib_run = open_run(proposal=900485, run=611)
scan = Scan(calib_run["SA3_XTD10_MONO/MDL/PHOTON_ENERGY", "actualEnergy"])
grating_signal = calib_run["SQS_EXP_GH2-2/CORR/RECEIVER:daqOutput", "data.adc"]
pulses = XrayPulses(calib_run)
grating_calib = Grating1DCalibration()
grating_calib.setup(grating_signal, scan, pulses)
# apply it in new data
new_run = open_run(...)
grating_calib.apply(new_run)
to_file ¤
Dump all data needed for applying the calibration into an h5 file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
The output file name. |
required |
setup ¤
setup(grating_signal: KeyData, scan: Scan, pulses: XrayPulses, grating_mask: Optional[KeyData] = None)
Setup calibration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
grating_signal
|
KeyData
|
Where to read the grating data from.
Example: |
required |
scan
|
Scan
|
Scan object identfying where to read the undulator energy from.
Example: |
required |
pulses
|
XrayPulses
|
Object with bunch pattern table.
Example: |
required |
grating_mask
|
Optional[KeyData]
|
Grating mask from the calibration system.
Example: |
None
|
get_pulse_period ¤
Estimate difference between samples in neighbour pulses.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pulses
|
XrayPulses
|
XrayPulses element for the run. |
required |
Returns: Sample difference between neighbour pulses.
mask_calibration_point ¤
If mask is False, the point at a given energy is ignored when
performing the fit.
A call to fit must be redone after this.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
energy
|
float
|
Energy value, in the same units as provided in |
required |
mask
|
bool
|
If True, keep the point. If False, remove it. |
False
|
tol
|
float
|
Tolerance for energy matching. |
1.0
|
apply ¤
Apply calibration to a new analysis run. It is assumed it contains the same settings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
run
|
DataCollection
|
Input run. |
required |
load_all
|
bool
|
If True, load all data in memory at once. This is faster, but uses more memory. Disable if not enough memory is available. |
True
|
extra.applications.Grating2DCalibration ¤
Bases: SerializableMixin
Calibrate a 2D grating spectrometer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
angle
|
float
|
The rotation angle in degrees if the camera is not aligned. |
0.0
|
to_file ¤
Dump all data needed for applying the calibration into an h5 file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
The output file name. |
required |
setup ¤
setup(grating_signal: KeyData, scan: Scan, grating_bkg: Optional[KeyData] = None, grating_motor: Optional[KeyData] = None)
Setup calibration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
grating_signal
|
KeyData
|
Where to read the grating data from.
Example: |
required |
scan
|
Scan
|
Scan object identfying where to read the undulator energy from.
Example: |
required |
grating_bkg
|
Optional[KeyData]
|
Where to read the grating background data from.
Example: |
None
|
grating_motor
|
Optional[KeyData]
|
KeyData corresponding to the motor position.
Example: |
None
|
estimate_crop_roi ¤
crop ¤
Crop picture after rotation to avoid edges.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
ndarray
|
The input data. |
required |
Returns: Cropped data.
apply ¤
Apply calibration to a new analysis run. It is assumed it contains the same settings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
run
|
DataCollection
|
Input run. |
required |
load_all
|
bool
|
If True, load all data in memory at once. This is faster, but uses more memory. Disable if not enugh memory is available. |
True
|