Skip to content

Commit

Permalink
Remove deprecated methods and organize RGB mapping pipeline stages
Browse files Browse the repository at this point in the history
  • Loading branch information
ejeschke committed Feb 20, 2024
1 parent 6b467b3 commit fd99fc1
Show file tree
Hide file tree
Showing 8 changed files with 519 additions and 673 deletions.
71 changes: 2 additions & 69 deletions ginga/RGBMap.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@
#
import uuid
import numpy as np
import warnings

from ginga.misc import Callback, Settings, Bunch
from ginga import ColorDist, trcalc
from ginga import cmap as mod_cmap
from ginga import imap as mod_imap
from ginga.util import pipeline
from ginga.util.stages.rgbmap import (RGBInput, Distribute, ShiftMap,
IntensityMap, ColorMap, RGBMapError)
from ginga.util.stages.color import (RGBInput, Distribute, ShiftMap,
IntensityMap, ColorMap, RGBMapError)


class RGBPlanes(object):
Expand Down Expand Up @@ -312,15 +311,6 @@ def calc_imap(self):
def reset_sarr(self, callback=True):
self.t_.set(contrast=0.5, brightness=0.5, callback=callback)

def _get_sarr(self):
warnings.warn("get_sarr() has been deprecated", DeprecationWarning)
return self.p_shift._get_sarr()

def _set_sarr(self, sarr, callback=True):
warnings.warn("set_sarr() has been deprecated", DeprecationWarning)
self.p_shift._set_sarr(sarr)
self.recalc()

def contrast_set_cb(self, setting, pct):
self.p_shift.set_contrast(pct)
self.recalc()
Expand All @@ -329,15 +319,6 @@ def brightness_set_cb(self, setting, pct):
self.p_shift.set_brightness(pct)
self.recalc()

def get_carr(self):
warnings.warn("get_carr() has been deprecated", DeprecationWarning)
return self.p_cmap.get_carr()

def set_carr(self, carr, callback=True):
warnings.warn("set_carr() has been deprecated", DeprecationWarning)
self.p_cmap.set_carr(carr)
self.recalc()

def _refresh_cache(self):
i_arr = np.arange(0, self.maxc + 1, dtype=np.uint)
self.p_dist.result.setvals(res_np=i_arr)
Expand Down Expand Up @@ -426,57 +407,9 @@ def get_rgb_array(self, idx, order=None):

return arr_out

def get_rgbarray(self, idx, order='RGB', image_order=None):
"""
Parameters
----------
idx : index array
order : str
The order of the color planes in the output array (e.g. "RGBA")
image_order : str or None
The order of channels if indexes already contain RGB info.
"""
warnings.warn("get_rgbarray(idx) has been deprecated--"
"use get_rgb_array(idx) instead",
DeprecationWarning)

if image_order not in (None, ''):
# reorder image channels for pipeline
state = self.pipeline.get('state')
if state.order != image_order:
idx = trcalc.reorder_image(state.order, idx, image_order)

arr_out = self.get_rgb_array(idx, order=order)
return RGBPlanes(arr_out, order)

def get_hasharray(self, idx):
return self.p_dist.dist.hash_array(idx)

def shift(self, pct, rotate=False, callback=True):
warnings.warn("shift() has been deprecated", DeprecationWarning)
#self.p_shift.shift(pct, rotate=rotate)
brightness = self.p_shift._shift_to_brightness(pct, reset=False)
self.t_.set(brightness=brightness)

def scale_and_shift(self, scale_pct, shift_pct, callback=True):
"""Stretch and/or shrink the color map via altering the shift map.
"""
warnings.warn("scale_and_shift() has been deprecated", DeprecationWarning)
#self.p_shift.scale_and_shift(scale_pct, shift_pct)
brightness = self.p_shift._shift_to_brightness(shift_pct, reset=True)
contrast = self.p_shift._scale_to_contrast(scale_pct, reset=True)
self.t_.set(brightness=brightness, contrast=contrast)

def stretch(self, scale_factor, callback=True):
"""Stretch the color map via altering the shift map.
"""
warnings.warn("stretch() has been deprecated", DeprecationWarning)
#self.p_shift.stretch(scale_factor)
contrast = self.p_shift._scale_to_contrast(scale_factor, reset=False)
self.t_.set(contrast=contrast)

def copy_attributes(self, dst_rgbmap, keylist=None):
if keylist is None:
keylist = self.settings_keys
Expand Down
85 changes: 0 additions & 85 deletions ginga/canvas/CanvasObject.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import numpy as np
from collections import namedtuple
import copy
import warnings

from ginga.misc import Callback, Bunch
from ginga import trcalc, colors
Expand Down Expand Up @@ -551,90 +550,6 @@ def get_llur(self):
a, b = trcalc.get_bounds(self.get_data_points())
return (a[0], a[1], b[0], b[1])

# --- TO BE DEPRECATED METHODS ---

def move_delta(self, xoff, yoff):
"""For backward compatibility. TO BE DEPRECATED--DO NOT USE.
Use move_delta_pt instead.
"""
warnings.warn("move_delta(xoff, yoff) has been deprecated--"
"use move_delta_pt((xoff, yoff)) instead",
DeprecationWarning)
self.move_delta_pt((xoff, yoff))

def move_to(self, xdst, ydst):
"""For backward compatibility. TO BE DEPRECATED--DO NOT USE.
Use move_to_pt() instead.
"""
warnings.warn("move_to(xdst, ydst) has been deprecated--"
"use move_to_pt((xdst, ydst)) instead",
DeprecationWarning)
self.move_to_pt((xdst, ydst))

def scale_by(self, scale_x, scale_y):
"""For backward compatibility. TO BE DEPRECATED--DO NOT USE.
Use scale_by_factors() instead.
"""
warnings.warn("scale_by(scale_x, scale_y) has been deprecated--"
"use scale_by_factors((scale_x, scale_y)) instead",
DeprecationWarning)
self.scale_by_factors((scale_x, scale_y))

def rescale_by(self, scale_x, scale_y, detail):
"""For backward compatibility. TO BE DEPRECATED--DO NOT USE.
Use rescale_by_factors() instead.
"""
warnings.warn("rescale_by() has been deprecated--"
"use rescale_by_factors() instead",
DeprecationWarning)
self.rescale_by_factors((scale_x, scale_y), detail)

def rotate(self, theta_deg, xoff=0, yoff=0):
"""For backward compatibility. TO BE DEPRECATED--DO NOT USE.
Use rotate_deg() instead.
"""
warnings.warn("rotate(theta_deg) has been deprecated--"
"use rotate_deg([theta_deg]) instead",
DeprecationWarning)
self.rotate_deg([theta_deg], (xoff, yoff))

def rotate_by(self, theta_deg):
"""For backward compatibility. TO BE DEPRECATED--DO NOT USE.
Use rotate_by_deg() instead.
"""
warnings.warn("rotate_by(theta_deg) has been deprecated--"
"use rotate_by_deg([theta_deg]) instead",
DeprecationWarning)
self.rotate_by_deg([theta_deg])

def contains_arr(self, x_arr, y_arr):
"""For backward compatibility. TO BE DEPRECATED--DO NOT USE.
Use contains_pts() instead.
"""
warnings.warn("contains_arr(x_arr, y_arr) has been deprecated--"
"use contains_pts(np.asarray((x_arr, y_arr)).T) instead",
DeprecationWarning)
pts = np.asarray((x_arr, y_arr)).T
return self.contains_pts(pts)

def contains(self, x, y):
"""For backward compatibility. TO BE DEPRECATED--DO NOT USE.
Use contains_pt() instead.
"""
warnings.warn("contains(x, y) has been deprecated--"
"use contains_pt((x, y)) instead",
DeprecationWarning)
return self.contains_pt((x, y))

def select_contains(self, viewer, x, y):
"""For backward compatibility. TO BE DEPRECATED--DO NOT USE.
Use select_contains_pt() instead.
"""
warnings.warn("select_contains(viewer, x, y) has been deprecated--"
"use select_contains_pt(viewer, (x, y)) instead",
DeprecationWarning)
return self.select_contains_pt(viewer, (x, y))


# this is the data structure to which drawing classes are registered
drawCatalog = Bunch.Bunch(caseless=True)
Expand Down
6 changes: 0 additions & 6 deletions ginga/canvas/types/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,12 +340,6 @@ def contains_pts(self, pts):
np.logical_or(xi <= xa, xj <= xa))
# NOTE: get a divide by zero here for some elements whose tf=False
# Need to figure out a way to conditionally do those w/tf=True
# Till then we use the warnings module to suppress the warning.
## with warnings.catch_warnings():
## warnings.simplefilter('default', RuntimeWarning)
# NOTE postscript: warnings context manager causes this computation
# to fail silently sometimes where it previously worked with a
# warning--commenting out the warning manager for now
cross = ((xi + (ya - yi).astype(float, copy=False) /
(yj - yi) * (xj - xi)) < xa)

Expand Down
26 changes: 6 additions & 20 deletions ginga/rv/Control.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import atexit
import shutil
import inspect
import warnings
from collections import OrderedDict
import webbrowser

Expand Down Expand Up @@ -2847,16 +2846,6 @@ def _showxy(self, viewer, data_x, data_y):
self.update_pending()
return True

def motion_cb(self, viewer, button, data_x, data_y):
"""Motion event in the channel viewer window. Show the pointing
information under the cursor.
"""
warnings.warn("This function has been deprecated--"
"use showxy() instead",
DeprecationWarning)
self.showxy(viewer, data_x, data_y)
return True

def dragdrop(self, chviewer, uris):
"""Called when a drop operation is performed on a channel viewer.
We are called back with a URL and we attempt to (down)load it if it
Expand All @@ -2867,6 +2856,12 @@ def dragdrop(self, chviewer, uris):
self.open_uris(uris, chname=chname)
return True

def force_focus_cb(self, viewer, event, data_x, data_y):
chname = self.get_channel_name(viewer)
if chname is not None:
self.force_focus(chname)
return True

def force_focus(self, chname):
if not self.settings.get('channel_follows_focus', False):
self.change_channel(chname, raisew=True)
Expand All @@ -2876,15 +2871,6 @@ def force_focus(self, chname):
if hasattr(v, 'take_focus'):
v.take_focus()

def force_focus_cb(self, viewer, event, data_x, data_y):
warnings.warn("This function has been deprecated--"
"use force_focus() instead",
DeprecationWarning)
chname = self.get_channel_name(viewer)
if chname is not None:
self.force_focus(chname)
return True

def focus_cb(self, viewer, tf, name):
"""Called when ``viewer`` gets ``(tf==True)`` or loses
``(tf==False)`` the focus.
Expand Down
4 changes: 0 additions & 4 deletions ginga/rv/plugins/Pan.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ def add_channel(self, viewer, channel):
iw = Viewers.GingaViewerWidget(panimage)
iw.resize(self._wd, self._ht)
self.nb.add_widget(iw)
#index = self.nb.index_of(iw)
paninfo = Bunch.Bunch(panimage=panimage, widget=iw,
compass_wcs=compass_wcs, compass_xy=compass_xy,
panrect=None)
Expand All @@ -173,9 +172,6 @@ def add_channel(self, viewer, channel):
fitsimage.copy_attributes(panimage, self.copy_attrs)

fitsimage.add_callback('redraw', self.redraw_cb, channel)
fitsimage.add_callback('image-set',
lambda viewer, image: self._redo(channel, image))

self.logger.debug("channel '%s' added." % (channel.name))

def delete_channel(self, viewer, channel):
Expand Down
Loading

0 comments on commit fd99fc1

Please sign in to comment.