_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q241500
ImageViewBase.set_data
train
def set_data(self, data, metadata=None): """Set an image to be displayed by providing raw data. This is a convenience method for first constructing an image with `~ginga.AstroImage.AstroImage` and then calling :meth:`set_image`. Parameters ---------- data : ndarray ...
python
{ "resource": "" }
q241501
ImageViewBase.clear
train
def clear(self): """Clear the displayed image.""" self._imgobj = None try: # See if there is an image on the canvas self.canvas.delete_object_by_tag(self._canvas_img_tag) self.redraw() except KeyError: pass
python
{ "resource": "" }
q241502
ImageViewBase.redraw
train
def redraw(self, whence=0): """Redraw the canvas. Parameters ---------- whence See :meth:`get_rgb_object`. """ with self._defer_lock: whence = min(self._defer_whence, whence) if not self.defer_redraw: if self._hold_re...
python
{ "resource": "" }
q241503
ImageViewBase.canvas_changed_cb
train
def canvas_changed_cb(self, canvas, whence): """Handle callback for when canvas has changed.""" self.logger.debug("root canvas changed, whence=%d" % (whence)) # special check for whether image changed out from under us in # a shared canvas scenario try: # See if ther...
python
{ "resource": "" }
q241504
ImageViewBase.delayed_redraw
train
def delayed_redraw(self): """Handle delayed redrawing of the canvas.""" # This is the optimized redraw method with self._defer_lock: # pick up the lowest necessary level of redrawing whence = self._defer_whence self._defer_whence = self._defer_whence_reset ...
python
{ "resource": "" }
q241505
ImageViewBase.set_redraw_lag
train
def set_redraw_lag(self, lag_sec): """Set lag time for redrawing the canvas. Parameters ---------- lag_sec : float Number of seconds to wait. """ self.defer_redraw = (lag_sec > 0.0) if self.defer_redraw: self.defer_lagtime = lag_sec
python
{ "resource": "" }
q241506
ImageViewBase.set_refresh_rate
train
def set_refresh_rate(self, fps): """Set the refresh rate for redrawing the canvas at a timed interval. Parameters ---------- fps : float Desired rate in frames per second. """ self.rf_fps = fps self.rf_rate = 1.0 / self.rf_fps #self.set_redra...
python
{ "resource": "" }
q241507
ImageViewBase.start_refresh
train
def start_refresh(self): """Start redrawing the canvas at the previously set timed interval. """ self.logger.debug("starting timed refresh interval") self.rf_flags['done'] = False self.rf_draw_count = 0 self.rf_timer_count = 0 self.rf_late_count = 0 self.r...
python
{ "resource": "" }
q241508
ImageViewBase.stop_refresh
train
def stop_refresh(self): """Stop redrawing the canvas at the previously set timed interval. """ self.logger.debug("stopping timed refresh") self.rf_flags['done'] = True self.rf_timer.clear()
python
{ "resource": "" }
q241509
ImageViewBase.get_refresh_stats
train
def get_refresh_stats(self): """Return the measured statistics for timed refresh intervals. Returns ------- stats : float The measured rate of actual back end updates in frames per second. """ if self.rf_draw_count == 0: fps = 0.0 else: ...
python
{ "resource": "" }
q241510
ImageViewBase.refresh_timer_cb
train
def refresh_timer_cb(self, timer, flags): """Refresh timer callback. This callback will normally only be called internally. Parameters ---------- timer : a Ginga GUI timer A GUI-based Ginga timer flags : dict-like A set of flags controlling the t...
python
{ "resource": "" }
q241511
ImageViewBase.redraw_now
train
def redraw_now(self, whence=0): """Redraw the displayed image. Parameters ---------- whence See :meth:`get_rgb_object`. """ try: time_start = time.time() self.redraw_data(whence=whence) # finally update the window drawabl...
python
{ "resource": "" }
q241512
ImageViewBase.redraw_data
train
def redraw_data(self, whence=0): """Render image from RGB map and redraw private canvas. .. note:: Do not call this method unless you are implementing a subclass. Parameters ---------- whence See :meth:`get_rgb_object`. """ if not self....
python
{ "resource": "" }
q241513
ImageViewBase.check_cursor_location
train
def check_cursor_location(self): """Check whether the data location of the last known position of the cursor has changed. If so, issue a callback. """ # Check whether cursor data position has changed relative # to previous value data_x, data_y = self.get_data_xy(self.las...
python
{ "resource": "" }
q241514
ImageViewBase.getwin_array
train
def getwin_array(self, order='RGB', alpha=1.0, dtype=None): """Get Numpy data array for display window. Parameters ---------- order : str The desired order of RGB color layers. alpha : float Opacity. dtype : numpy dtype Numpy data ty...
python
{ "resource": "" }
q241515
ImageViewBase.get_datarect
train
def get_datarect(self): """Get the approximate bounding box of the displayed image. Returns ------- rect : tuple Bounding box in data coordinates in the form of ``(x1, y1, x2, y2)``. """ x1, y1, x2, y2 = self._org_x1, self._org_y1, self._org_x2, ...
python
{ "resource": "" }
q241516
ImageViewBase.get_limits
train
def get_limits(self, coord='data'): """Get the bounding box of the viewer extents. Returns ------- limits : tuple Bounding box in coordinates of type `coord` in the form of ``(ll_pt, ur_pt)``. """ limits = self.t_['limits'] if limits ...
python
{ "resource": "" }
q241517
ImageViewBase.set_limits
train
def set_limits(self, limits, coord='data'): """Set the bounding box of the viewer extents. Parameters ---------- limits : tuple or None A tuple setting the extents of the viewer in the form of ``(ll_pt, ur_pt)``. """ if limits is not None: ...
python
{ "resource": "" }
q241518
ImageViewBase.get_rgb_object
train
def get_rgb_object(self, whence=0): """Create and return RGB slices representing the data that should be rendered at the current zoom level and pan settings. Parameters ---------- whence : {0, 1, 2, 3} Optimization flag that reduces the time to create the...
python
{ "resource": "" }
q241519
ImageViewBase._reset_bbox
train
def _reset_bbox(self): """This function should only be called internally. It resets the viewers bounding box based on changes to pan or scale. """ scale_x, scale_y = self.get_scale_xy() pan_x, pan_y = self.get_pan(coord='data')[:2] win_wd, win_ht = self.get_window_size()...
python
{ "resource": "" }
q241520
ImageViewBase.overlay_images
train
def overlay_images(self, canvas, data, whence=0.0): """Overlay data from any canvas image objects. Parameters ---------- canvas : `~ginga.canvas.types.layer.DrawingCanvas` Canvas containing possible images to overlay. data : ndarray Output array on which...
python
{ "resource": "" }
q241521
ImageViewBase.convert_via_profile
train
def convert_via_profile(self, data_np, order, inprof_name, outprof_name): """Convert the given RGB data from the working ICC profile to the output profile in-place. Parameters ---------- data_np : ndarray RGB image data to be displayed. order : str ...
python
{ "resource": "" }
q241522
ImageViewBase.get_data_xy
train
def get_data_xy(self, win_x, win_y, center=None): """Get the closest coordinates in the data array to those reported on the window. Parameters ---------- win_x, win_y : float or ndarray Window coordinates. center : bool If `True`, then the coordi...
python
{ "resource": "" }
q241523
ImageViewBase.offset_to_window
train
def offset_to_window(self, off_x, off_y): """Convert data offset to window coordinates. Parameters ---------- off_x, off_y : float or ndarray Data offsets. Returns ------- coord : tuple Offset in window coordinates in the form of ``(x, y)...
python
{ "resource": "" }
q241524
ImageViewBase.get_pan_rect
train
def get_pan_rect(self): """Get the coordinates in the actual data corresponding to the area shown in the display for the current zoom level and pan. Returns ------- points : list Coordinates in the form of ``[(x0, y0), (x1, y1), (x2, y2), (x3, y3)]`` ...
python
{ "resource": "" }
q241525
ImageViewBase.get_data
train
def get_data(self, data_x, data_y): """Get the data value at the given position. Indices are zero-based, as in Numpy. Parameters ---------- data_x, data_y : int Data indices for X and Y, respectively. Returns ------- value Data sl...
python
{ "resource": "" }
q241526
ImageViewBase.get_pixel_distance
train
def get_pixel_distance(self, x1, y1, x2, y2): """Calculate distance between the given pixel positions. Parameters ---------- x1, y1, x2, y2 : number Pixel coordinates. Returns ------- dist : float Rounded distance. """ dx...
python
{ "resource": "" }
q241527
ImageViewBase._sanity_check_scale
train
def _sanity_check_scale(self, scale_x, scale_y): """Do a sanity check on the proposed scale vs. window size. Raises an exception if there will be a problem. """ win_wd, win_ht = self.get_window_size() if (win_wd <= 0) or (win_ht <= 0): raise ImageViewError("window siz...
python
{ "resource": "" }
q241528
ImageViewBase.scale_cb
train
def scale_cb(self, setting, value): """Handle callback related to image scaling.""" zoomlevel = self.zoom.calc_level(value) self.t_.set(zoomlevel=zoomlevel) self.redraw(whence=0)
python
{ "resource": "" }
q241529
ImageViewBase.set_scale_base_xy
train
def set_scale_base_xy(self, scale_x_base, scale_y_base): """Set stretch factors. Parameters ---------- scale_x_base, scale_y_base : float Stretch factors for X and Y, respectively. """ self.t_.set(scale_x_base=scale_x_base, scale_y_base=scale_y_base)
python
{ "resource": "" }
q241530
ImageViewBase.get_scale_text
train
def get_scale_text(self): """Report current scaling in human-readable format. Returns ------- text : str ``'<num> x'`` if enlarged, or ``'1/<num> x'`` if shrunken. """ scalefactor = self.get_scale_max() if scalefactor >= 1.0: text = '%.2f...
python
{ "resource": "" }
q241531
ImageViewBase.set_zoom_algorithm
train
def set_zoom_algorithm(self, name): """Set zoom algorithm. Parameters ---------- name : str Name of a zoom algorithm to use. """ name = name.lower() alg_names = list(zoom.get_zoom_alg_names()) if name not in alg_names: raise Image...
python
{ "resource": "" }
q241532
ImageViewBase.zoomsetting_change_cb
train
def zoomsetting_change_cb(self, setting, value): """Handle callback related to changes in zoom.""" alg_name = self.t_['zoom_algorithm'] self.zoom = zoom.get_zoom_alg(alg_name)(self) self.zoom_to(self.get_zoom())
python
{ "resource": "" }
q241533
ImageViewBase.interpolation_change_cb
train
def interpolation_change_cb(self, setting, value): """Handle callback related to changes in interpolation.""" canvas_img = self.get_canvas_image() canvas_img.interpolation = value canvas_img.reset_optimize() self.redraw(whence=0)
python
{ "resource": "" }
q241534
ImageViewBase.set_scale_limits
train
def set_scale_limits(self, scale_min, scale_max): """Set scale limits. Parameters ---------- scale_min, scale_max : float Minimum and maximum scale limits, respectively. """ # TODO: force scale to within limits if already outside? self.t_.set(scale_m...
python
{ "resource": "" }
q241535
ImageViewBase.enable_autozoom
train
def enable_autozoom(self, option): """Set ``autozoom`` behavior. Parameters ---------- option : {'on', 'override', 'once', 'off'} Option for zoom behavior. A list of acceptable options can also be obtained by :meth:`get_autozoom_options`. Raises ...
python
{ "resource": "" }
q241536
ImageViewBase.set_pan
train
def set_pan(self, pan_x, pan_y, coord='data', no_reset=False): """Set pan position. Parameters ---------- pan_x, pan_y : float Pan positions in X and Y. coord : {'data', 'wcs'} Indicates whether the given pan positions are in data or WCS space. ...
python
{ "resource": "" }
q241537
ImageViewBase.pan_cb
train
def pan_cb(self, setting, value): """Handle callback related to changes in pan.""" pan_x, pan_y = value[:2] self.logger.debug("pan set to %.2f,%.2f" % (pan_x, pan_y)) self.redraw(whence=0)
python
{ "resource": "" }
q241538
ImageViewBase.get_pan
train
def get_pan(self, coord='data'): """Get pan positions. Parameters ---------- coord : {'data', 'wcs'} Indicates whether the pan positions are returned in data or WCS space. Returns ------- positions : tuple X and Y positions, i...
python
{ "resource": "" }
q241539
ImageViewBase.center_image
train
def center_image(self, no_reset=True): """Pan to the center of the image. Parameters ---------- no_reset : bool See :meth:`set_pan`. """ try: xy_mn, xy_mx = self.get_limits() data_x = float(xy_mn[0] + xy_mx[0]) / 2.0 data_...
python
{ "resource": "" }
q241540
ImageViewBase.enable_autocenter
train
def enable_autocenter(self, option): """Set ``autocenter`` behavior. Parameters ---------- option : {'on', 'override', 'once', 'off'} Option for auto-center behavior. A list of acceptable options can also be obtained by :meth:`get_autocenter_options`. Ra...
python
{ "resource": "" }
q241541
ImageViewBase.cut_levels
train
def cut_levels(self, loval, hival, no_reset=False): """Apply cut levels on the image view. Parameters ---------- loval, hival : float Low and high values of the cut levels, respectively. no_reset : bool Do not reset ``autocuts`` setting. """ ...
python
{ "resource": "" }
q241542
ImageViewBase.auto_levels
train
def auto_levels(self, autocuts=None): """Apply auto-cut levels on the image view. Parameters ---------- autocuts : subclass of `~ginga.AutoCuts.AutoCutsBase` or `None` An object that implements the desired auto-cut algorithm. If not given, use algorithm from pref...
python
{ "resource": "" }
q241543
ImageViewBase.auto_levels_cb
train
def auto_levels_cb(self, setting, value): """Handle callback related to changes in auto-cut levels.""" # Did we change the method? method = self.t_['autocut_method'] params = self.t_.get('autocut_params', []) params = dict(params) if method != str(self.autocuts): ...
python
{ "resource": "" }
q241544
ImageViewBase.enable_autocuts
train
def enable_autocuts(self, option): """Set ``autocuts`` behavior. Parameters ---------- option : {'on', 'override', 'once', 'off'} Option for auto-cut behavior. A list of acceptable options can also be obtained by :meth:`get_autocuts_options`. Raises ...
python
{ "resource": "" }
q241545
ImageViewBase.set_autocut_params
train
def set_autocut_params(self, method, **params): """Set auto-cut parameters. Parameters ---------- method : str Auto-cut algorithm. A list of acceptable options can be obtained by :meth:`get_autocut_methods`. params : dict Algorithm-specific ...
python
{ "resource": "" }
q241546
ImageViewBase.transform
train
def transform(self, flip_x, flip_y, swap_xy): """Transform view of the image. .. note:: Transforming the image is generally faster than rotating, if rotating in 90 degree increments. Also see :meth:`rotate`. Parameters ---------- flipx, flipy : bool ...
python
{ "resource": "" }
q241547
ImageViewBase.transform_cb
train
def transform_cb(self, setting, value): """Handle callback related to changes in transformations.""" self.make_callback('transform') # whence=0 because need to calculate new extents for proper # cutout for rotation (TODO: always make extents consider # room for rotation) ...
python
{ "resource": "" }
q241548
ImageViewBase.copy_attributes
train
def copy_attributes(self, dst_fi, attrlist, share=False): """Copy interesting attributes of our configuration to another image view. Parameters ---------- dst_fi : subclass of `ImageViewBase` Another instance of image view. attrlist : list A list...
python
{ "resource": "" }
q241549
ImageViewBase.auto_orient
train
def auto_orient(self): """Set the orientation for the image to a reasonable default.""" image = self.get_image() if image is None: return invert_y = not isinstance(image, AstroImage.AstroImage) # Check for various things to set based on metadata header = imag...
python
{ "resource": "" }
q241550
ImageViewBase.get_image_as_buffer
train
def get_image_as_buffer(self, output=None): """Get the current image shown in the viewer, with any overlaid graphics, in a IO buffer with channels as needed and ordered by the back end widget. This can be overridden by subclasses. Parameters ---------- output : ...
python
{ "resource": "" }
q241551
ImageViewBase.get_rgb_image_as_bytes
train
def get_rgb_image_as_bytes(self, format='png', quality=90): """Get the current image shown in the viewer, with any overlaid graphics, in the form of a buffer in the form of bytes. Parameters ---------- format : str See :meth:`get_rgb_image_as_buffer`. qualit...
python
{ "resource": "" }
q241552
ImageViewBase.save_rgb_image_as_file
train
def save_rgb_image_as_file(self, filepath, format='png', quality=90): """Save the current image shown in the viewer, with any overlaid graphics, in a file with the specified format and quality. This can be overridden by subclasses. Parameters ---------- filepath : str ...
python
{ "resource": "" }
q241553
ImageViewBase.set_onscreen_message
train
def set_onscreen_message(self, text, redraw=True): """Called by a subclass to update the onscreen message. Parameters ---------- text : str The text to show in the display. """ width, height = self.get_window_size() font = self.t_.get('onscreen_font...
python
{ "resource": "" }
q241554
ImageViewBase._calc_font_size
train
def _calc_font_size(self, win_wd): """Heuristic to calculate an appropriate font size based on the width of the viewer window. Parameters ---------- win_wd : int The width of the viewer window. Returns ------- font_size : int Appr...
python
{ "resource": "" }
q241555
FileSelection.popup
train
def popup(self, title, callfn, initialdir=None, filename=None): """Let user select and load file.""" self.cb = callfn self.filew.set_title(title) if initialdir: self.filew.set_current_folder(initialdir) if filename: #self.filew.set_filename(filename) ...
python
{ "resource": "" }
q241556
get_fileinfo
train
def get_fileinfo(self, filespec, dldir=None): """Break down a file specification into its components. Parameters ---------- filespec : str The path of the file to load (can be a URL). dldir Returns ------- res : `~ginga.misc.Bunch.Bunch` """ if dldir is None: ...
python
{ "resource": "" }
q241557
Zoom.zoomset_cb
train
def zoomset_cb(self, setting, zoomlevel, fitsimage): """This method is called when a main FITS widget changes zoom level. """ if not self.gui_up: return fac_x, fac_y = fitsimage.get_scale_base_xy() fac_x_me, fac_y_me = self.zoomimage.get_scale_base_xy() if (fa...
python
{ "resource": "" }
q241558
Zoom.set_amount_cb
train
def set_amount_cb(self, widget, val): """This method is called when 'Zoom Amount' control is adjusted. """ self.zoom_amount = val zoomlevel = self.fitsimage_focus.get_zoom() self._zoomset(self.fitsimage_focus, zoomlevel)
python
{ "resource": "" }
q241559
RemoteImage._slice
train
def _slice(self, view): """ Send view to remote server and do slicing there. """ if self._data is not None: return self._data[view] return self._proxy.get_view(self.id, view)
python
{ "resource": "" }
q241560
MyGlobalPlugin.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. The method may be omi...
python
{ "resource": "" }
q241561
MyGlobalPlugin.focus_cb
train
def focus_cb(self, viewer, channel): """ Callback from the reference viewer shell when the focus changes between channels. """ chname = channel.name if self.active != chname: # focus has shifted to a different channel than our idea # of the active...
python
{ "resource": "" }
q241562
MyGlobalPlugin.redo
train
def redo(self, channel, image): """ Called from the reference viewer shell when a new image has been added to a channel. """ chname = channel.name # Only update our GUI if the activity is in the focused # channel if self.active == chname: imna...
python
{ "resource": "" }
q241563
_main
train
def _main(): """Run from command line.""" usage = "usage: %prog [options] cmd [arg] ..." optprs = OptionParser(usage=usage, version=version) optprs.add_option("--debug", dest="debug", default=False, action="store_true", help="Enter the pdb debugger on main()"...
python
{ "resource": "" }
q241564
RGBFileHandler._imload
train
def _imload(self, filepath, kwds): """Load an image file, guessing the format, and return a numpy array containing an RGB image. If EXIF keywords can be read they are returned in the dict _kwds_. """ start_time = time.time() typ, enc = mimetypes.guess_type(filepath) ...
python
{ "resource": "" }
q241565
RGBFileHandler.imresize
train
def imresize(self, data, new_wd, new_ht, method='bilinear'): """Scale an image in numpy array _data_ to the specified width and height. A smooth scaling is preferred. """ old_ht, old_wd = data.shape[:2] start_time = time.time() if have_pilutil: means = 'PIL'...
python
{ "resource": "" }
q241566
RGBPlanes.get_array
train
def get_array(self, order, dtype=None): """Get Numpy array that represents the RGB layers. Parameters ---------- order : str The desired order of RGB color layers. Returns ------- arr : ndarray Numpy array that represents the RGB layers. ...
python
{ "resource": "" }
q241567
RGBMapper.set_cmap
train
def set_cmap(self, cmap, callback=True): """ Set the color map used by this RGBMapper. `cmap` specifies a ColorMap object. If `callback` is True, then any callbacks associated with this change will be invoked. """ self.cmap = cmap with self.suppress_changed: ...
python
{ "resource": "" }
q241568
RGBMapper.set_imap
train
def set_imap(self, imap, callback=True): """ Set the intensity map used by this RGBMapper. `imap` specifies an IntensityMap object. If `callback` is True, then any callbacks associated with this change will be invoked. """ self.imap = imap self.calc_imap() ...
python
{ "resource": "" }
q241569
RGBMapper.stretch
train
def stretch(self, scale_factor, callback=True): """Stretch the color map via altering the shift map. """ self.scale_pct *= scale_factor self.scale_and_shift(self.scale_pct, 0.0, callback=callback)
python
{ "resource": "" }
q241570
WCSMatch._set_reference_channel_cb
train
def _set_reference_channel_cb(self, w, idx): """This is the GUI callback for the control that sets the reference channel. """ chname = self.chnames[idx] self._set_reference_channel(chname)
python
{ "resource": "" }
q241571
WCSMatch.set_reference_channel
train
def set_reference_channel(self, chname): """This is the API call to set the reference channel. """ # change the GUI control to match idx = self.chnames.index(str(chname)) self.w.ref_channel.set_index(idx) return self._set_reference_channel(chname)
python
{ "resource": "" }
q241572
WCSMatch.zoomset_cb
train
def zoomset_cb(self, setting, value, chviewer, info): """This callback is called when a channel window is zoomed. """ return self.zoomset(chviewer, info.chinfo)
python
{ "resource": "" }
q241573
WCSMatch.rotset_cb
train
def rotset_cb(self, setting, value, chviewer, info): """This callback is called when a channel window is rotated. """ return self.rotset(chviewer, info.chinfo)
python
{ "resource": "" }
q241574
WCSMatch.panset_cb
train
def panset_cb(self, setting, value, chviewer, info): """This callback is called when a channel window is panned. """ return self.panset(chviewer, info.chinfo)
python
{ "resource": "" }
q241575
TimerFactory.timer_tick
train
def timer_tick(self): """Callback executed every self.base_interval_msec to check timer expirations. """ # TODO: should exceptions thrown from this be caught and ignored self.process_timers() delta = datetime.timedelta(milliseconds=self.base_interval_msec) self._...
python
{ "resource": "" }
q241576
ColorMapPicker.select_cb
train
def select_cb(self, viewer, event, data_x, data_y): """Called when the user clicks on the color bar viewer. Calculate the index of the color bar they clicked on and set that color map in the current channel viewer. """ if not (self._cmxoff <= data_x < self._cmwd): # n...
python
{ "resource": "" }
q241577
ColorMapPicker.scroll_cb
train
def scroll_cb(self, viewer, direction, amt, data_x, data_y): """Called when the user scrolls in the color bar viewer. Pan up or down to show additional bars. """ bd = viewer.get_bindings() direction = bd.get_direction(direction) pan_x, pan_y = viewer.get_pan()[:2] ...
python
{ "resource": "" }
q241578
ColorMapPicker.rebuild_cmaps
train
def rebuild_cmaps(self): """Builds a color RGB image containing color bars of all the possible color maps and their labels. """ self.logger.info("building color maps image") ht, wd, sep = self._cmht, self._cmwd, self._cmsep viewer = self.p_view # put the canvas i...
python
{ "resource": "" }
q241579
Desktop.record_sizes
train
def record_sizes(self): """Record sizes of all container widgets in the layout. The sizes are recorded in the `params` mappings in the layout. """ for rec in self.node.values(): w = rec.widget wd, ht = w.get_size() rec.params.update(dict(name=rec.name...
python
{ "resource": "" }
q241580
GingaWrapper.help
train
def help(self, *args): """Get help for a remote interface method. Examples -------- help('ginga', `method`) name of the method for which you want help help('channel', `chname`, `method`) name of the method in the channel for which you want help ...
python
{ "resource": "" }
q241581
GingaWrapper.load_buffer
train
def load_buffer(self, imname, chname, img_buf, dims, dtype, header, metadata, compressed): """Display a FITS image buffer. Parameters ---------- imname : string a name to use for the image in Ginga chname : string channel in which to l...
python
{ "resource": "" }
q241582
use
train
def use(name): """ Set the name of the GUI toolkit we should use. """ global toolkit, family name = name.lower() if name.startswith('choose'): pass elif name.startswith('qt') or name.startswith('pyside'): family = 'qt' if name == 'qt': name = 'qt4' ...
python
{ "resource": "" }
q241583
SettingGroup.share_settings
train
def share_settings(self, other, keylist=None, include_callbacks=True, callback=True): """Sharing settings with `other` """ if keylist is None: keylist = self.group.keys() if include_callbacks: for key in keylist: oset, mset =...
python
{ "resource": "" }
q241584
use
train
def use(wcspkg, raise_err=True): """Choose WCS package.""" global coord_types, wcs_configured, WCS if wcspkg not in common.custom_wcs: # Try to dynamically load WCS modname = 'wcs_%s' % (wcspkg) path = os.path.join(wcs_home, '%s.py' % (modname)) try: my_import(mo...
python
{ "resource": "" }
q241585
PlotTable._set_combobox
train
def _set_combobox(self, attrname, vals, default=0): """Populate combobox with given list.""" combobox = getattr(self.w, attrname) for val in vals: combobox.append_text(val) if default > len(vals): default = 0 val = vals[default] combobox.show_text(...
python
{ "resource": "" }
q241586
PlotTable.clear_data
train
def clear_data(self): """Clear comboboxes and columns.""" self.tab = None self.cols = [] self._idx = [] self.x_col = '' self.y_col = '' self.w.xcombo.clear() self.w.ycombo.clear() self.w.x_lo.set_text('') self.w.x_hi.set_text('') se...
python
{ "resource": "" }
q241587
PlotTable.clear_plot
train
def clear_plot(self): """Clear plot display.""" self.tab_plot.clear() self.tab_plot.draw() self.save_plot.set_enabled(False)
python
{ "resource": "" }
q241588
PlotTable.plot_two_columns
train
def plot_two_columns(self, reset_xlimits=False, reset_ylimits=False): """Simple line plot for two selected columns.""" self.clear_plot() if self.tab is None: # No table data to plot return plt_kw = { 'lw': self.settings.get('linewidth', 1), 'ls': se...
python
{ "resource": "" }
q241589
PlotTable._get_plot_data
train
def _get_plot_data(self): """Extract only good data point for plotting.""" _marker_type = self.settings.get('markerstyle', 'o') if self.x_col == self._idxname: x_data = self._idx else: x_data = self.tab[self.x_col].data if self.y_col == self._idxname: ...
python
{ "resource": "" }
q241590
PlotTable._get_label
train
def _get_label(self, axis): """Return plot label for column for the given axis.""" if axis == 'x': colname = self.x_col else: # y colname = self.y_col if colname == self._idxname: label = 'Index' else: col = self.tab[colname] ...
python
{ "resource": "" }
q241591
PlotTable.x_select_cb
train
def x_select_cb(self, w, index): """Callback to set X-axis column.""" try: self.x_col = self.cols[index] except IndexError as e: self.logger.error(str(e)) else: self.plot_two_columns(reset_xlimits=True)
python
{ "resource": "" }
q241592
PlotTable.y_select_cb
train
def y_select_cb(self, w, index): """Callback to set Y-axis column.""" try: self.y_col = self.cols[index] except IndexError as e: self.logger.error(str(e)) else: self.plot_two_columns(reset_ylimits=True)
python
{ "resource": "" }
q241593
PlotTable.save_cb
train
def save_cb(self): """Save plot to file.""" # This just defines the basename. # Extension has to be explicitly defined or things can get messy. w = Widgets.SaveDialog(title='Save plot') target = w.get_path() if target is None: # Save canceled retu...
python
{ "resource": "" }
q241594
convert
train
def convert(filepath, outfilepath): """Convert FITS image to PDF.""" logger = logging.getLogger("example1") logger.setLevel(logging.INFO) fmt = logging.Formatter(STD_FORMAT) stderrHdlr = logging.StreamHandler() stderrHdlr.setFormatter(fmt) logger.addHandler(stderrHdlr) fi = ImageViewCa...
python
{ "resource": "" }
q241595
TVMask.redo
train
def redo(self): """Image or masks have changed. Clear and redraw.""" if not self.gui_up: return self.clear_mask() image = self.fitsimage.get_image() if image is None: return n_obj = len(self._maskobjs) self.logger.debug('Displaying {0} m...
python
{ "resource": "" }
q241596
TVMask.clear_mask
train
def clear_mask(self): """Clear mask from image. This does not clear loaded masks from memory.""" if self.masktag: try: self.canvas.delete_object_by_tag(self.masktag, redraw=False) except Exception: pass if self.maskhltag: ...
python
{ "resource": "" }
q241597
TVMask.load_file
train
def load_file(self, filename): """Load mask image. Results are appended to previously loaded masks. This can be used to load mask per color. """ if not os.path.isfile(filename): return self.logger.info('Loading mask image from {0}'.format(filename)) ...
python
{ "resource": "" }
q241598
TVMask._rgbtomask
train
def _rgbtomask(self, obj): """Convert RGB arrays from mask canvas object back to boolean mask.""" dat = obj.get_image().get_data() # RGB arrays return dat.sum(axis=2).astype(np.bool)
python
{ "resource": "" }
q241599
TVMask.hl_table2canvas
train
def hl_table2canvas(self, w, res_dict): """Highlight mask on canvas when user click on table.""" objlist = [] # Remove existing highlight if self.maskhltag: try: self.canvas.delete_object_by_tag(self.maskhltag, redraw=False) except Exception: ...
python
{ "resource": "" }