Skip to content
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

EELS functional fine structure #3206

Merged
merged 49 commits into from Sep 22, 2023

Conversation

francisco-dlp
Copy link
Member

@francisco-dlp francisco-dlp commented Jul 28, 2023

Main feature

Currently the fine structure of EELSCLEdges is hardcoded as a spline. This adds the possibilty to use other Components as EELSCLEdge fine strucuture.

To implement the feature, this adds 3 attributes to EELSModel:

  • ext_fine_structure fine_structure_components: a set to add the fine structure components
  • int_fine_structure fine_structure_spline fine_structure_spline_active: bool. When True, the spline fine structure feature is active. It can be combined with fine_structure_components.
  • fine_structure_onset fine_structure_spline_onset: the energy (from the onset) from where to use the "standard" fine structure. This can be None.
  • where_ext_fine_structure_zero

Other changes

  • Automatic update of model figure when changing the fine structure configuration
  • New EELSCLEdge methods fix_fine_structure and free_fine_structure

Example

import hyperspy.api as hs

s = hs.datasets.eelsdb(title="Hexagonal Boron Nitride",
                       spectrum_type="coreloss")[0]
ll = hs.datasets.eelsdb(title="Hexagonal Boron Nitride",
                        spectrum_type="lowloss")[0]

s.set_microscope_parameters(beam_energy=300,
                            convergence_angle=0.2,
                            collection_angle=2.55)

s.add_elements(('B', 'N'))
m = s.create_model(ll=ll)
m.enable_fine_structure()

m.set_signal_range(160.)
m.components.B_K.onset_energy.value = 194
m.components.N_K.onset_energy.value = 402.5
m.components.B_K.fine_structure_width = 40
m.components.N_K.fine_structure_width = 45
m.components.B_K.fine_structure_smoothing = 0.4


g1 = hs.model.components1D.GaussianHF(centre=194.7, fwhm=3., height=5)
g1.name = "B_K_l1"
g2 = hs.model.components1D.GaussianHF(centre=201.9, fwhm=5., height=5)
g2.name = "B_K_l2"
m.extend((g1, g2,))

m.components.B_K.fine_structure_components.update((g1, g2))

m.components.B_K.fine_structure_spline_onset = 205. - m.components.B_K.onset_energy.value

m.smart_fit()
m.plot(plot_components=True)

EELS_BN_B_zoomin_with_gaussians

TODO

  • User Guide documentation
  • Docstrings
  • Tests

@francisco-dlp
Copy link
Member Author

I would like this to be included in the 2.0 release if possible (in the splitted EELS package), but I am leaving on holidays tomorrow and I won't be able to work on the documentation and thte tests until the week of the 28th of August.

@codecov
Copy link

codecov bot commented Jul 28, 2023

Codecov Report

Patch coverage: 86.76% and project coverage change: +0.10% 🎉

Comparison is base (b586b9b) 81.29% compared to head (003d5c7) 81.40%.

Additional details and impacted files
@@                  Coverage Diff                   @@
##           RELEASE_next_major    #3206      +/-   ##
======================================================
+ Coverage               81.29%   81.40%   +0.10%     
======================================================
  Files                     173      173              
  Lines                   24212    24312     +100     
  Branches                 5627     5672      +45     
======================================================
+ Hits                    19684    19792     +108     
+ Misses                   3225     3208      -17     
- Partials                 1303     1312       +9     
Files Changed Coverage Δ
hyperspy/_components/eels_cl_edge.py 84.38% <86.71%> (+0.08%) ⬆️
hyperspy/models/eelsmodel.py 79.89% <87.50%> (+3.13%) ⬆️

... and 2 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@CSSFrancis
Copy link
Member

@francisco-dlp This looks good! My plan was to finish splitting the EDS and EELS once #3148 is finished. The good thing about splitting things is that once the EELS EDS is split it doesn't really matter if this is released before/after 2.0.0 as we can just make a minor release in the EELS EDS package.

That being said, I was hoping that we can make a release candidate for the 2.0.0 in the next month or so and then we can go through the process of updating the downstream packages so most likely this won't occur in that time frame (unless people have substantial time to work on these things.

@ericpre
Copy link
Member

ericpre commented Sep 2, 2023

@francisco-dlp, not much happen in August, would you be able to add documentation and tests in the coming week? If not, maybe just an example to check that this is working when moving code around?

@ericpre ericpre added this to the v2.0 Split milestone Sep 2, 2023
@francisco-dlp
Copy link
Member Author

Yes, I'll add docs this week.

doc/user_guide/eels.rst Outdated Show resolved Hide resolved
doc/user_guide/eels.rst Show resolved Hide resolved
doc/user_guide/eels.rst Outdated Show resolved Hide resolved
doc/user_guide/eels.rst Outdated Show resolved Hide resolved
doc/user_guide/eels.rst Outdated Show resolved Hide resolved
doc/user_guide/eels.rst Outdated Show resolved Hide resolved
doc/user_guide/eels.rst Show resolved Hide resolved
doc/user_guide/eels.rst Outdated Show resolved Hide resolved
doc/user_guide/eels.rst Outdated Show resolved Hide resolved
doc/user_guide/eels.rst Outdated Show resolved Hide resolved
doc/user_guide/eels.rst Outdated Show resolved Hide resolved
doc/user_guide/eels.rst Outdated Show resolved Hide resolved
hyperspy/_components/eels_cl_edge.py Outdated Show resolved Hide resolved
hyperspy/_components/eels_cl_edge.py Outdated Show resolved Hide resolved
hyperspy/_components/eels_cl_edge.py Outdated Show resolved Hide resolved
hyperspy/_components/eels_cl_edge.py Outdated Show resolved Hide resolved
Copy link
Member

@ericpre ericpre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very nice!

I suspect that they will conflict with #3082 when it get merge with RELEASE_next_major. I can do the rebase if this helps.

loss probability caused by the interactions with the material's electronic structure.
It offers insights into the material's electronic properties, bonding, and local environments.
Therefore, we cannot model them from first-principles because i) the material is usually unknown
ii) HyperSpy only supports Hydrogenic and Hartree-Slater EELS core-loss models. Instead, the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since #3082, there is support for other GOS?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. What about "HyperSpy only supports atomic simulations" instead?

Once I polish this a little and add the test, it'll be ready for review.

@francisco-dlp
Copy link
Member Author

This is now ready for review.

@ericpre ericpre changed the base branch from RELEASE_next_minor to RELEASE_next_major September 22, 2023 18:35
@ericpre ericpre merged commit 7f3bca0 into hyperspy:RELEASE_next_major Sep 22, 2023
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants