Skip to content

Commit 2f3bd38

Browse files
committed
Remove pixel offset from ginga widget
1 parent 92c2eb5 commit 2f3bd38

File tree

2 files changed

+5
-49
lines changed

2 files changed

+5
-49
lines changed

astrowidgets/ginga.py

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,6 @@ def __init__(self, logger=None, image_width=500, image_height=500,
7777
self._jup_img.max_width = '100%'
7878
self._jup_img.height = 'auto'
7979

80-
self._pixel_offset = pixel_coords_offset
81-
8280
# Set the width of the box containing the image to the desired width
8381
# Note: We are NOT setting the height. That is because the height
8482
# is automatically set by the image aspect ratio.
@@ -196,8 +194,8 @@ def _mouse_move_cb(self, viewer, button, data_x, data_y):
196194
except Exception:
197195
imval = 'N/A'
198196

199-
val = (f'X: {data_x + self._pixel_offset:.2f}, '
200-
f'Y: {data_y + self._pixel_offset:.2f}')
197+
val = (f'X: {data_x:.2f}, '
198+
f'Y: {data_y:.2f}')
201199

202200
if image.wcs.wcs is not None:
203201
try:
@@ -239,8 +237,8 @@ def _mouse_click_cb(self, viewer, event, data_x, data_y):
239237

240238
# For debugging.
241239
with self.print_out:
242-
print(f'Centered on X={data_x + self._pixel_offset} '
243-
f'Y={data_y + self._pixel_offset}')
240+
print(f'Centered on X={data_x} '
241+
f'Y={data_y}')
244242

245243
def load_fits(self, filename, numhdu=None, memmap=None):
246244
"""Load a FITS file or HDU into the viewer.
@@ -320,7 +318,7 @@ def center_on(self, point):
320318
if isinstance(point, SkyCoord):
321319
self._viewer.set_pan(point.ra.deg, point.dec.deg, coord='wcs')
322320
else:
323-
self._viewer.set_pan(*(np.asarray(point) - self._pixel_offset))
321+
self._viewer.set_pan(*(np.asarray(point)))
324322

325323
@deprecated('0.3', alternative='offset_by')
326324
def offset_to(self, dx, dy, skycoord_offset=False):
@@ -570,10 +568,6 @@ def get_markers_by_name(self, marker_name, x_colname='x', y_colname='y',
570568

571569
sky_col = SkyCoord(radec_col[:, 0], radec_col[:, 1], unit='deg')
572570

573-
# Convert X,Y from 0-indexed to 1-indexed
574-
if self._pixel_offset != 0:
575-
xy_col += self._pixel_offset
576-
577571
# Build table
578572
if include_skycoord:
579573
markers_table = Table(
@@ -667,12 +661,6 @@ def add_markers(self, table, x_colname='x', y_colname='y',
667661
else: # Use X,Y
668662
coord_x = table[x_colname].data
669663
coord_y = table[y_colname].data
670-
# Convert data coordinates from 1-indexed to 0-indexed
671-
if self._pixel_offset != 0:
672-
# Don't use the in-place operator -= here that modifies
673-
# the input table.
674-
coord_x = coord_x - self._pixel_offset
675-
coord_y = coord_y - self._pixel_offset
676664

677665
# Prepare canvas and retain existing marks
678666
try:

astrowidgets/tests/test_ginga_widget.py

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -97,38 +97,6 @@ def test_adding_markers_as_world_recovers_with_get_markers():
9797
mark_coord_table['coord'].dec.deg)
9898

9999

100-
def test_can_set_pixel_offset_at_object_level():
101-
# The pixel offset below is nonsensical. It is chosen simply
102-
# to make it easy to check for.
103-
offset = 3
104-
image = ImageWidget(image_width=300, image_height=300,
105-
pixel_coords_offset=offset)
106-
assert image._pixel_offset == offset
107-
108-
109-
def test_move_callback_includes_offset():
110-
# The pixel offset below is nonsensical. It is chosen simply
111-
# to make it easy to check for.
112-
offset = 3
113-
image = ImageWidget(image_width=300, image_height=300,
114-
pixel_coords_offset=offset)
115-
data = np.random.random([300, 300])
116-
image.load_array(data)
117-
# Send a fake move to the callback. What gets put in the cursor
118-
# value should be the event we sent in plus the offset.
119-
image.click_center = True
120-
data_x = 100
121-
data_y = 200
122-
image._mouse_move_cb(image._viewer, None, data_x, data_y)
123-
output_contents = image._jup_coord.value
124-
x_out = re.search(r'X: ([\d\.\d]+)', output_contents)
125-
x_out = x_out.groups(1)[0]
126-
y_out = re.search(r'Y: ([\d\.\d]+)', output_contents)
127-
y_out = y_out.groups(1)[0]
128-
assert float(x_out) == data_x + offset
129-
assert float(y_out) == data_y + offset
130-
131-
132100
def test_can_add_markers_with_names():
133101
"""
134102
Test a few things related to naming marker sets

0 commit comments

Comments
 (0)