Skip to content

Commit b1bba41

Browse files
authored
Fix importing array trace (#3697)
* fix importing array trace; * change log
1 parent f32e878 commit b1bba41

File tree

3 files changed

+20
-17
lines changed

3 files changed

+20
-17
lines changed

CHANGES.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,8 @@ Specviz2d
198198
- Fixed an issue with default angle unit being set in unit conversion plugin, which fixed
199199
a bug when background data from the spectral extraction plugin is added to the viewer. [#3661]
200200

201+
- Fixed a bug loading array traces into Specviz2d. [#3697]
202+
201203
4.2.3 (2025-06-16)
202204
==================
203205

jdaviz/configs/specviz/plugins/unit_conversion/unit_conversion.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ def _on_add_data_to_viewer(self, msg):
304304
# NOTE: this assumes that all image data is coerced to surface brightness units
305305
layers = [lyr for lyr in msg.viewer.layers if lyr.layer.data.label == msg.data.label]
306306

307-
if not isinstance(data_obj, tracing.FlatTrace):
307+
if not isinstance(data_obj, tracing.Trace):
308308

309309
if not len(self.spectral_unit_selected) and hasattr(data_obj, 'spectral_axis'):
310310
try:

jdaviz/configs/specviz2d/plugins/spectral_extraction/tests/test_spectral_extraction.py

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,22 +39,6 @@ def test_plugin(specviz2d_helper):
3939
assert pext.marks['trace'].marks_list[0].visible is True
4040
assert len(pext.marks['trace'].marks_list[0].x) > 0
4141

42-
# test importing traces
43-
img = specviz2d_helper.get_data('Spectrum 2D')
44-
flat_trace = tracing.FlatTrace(img, trace_pos=25)
45-
fit_trace = tracing.FitTrace(img)
46-
47-
for imported_trace in [flat_trace, fit_trace]:
48-
pext.import_trace(imported_trace)
49-
exported_trace = pext.export_trace(add_data=False)
50-
assert isinstance(exported_trace, type(imported_trace))
51-
52-
# # array trace needs to go through loader, uncomment after JDAT-5518
53-
# array_trace = tracing.ArrayTrace(img, np.arange(len(img.spectral_axis)))
54-
# specviz2d_helper.load(array_trace)
55-
# exported_trace = pext.export_trace(add_data=False)
56-
# assert isinstance(exported_trace, tracing.ArrayTrace)
57-
5842
# create FlatTrace
5943
pext.trace_type_selected = 'Flat'
6044
pext.trace_pixel = 28
@@ -176,6 +160,23 @@ def test_plugin(specviz2d_helper):
176160
with pytest.raises(ValueError):
177161
pext.export_extract(invalid_kwarg=5)
178162

163+
# test importing traces
164+
img = specviz2d_helper.get_data('Spectrum 2D')
165+
flat_trace = tracing.FlatTrace(img, trace_pos=25)
166+
fit_trace = tracing.FitTrace(img)
167+
168+
for imported_trace in [flat_trace, fit_trace]:
169+
pext.import_trace(imported_trace)
170+
exported_trace = pext.export_trace(add_data=False)
171+
assert isinstance(exported_trace, type(imported_trace))
172+
173+
# array trace needs to go through loader, uncomment after JDAT-5518
174+
array_trace = tracing.ArrayTrace(img, np.arange(len(img.spectral_axis)))
175+
specviz2d_helper.load(array_trace, data_label='array_trace')
176+
pext.trace_trace.selected = 'array_trace'
177+
exported_trace = pext.export_trace(add_data=False)
178+
assert isinstance(exported_trace, tracing.ArrayTrace)
179+
179180

180181
@pytest.mark.remote_data
181182
@pytest.mark.filterwarnings('ignore')

0 commit comments

Comments
 (0)