Skip to content

Commit

Permalink
minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Nabil Freij authored and nabobalis committed Feb 7, 2022
1 parent 7775633 commit 3193d73
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 32 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,4 @@ glue/qt/glue_qt_resources.py
.pytest_cache
.tox
.vscode
.history
4 changes: 1 addition & 3 deletions glue/core/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
from glue.core.contracts import contract
from glue.core.joins import get_mask_with_key_joins
from glue.config import settings, data_translator, subset_state_translator
from glue.utils import (compute_statistic,
unbroadcast, iterate_chunks,
from glue.utils import (compute_statistic, unbroadcast, iterate_chunks,
datetime64_to_mpl, broadcast_to, categorical_ndarray,
format_choices, random_views_for_dask_array)
from glue.core.coordinate_helpers import axis_label
Expand Down Expand Up @@ -1687,7 +1686,6 @@ def compute_statistic(self, statistic, cid, subset_state=None, axis=None,
values = self.compute_statistic(statistic, cid, subset_state=subset_state,
axis=axis, finite=finite, positive=positive,
percentile=percentile, view=chunk_view)

result[chunk_view[axis_index]] = values

return result
Expand Down
12 changes: 12 additions & 0 deletions glue/utils/wcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,19 @@


def get_identity_wcs(naxis):
"""
[summary]
Parameters
----------
naxis : [type]
[description]
Returns
-------
[type]
[description]
"""
wcs = WCS(naxis=naxis)
wcs.wcs.ctype = ['X'] * naxis
wcs.wcs.crval = [0.] * naxis
Expand Down
1 change: 0 additions & 1 deletion glue/viewers/common/qt/data_slice_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ def __init__(self, label='', world=None, lo=0, hi=10,

def set_label_from_slider(self):
value = self.state.slice_center

if self.state.use_world:
value = self._world[value]
if self._world_warning:
Expand Down
3 changes: 1 addition & 2 deletions glue/viewers/image/qt/data_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ class ImageViewer(MatplotlibImageMixin, MatplotlibDataViewer):

tools = ['select:rectangle', 'select:xrange',
'select:yrange', 'select:circle',
'select:polygon', 'image:point_selection',
'image:contrast_bias',
'select:polygon', 'image:point_selection', 'image:contrast_bias',
'profile-viewer']

def __init__(self, session, parent=None, state=None):
Expand Down
4 changes: 0 additions & 4 deletions glue/viewers/image/qt/slice_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from glue.viewers.image.state import AggregateSlice
from glue.utils.decorators import avoid_circular


__all__ = ['MultiSliceWidgetHelper']


Expand Down Expand Up @@ -57,7 +56,6 @@ def sync_state_from_sliders(self, *args):
else:
slices.append(self.viewer_state.slices[i])
self.viewer_state.slices = tuple(slices)

self._reference_data = self.viewer_state.reference_data

@avoid_circular
Expand Down Expand Up @@ -96,7 +94,6 @@ def sync_sliders_from_state(self, *args):
pixel_axis=world_axis_index,
world_axis=world_axis_index)
world_unit = self.data.coords.world_axis_units[world_axis_index]

world_warning = len(dependent_axes(self.data.coords, i)) > 1
world_label = self.data.world_component_ids[i].label
else:
Expand All @@ -110,7 +107,6 @@ def sync_sliders_from_state(self, *args):
world_unit=world_unit, world_warning=world_warning)

self.slider_state = slider.state

self.slider_state.add_callback('slice_center', self.sync_state_from_sliders)
self._sliders.append(slider)
self.layout.addWidget(slider)
Expand Down
14 changes: 1 addition & 13 deletions glue/viewers/image/viewer.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import os

from astropy.wcs import WCS

from glue.core.subset import roi_to_subset_state
from glue.core.coordinates import Coordinates, LegacyCoordinates
from glue.core.coordinate_helpers import dependent_axes
Expand All @@ -12,21 +10,11 @@

from glue.viewers.image.frb_artist import imshow
from glue.viewers.image.composite_array import CompositeArray
from glue.utils.wcs import get_identity_wcs

__all__ = ['MatplotlibImageMixin']


def get_identity_wcs(naxis):

wcs = WCS(naxis=naxis)
wcs.wcs.ctype = ['X'] * naxis
wcs.wcs.crval = [0.] * naxis
wcs.wcs.crpix = [1.] * naxis
wcs.wcs.cdelt = [1.] * naxis

return wcs


EXTRA_FOOTER = """
# Set tick label size - for now tick_params (called lower down) doesn't work
# properly, but these lines won't be needed in future.
Expand Down
3 changes: 1 addition & 2 deletions glue/viewers/profile/layer_artist.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def __init__(self, axes, viewer_state, layer_state=None, layer=None):
self._viewer_state.add_global_callback(self._update_profile)
self.state.add_global_callback(self._update_profile)

self.plot_artist = self.axes.plot([1, 2, 3], [3, 4, 5], 'k-', drawstyle='steps-mid',
self.plot_artist = self.axes.plot([1, 2, 3], [3, 4, 5], drawstyle='steps-mid',
color=self.state.layer.style.color)[0]
self.mpl_artists = [self.plot_artist]

Expand All @@ -45,7 +45,6 @@ def _calculate_profile_thread(self, reset=False):
# otherwise the thread tries to send these to the glue logger (which
# uses Qt), which then results in this kind of error:
# QObject::connect: Cannot queue arguments of type 'QTextCursor'

with warnings.catch_warnings():
warnings.simplefilter("ignore")
if reset:
Expand Down
2 changes: 0 additions & 2 deletions glue/viewers/profile/qt/options_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ def __init__(self, viewer_state, session, parent=None):
self.viewer_state.add_callback('x_att', self._on_attribute_change)

self.ui.text_warning.hide()

self.ui.axes_editor.button_apply_all.clicked.connect(self._apply_all_viewers)

def _on_function_change(self, *args):
Expand All @@ -52,7 +51,6 @@ def _on_function_change(self, *args):
layout=self.ui.layout_slices)
self.ui.text_warning.hide()
self.ui.text_warning.setText('')

else:
if self.profile_slice_helper:
self.profile_slice_helper.remove()
Expand Down
19 changes: 14 additions & 5 deletions glue/viewers/profile/state.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import copy
from collections import OrderedDict
import pdb

import numpy as np

Expand Down Expand Up @@ -60,7 +61,7 @@ def __init__(self, **kwargs):

self.add_callback('layers', self._layers_changed)
self.add_callback('reference_data', self._reference_data_changed, echo_old=True)
self.add_callback('x_att', self._update_att)
self.add_callback('x_att', self._update_x_att)
self.add_callback('normalize', self._reset_y_limits)

self.x_att_helper = ComponentIDComboHelper(self, 'x_att',
Expand All @@ -85,9 +86,9 @@ def _display_world(self):
return getattr(self.reference_data, 'coords', None) is not None

@defer_draw
def _update_att(self, *args):
def _update_x_att(self, *args):
"""
Define self.x_att_pixel in viewer state.
Defines ``self.x_att_pixel`` in the viewer state.
"""
if self.x_att is not None:
if self._display_world:
Expand Down Expand Up @@ -180,7 +181,7 @@ def _reference_data_changed(self, before=None, after=None):
self.x_att_helper.world_coord = False
self.x_att = self.reference_data.pixel_component_ids[0]

self._update_att()
self._update_x_att()

self.reset_limits()

Expand All @@ -204,9 +205,17 @@ def wcsaxes_slice(self):
"""
if self.reference_data is None:
return None
elif self.x_att_pixel is None:
# TODO: This should not be here.
# I can not work out how to get this to be set at initialisation.
self.x_att_helper.set_multiple_data([self.reference_data])
self.x_att_helper.world_coord = False
self.x_att = self.reference_data.pixel_component_ids[0]
self._update_x_att()

slices = []
for i in range(self.reference_data.ndim):
if i == self.x_att_pixel.axis:
if self.x_att_pixel and i == self.x_att_pixel.axis:
slices.append('x')
else:
slices.append(0)
Expand Down

0 comments on commit 3193d73

Please sign in to comment.