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

Background window fixes and improvement #86

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

ericpre
Copy link
Member

@ericpre ericpre commented Sep 18, 2024

Fix #79.

Progress of the PR

  • Raise error when windows is out of the range of the signal,
  • fix plotting windows with navigation dimension >=2,
  • [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.

Minimal example of the bug fix or the new feature

import exspy
import numpy as np

s = exspy.data.EDS_TEM_FePt_nanoparticles()

# create a signal with navgation dimension >= 2
rng = np.random.default_rng()
[s * v*10 for v in rng.random((10))]
s = hs.stack([s * v*10 for v in rng.random((10))])
s = hs.stack([s * v*10 for v in rng.random((5))])

bw = s.estimate_background_windows(line_width=[5.0, 2.0])
iw = s.estimate_integration_windows(windows_width=3)

s.plot(True, background_windows=bw, integration_windows=iw)

Raise the following error:

    s.plot(True, background_windows=bw, integration_windows=iw)

  File ~\Dev\exspy\exspy\signals\eds.py:933 in plot
    self._plot_xray_lines(

  File ~\Dev\exspy\exspy\signals\eds.py:989 in _plot_xray_lines
    self._add_background_windows_markers(

  File ~\Dev\exspy\exspy\signals\eds.py:1140 in _add_background_windows_markers
    segments = np.array(segments)

ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 3 dimensions. The detected shape was (4, 2, 2) + inhomogeneous part.

Copy link

codecov bot commented Sep 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.82%. Comparing base (ee31d0a) to head (4b844b0).

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #86      +/-   ##
==========================================
+ Coverage   88.70%   88.82%   +0.12%     
==========================================
  Files          77       77              
  Lines        7453     7475      +22     
  Branches     1200     1205       +5     
==========================================
+ Hits         6611     6640      +29     
+ Misses        572      567       -5     
+ Partials      270      268       -2     

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

@ericpre
Copy link
Member Author

ericpre commented Sep 18, 2024

@CSSFrancis, can you please have a look at this PR, it seems that the migration to new markers API didn't support navigation dimension >=2.

@ericpre ericpre added this to the v0.3 milestone Sep 18, 2024
@ericpre ericpre added bug Something isn't working enhancement New feature or request needs review labels Sep 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request needs review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Background Window Plotting not working with 2D signal
1 participant