Skip to content

implemented spectral response correction and calculate spectral response correction#255

Open
Lulus792 wants to merge 2 commits intoLumiSpy:mainfrom
Lulus792:spectral_response
Open

implemented spectral response correction and calculate spectral response correction#255
Lulus792 wants to merge 2 commits intoLumiSpy:mainfrom
Lulus792:spectral_response

Conversation

@Lulus792
Copy link
Contributor

@Lulus792 Lulus792 commented Feb 20, 2026

Implemented into CommonLumi the spectral_response_correction aswell as calculate_reponse_correction. Using a helper function _apply which takes an operator besides the ref signal since both function only differ in that functionality. Added tests aswell.

Description of the change

  • implemented spectral_response_correction
  • implemented calculate_spectral_response

Progress of the PR

  • Change implemented (can be split into several points),
  • docstring updated (if appropriate),
  • added tests,
  • add a changelog entry in the upcoming_changes folder (see upcoming_changes/README.rst),
  • ready for review.

Minimal example of the bug fix or the new feature

import lumispy as lum
import numpy as np
s = lum.signals.LumiSpectrum(np.arange(10))
ref = lum.signals.LumiSpectrum(0.2 * np.ones_like(np.arange(10)))
s.spectral_response_correction(ref, inplace=True)

@Lulus792 Lulus792 force-pushed the spectral_response branch 3 times, most recently from af16b33 to 5c2e11e Compare February 20, 2026 17:26
@ericpre
Copy link
Contributor

ericpre commented Feb 20, 2026

How different is it from the following:

import lumispy as lum
import numpy as np

s = lum.signals.LumiSpectrum(np.arange(10))
ref = lum.signals.LumiSpectrum(0.2 * np.ones_like(np.arange(10)))
s = s * ref

If there is no difference, and if the https://peps.python.org/pep-0020/ is followed, s = s * ref should be preferred because it is simple and explicit and the method spectral_response_correction is not obvious what correction it would be applying.

@Lulus792
Copy link
Contributor Author

from what i know the idea was to implement two functions one for multiplication and the other for division. where for spectral_response_correction you want to remove the reference signal that you get from the measurement instrument which is apperently done via multiplication. And the same exist with division tho i am also not quite sure. Thats at least what i understould tho i would have to ask @jlaehne

@Lulus792
Copy link
Contributor Author

i suppose there isnt a difference its i suppose simpöy to be more meanigful? Tho as insaid not entirely sure tho it should be the same as your example

@jlaehne
Copy link
Contributor

jlaehne commented Feb 23, 2026

How different is it from the following:

import lumispy as lum
import numpy as np

s = lum.signals.LumiSpectrum(np.arange(10))
ref = lum.signals.LumiSpectrum(0.2 * np.ones_like(np.arange(10)))
s = s * ref

If there is no difference, and if the https://peps.python.org/pep-0020/ is followed, s = s * ref should be preferred because it is simple and explicit and the method spectral_response_correction is not obvious what correction it would be applying.

Indeed, the function should use s = s * ref in the end, but will become a wrapper to handle cases of mismatching signal axes using interpolate_on_axis. ref should be cast onto the axis of s. And if s has a larger range than ref, it's axis should be restricted to the range where the mathematical operation can be applied.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants