diff --git a/changelog/232.bugfix.rst b/changelog/232.bugfix.rst new file mode 100644 index 00000000..77af183a --- /dev/null +++ b/changelog/232.bugfix.rst @@ -0,0 +1 @@ +`~sunkit_instruments.response.SourceSpectra.temperature_response` now gives the same result whatever the wavelength unit of the spectra; spectra in units other than Angstrom gave a zero response. diff --git a/sunkit_instruments/response/tests/test_channel.py b/sunkit_instruments/response/tests/test_channel.py index 69a95f80..d049d06d 100644 --- a/sunkit_instruments/response/tests/test_channel.py +++ b/sunkit_instruments/response/tests/test_channel.py @@ -85,6 +85,15 @@ def test_spectra_repr(fake_spectra): assert isinstance(fake_spectra.__repr__(), str) +def test_temperature_response_wavelength_unit(fake_channel, fake_spectra): + spectra_nm = SourceSpectra( + fake_spectra.temperature, + fake_spectra.wavelength.to("nm"), + fake_spectra.data.to("photon cm3 s-1 sr-1 nm-1"), + ) + assert u.allclose(spectra_nm.temperature_response(fake_channel), fake_spectra.temperature_response(fake_channel)) + + @pytest.mark.parametrize('obstime', [None, '2020-01-01']) def test_temperature_response(fake_channel, fake_spectra, obstime): temp_response = fake_spectra.temperature_response(fake_channel, obstime=obstime) diff --git a/sunkit_instruments/response/thermal.py b/sunkit_instruments/response/thermal.py index 7de91ee5..b66ef396 100644 --- a/sunkit_instruments/response/thermal.py +++ b/sunkit_instruments/response/thermal.py @@ -161,8 +161,8 @@ def temperature_response( wave_response.to_value(wave_response.unit), dims=['wavelength'], coords=[xarray.Variable('wavelength', - channel.wavelength.to_value('Angstrom'), - attrs={'unit': 'Angstrom'}),], + channel.wavelength.to_value(self._da.wavelength.unit), + attrs={'unit': self._da.wavelength.unit}),], attrs={'unit': wave_response.unit.to_string()} ) spec_interp = self._da.interp(