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

fit_background fixes #76

Merged
merged 4 commits into from
Sep 11, 2024
Merged

Conversation

ericpre
Copy link
Member

@ericpre ericpre commented Aug 14, 2024

Fitting the background in EDS model doesn't work with linear fitting, because the twin lines are disactivated properly when running linear fitting.

import exspy

s = exspy.data.EDS_SEM_TM002()
m = s.isig[5.0:15.0].create_model()
m.plot()
m.fit_background(optimizer="lstsq")

which will raise the following error:

    m.fit_background(optimizer="lstsq")

  File ~\Dev\exspy\exspy\models\edsmodel.py:394 in fit_background
    self.fit(**kwargs)

  File ~\Dev\hyperspy\hyperspy\model.py:1797 in fit
    fit_output = self._linear_fit(

  File ~\Dev\hyperspy\hyperspy\model.py:1217 in _linear_fit
    index = parameters.index(p)

ValueError: <Parameter A of Cu_Ka component> is not in list

Progress of the PR

  • Fix fit_background with linear fitting,
  • fix resetting signal range after fitting background,
  • suspend plot when fitting background,
  • simplify/shorten title of EDS maps,
  • [n/a] docstring updated (if appropriate),
  • [n/a] update user guide (if appropriate),
  • added tests,
  • add a changelog entry in the upcoming_changes folder (see upcoming_changes/README.rst),
  • Check formatting of the changelog entry (and eventual user guide changes) in the docs/readthedocs.org:exspy build of this PR (link in github checks)
  • ready for review.

Copy link

codecov bot commented Aug 14, 2024

Codecov Report

Attention: Patch coverage is 93.75000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 88.69%. Comparing base (75ca046) to head (88949ab).
Report is 9 commits behind head on main.

Files with missing lines Patch % Lines
exspy/models/edsmodel.py 86.95% 1 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #76      +/-   ##
==========================================
+ Coverage   88.62%   88.69%   +0.06%     
==========================================
  Files          76       76              
  Lines        7411     7439      +28     
  Branches     1192     1197       +5     
==========================================
+ Hits         6568     6598      +30     
+ Misses        574      572       -2     
  Partials      269      269              

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

@ericpre ericpre added this to the v0.3 milestone Aug 14, 2024
@ericpre ericpre mentioned this pull request Aug 15, 2024
4 tasks
Copy link
Contributor

@jlaehne jlaehne left a comment

Choose a reason for hiding this comment

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

looks OK to me

@jlaehne jlaehne merged commit 800b740 into hyperspy:main Sep 11, 2024
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants