-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added analysis code used to calibrate Cookiebox and grating spectrometer #284
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #284 +/- ##
==========================================
- Coverage 74.07% 64.29% -9.78%
==========================================
Files 23 25 +2
Lines 3020 3666 +646
==========================================
+ Hits 2237 2357 +120
- Misses 783 1309 +526 ☔ View full report in Codecov by Sentry. |
…ne to change a single setting and it automatically reruns the calibration.
…ne to change a single setting and it automatically reruns the calibration.
PS: A test could be written by comparing how the calibration applied to a run differs from the results of the code applied previously to the same run. The issue is that we don't have access to data in those tests. |
The
|
This PR includes the addition of an
ingredients
directory in EXtra, in which self-contained analysis steps are to be performed. Two elements have been added:CookieboxCalib
calibrates eTOF data from a calibration run (or a union thereof).GratingCalib
calibrates grating spectrometer data from a background run and a calibration run (or a union thereof).GratingCalib
This device takes a background run, and monochromated runs, subtracts the background average data, sorts the monochromated runs by the mono energy and optionally rotates them.
After this step, it fits a line mapping the sample index of the grating data to energy.
The
apply
function applies the background subtraction and rotation for a new run and returns anxarray.Dataset
containing the transformed data with an energy axis.CookieboxCalib
eTOFs provide a 1D trace for all pulses, which can be transformed into traces per pulse by the
AdqRawChannel
Extra component. However, the trace sample axis is meaningless and needs to be converted into energy using a non-linear function. Usually one data analysis run is taken in which the undulator energy is scanned to obtain this map, which is then applied in the actual analysis run.The objective is to take a calibration run (where an energy scan is made) and from that run calculate a) the map to be used to interpolate eTOF energy axis from "sample number" into eV; and b) calculate the transmission correction, which corrects the appropriate intensity of the data, given that the eTOF does not measure electrons with equal probability in all energy ranges.
The concrete steps taken when the object is initialized (
obj = CookieboxCalib(calib_run)
) from a calibration run are:The concrete steps taken when the
obj.apply(other_run)
is called with a run to be calibrated are:The variables calculated can be visualized using
obj.plot_diagnostics()
and similar other functions for validation and other cross-checks.The current code works with fine-tuning of the constructor arguments
first_pulse_offset
,auger_start_roi
,start_roi
andstop_roi
. There is code already to make it detect them automatically ifNone
is set, but it cannot be guaranteed to always work.Further steps proposed previously by @philsmt which have not been applied yet:
update_...
member functions and appropriate setters and getters. The setters and getters update a variable and call the update functions to redo calculations after resetting the corresponding variables.tof_settings
. One could then settof_settings={'1_A': AdqRawChannel(...), '1_C': AdqRawChannel(...)}
to us this functionality. Providing a run is still necessary, as other objects (XGM, undulator reading and scans) are needed.