|
7 | 7 | from astropy.utils import deprecated |
8 | 8 | from glue.core.link_helpers import LinkSame |
9 | 9 |
|
10 | | -from jdaviz.core.events import SnackbarMessage, NewViewerMessage |
| 10 | +from jdaviz.core.events import NewViewerMessage |
11 | 11 | from jdaviz.core.helpers import ImageConfigHelper |
12 | | -from jdaviz.utils import (data_has_valid_wcs, get_wcs_only_layer_labels, |
13 | | - get_reference_image_data, _wcs_only_label) |
| 12 | +from jdaviz.utils import (get_wcs_only_layer_labels, |
| 13 | + get_reference_image_data) |
14 | 14 |
|
15 | 15 | __all__ = ['Imviz'] |
16 | 16 |
|
@@ -146,8 +146,6 @@ def load_data(self, data, data_label=None, show_in_viewer=True, **kwargs): |
146 | 146 | """ |
147 | 147 | self.app.state.dev_loaders = True |
148 | 148 |
|
149 | | - prev_data_labels = self.app.data_collection.labels |
150 | | - |
151 | 149 | extensions = None if 'ext' not in kwargs else kwargs['ext'] |
152 | 150 |
|
153 | 151 | if 'gwcs_to_fits_sip' not in kwargs and 'Orientation' in self.plugins.keys(): |
@@ -195,81 +193,12 @@ def load_data(self, data, data_label=None, show_in_viewer=True, **kwargs): |
195 | 193 | if data_label: |
196 | 194 | kw['data_label'] = data_label |
197 | 195 |
|
198 | | - self.loaders['object'].object = data[i, :, :] |
199 | | - if data_label: |
200 | | - self.loaders['object'].importer.data_label.value = data_label |
201 | | - if extensions is not None: |
202 | | - # Slight hack to load extensions using the ext kwarg |
203 | | - self.loaders['object']._obj.importer.extension.selected = [f'{enum + 1}: {name}' for enum, name in enumerate(extensions)] # noqa |
204 | | - self.loaders['object'].importer() |
205 | | - # data_label = data_label |
206 | | - # self._load(data[i, :, :], data_label=data_label, ext=extensions) |
207 | | - # self.app.load_data(data[i, :, :], parser_reference='imviz-data-parser', **kw) |
| 196 | + self._load(data[i, :, :], data_label=data_label, extension=extensions) |
208 | 197 |
|
209 | 198 | else: |
210 | 199 | if data_label: |
211 | 200 | kwargs['data_label'] = data_label |
212 | | - self.loaders['object'].object = data |
213 | | - if data_label: |
214 | | - self.loaders['object'].importer.data_label.value = data_label |
215 | | - if extensions is not None: |
216 | | - self.loaders['object']._obj.importer.extension.selected = [f'{enum+1}: {name}' |
217 | | - for enum, name in |
218 | | - enumerate(extensions)] |
219 | | - self.loaders['object'].importer() |
220 | | - # self._load(data, data_label=data_label, ext=extensions) |
221 | | - # self.app.load_data(data, parser_reference='imviz-data-parser', **kwargs) |
222 | | - return |
223 | | - # find the current label(s) - TODO: replace this by calling default label functionality |
224 | | - # above instead of having to refind it |
225 | | - applied_labels = [] |
226 | | - applied_visible = [] |
227 | | - layer_is_wcs_only = [] |
228 | | - layer_has_wcs = [] |
229 | | - for data in self.app.data_collection: |
230 | | - label = data.label |
231 | | - if label not in prev_data_labels: |
232 | | - applied_labels.append(label) |
233 | | - applied_visible.append(True) |
234 | | - layer_is_wcs_only.append(data.meta.get(_wcs_only_label, False)) |
235 | | - layer_has_wcs.append(data_has_valid_wcs(data)) |
236 | | - |
237 | | - if show_in_viewer is True: |
238 | | - show_in_viewer = f"{self.app.config}-0" |
239 | | - |
240 | | - if show_in_viewer: |
241 | | - linked_by_wcs = self.app._align_by == 'wcs' |
242 | | - if linked_by_wcs: |
243 | | - for applied_label, visible, is_wcs_only, has_wcs in zip( |
244 | | - applied_labels, applied_visible, layer_is_wcs_only, layer_has_wcs |
245 | | - ): |
246 | | - if not is_wcs_only and linked_by_wcs and not has_wcs: |
247 | | - self.app.hub.broadcast(SnackbarMessage( |
248 | | - f"'{applied_label}' will be added to the data collection but not " |
249 | | - f"the viewer '{show_in_viewer}', since data are aligned by WCS, but " |
250 | | - f"'{applied_label}' has no WCS.", |
251 | | - color="warning", timeout=8000, sender=self) |
252 | | - ) |
253 | | - |
254 | | - if self._in_batch_load and show_in_viewer: |
255 | | - for applied_label, is_wcs_only in zip(applied_labels, layer_is_wcs_only): |
256 | | - if not is_wcs_only: |
257 | | - self._delayed_show_in_viewer_labels[applied_label] = show_in_viewer |
258 | | - |
259 | | - else: |
260 | | - if 'Orientation' not in self.plugins.keys(): |
261 | | - # otherwise plugin will handle linking automatically with DataCollectionAddMessage |
262 | | - self.link_data(align_by='wcs') |
263 | | - |
264 | | - # One input might load into multiple Data objects. |
265 | | - # NOTE: If the batch_load context manager was used, it will |
266 | | - # handle that logic instead. |
267 | | - if show_in_viewer: |
268 | | - for applied_label, visible, has_wcs in zip( |
269 | | - applied_labels, applied_visible, layer_has_wcs |
270 | | - ): |
271 | | - if (has_wcs and linked_by_wcs) or not linked_by_wcs: |
272 | | - self.app.add_data_to_viewer(show_in_viewer, applied_label, visible=visible) |
| 201 | + self._load(data, data_label=data_label, extension=extensions) |
273 | 202 |
|
274 | 203 | def link_data(self, align_by='pixels', wcs_fallback_scheme=None, wcs_fast_approximation=True): |
275 | 204 | """(Re)link loaded data in Imviz with the desired link type. |
|
0 commit comments