-
Notifications
You must be signed in to change notification settings - Fork 206
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
Update eds background #3044
base: RELEASE_next_minor
Are you sure you want to change the base?
Update eds background #3044
Conversation
Hi all, sorry for creating a new PR one more time but I think this one is the good one (I hope). If someone have time to review it, please tell me what you would like to change =). |
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## RELEASE_next_minor #3044 +/- ##
======================================================
- Coverage 81.01% 80.74% -0.27%
======================================================
Files 209 211 +2
Lines 32806 33121 +315
Branches 7540 7601 +61
======================================================
+ Hits 26579 26745 +166
- Misses 4469 4589 +120
- Partials 1758 1787 +29
☔ View full report in Codecov by Sentry. |
Hi all, s=hs.datasets.example_signals.EDS_SEM_Spectrum()
s.add_lines()
m=s.create_model(auto_background=False)
m.add_physical_background()
m.components.Bremsstrahlung.initialize()
m.fit_background(bounded=True)
m.fit()
m.plot(plot_components=True) Where the initializing step allow to get arguments from the model and estimate the composition of each pixel before storing it in an array that is save in the dictionary. s=hs.datasets.example_signals.EDS_SEM_Spectrum()
s.set_lines([])
m = s.create_model(auto_background=False)
m.add_physical_background()
m.components.Bremsstrahlung.initialize()
m.fit_background(bounded=True)
m.fit(bounded=True)
x=m.as_dictionary() or s=hs.datasets.example_signals.EDS_SEM_Spectrum()
s.set_lines([])
m = s.create_model(auto_background=False)
m.add_physical_background()
x=m.as_dictionary() I just want to make sure my code is in line with the coding style of hyperspy and I hope you will be able to help me on this particular point. So far it does run well (except for extracting it as a dictionary) which cause only one test to fail, but trying to go around this test made me think about all these questions. |
Thanks @ZanettaPM for coming back to this! I hope that this time, it can be finished! Third time lucky? :)
Not all components are defined as For the failing test, this component should be treated separately as this is done with the
I will need to look at it in more details, but this will need to be sorted. |
Ok I will start to think about a way to convert that as an expression, but this is probably something that we can update later after merging. Ok I will treat this component in another test then. Let me do that quickly. Yes, I started to look at the Thank you @ericpre for the help! |
Ok I think I fixed everything. I preferred to not touch to the whitelist exportation as it is already pretty well tuned for all components. Instead, few information are saved in |
As far as I remember, one if/else block can be easily integrated in an expression component, but it is not simple for multiple. Might need something like an expression referencing another one. On another note, would it be possible to increase the coverage further? There are a number of codecov warnings in the comments to the changed file, which would be best addressed directly in this PR. |
I can work on it yes. I am just not sure how. I can add more test to cover the lines indicated. But I will have to find how to test it correctly. |
Yes, what is needed are additional test routines that make sure the indicated lines are executed by one of the tests and their intended use verified. Then, the calculated coverage should increase. For lines, where an additional test makes no sense, a comment |
Oh this is interesting to know thank you for the tips! |
update HSpy
Description of the change
This is an updated version of PR #2836 . It is now rebased on 1.7.5
A new background component taking into account the detector efficiency, the composition of the sample and the edge jump is added to the components1D as an alternative to the Polynomial background.
This Background is based on Kramer emission law [Kramer 1923] (other emission models are also available) and convoluted with absorption model from Love and Scott [Sewell. et al, 1985] and the detector efficiency curve of the SEM/TEM.
Once this is merged it can easily take the output from PR #2535 and use detector efficiency curve for fitting the data.
Key words: Kramer's Law, Mass absorption mixture function, quantification, better fit
Progress of the PR
Example of how to fit the component
SEM example
TEM example