LumiSpy / lumispy

Luminescence data analysis with HyperSpy.
https://lumispy.org
GNU General Public License v3.0
25 stars 17 forks source link

Transpose centroid output #184

Closed jlaehne closed 1 year ago

jlaehne commented 1 year ago

Description of the change

I realized that for a map the new centroid function, similar to e.g. valuemax and indexmax in HyperSpy returns a BaseSignal with 2 navigation dimensions and 0D signal, which theoretically makes sense, but is inconvenient for plotting as it plots including the navigator, which makes little sense for 0D signals, and colormap cannot be changed.

In contrast, estimate_peak_width returns the transposed signal, thus Signal2D object without navigation dimensions, which is more convenient for plotting - and is okay in the sense that it is just an image of values for the different positions. The as_signal command for parameters from a fit also results in Signal2D. I therefore think, it is the more sensible output here.

We should consider making that more consistent also in HyperSpy (e.g. with the 2.0 release).

As I was at it, I also removed optional parameters from the title if they are not set.

Progress of the PR

Minimal example of the bug fix or the new feature

from lumispy.signals.luminescence_spectrum import LumiSpectrum
s = LumiSpectrum([[[1, 2, 3, 4, 5]] * 3] *4)
com = s.centroid()
com

now results in

<Signal2D, title: Centroid map, dimensions: (|3, 4)>
codecov-commenter commented 1 year ago

Codecov Report

Patch coverage: 100.00% and project coverage change: -0.55 :warning:

Comparison is base (d3cf6ac) 100.00% compared to head (014c93b) 99.45%.

:mega: This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #184 +/- ## =========================================== - Coverage 100.00% 99.45% -0.55% =========================================== Files 12 12 Lines 545 554 +9 =========================================== + Hits 545 551 +6 - Misses 0 3 +3 ``` | [Impacted Files](https://codecov.io/gh/LumiSpy/lumispy/pull/184?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=LumiSpy) | Coverage Δ | | |---|---|---| | [lumispy/signals/luminescence\_spectrum.py](https://codecov.io/gh/LumiSpy/lumispy/pull/184?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=LumiSpy#diff-bHVtaXNweS9zaWduYWxzL2x1bWluZXNjZW5jZV9zcGVjdHJ1bS5weQ==) | `100.00% <100.00%> (ø)` | | ... and [1 file with indirect coverage changes](https://codecov.io/gh/LumiSpy/lumispy/pull/184/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=LumiSpy) Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=LumiSpy). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=LumiSpy)

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.