Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Meta PR] Imviz: astrowidget API #632

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
168 changes: 168 additions & 0 deletions jdaviz/configs/imviz/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,21 @@ class Imviz(ConfigHelper):
"""Imviz Helper class"""
_default_configuration = 'imviz'

def __init__(self, app=None, **kwargs):
super().__init__(app=app)

# astrowidgets ducktyping (not MVP)

if 'image_width' in kwargs:
self.image_width = kwargs['image_width']

if 'image_height' in kwargs:
self.image_height = kwargs['image_height']

if 'pixel_coords_offset' in kwargs:
# This gets tied to self.pixel_offset
raise NotImplementedError

def load_data(self, data, parser_reference=None, **kwargs):
"""Load data into Imviz.

Expand Down Expand Up @@ -79,6 +94,159 @@ def load_data(self, data, parser_reference=None, **kwargs):
self.app.load_data(
data, parser_reference=parser_reference, **kwargs)

# astrowidgets ducktyping (MVP)

def center_on(self, point):
raise NotImplementedError

def offset_to(self, dx, dy, skycoord_offset=False):
raise NotImplementedError
Comment on lines +99 to +103
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #687


@property
def zoom_level(self):
raise NotImplementedError

@zoom_level.setter
def zoom_level(self, val):
raise NotImplementedError

def zoom(self, val):
raise NotImplementedError

@property
def stretch_options(self):
raise NotImplementedError

@property
def stretch(self):
raise NotImplementedError

@stretch.setter
def stretch(self, val):
raise NotImplementedError

@property
def autocut_options(self):
raise NotImplementedError

@property
def cuts(self):
raise NotImplementedError

@cuts.setter
def cuts(self, val):
raise NotImplementedError

@property
def colormap_options(self):
raise NotImplementedError

def set_colormap(self, cmap):
raise NotImplementedError

@property
def click_center(self):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to self: In an offline conversion with @PatrickOgle , we have removed click_center and click_drag from MVP, as one can just use the pan/zoom button.

return False # No way to do this right now

@click_center.setter
def click_center(self, val):
raise NotImplementedError

@property
def click_drag(self):
return False # No way to do this right now

@click_drag.setter
def click_drag(self, value):
raise NotImplementedError

@property
def scroll_pan(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I first red this as scroll_pun, and have to say I'm a bit disappointed in the reality that it's pan

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can have a scroll_pun mode where the viewer just spews puns in the "snackbar" as you scroll...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return False # No way to do this right now

@scroll_pan.setter
def scroll_pan(self, value):
raise NotImplementedError

def save(self, filename):
raise NotImplementedError

# markers (MVP)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eteq -- Are we on the same page w.r.t. markers now?

Still need to discuss loaders.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Markers MVP: See #699


RESERVED_MARKER_SET_NAMES = ['all']

def add_markers(self, table, x_colname='x', y_colname='y',
skycoord_colname='coord', use_skycoord=False,
marker_name=None):
raise NotImplementedError

def remove_markers(self, marker_name=None):
raise NotImplementedError

def reset_markers(self):
raise NotImplementedError

# astrowidgets ducktyping (not MVP)
#
# NOTES:
# * logger is excluded because it is too Ginga-specific.
# * cursor is excluded because coordinate info is in a plugin.

@property
def image_width(self):
raise NotImplementedError

@image_width.setter
def image_width(self, value):
raise NotImplementedError

@property
def image_height(self):
raise NotImplementedError

@image_height.setter
def image_height(self, value):
raise NotImplementedError

@property
def pixel_offset(self):
return 0 # No way to customize right now

# Loaders (not MVP)

def load_fits(self, fitsorfn, numhdu=None, memmap=None):
raise NotImplementedError

def load_nddata(self, nddata):
raise NotImplementedError

def load_array(self, arr):
raise NotImplementedError
Comment on lines +217 to +224
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is MVP in the sense that it's part of the existing load_data, right? I.e., these could be trivial wrappers into that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we debated whether having load_xxx in addition to imviz.load_data would be too confusing.

PEP 20: There should be one-- and preferably only one --obvious way to do it.


# Markers (not MVP)

@property
def is_marking(self):
return False # No way to mark right now

def start_marking(self, marker_name=None, marker=None):
raise NotImplementedError

def stop_marking(self, clear_markers=False):
raise NotImplementedError

@property
def marker(self):
return {} # No way to mark right now

@marker.setter
def marker(self, val):
raise NotImplementedError

def get_markers(self, x_colname='x', y_colname='y',
skycoord_colname='coord', marker_name=None):
raise NotImplementedError


def split_filename_with_fits_ext(filename):
"""Split a ``filename[ext]`` input into filename and FITS extension.
Expand Down