LumiSpy / lumispy

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

Implemented plot_span_map function #148

Closed 0Hughman0 closed 1 year ago

0Hughman0 commented 1 year ago

Description of the change

A few sentences and/or a bulleted list to describe and motivate the change:

Progress of the PR

Minimal example of the bug fix or the new feature

import numpy as np
import hyperspy.api as hs

from lumispy.utils.analysis import plot_span_map

s = hs.signals.Signal1D(data=np.random.random((64, 64, 1024)), 
                        axes=[{'name': 'x', 'size': 64}, 
                              {'name': 'y', 'size': 64}, 
                              {'name': 'sig', 'size': 1024}])

plot_span_map(s, nspans=2)

Capture

codecov-commenter commented 1 year ago

Codecov Report

Base: 98.36% // Head: 94.94% // Decreases project coverage by -3.41% :warning:

Coverage data is based on head (e8c36f2) compared to base (a3ac072). Patch coverage: 0.00% of modified lines in pull request are covered.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #148 +/- ## ========================================== - Coverage 98.36% 94.94% -3.42% ========================================== Files 11 12 +1 Lines 550 574 +24 ========================================== + Hits 541 545 +4 - Misses 9 29 +20 ``` | [Impacted Files](https://codecov.io/gh/LumiSpy/lumispy/pull/148?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=LumiSpy) | Coverage Δ | | |---|---|---| | [lumispy/utils/analysis.py](https://codecov.io/gh/LumiSpy/lumispy/pull/148/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=LumiSpy#diff-bHVtaXNweS91dGlscy9hbmFseXNpcy5weQ==) | `0.00% <0.00%> (ø)` | | | [lumispy/signals/luminescence\_spectrum.py](https://codecov.io/gh/LumiSpy/lumispy/pull/148/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=LumiSpy#diff-bHVtaXNweS9zaWduYWxzL2x1bWluZXNjZW5jZV9zcGVjdHJ1bS5weQ==) | `100.00% <0.00%> (+5.05%)` | :arrow_up: | 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 at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

0Hughman0 commented 1 year ago

Sorry, black somehow got carried away and 'fixed' a bunch of files that aren't mine 😬.

jlaehne commented 1 year ago

Sorry, still did not find the time for a detailed look at the code. But already the demo video is very cool.

As suggested by @ericpre in https://github.com/LumiSpy/lumispy/issues/139#issuecomment-1231397069 it would be quite useful for any hyperspectral signal (EDX, EELS) and not only luminescence - so we should at least discuss incorporating it upstream.

For linescans, I could imagine an equivalent tool (possibly covered by the same function) that plots intensity traces for the chosen spectral ROIs.

0Hughman0 commented 1 year ago

Great thanks.

With some guidance I would be happy to help adapt the code to be incorporated into hyperspy.

I think knowing how best to handle the various shapes of data will be the challenge here.

jlaehne commented 1 year ago

@LMSC-NTappy check out this PR

jlaehne commented 1 year ago

With some guidance I would be happy to help adapt the code to be incorporated into hyperspy.

I still think an upstream contribution would be great. To have the functionality available more quickly, a way forward could be to merge it in LumiSpy and make a release. Once it is also available in HyperSpy, we could deprecate it on the LumiSpy side.

I think knowing how best to handle the various shapes of data will be the challenge here.

Currently you have a span-ROI, but in a 2D map one would have rectangular ROIs to select parts of the data for the filtering. Would be surely nice to have that as well. Actually, once we integrate more functionality for Streak-Camera-Images, it would be helpful to have 2D signal support for LumiSpy as well.

@0Hughman0 could you solve the merge conflicts?

0Hughman0 commented 1 year ago

Hi,

Currently rushing to write up my PhD!

Would be happy to do this, but will have to wait until likely April.

LMSC-NTappy commented 1 year ago

@LMSC-NTappy check out this PR

Will do!

jlaehne commented 1 year ago

Any time to upstream this to HyperSpy, could possibly make it into the v2.0 release scheduled for September?

0Hughman0 commented 1 year ago

Hiya,

Sorry for the delay, thanks for your patience!

I'll have a go at getting this going swiftly.

I'm trying to find when the release is scheduled for 2.0, but no luck? I can hopefully sort in the next few days.

I guess I should make a new PR on the hyperspy repo?

Change's I'll make:

jlaehne commented 1 year ago

Sound like a good plan

I'm trying to find when the release is scheduled for 2.0, but no luck? I can hopefully sort in the next few days. In general, the idea for now mentioned in some other PRs is to release it in the course of September (though looks more like late September already I would say).

I guess I should make a new PR on the hyperspy repo? I think that would be the best strategy, one can transfer PRs, but I think it would be cleaner to start a new one - @ericpre has more experience with that though.

0Hughman0 commented 1 year ago

This PR has been moved to one for hyperspy:

https://github.com/hyperspy/hyperspy/pull/3224