Calibration - #13
Conversation
…rt` instead of just using `concentration_report`
|
BTW, the auto calibration only supports |
|
The auto_calibration does no write the new energy_scale, energy offset etc anywhere, resulting in the EDXS model being initialized with not "auto_calibrated" energy axis. Then when calling build G, checks are performed against this stale energy axis causing problems: if you crop from 0.7 keV a spectrum image that contains oxygen, it gives an error. |
|
Also out of range lines always give an error when using autocalibrate |
I have solved the problem in a dual form. It is a matter of frame of reference:
I can convert the solution to your form easily.
That will be solved automatically after the convertion. |
|
I will try to check the PRs soon but I'll be on vacations starting from the 31/07 and I'll be back on the 24/08. I am sorry I couldn't work on the PRs recently. If you need to implement the PRs soon, I guess you can go ahead and I'll review the changes afterwards. It is not ideal but I don't want to slow down everything. |
|
The algorithm now behaves as follows: Calling
Running In a nutshell, step 2 is affine correction of the datacube assuming the theoretical lines are correct, and step 3 is the correction of the theoretical lines themselves. |
…dded missing parentheses
@adriente no worries. i say |
|
@perrymok The auto calibration is doing a very poor job, it is impossible that the initial spectrum is this off. see image attached: |
|
you used a window that is too big. i will implement the plotting of table in espm to visualise the shift to the user so that they can choose the correct window. |
…ling `EDSespm::auto_calibrate`
|
i have added a TL;DR in TL;DRIn order to use auto calibration, do the following:
|

This PR fixes #6.
TL;DR
In order to use auto calibration, do the following:
EDSespm::plot_tableto see how shifted the dataset is.EDSespm::auto_calibratewithwindowyou obtained in step 1.This does the following:
EDSespm::build_Gwithuse_calibration=Trueif you want to use the higher degree correction.WRT
TheEDSespm::auto_calibratemethod does the following:For each element, individually fit the lines with cross section$\geq$ $\times$ [cross section of the largest line in that element].filter_csdegreepolynomialApply this polynomial$p$ to each line in the theoretical table, and store the calibrated table at $p$ will also be stored at EDXS::calibrated_db_dict.EDXS::energy_calibration_poly.CallingEDSespm::build_Gwithuse_calibration=Truewill automatically triggerauto_calibration.Calling
EDSespm::auto_calibratewillEDSespm::fit_single_peakself.axes_manager[-1].{scale, offset}degreepolynomial correction for the table in this new coordinate system, and store it inself.modelRunning
EDSespm::auto_calibratefollowed byEDSespm::build_Gwill build G using the correction done in step 2 but not the correction in step 3. In order to also benefit from the correction done in step 3,use_calibration=Truehas to be passed tobuild_G.In a nutshell, step 2 is affine correction of the datacube assuming the theoretical lines are correct, and step 3 is the high degree correction of the theoretical lines themselves.
EDSespm::fit_tableandEDSespm::fit_single_peakhave no side effect (it does not mutateselfor any of its properties).EDSespm::auto_calibrate, on the other hand, does have side effect (it setsself.model.{calibrated_db_dict, energy_calibration_poly})For a quick tour, please see
notebooks/calibration.ipynb.