Skip to content

Commit e6a10f9

Browse files
committed
Document all of the methods in the interface
1 parent 402d304 commit e6a10f9

File tree

1 file changed

+142
-2
lines changed

1 file changed

+142
-2
lines changed

astrowidgets/interface_definition.py

Lines changed: 142 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,34 +45,110 @@ class ImageViewerInterface(Protocol):
4545
# Methods for loading data
4646
@abstractmethod
4747
def load_fits(self, file):
48+
"""
49+
Load a FITS file into the viewer.
50+
51+
Parameters
52+
----------
53+
file : str or `astropy.io.fits.HDU`
54+
The FITS file to load. If a string, it can be a URL or a
55+
file path.
56+
"""
4857
raise NotImplementedError
4958

5059
@abstractmethod
5160
def load_array(self, array):
61+
"""
62+
Load a 2D array into the viewer.
63+
64+
Parameters
65+
----------
66+
array : array-like
67+
The array to load.
68+
"""
5269
raise NotImplementedError
5370

5471
@abstractmethod
5572
def load_nddata(self, data):
73+
"""
74+
Load an `astropy.nddata.NDData` object into the viewer.
75+
76+
Parameters
77+
----------
78+
data : `astropy.nddata.NDData`
79+
The NDData object to load.
80+
"""
5681
raise NotImplementedError
5782

5883
# Saving contents of the view and accessing the view
5984
@abstractmethod
6085
def save(self, filename):
86+
"""
87+
Save the current view to a file.
88+
89+
Parameters
90+
----------
91+
filename : str
92+
The file to save to. The format is determined by the
93+
extension.
94+
"""
6195
raise NotImplementedError
6296

6397
# Marker-related methods
6498
@abstractmethod
6599
def start_marking(self, marker_name=None):
100+
"""
101+
Start interactive marking of points on the image.
102+
103+
Parameters
104+
----------
105+
marker_name : str, optional
106+
The name of the marker set to use. If not given, a unique
107+
name will be generated.
108+
"""
66109
raise NotImplementedError
67110

68111
@abstractmethod
69112
def stop_marking(self, clear_markers=False):
113+
"""
114+
Stop interactive marking of points on the image.
115+
116+
Parameters
117+
----------
118+
clear_markers : bool, optional
119+
If `True`, clear the markers that were created during
120+
interactive marking. Default is `False`.
121+
"""
70122
raise NotImplementedError
71123

72124
@abstractmethod
73125
def add_markers(self, table, x_colname='x', y_colname='y',
74126
skycoord_colname='coord', use_skycoord=False,
75127
marker_name=None):
128+
"""
129+
Add markers to the image.
130+
131+
Parameters
132+
----------
133+
table : `astropy.table.Table`
134+
The table containing the marker positions.
135+
x_colname : str, optional
136+
The name of the column containing the x positions. Default
137+
is ``'x'``.
138+
y_colname : str, optional
139+
The name of the column containing the y positions. Default
140+
is ``'y'``.
141+
skycoord_colname : str, optional
142+
The name of the column containing the sky coordinates. If
143+
given, the ``use_skycoord`` parameter is ignored. Default
144+
is ``'coord'``.
145+
use_skycoord : bool, optional
146+
If `True`, the ``skycoord_colname`` column will be used to
147+
get the marker positions. Default is `False`.
148+
marker_name : str, optional
149+
The name of the marker set to use. If not given, a unique
150+
name will be generated.
151+
"""
76152
raise NotImplementedError
77153

78154
# @abstractmethod
@@ -81,6 +157,9 @@ def add_markers(self, table, x_colname='x', y_colname='y',
81157

82158
@abstractmethod
83159
def reset_markers(self):
160+
"""
161+
Remove all markers from the image.
162+
"""
84163
raise NotImplementedError
85164

86165
# @abstractmethod
@@ -89,6 +168,15 @@ def reset_markers(self):
89168

90169
@abstractmethod
91170
def remove_markers(self, marker_name=None):
171+
"""
172+
Remove markers from the image.
173+
174+
Parameters
175+
----------
176+
marker_name : str, optional
177+
The name of the marker set to remove. If not given, all
178+
markers will be removed.
179+
"""
92180
raise NotImplementedError
93181

94182
# @abstractmethod
@@ -99,17 +187,69 @@ def remove_markers(self, marker_name=None):
99187
def get_markers(self, x_colname='x', y_colname='y',
100188
skycoord_colname='coord',
101189
marker_name=None):
190+
"""
191+
Get the marker positions.
192+
193+
Parameters
194+
----------
195+
x_colname : str, optional
196+
The name of the column containing the x positions. Default
197+
is ``'x'``.
198+
y_colname : str, optional
199+
The name of the column containing the y positions. Default
200+
is ``'y'``.
201+
skycoord_colname : str, optional
202+
The name of the column containing the sky coordinates. Default
203+
is ``'coord'``.
204+
marker_name : str, optional
205+
The name of the marker set to use. If not given, all
206+
markers will be returned.
207+
208+
Returns
209+
-------
210+
table : `astropy.table.Table`
211+
The table containing the marker positions.
212+
"""
102213
raise NotImplementedError
103214

104215
# Methods that modify the view
105216
@abstractmethod
106-
def center_on(self):
217+
def center_on(self, point):
218+
"""
219+
Center the view on the point.
220+
221+
Parameters
222+
----------
223+
tuple or `~astropy.coordinates.SkyCoord`
224+
If tuple of ``(X, Y)`` is given, it is assumed
225+
to be in data coordinates.
226+
"""
107227
raise NotImplementedError
108228

109229
@abstractmethod
110-
def offset_by(self):
230+
def offset_by(self, dx, dy):
231+
"""
232+
Move the center to a point that is given offset
233+
away from the current center.
234+
235+
Parameters
236+
----------
237+
dx, dy : float or `~astropy.unit.Quantity`
238+
Offset value. Without a unit, assumed to be pixel offsets.
239+
If a unit is attached, offset by pixel or sky is assumed from
240+
the unit.
241+
"""
111242
raise NotImplementedError
112243

113244
@abstractmethod
114245
def zoom(self):
246+
"""
247+
Zoom in or out by the given factor.
248+
249+
Parameters
250+
----------
251+
val : int
252+
The zoom level to zoom the image.
253+
See `zoom_level`.
254+
"""
115255
raise NotImplementedError

0 commit comments

Comments
 (0)