_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q241300 | add_zoom_buttons | train | def add_zoom_buttons(viewer, canvas=None, color='black'):
"""Add zoom buttons to a canvas.
Parameters
----------
viewer : an ImageView subclass instance
If True, show the color bar; else remove it if present.
canvas : a DrawingCanvas instance
The canvas to which the buttons should ... | python | {
"resource": ""
} |
q241301 | ImageViewGtk.expose_event | train | def expose_event(self, widget, event):
"""When an area of the window is exposed, we just copy out of the
server-side, off-screen surface to that area.
"""
x, y, width, height = event.area
self.logger.debug("surface is %s" % self.surface)
if self.surface is not None:
... | python | {
"resource": ""
} |
q241302 | ImageViewGtk.size_request | train | def size_request(self, widget, requisition):
"""Callback function to request our desired size.
"""
requisition.width, requisition.height = self.get_desired_size()
return True | python | {
"resource": ""
} |
q241303 | GingaShell.get_plugin_spec | train | def get_plugin_spec(self, name):
"""Get the specification attributes for plugin with name `name`."""
l_name = name.lower()
for spec in self.plugins:
name = spec.get('name', spec.get('klass', spec.module))
if name.lower() == l_name:
return spec
rais... | python | {
"resource": ""
} |
q241304 | GingaShell.help_text | train | def help_text(self, name, text, text_kind='plain', trim_pfx=0):
"""
Provide help text for the user.
This method will convert the text as necessary with docutils and
display it in the WBrowser plugin, if available. If the plugin is
not available and the text is type 'rst' then t... | python | {
"resource": ""
} |
q241305 | GingaShell.load_file | train | def load_file(self, filepath, chname=None, wait=True,
create_channel=True, display_image=True,
image_loader=None):
"""Load a file and display it.
Parameters
----------
filepath : str
The path of the file to load (must reference a local fil... | python | {
"resource": ""
} |
q241306 | GingaShell.add_download | train | def add_download(self, info, future):
"""
Hand off a download to the Downloads plugin, if it is present.
Parameters
----------
info : `~ginga.misc.Bunch.Bunch`
A bunch of information about the URI as returned by
`ginga.util.iohelper.get_fileinfo()`
... | python | {
"resource": ""
} |
q241307 | GingaShell.open_file_cont | train | def open_file_cont(self, pathspec, loader_cont_fn):
"""Open a file and do some action on it.
Parameters
----------
pathspec : str
The path of the file to load (can be a URI, but must reference
a local file).
loader_cont_fn : func (data_obj) -> None
... | python | {
"resource": ""
} |
q241308 | GingaShell.open_uris | train | def open_uris(self, uris, chname=None, bulk_add=False):
"""Open a set of URIs.
Parameters
----------
uris : list of str
The URIs of the files to load
chname: str, optional (defaults to channel with focus)
The name of the channel in which to load the item... | python | {
"resource": ""
} |
q241309 | GingaShell.zoom_in | train | def zoom_in(self):
"""Zoom the view in one zoom step.
"""
viewer = self.getfocus_viewer()
if hasattr(viewer, 'zoom_in'):
viewer.zoom_in()
return True | python | {
"resource": ""
} |
q241310 | GingaShell.zoom_out | train | def zoom_out(self):
"""Zoom the view out one zoom step.
"""
viewer = self.getfocus_viewer()
if hasattr(viewer, 'zoom_out'):
viewer.zoom_out()
return True | python | {
"resource": ""
} |
q241311 | GingaShell.zoom_fit | train | def zoom_fit(self):
"""Zoom the view to fit the image entirely in the window.
"""
viewer = self.getfocus_viewer()
if hasattr(viewer, 'zoom_fit'):
viewer.zoom_fit()
return True | python | {
"resource": ""
} |
q241312 | GingaShell.prev_img_ws | train | def prev_img_ws(self, ws, loop=True):
"""Go to the previous image in the focused channel in the workspace.
"""
channel = self.get_active_channel_ws(ws)
if channel is None:
return
channel.prev_image()
return True | python | {
"resource": ""
} |
q241313 | GingaShell.next_img_ws | train | def next_img_ws(self, ws, loop=True):
"""Go to the next image in the focused channel in the workspace.
"""
channel = self.get_active_channel_ws(ws)
if channel is None:
return
channel.next_image()
return True | python | {
"resource": ""
} |
q241314 | GingaShell.prev_img | train | def prev_img(self, loop=True):
"""Go to the previous image in the channel.
"""
channel = self.get_current_channel()
if channel is None:
self.show_error("Please create a channel.", raisetab=True)
return
channel.prev_image()
return True | python | {
"resource": ""
} |
q241315 | GingaShell.next_img | train | def next_img(self, loop=True):
"""Go to the next image in the channel.
"""
channel = self.get_current_channel()
if channel is None:
self.show_error("Please create a channel.", raisetab=True)
return
channel.next_image()
return True | python | {
"resource": ""
} |
q241316 | GingaShell.close_plugins | train | def close_plugins(self, channel):
"""Close all plugins associated with the channel."""
opmon = channel.opmon
for key in opmon.get_active():
obj = opmon.get_plugin(key)
try:
self.gui_call(obj.close)
except Exception as e:
self.l... | python | {
"resource": ""
} |
q241317 | GingaShell.add_channel | train | def add_channel(self, chname, workspace=None,
num_images=None, settings=None,
settings_template=None,
settings_share=None, share_keylist=None):
"""Create a new Ginga channel.
Parameters
----------
chname : str
The n... | python | {
"resource": ""
} |
q241318 | GingaShell.delete_channel | train | def delete_channel(self, chname):
"""Delete a given channel from viewer."""
name = chname.lower()
if len(self.channel_names) < 1:
self.logger.error('Delete channel={0} failed. '
'No channels left.'.format(chname))
return
with self.l... | python | {
"resource": ""
} |
q241319 | GingaShell.add_menu | train | def add_menu(self, name):
"""Add a menu with name `name` to the global menu bar.
Returns a menu widget.
"""
if self.menubar is None:
raise ValueError("No menu bar configured")
return self.menubar.add_name(name) | python | {
"resource": ""
} |
q241320 | GingaShell.get_menu | train | def get_menu(self, name):
"""Get the menu with name `name` from the global menu bar.
Returns a menu widget.
"""
if self.menubar is None:
raise ValueError("No menu bar configured")
return self.menubar.get_menu(name) | python | {
"resource": ""
} |
q241321 | GingaShell.register_viewer | train | def register_viewer(self, vclass):
"""Register a channel viewer with the reference viewer.
`vclass` is the class of the viewer.
"""
self.viewer_db[vclass.vname] = Bunch.Bunch(vname=vclass.vname,
vclass=vclass,
... | python | {
"resource": ""
} |
q241322 | GingaShell.get_viewer_names | train | def get_viewer_names(self, dataobj):
"""Returns a list of viewer names that are registered that
can view `dataobj`.
"""
res = []
for bnch in self.viewer_db.values():
for vtype in bnch.vtypes:
if isinstance(dataobj, vtype):
res.appen... | python | {
"resource": ""
} |
q241323 | GingaShell.make_viewer | train | def make_viewer(self, vname, channel):
"""Make a viewer whose type name is `vname` and add it to `channel`.
"""
if vname not in self.viewer_db:
raise ValueError("I don't know how to build a '%s' viewer" % (
vname))
stk_w = channel.widget
bnch = self.... | python | {
"resource": ""
} |
q241324 | GingaShell.collapse_pane | train | def collapse_pane(self, side):
"""
Toggle collapsing the left or right panes.
"""
# TODO: this is too tied to one configuration, need to figure
# out how to generalize this
hsplit = self.w['hpnl']
sizes = hsplit.get_sizes()
lsize, msize, rsize = sizes
... | python | {
"resource": ""
} |
q241325 | GingaShell.quit | train | def quit(self, *args):
"""Quit the application.
"""
self.logger.info("Attempting to shut down the application...")
if self.layout_file is not None:
self.error_wrap(self.ds.write_layout_conf, self.layout_file)
self.stop()
self.w.root = None
while len(... | python | {
"resource": ""
} |
q241326 | GingaShell.showxy | train | def showxy(self, viewer, data_x, data_y):
"""Called by the mouse-tracking callback to handle reporting of
cursor position to various plugins that subscribe to the
'field-info' callback.
"""
# This is an optimization to get around slow coordinate
# transformation by astrop... | python | {
"resource": ""
} |
q241327 | GingaShell._cursor_timer_cb | train | def _cursor_timer_cb(self, timer):
"""Callback when the cursor timer expires.
"""
data = timer.data
self.gui_do_oneshot('field-info', self._showxy,
data.viewer, data.data_x, data.data_y) | python | {
"resource": ""
} |
q241328 | GingaShell._showxy | train | def _showxy(self, viewer, data_x, data_y):
"""Update the info from the last position recorded under the cursor.
"""
self._cursor_last_update = time.time()
try:
image = viewer.get_image()
if (image is None) or not isinstance(image, BaseImage.BaseImage):
... | python | {
"resource": ""
} |
q241329 | GingaShell.motion_cb | train | def motion_cb(self, viewer, button, data_x, data_y):
"""Motion event in the channel viewer window. Show the pointing
information under the cursor.
"""
self.showxy(viewer, data_x, data_y)
return True | python | {
"resource": ""
} |
q241330 | GingaShell.keypress | train | def keypress(self, viewer, event, data_x, data_y):
"""Key press event in a channel window."""
keyname = event.key
chname = self.get_channel_name(viewer)
self.logger.debug("key press (%s) in channel %s" % (
keyname, chname))
# TODO: keyboard accelerators to raise tabs ... | python | {
"resource": ""
} |
q241331 | GingaShell.show_channel_names | train | def show_channel_names(self):
"""Show each channel's name in its image viewer.
Useful in 'grid' or 'stack' workspace type to identify which window
is which.
"""
for name in self.get_channel_names():
channel = self.get_channel(name)
channel.fitsimage.onscre... | python | {
"resource": ""
} |
q241332 | TVMark._short_color_list | train | def _short_color_list(self):
"""Color list is too long. Discard variations with numbers."""
return [c for c in colors.get_colors() if not re.search(r'\d', c)] | python | {
"resource": ""
} |
q241333 | TVMark._get_markobj | train | def _get_markobj(self, x, y, marktype, marksize, markcolor, markwidth):
"""Generate canvas object for given mark parameters."""
if marktype == 'circle':
obj = self.dc.Circle(
x=x, y=y, radius=marksize, color=markcolor, linewidth=markwidth)
elif marktype in ('cross', '... | python | {
"resource": ""
} |
q241334 | TVMark.clear_marking | train | def clear_marking(self):
"""Clear marking from image.
This does not clear loaded coordinates from memory."""
if self.marktag:
try:
self.canvas.delete_object_by_tag(self.marktag, redraw=False)
except Exception:
pass
if self.markhlta... | python | {
"resource": ""
} |
q241335 | TVMark.load_file | train | def load_file(self, filename):
"""Load coordinates file.
Results are appended to previously loaded coordinates.
This can be used to load one file per color.
"""
if not os.path.isfile(filename):
return
self.logger.info('Loading coordinates from {0}'.format(f... | python | {
"resource": ""
} |
q241336 | TVMark._convert_radec | train | def _convert_radec(self, val):
"""Convert RA or DEC table column to degrees and extract data.
Assume already in degrees if cannot convert.
"""
try:
ans = val.to('deg')
except Exception as e:
self.logger.error('Cannot convert, assume already in degrees')
... | python | {
"resource": ""
} |
q241337 | TVMark.hl_table2canvas | train | def hl_table2canvas(self, w, res_dict):
"""Highlight marking on canvas when user click on table."""
objlist = []
width = self.markwidth + self._dwidth
# Remove existing highlight
if self.markhltag:
try:
self.canvas.delete_object_by_tag(self.markhltag,... | python | {
"resource": ""
} |
q241338 | TVMark.hl_canvas2table_box | train | def hl_canvas2table_box(self, canvas, tag):
"""Highlight all markings inside user drawn box on table."""
self.treeview.clear_selection()
# Remove existing box
cobj = canvas.get_object_by_tag(tag)
if cobj.kind != 'rectangle':
return
canvas.delete_object_by_tag... | python | {
"resource": ""
} |
q241339 | TVMark.hl_canvas2table | train | def hl_canvas2table(self, canvas, button, data_x, data_y):
"""Highlight marking on table when user click on canvas."""
self.treeview.clear_selection()
# Remove existing highlight
if self.markhltag:
try:
canvas.delete_object_by_tag(self.markhltag, redraw=True)... | python | {
"resource": ""
} |
q241340 | TVMark._highlight_path | train | def _highlight_path(self, hlpath):
"""Highlight an entry in the table and associated marking."""
self.logger.debug('Highlighting {0}'.format(hlpath))
self.treeview.select_path(hlpath)
# TODO: Does not work in Qt. This is known issue in Ginga.
self.treeview.scroll_to_path(hlpath) | python | {
"resource": ""
} |
q241341 | TVMark.set_marktype_cb | train | def set_marktype_cb(self, w, index):
"""Set type of marking."""
self.marktype = self._mark_options[index]
# Mark size is not used for point
if self.marktype != 'point':
self.w.mark_size.set_enabled(True)
else:
self.w.mark_size.set_enabled(False) | python | {
"resource": ""
} |
q241342 | TVMark.set_markwidth | train | def set_markwidth(self):
"""Set width of marking."""
try:
sz = int(self.w.mark_width.get_text())
except ValueError:
self.logger.error('Cannot set mark width')
self.w.mark_width.set_text(str(self.markwidth))
else:
self.markwidth = sz | python | {
"resource": ""
} |
q241343 | Header.redo | train | def redo(self, channel, image):
"""This is called when image changes."""
self._image = None # Skip cache checking in set_header()
info = channel.extdata._header_info
self.set_header(info, image) | python | {
"resource": ""
} |
q241344 | Header.blank | train | def blank(self, channel):
"""This is called when image is cleared."""
self._image = None
info = channel.extdata._header_info
info.table.clear() | python | {
"resource": ""
} |
q241345 | Clock.clock_resized_cb | train | def clock_resized_cb(self, viewer, width, height):
"""This method is called when an individual clock is resized.
It deletes and reconstructs the placement of the text objects
in the canvas.
"""
self.logger.info("resized canvas to %dx%d" % (width, height))
# add text objec... | python | {
"resource": ""
} |
q241346 | Clock.update_clock | train | def update_clock(self, dt):
"""This method is called by the ClockApp whenever the timer fires
to update the clock. `dt` is a timezone-aware datetime object.
"""
dt = dt.astimezone(self.tzinfo)
fmt = "%H:%M"
if self.show_seconds:
fmt = "%H:%M:%S"
self... | python | {
"resource": ""
} |
q241347 | ClockApp.add_clock | train | def add_clock(self, timezone, color='lightgreen', show_seconds=None):
"""Add a clock to the grid. `timezone` is a string representing
a valid timezone.
"""
if show_seconds is None:
show_seconds = self.options.show_seconds
clock = Clock(self.app, self.logger, timezon... | python | {
"resource": ""
} |
q241348 | ClockApp.timer_cb | train | def timer_cb(self, timer):
"""Timer callback. Update all our clocks."""
dt_now = datetime.utcnow().replace(tzinfo=pytz.utc)
self.logger.debug("timer fired. utc time is '%s'" % (str(dt_now)))
for clock in self.clocks.values():
clock.update_clock(dt_now)
# update clo... | python | {
"resource": ""
} |
q241349 | TableViewGw.set_table_cb | train | def set_table_cb(self, viewer, table):
"""Display the given table object."""
self.clear()
tree_dict = OrderedDict()
# Extract data as astropy table
a_tab = table.get_data()
# Fill masked values, if applicable
try:
a_tab = a_tab.filled()
excep... | python | {
"resource": ""
} |
q241350 | ChangeHistory.build_gui | train | def build_gui(self, container):
"""This method is called when the plugin is invoked. It builds the
GUI used by the plugin into the widget layout passed as
``container``.
This method could be called several times if the plugin is opened
and closed.
"""
vbox, sw,... | python | {
"resource": ""
} |
q241351 | ChangeHistory.redo | train | def redo(self, channel, image):
"""Add an entry with image modification info."""
chname = channel.name
if image is None:
# shouldn't happen, but let's play it safe
return
imname = image.get('name', 'none')
iminfo = channel.get_image_info(imname)
t... | python | {
"resource": ""
} |
q241352 | ChangeHistory.remove_image_info_cb | train | def remove_image_info_cb(self, gshell, channel, iminfo):
"""Delete entries related to deleted image."""
chname = channel.name
if chname not in self.name_dict:
return
fileDict = self.name_dict[chname]
name = iminfo.name
if name not in fileDict:
re... | python | {
"resource": ""
} |
q241353 | ChangeHistory.add_image_info_cb | train | def add_image_info_cb(self, gshell, channel, iminfo):
"""Add entries related to an added image."""
timestamp = iminfo.time_modified
if timestamp is None:
# Not an image we are interested in tracking
return
self.add_entry(channel.name, iminfo) | python | {
"resource": ""
} |
q241354 | Thumbs.drag_drop_cb | train | def drag_drop_cb(self, viewer, urls):
"""Punt drag-drops to the ginga shell.
"""
channel = self.fv.get_current_channel()
if channel is None:
return
self.fv.open_uris(urls, chname=channel.name, bulk_add=True)
return True | python | {
"resource": ""
} |
q241355 | Thumbs.update_highlights | train | def update_highlights(self, old_highlight_set, new_highlight_set):
"""Unhighlight the thumbnails represented by `old_highlight_set`
and highlight the ones represented by new_highlight_set.
Both are sets of thumbkeys.
"""
with self.thmblock:
un_hilite_set = old_highl... | python | {
"resource": ""
} |
q241356 | Thumbs.have_thumbnail | train | def have_thumbnail(self, fitsimage, image):
"""Returns True if we already have a thumbnail version of this image
cached, False otherwise.
"""
chname = self.fv.get_channel_name(fitsimage)
# Look up our version of the thumb
idx = image.get('idx', None)
path = image... | python | {
"resource": ""
} |
q241357 | Thumbs.auto_scroll | train | def auto_scroll(self, thumbkey):
"""Scroll the window to the thumb."""
if not self.gui_up:
return
# force scroll to bottom of thumbs, if checkbox is set
scrollp = self.w.auto_scroll.get_state()
if not scrollp:
return
bnch = self.thumb_dict[thumbke... | python | {
"resource": ""
} |
q241358 | Thumbs.clear_widget | train | def clear_widget(self):
"""
Clears the thumbnail display widget of all thumbnails, but does
not remove them from the thumb_dict or thumb_list.
"""
if not self.gui_up:
return
canvas = self.c_view.get_canvas()
canvas.delete_all_objects()
self.c_v... | python | {
"resource": ""
} |
q241359 | AstroImage.load_nddata | train | def load_nddata(self, ndd, naxispath=None):
"""Load from an astropy.nddata.NDData object.
"""
self.clear_metadata()
# Make a header based on any NDData metadata
ahdr = self.get_header()
ahdr.update(ndd.meta)
self.setup_data(ndd.data, naxispath=naxispath)
... | python | {
"resource": ""
} |
q241360 | AstroImage.set_naxispath | train | def set_naxispath(self, naxispath):
"""Choose a slice out of multidimensional data.
"""
revnaxis = list(naxispath)
revnaxis.reverse()
# construct slice view and extract it
view = tuple(revnaxis + [slice(None), slice(None)])
data = self.get_mddata()[view]
... | python | {
"resource": ""
} |
q241361 | AstroImage.get_keyword | train | def get_keyword(self, kwd, *args):
"""Get an item from the fits header, if any."""
try:
kwds = self.get_header()
return kwds[kwd]
except KeyError:
# return a default if there is one
if len(args) > 0:
return args[0]
raise... | python | {
"resource": ""
} |
q241362 | AstroImage.as_nddata | train | def as_nddata(self, nddata_class=None):
"Return a version of ourself as an astropy.nddata.NDData object"
if nddata_class is None:
from astropy.nddata import NDData
nddata_class = NDData
# transfer header, preserving ordering
ahdr = self.get_header()
heade... | python | {
"resource": ""
} |
q241363 | AstroImage.as_hdu | train | def as_hdu(self):
"Return a version of ourself as an astropy.io.fits.PrimaryHDU object"
from astropy.io import fits
# transfer header, preserving ordering
ahdr = self.get_header()
header = fits.Header(ahdr.items())
data = self.get_mddata()
hdu = fits.PrimaryHDU(... | python | {
"resource": ""
} |
q241364 | AstroImage.astype | train | def astype(self, type_name):
"""Convert AstroImage object to some other kind of object.
"""
if type_name == 'nddata':
return self.as_nddata()
if type_name == 'hdu':
return self.as_hdu()
raise ValueError("Unrecognized conversion type '%s'" % (type_name)) | python | {
"resource": ""
} |
q241365 | hmsToDeg | train | def hmsToDeg(h, m, s):
"""Convert RA hours, minutes, seconds into an angle in degrees."""
return h * degPerHMSHour + m * degPerHMSMin + s * degPerHMSSec | python | {
"resource": ""
} |
q241366 | hmsStrToDeg | train | def hmsStrToDeg(ra):
"""Convert a string representation of RA into a float in degrees."""
hour, min, sec = ra.split(':')
ra_deg = hmsToDeg(int(hour), int(min), float(sec))
return ra_deg | python | {
"resource": ""
} |
q241367 | dmsStrToDeg | train | def dmsStrToDeg(dec):
"""Convert a string representation of DEC into a float in degrees."""
sign_deg, min, sec = dec.split(':')
sign = sign_deg[0:1]
if sign not in ('+', '-'):
sign = '+'
deg = sign_deg
else:
deg = sign_deg[1:]
dec_deg = decTimeToDeg(sign, int(deg), int(mi... | python | {
"resource": ""
} |
q241368 | eqToEq2000 | train | def eqToEq2000(ra_deg, dec_deg, eq):
"""Convert Eq to Eq 2000."""
ra_rad = math.radians(ra_deg)
dec_rad = math.radians(dec_deg)
x = math.cos(dec_rad) * math.cos(ra_rad)
y = math.cos(dec_rad) * math.sin(ra_rad)
z = math.sin(dec_rad)
p11, p12, p13, p21, p22, p23, p31, p32, p33 = trans_coeff(... | python | {
"resource": ""
} |
q241369 | get_rotation_and_scale | train | def get_rotation_and_scale(header, skew_threshold=0.001):
"""Calculate rotation and CDELT."""
((xrot, yrot),
(cdelt1, cdelt2)) = get_xy_rotation_and_scale(header)
if math.fabs(xrot) - math.fabs(yrot) > skew_threshold:
raise ValueError("Skew detected: xrot=%.4f yrot=%.4f" % (
xrot, ... | python | {
"resource": ""
} |
q241370 | get_relative_orientation | train | def get_relative_orientation(image, ref_image):
"""Computes the relative orientation and scale of an image to a reference
image.
Parameters
----------
image
AstroImage based object
ref_image
AstroImage based object
Returns
-------
result
Bunch object contai... | python | {
"resource": ""
} |
q241371 | deg2fmt | train | def deg2fmt(ra_deg, dec_deg, format):
"""Format coordinates."""
rhr, rmn, rsec = degToHms(ra_deg)
dsgn, ddeg, dmn, dsec = degToDms(dec_deg)
if format == 'hms':
return rhr, rmn, rsec, dsgn, ddeg, dmn, dsec
elif format == 'str':
#ra_txt = '%02d:%02d:%06.3f' % (rhr, rmn, rsec)
... | python | {
"resource": ""
} |
q241372 | deltaStarsRaDecDeg1 | train | def deltaStarsRaDecDeg1(ra1_deg, dec1_deg, ra2_deg, dec2_deg):
"""Spherical triangulation."""
phi, dist = dispos(ra1_deg, dec1_deg, ra2_deg, dec2_deg)
return arcsecToDeg(dist * 60.0) | python | {
"resource": ""
} |
q241373 | get_starsep_RaDecDeg | train | def get_starsep_RaDecDeg(ra1_deg, dec1_deg, ra2_deg, dec2_deg):
"""Calculate separation."""
sep = deltaStarsRaDecDeg(ra1_deg, dec1_deg, ra2_deg, dec2_deg)
sgn, deg, mn, sec = degToDms(sep)
if deg != 0:
txt = '%02d:%02d:%06.3f' % (deg, mn, sec)
else:
txt = '%02d:%06.3f' % (mn, sec)
... | python | {
"resource": ""
} |
q241374 | get_RaDecOffsets | train | def get_RaDecOffsets(ra1_deg, dec1_deg, ra2_deg, dec2_deg):
"""Calculate offset."""
delta_ra_deg = ra1_deg - ra2_deg
adj = math.cos(math.radians(dec2_deg))
if delta_ra_deg > 180.0:
delta_ra_deg = (delta_ra_deg - 360.0) * adj
elif delta_ra_deg < -180.0:
delta_ra_deg = (delta_ra_deg + ... | python | {
"resource": ""
} |
q241375 | lon_to_deg | train | def lon_to_deg(lon):
"""Convert longitude to degrees."""
if isinstance(lon, str) and (':' in lon):
# TODO: handle other coordinate systems
lon_deg = hmsStrToDeg(lon)
else:
lon_deg = float(lon)
return lon_deg | python | {
"resource": ""
} |
q241376 | lat_to_deg | train | def lat_to_deg(lat):
"""Convert latitude to degrees."""
if isinstance(lat, str) and (':' in lat):
# TODO: handle other coordinate systems
lat_deg = dmsStrToDeg(lat)
else:
lat_deg = float(lat)
return lat_deg | python | {
"resource": ""
} |
q241377 | get_ruler_distances | train | def get_ruler_distances(image, p1, p2):
"""Get the distance calculated between two points. A Bunch of
results is returned, containing pixel values and distance values
if the image contains a valid WCS.
"""
x1, y1 = p1[:2]
x2, y2 = p2[:2]
dx, dy = x2 - x1, y2 - y1
res = Bunch.Bunch(x1=x... | python | {
"resource": ""
} |
q241378 | add_font | train | def add_font(font_file, font_name=None):
"""Add a font description to our directory of externally loadable fonts.
`font_file` is the path to the font, and optional `font_name` is the
name to register it under.
"""
global font_dir
if font_name is None:
# determine family name from filena... | python | {
"resource": ""
} |
q241379 | have_font | train | def have_font(font_name):
"""Return True if the given font name is registered as one of our
externally loadable fonts. If `font_name` is not found, it will try
to look it up as an alias and report if that is found.
"""
if font_name in font_dir:
return True
# try it as an alias
font... | python | {
"resource": ""
} |
q241380 | Drawing.toggle_create_button | train | def toggle_create_button(self):
"""Enable or disable Create Mask button based on drawn objects."""
if len(self._drawn_tags) > 0:
self.w.create_mask.set_enabled(True)
else:
self.w.create_mask.set_enabled(False) | python | {
"resource": ""
} |
q241381 | Drawing.create_mask | train | def create_mask(self):
"""Create boolean mask from drawing.
All areas enclosed by all the shapes drawn will be set to 1 (True)
in the mask. Otherwise, the values will be set to 0 (False).
The mask will be inserted as a new image buffer, like ``Mosaic``.
"""
ntags = len(... | python | {
"resource": ""
} |
q241382 | CommandInterpreter.cmd_load | train | def cmd_load(self, *args, **kwargs):
"""load file ... ch=chname
Read files or URLs into the given channel.
If the item is a path and it does not begin with a slash it is assumed
to be relative to the current working directory. File patterns can
also be provided.
"""
... | python | {
"resource": ""
} |
q241383 | CommandInterpreter.cmd_cuts | train | def cmd_cuts(self, lo=None, hi=None, ch=None):
"""cuts lo=val hi=val ch=chname
If neither `lo` nor `hi` is provided, returns the current cut levels.
Otherwise sets the corresponding cut level for the given channel.
If `ch` is omitted, assumes the current channel.
"""
vie... | python | {
"resource": ""
} |
q241384 | CommandInterpreter.cmd_ac | train | def cmd_ac(self, ch=None):
"""ac ch=chname
Calculate and set auto cut levels for the given channel.
If `ch` is omitted, assumes the current channel.
"""
viewer = self.get_viewer(ch)
if viewer is None:
self.log("No current viewer/channel.")
return
... | python | {
"resource": ""
} |
q241385 | CommandInterpreter.cmd_cm | train | def cmd_cm(self, nm=None, ch=None):
"""cm nm=color_map_name ch=chname
Set a color map (name `nm`) for the given channel.
If no value is given, reports the current color map.
"""
viewer = self.get_viewer(ch)
if viewer is None:
self.log("No current viewer/chann... | python | {
"resource": ""
} |
q241386 | CommandInterpreter.cmd_cminv | train | def cmd_cminv(self, ch=None):
"""cminv ch=chname
Invert the color map in the channel/viewer
"""
viewer = self.get_viewer(ch)
if viewer is None:
self.log("No current viewer/channel.")
return
viewer.invert_cmap() | python | {
"resource": ""
} |
q241387 | CommandInterpreter.cmd_dist | train | def cmd_dist(self, nm=None, ch=None):
"""dist nm=dist_name ch=chname
Set a color distribution for the given channel.
Possible values are linear, log, power, sqrt, squared, asinh, sinh,
and histeq.
If no value is given, reports the current color distribution
algorithm.
... | python | {
"resource": ""
} |
q241388 | CommandInterpreter.cmd_imap | train | def cmd_imap(self, nm=None, ch=None):
"""imap nm=intensity_map_name ch=chname
Set an intensity map (name `nm`) for the given channel.
If no value is given, reports the current intensity map.
"""
viewer = self.get_viewer(ch)
if viewer is None:
self.log("No cur... | python | {
"resource": ""
} |
q241389 | CommandInterpreter.cmd_rot | train | def cmd_rot(self, deg=None, ch=None):
"""rot deg=num_deg ch=chname
Rotate the image for the given viewer/channel by the given
number of degrees.
If no value is given, reports the current rotation.
"""
viewer = self.get_viewer(ch)
if viewer is None:
se... | python | {
"resource": ""
} |
q241390 | CommandInterpreter.cmd_tr | train | def cmd_tr(self, x=None, y=None, xy=None, ch=None):
"""tr x=0|1 y=0|1 xy=0|1 ch=chname
Transform the image for the given viewer/channel by flipping
(x=1 and/or y=1) or swapping axes (xy=1).
If no value is given, reports the current rotation.
"""
viewer = self.get_viewer(... | python | {
"resource": ""
} |
q241391 | CommandInterpreter.cmd_scale | train | def cmd_scale(self, x=None, y=None, ch=None):
"""scale x=scale_x y=scale_y ch=chname
Scale the image for the given viewer/channel by the given amounts.
If only one scale value is given, the other is assumed to be the
same. If no value is given, reports the current scale.
"""
... | python | {
"resource": ""
} |
q241392 | CommandInterpreter.cmd_z | train | def cmd_z(self, lvl=None, ch=None):
"""z lvl=level ch=chname
Zoom the image for the given viewer/channel to the given zoom
level. Levels can be positive or negative numbers and are
relative to a scale of 1:1 at zoom level 0.
"""
viewer = self.get_viewer(ch)
if v... | python | {
"resource": ""
} |
q241393 | CommandInterpreter.cmd_zf | train | def cmd_zf(self, ch=None):
"""zf ch=chname
Zoom the image for the given viewer/channel to fit the window.
"""
viewer = self.get_viewer(ch)
if viewer is None:
self.log("No current viewer/channel.")
return
viewer.zoom_fit()
cur_lvl = viewer... | python | {
"resource": ""
} |
q241394 | CommandInterpreter.cmd_c | train | def cmd_c(self, ch=None):
"""c ch=chname
Center the image for the given viewer/channel.
"""
viewer = self.get_viewer(ch)
if viewer is None:
self.log("No current viewer/channel.")
return
viewer.center_image() | python | {
"resource": ""
} |
q241395 | CommandInterpreter.cmd_pan | train | def cmd_pan(self, x=None, y=None, ch=None):
"""scale ch=chname x=pan_x y=pan_y
Set the pan position for the given viewer/channel to the given
pixel coordinates.
If no coordinates are given, reports the current position.
"""
viewer = self.get_viewer(ch)
if viewer ... | python | {
"resource": ""
} |
q241396 | TimerHeap.timer | train | def timer(self, jitter, action, *args, **kwargs):
"""Convenience method to create a Timer from the heap"""
return Timer(self, jitter, action, *args, **kwargs) | python | {
"resource": ""
} |
q241397 | TimerHeap.add | train | def add(self, timer):
"""Add a timer to the heap"""
with self.lock:
if self.heap:
top = self.heap[0]
else:
top = None
assert timer not in self.timers
self.timers[timer] = timer
heapq.heappush(self.heap, timer)
... | python | {
"resource": ""
} |
q241398 | TimerHeap._remove | train | def _remove(self, timer):
"""Remove timer from heap lock and presence are assumed"""
assert timer.timer_heap == self
del self.timers[timer]
assert timer in self.heap
self.heap.remove(timer)
heapq.heapify(self.heap) | python | {
"resource": ""
} |
q241399 | TimerHeap.remove | train | def remove(self, timer):
"""Remove a timer from the heap, return True if already run"""
with self.lock:
# This is somewhat expensive as we have to heapify.
if timer in self.timers:
self._remove(timer)
return False
else:
... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.