LSST Applications 29.0.1,g0fba68d861+132dd21e0a,g107a963962+1bb9f809a9,g1fd858c14a+005be21cae,g21d47ad084+8a07b29876,g325378336f+5d73323c8f,g330003fc43+40b4eaffc6,g35bb328faa+fcb1d3bbc8,g36ff55ed5b+9c28a42a87,g4e0f332c67+5fbd1e3e73,g53246c7159+fcb1d3bbc8,g60b5630c4e+9c28a42a87,g67b6fd64d1+a38b34ea13,g78460c75b0+2f9a1b4bcd,g786e29fd12+cf7ec2a62a,g7b71ed6315+fcb1d3bbc8,g86c591e316+6b2b2d0295,g8852436030+bf14db0e33,g89139ef638+a38b34ea13,g8b8da53e10+e3777245af,g9125e01d80+fcb1d3bbc8,g989de1cb63+a38b34ea13,g9f1445be69+9c28a42a87,g9f33ca652e+52c8f07962,ga9baa6287d+9c28a42a87,ga9e4eb89a6+9f84bd6575,gabe3b4be73+1e0a283bba,gb037a4e798+f3cbcd26c0,gb1101e3267+e7be8da0f8,gb58c049af0+f03b321e39,gb89ab40317+a38b34ea13,gcf25f946ba+bf14db0e33,gd6cbbdb0b4+bce7f7457e,gd9a9a58781+fcb1d3bbc8,gde0f65d7ad+53d424b1ae,ge278dab8ac+222406d50a,ge410e46f29+a38b34ea13,ge80e9994a3+664d6357dc,gf67bdafdda+a38b34ea13
LSST Data Management Base Package
Loading...
Searching...
No Matches
lsst.display.firefly.firefly.DisplayImpl Class Reference
Inheritance diagram for lsst.display.firefly.firefly.DisplayImpl:
lsst.afw.display.virtualDevice.DisplayImpl

Public Member Functions

 __init__ (self, display, verbose=False, url=None, name=None, *args, **kwargs)
 
 getClient (self)
 
 clearViewer (self)
 
 resetLayout (self)
 
 overlayFootprints (self, catalog, color='rgba(74, 144, 226, 0.60)', highlightColor='cyan', selectColor='orange', style='fill', layerString='detection footprints ', titleString='catalog footprints ')
 

Public Attributes

 display = display
 
 verbose = verbose
 
 frame
 

Protected Member Functions

 _getRegionLayerId (self)
 
 _clearImage (self)
 
 _mtv (self, image, mask=None, wcs=None, title="", metadata=None)
 
 _remove_masks (self)
 
 _buffer (self, enable=True)
 Enable or disable buffering of writes to the display param enable True or False, as appropriate.
 
 _flush (self)
 Flush any I/O buffers.
 
 _uploadTextData (self, regions)
 
 _close (self)
 
 _dot (self, symb, c, r, size, ctype, fontFamily="helvetica", textAngle=None)
 
 _drawLines (self, points, ctype)
 
 _erase (self)
 
 _setCallback (self, what, func)
 
 _getEvent (self)
 
 _scale (self, algorithm, min, max, unit=None, *args, **kwargs)
 
 _setMaskTransparency (self, transparency, maskName)
 
 _getMaskTransparency (self, maskName)
 
 _setMaskPlaneColor (self, maskName, color)
 
 _show (self)
 
 _zoom (self, zoomfac)
 
 _pan (self, colc, rowc)
 
 _setImageColormap (self, cmap)
 

Protected Attributes

bool _isBuffered = False
 
list _regions = []
 
 _regionLayerId = self._getRegionLayerId()
 
 _fireflyFitsID = None
 
 _fireflyMaskOnServer = None
 
 _client = _fireflyClient
 
 _channel = _fireflyClient.channel
 
 _url = _fireflyClient.get_firefly_url()
 
list _maskIds = []
 
dict _maskDict = {}
 
dict _maskPlaneColors = {}
 
dict _maskTransparencies = {}
 
 _lastZoom = None
 
list _lastPan = None
 
 _lastStretch = None
 
 _stretchAlgorithm = algorithm
 
 _stretchMin = min
 
 _stretchMax = max
 
 _stretchUnit = unit
 

Detailed Description

Device to talk to a firefly display

Definition at line 56 of file firefly.py.

Constructor & Destructor Documentation

◆ __init__()

lsst.display.firefly.firefly.DisplayImpl.__init__ ( self,
display,
verbose = False,
url = None,
name = None,
* args,
** kwargs )

Definition at line 76 of file firefly.py.

77 name=None, *args, **kwargs):
78 virtualDevice.DisplayImpl.__init__(self, display, verbose)
79
80 if self.verbose:
81 print("Opening firefly device %s" % (self.display.frame if self.display else "[None]"))
82
83 global _fireflyClient
84 if not _fireflyClient:
85 import os
86 start_tab = None
87 html_file = kwargs.get('html_file',
88 os.environ.get('FIREFLY_HTML', ''))
89 if url is None:
90 if (('fireflyLabExtension' in os.environ) and
91 ('fireflyURLLab' in os.environ)):
92 url = os.environ['fireflyURLLab']
93 start_tab = kwargs.get('start_tab', True)
94 start_browser_tab = kwargs.get('start_browser_tab', False)
95 if (name is None) and ('fireflyChannelLab' in os.environ):
96 name = os.environ['fireflyChannelLab']
97 elif 'FIREFLY_URL' in os.environ:
98 url = os.environ['FIREFLY_URL']
99 else:
100 raise RuntimeError('Cannot determine url from environment; you must pass url')
101
102 token = kwargs.get('token',
103 os.environ.get('ACCESS_TOKEN', None))
104
105 try:
106 if start_tab:
107 if verbose:
108 print('Starting Jupyterlab client')
109 _fireflyClient = firefly_client.FireflyClient.make_lab_client(
110 start_tab=True, start_browser_tab=start_browser_tab,
111 html_file=html_file, verbose=verbose,
112 token=token)
113
114 else:
115 if verbose:
116 print('Starting vanilla client')
117 _fireflyClient = firefly_client.FireflyClient.make_client(
118 url=url, html_file=html_file, launch_browser=True,
119 channel_override=name, verbose=verbose,
120 token=token)
121
122 except (HandshakeError, gaierror) as e:
123 raise RuntimeError(f"Unable to connect to {url or ''}: {e}")
124
125 try:
126 _fireflyClient.add_listener(self.__handleCallbacks)
127 except Exception as e:
128 raise RuntimeError("Cannot add listener. Browser must be connected"
129 f"to {_fireflyClient.get_firefly_url()}: {e}")
130
131 self._isBuffered = False
132 self._regions = []
133 self._regionLayerId = self._getRegionLayerId()
134 self._fireflyFitsID = None
135 self._fireflyMaskOnServer = None
136 self._client = _fireflyClient
137 self._channel = _fireflyClient.channel
138 self._url = _fireflyClient.get_firefly_url()
139 self._maskIds = []
140 self._maskDict = {}
141 self._maskPlaneColors = {}
142 self._maskTransparencies = {}
143 self._lastZoom = None
144 self._lastPan = None
145 self._lastStretch = None
146

Member Function Documentation

◆ _buffer()

lsst.display.firefly.firefly.DisplayImpl._buffer ( self,
enable = True )
protected

Enable or disable buffering of writes to the display param enable True or False, as appropriate.

Reimplemented from lsst.afw.display.virtualDevice.DisplayImpl.

Definition at line 231 of file firefly.py.

231 def _buffer(self, enable=True):
232 """!Enable or disable buffering of writes to the display
233 param enable True or False, as appropriate
234 """
235 self._isBuffered = enable
236

◆ _clearImage()

lsst.display.firefly.firefly.DisplayImpl._clearImage ( self)
protected
Delete the current image in the Firefly viewer

Definition at line 150 of file firefly.py.

150 def _clearImage(self):
151 """Delete the current image in the Firefly viewer
152 """
153 self._client.dispatch(action_type='ImagePlotCntlr.deletePlotView',
154 payload=dict(plotId=str(self.display.frame)))
155

◆ _close()

lsst.display.firefly.firefly.DisplayImpl._close ( self)
protected
Called when the device is closed

Reimplemented from lsst.afw.display.virtualDevice.DisplayImpl.

Definition at line 258 of file firefly.py.

258 def _close(self):
259 """Called when the device is closed"""
260 if self.verbose:
261 print("Closing firefly device %s" % (self.display.frame if self.display else "[None]"))
262 if _fireflyClient is not None:
263 _fireflyClient.disconnect()
264 _fireflyClient.session.close()
265

◆ _dot()

lsst.display.firefly.firefly.DisplayImpl._dot ( self,
symb,
c,
r,
size,
ctype,
fontFamily = "helvetica",
textAngle = None )
protected
Draw a symbol onto the specified DS9 frame at (col,row) = (c,r) [0-based coordinates]
Possible values are:
    +                Draw a +
    x                Draw an x
    *                Draw a *
    o                Draw a circle
    @:Mxx,Mxy,Myy    Draw an ellipse with moments (Mxx, Mxy, Myy) (argument size is ignored)
    An object derived from afwGeom.ellipses.BaseCore Draw the ellipse (argument size is ignored)
Any other value is interpreted as a string to be drawn. Strings obey the fontFamily (which may be extended
with other characteristics, e.g. "times bold italic".  Text will be drawn rotated by textAngle (textAngle
is ignored otherwise).

N.b. objects derived from BaseCore include Axes and Quadrupole.

Reimplemented from lsst.afw.display.virtualDevice.DisplayImpl.

Definition at line 266 of file firefly.py.

266 def _dot(self, symb, c, r, size, ctype, fontFamily="helvetica", textAngle=None):
267 """Draw a symbol onto the specified DS9 frame at (col,row) = (c,r) [0-based coordinates]
268 Possible values are:
269 + Draw a +
270 x Draw an x
271 * Draw a *
272 o Draw a circle
273 @:Mxx,Mxy,Myy Draw an ellipse with moments (Mxx, Mxy, Myy) (argument size is ignored)
274 An object derived from afwGeom.ellipses.BaseCore Draw the ellipse (argument size is ignored)
275 Any other value is interpreted as a string to be drawn. Strings obey the fontFamily (which may be extended
276 with other characteristics, e.g. "times bold italic". Text will be drawn rotated by textAngle (textAngle
277 is ignored otherwise).
278
279 N.b. objects derived from BaseCore include Axes and Quadrupole.
280 """
281 self._uploadTextData(ds9Regions.dot(symb, c, r, size, ctype, fontFamily, textAngle))
282

◆ _drawLines()

lsst.display.firefly.firefly.DisplayImpl._drawLines ( self,
points,
ctype )
protected
Connect the points, a list of (col,row)
Ctype is the name of a colour (e.g. 'red')

Reimplemented from lsst.afw.display.virtualDevice.DisplayImpl.

Definition at line 283 of file firefly.py.

283 def _drawLines(self, points, ctype):
284 """Connect the points, a list of (col,row)
285 Ctype is the name of a colour (e.g. 'red')"""
286
287 self._uploadTextData(ds9Regions.drawLines(points, ctype))
288

◆ _erase()

lsst.display.firefly.firefly.DisplayImpl._erase ( self)
protected
Erase all overlays on the image

Reimplemented from lsst.afw.display.virtualDevice.DisplayImpl.

Definition at line 289 of file firefly.py.

289 def _erase(self):
290 """Erase all overlays on the image"""
291 if self.verbose:
292 print(f'region layer id is {self._regionLayerId}')
293 if self._regionLayerId:
294 _fireflyClient.delete_region_layer(self._regionLayerId, plot_id=str(self.display.frame))
295

◆ _flush()

lsst.display.firefly.firefly.DisplayImpl._flush ( self)
protected

Flush any I/O buffers.

Reimplemented from lsst.afw.display.virtualDevice.DisplayImpl.

Definition at line 237 of file firefly.py.

237 def _flush(self):
238 """!Flush any I/O buffers
239 """
240 if not self._regions:
241 return
242
243 if self.verbose:
244 print("Flushing %d regions" % len(self._regions))
245 print(self._regions)
246
247 self._regionLayerId = self._getRegionLayerId()
248 _fireflyClient.add_region_data(region_data=self._regions, plot_id=str(self.display.frame),
249 region_layer_id=self._regionLayerId)
250 self._regions = []
251

◆ _getEvent()

lsst.display.firefly.firefly.DisplayImpl._getEvent ( self)
protected
Return an event generated by a keypress or mouse click

Reimplemented from lsst.afw.display.virtualDevice.DisplayImpl.

Definition at line 308 of file firefly.py.

308 def _getEvent(self):
309 """Return an event generated by a keypress or mouse click
310 """
311 ev = interface.Event("q")
312
313 if self.verbose:
314 print(f"virtual[{self.display.frame}]._getEvent() -> {ev}")
315
316 return ev

◆ _getMaskTransparency()

lsst.display.firefly.firefly.DisplayImpl._getMaskTransparency ( self,
maskName )
protected
Return the current mask's transparency

Reimplemented from lsst.afw.display.virtualDevice.DisplayImpl.

Definition at line 446 of file firefly.py.

446 def _getMaskTransparency(self, maskName):
447 """Return the current mask's transparency"""
448 transparency = None
449 if maskName in self._maskTransparencies:
450 transparency = self._maskTransparencies[maskName]
451 return transparency
452

◆ _getRegionLayerId()

lsst.display.firefly.firefly.DisplayImpl._getRegionLayerId ( self)
protected

Definition at line 147 of file firefly.py.

147 def _getRegionLayerId(self):
148 return f"lsstRegions{self.display.frame}" if self.display else "None"
149

◆ _mtv()

lsst.display.firefly.firefly.DisplayImpl._mtv ( self,
image,
mask = None,
wcs = None,
title = "",
metadata = None )
protected
Display an Image and/or Mask on a Firefly display

Reimplemented from lsst.afw.display.virtualDevice.DisplayImpl.

Definition at line 156 of file firefly.py.

156 def _mtv(self, image, mask=None, wcs=None, title="", metadata=None):
157 """Display an Image and/or Mask on a Firefly display
158 """
159 if title == "":
160 title = str(self.display.frame)
161 if image:
162 if self.verbose:
163 print('displaying image')
164 self._erase()
165
166 with BytesIO() as fd:
167 afwDisplay.writeFitsImage(fd, image, wcs, title, metadata=metadata)
168 fd.seek(0, 0)
169 self._fireflyFitsID = _fireflyClient.upload_fits_data(fd)
170
171 try:
172 viewer_id = f'image-{_fireflyClient.render_tree_id}-{self.frame}'
173 except AttributeError:
174 viewer_id = f'image-{self.frame}'
175 extraParams = dict(Title=title,
176 MultiImageIdx=0,
177 PredefinedOverlayIds=' ',
178 viewer_id=viewer_id)
179 # Firefly's Javascript API requires a space for parameters;
180 # otherwise the parameter will be ignored
181
182 if self._lastZoom:
183 extraParams['InitZoomLevel'] = self._lastZoom
184 extraParams['ZoomType'] = 'LEVEL'
185 if self._lastPan:
186 extraParams['InitialCenterPosition'] = f'{self._lastPan[0]:.3f};{self._lastPan[1]:.3f};PIXEL'
187 if self._lastStretch:
188 extraParams['RangeValues'] = self._lastStretch
189
190 ret = _fireflyClient.show_fits(self._fireflyFitsID, plot_id=str(self.display.frame),
191 **extraParams)
192
193 if not ret["success"]:
194 raise RuntimeError("Display of image failed")
195
196 if mask:
197 if self.verbose:
198 print('displaying mask')
199 with BytesIO() as fdm:
200 afwDisplay.writeFitsImage(fdm, mask, wcs, title, metadata=metadata)
201 fdm.seek(0, 0)
202 self._fireflyMaskOnServer = _fireflyClient.upload_fits_data(fdm)
203
204 maskPlaneDict = mask.getMaskPlaneDict()
205 for k, v in maskPlaneDict.items():
206 self._maskDict[k] = v
207 self._maskPlaneColors[k] = self.display.getMaskPlaneColor(k)
208 usedPlanes = int(afwMath.makeStatistics(mask, afwMath.SUM).getValue())
209 for k in self._maskDict:
210 if (((1 << self._maskDict[k]) & usedPlanes) and
211 (k in self._maskPlaneColors) and
212 (self._maskPlaneColors[k] is not None) and
213 (self._maskPlaneColors[k].lower() != 'ignore')):
214 _fireflyClient.add_mask(bit_number=self._maskDict[k],
215 image_number=0,
216 plot_id=str(self.display.frame),
217 mask_id=k,
218 title=k + ' - bit %d'%self._maskDict[k],
219 color=self._maskPlaneColors[k],
220 file_on_server=self._fireflyMaskOnServer)
221 if k in self._maskTransparencies:
222 self._setMaskTransparency(self._maskTransparencies[k], k)
223 self._maskIds.append(k)
224
Statistics makeStatistics(lsst::afw::image::Image< Pixel > const &img, lsst::afw::image::Mask< image::MaskPixel > const &msk, int const flags, StatisticsControl const &sctrl=StatisticsControl())
Handle a watered-down front-end to the constructor (no variance)
Definition Statistics.h:361

◆ _pan()

lsst.display.firefly.firefly.DisplayImpl._pan ( self,
colc,
rowc )
protected
Pan to specified pixel coordinates

Parameters:
-----------
colc, rowc : `float`
    column and row in units of pixels (zero-based convention,
      with the xy0 already subtracted off)

Reimplemented from lsst.afw.display.virtualDevice.DisplayImpl.

Definition at line 492 of file firefly.py.

492 def _pan(self, colc, rowc):
493 """Pan to specified pixel coordinates
494
495 Parameters:
496 -----------
497 colc, rowc : `float`
498 column and row in units of pixels (zero-based convention,
499 with the xy0 already subtracted off)
500 """
501 self._lastPan = [colc+0.5, rowc+0.5] # saved for future use in _mtv
502 # Firefly's internal convention is first pixel is (0.5, 0.5)
503 _fireflyClient.set_pan(plot_id=str(self.display.frame), x=colc, y=rowc)
504

◆ _remove_masks()

lsst.display.firefly.firefly.DisplayImpl._remove_masks ( self)
protected
Remove mask layers

Definition at line 225 of file firefly.py.

225 def _remove_masks(self):
226 """Remove mask layers"""
227 for k in self._maskIds:
228 _fireflyClient.remove_mask(plot_id=str(self.display.frame), mask_id=k)
229 self._maskIds = []
230

◆ _scale()

lsst.display.firefly.firefly.DisplayImpl._scale ( self,
algorithm,
min,
max,
unit = None,
* args,
** kwargs )
protected
Scale the image stretch and limits

Parameters:
-----------
algorithm : `str`
    stretch algorithm, e.g. 'linear', 'log', 'loglog', 'equal', 'squared',
    'sqrt', 'asinh', powerlaw_gamma'
min : `float` or `str`
    lower limit, or 'minmax' for full range, or 'zscale'
max : `float` or `str`
    upper limit; overrriden if min is 'minmax' or 'zscale'
unit : `str`
    unit for min and max. 'percent', 'absolute', 'sigma'.
    if not specified, min and max are presumed to be in 'absolute' units.

*args, **kwargs : additional position and keyword arguments.
    The options are shown below:

    **Q** : `float`, optional
        The asinh softening parameter for asinh stretch.
        Use Q=0 for linear stretch, increase Q to make brighter features visible.
        When not specified or None, Q is calculated by Firefly to use full color range.
    **gamma**
        The gamma value for power law gamma stretch (default 2.0)
    **zscale_contrast** : `int`, optional
        Contrast parameter in percent for zscale algorithm (default 25)
    **zscale_samples** : `int`, optional
        Number of samples for zscale algorithm (default 600)
    **zscale_samples_perline** : `int`, optional
        Number of samples per line for zscale algorithm (default 120)

Reimplemented from lsst.afw.display.virtualDevice.DisplayImpl.

Definition at line 321 of file firefly.py.

321 def _scale(self, algorithm, min, max, unit=None, *args, **kwargs):
322 """Scale the image stretch and limits
323
324 Parameters:
325 -----------
326 algorithm : `str`
327 stretch algorithm, e.g. 'linear', 'log', 'loglog', 'equal', 'squared',
328 'sqrt', 'asinh', powerlaw_gamma'
329 min : `float` or `str`
330 lower limit, or 'minmax' for full range, or 'zscale'
331 max : `float` or `str`
332 upper limit; overrriden if min is 'minmax' or 'zscale'
333 unit : `str`
334 unit for min and max. 'percent', 'absolute', 'sigma'.
335 if not specified, min and max are presumed to be in 'absolute' units.
336
337 *args, **kwargs : additional position and keyword arguments.
338 The options are shown below:
339
340 **Q** : `float`, optional
341 The asinh softening parameter for asinh stretch.
342 Use Q=0 for linear stretch, increase Q to make brighter features visible.
343 When not specified or None, Q is calculated by Firefly to use full color range.
344 **gamma**
345 The gamma value for power law gamma stretch (default 2.0)
346 **zscale_contrast** : `int`, optional
347 Contrast parameter in percent for zscale algorithm (default 25)
348 **zscale_samples** : `int`, optional
349 Number of samples for zscale algorithm (default 600)
350 **zscale_samples_perline** : `int`, optional
351 Number of samples per line for zscale algorithm (default 120)
352 """
353 stretch_algorithms = ('linear', 'log', 'loglog', 'equal', 'squared', 'sqrt',
354 'asinh', 'powerlaw_gamma')
355 interval_methods = ('percent', 'maxmin', 'absolute', 'zscale', 'sigma')
356 #
357 #
358 # Normalise algorithm's case
359 #
360 if algorithm:
361 algorithm = dict((a.lower(), a) for a in stretch_algorithms).get(algorithm.lower(), algorithm)
362
363 if algorithm not in stretch_algorithms:
364 raise FireflyError(
365 'Algorithm {} is invalid; please choose one of "{}"'.format(
366 algorithm, '", "'.join(stretch_algorithms)
367 )
368 )
369 self._stretchAlgorithm = algorithm
370 else:
371 algorithm = 'linear'
372
373 # Translate parameters for asinh and powerlaw_gamma stretches
374 if 'Q' in kwargs:
375 kwargs['asinh_q_value'] = kwargs['Q']
376 del kwargs['Q']
377
378 if 'gamma' in kwargs:
379 kwargs['gamma_value'] = kwargs['gamma']
380 del kwargs['gamma']
381
382 if min == 'minmax':
383 interval_type = 'percent'
384 unit = 'percent'
385 min, max = 0, 100
386 elif min == 'zscale':
387 interval_type = 'zscale'
388 else:
389 interval_type = None
390
391 if not unit:
392 unit = 'absolute'
393
394 units = ('percent', 'absolute', 'sigma')
395 if unit not in units:
396 raise FireflyError(
397 'Unit {} is invalid; please choose one of "{}"'.format(unit, '", "'.join(units))
398 )
399
400 if unit == 'sigma':
401 interval_type = 'sigma'
402 elif unit == 'absolute' and interval_type is None:
403 interval_type = 'absolute'
404 elif unit == 'percent':
405 interval_type = 'percent'
406
407 self._stretchMin = min
408 self._stretchMax = max
409 self._stretchUnit = unit
410
411 if interval_type not in interval_methods:
412 raise FireflyError(f'Interval method {interval_type} is invalid')
413
414 rval = {}
415 if interval_type != 'zscale':
416 rval = _fireflyClient.set_stretch(str(self.display.frame), stype=interval_type,
417 algorithm=algorithm, lower_value=min,
418 upper_value=max, **kwargs)
419 else:
420 if 'zscale_contrast' not in kwargs:
421 kwargs['zscale_contrast'] = 25
422 if 'zscale_samples' not in kwargs:
423 kwargs['zscale_samples'] = 600
424 if 'zscale_samples_perline' not in kwargs:
425 kwargs['zscale_samples_perline'] = 120
426 rval = _fireflyClient.set_stretch(str(self.display.frame), stype='zscale',
427 algorithm=algorithm, **kwargs)
428
429 if 'rv_string' in rval:
430 self._lastStretch = rval['rv_string']
431

◆ _setCallback()

lsst.display.firefly.firefly.DisplayImpl._setCallback ( self,
what,
func )
protected

Reimplemented from lsst.afw.display.virtualDevice.DisplayImpl.

Definition at line 296 of file firefly.py.

296 def _setCallback(self, what, func):
297 if func != interface.noop_callback:
298 try:
299 status = _fireflyClient.add_extension('POINT' if False else 'AREA_SELECT', title=what,
300 plot_id=str(self.display.frame),
301 extension_id=what)
302 if not status['success']:
303 pass
304 except Exception as e:
305 raise RuntimeError("Cannot set callback. Browser must be (re)opened "
306 f"to {_fireflyClient.url_bw}{_fireflyClient.channel} : {e}")
307

◆ _setImageColormap()

lsst.afw.display.virtualDevice.DisplayImpl._setImageColormap ( self,
cmap )
protectedinherited
Set the desired colormap

Parameters
----------
cmap : `str`
    the name of a colormap (e.g. "gray") or a backend-specific object

Reimplemented in lsst.display.matplotlib.matplotlib.DisplayImpl.

Definition at line 150 of file virtualDevice.py.

150 def _setImageColormap(self, cmap):
151 """Set the desired colormap
152
153 Parameters
154 ----------
155 cmap : `str`
156 the name of a colormap (e.g. "gray") or a backend-specific object
157 """
158 if self.verbose:
159 print("virtual[%s]._setImageColormap(cmap=\"%s\")" % (self.frame, cmap))
160

◆ _setMaskPlaneColor()

lsst.display.firefly.firefly.DisplayImpl._setMaskPlaneColor ( self,
maskName,
color )
protected
Specify mask color 

Definition at line 453 of file firefly.py.

453 def _setMaskPlaneColor(self, maskName, color):
454 """Specify mask color """
455 _fireflyClient.remove_mask(plot_id=str(self.display.frame),
456 mask_id=maskName)
457 self._maskPlaneColors[maskName] = color
458 if (color.lower() != 'ignore'):
459 _fireflyClient.add_mask(bit_number=self._maskDict[maskName],
460 image_number=1,
461 plot_id=str(self.display.frame),
462 mask_id=maskName,
463 color=self.display.getMaskPlaneColor(maskName),
464 file_on_server=self._fireflyFitsID)
465

◆ _setMaskTransparency()

lsst.display.firefly.firefly.DisplayImpl._setMaskTransparency ( self,
transparency,
maskName )
protected
Specify mask transparency (percent); or None to not set it when loading masks

Reimplemented from lsst.afw.display.virtualDevice.DisplayImpl.

Definition at line 432 of file firefly.py.

432 def _setMaskTransparency(self, transparency, maskName):
433 """Specify mask transparency (percent); or None to not set it when loading masks"""
434 if maskName is not None:
435 masklist = [maskName]
436 else:
437 masklist = set(self._maskIds + list(self.display._defaultMaskPlaneColor.keys()))
438 for k in masklist:
439 self._maskTransparencies[k] = transparency
440 _fireflyClient.dispatch(action_type='ImagePlotCntlr.overlayPlotChangeAttributes',
441 payload={'plotId': str(self.display.frame),
442 'imageOverlayId': k,
443 'attributes': {'opacity': 1.0 - transparency/100.},
444 'doReplot': False})
445

◆ _show()

lsst.display.firefly.firefly.DisplayImpl._show ( self)
protected
Show the requested window

Reimplemented from lsst.afw.display.virtualDevice.DisplayImpl.

Definition at line 466 of file firefly.py.

466 def _show(self):
467 """Show the requested window"""
468 if self._client.render_tree_id is not None:
469 # we are using Jupyterlab
470 self._client.dispatch(self._client.ACTION_DICT['StartLabWindow'],
471 {})
472 else:
473 localbrowser, url = _fireflyClient.launch_browser(verbose=self.verbose)
474 if not localbrowser and not self.verbose:
475 _fireflyClient.display_url()
476

◆ _uploadTextData()

lsst.display.firefly.firefly.DisplayImpl._uploadTextData ( self,
regions )
protected

Definition at line 252 of file firefly.py.

252 def _uploadTextData(self, regions):
253 self._regions += regions
254
255 if not self._isBuffered:
256 self._flush()
257

◆ _zoom()

lsst.display.firefly.firefly.DisplayImpl._zoom ( self,
zoomfac )
protected
Zoom display by specified amount

Parameters:
-----------
zoomfac: `float`
    zoom level in screen pixels per image pixel

Reimplemented from lsst.afw.display.virtualDevice.DisplayImpl.

Definition at line 481 of file firefly.py.

481 def _zoom(self, zoomfac):
482 """Zoom display by specified amount
483
484 Parameters:
485 -----------
486 zoomfac: `float`
487 zoom level in screen pixels per image pixel
488 """
489 self._lastZoom = zoomfac
490 _fireflyClient.set_zoom(plot_id=str(self.display.frame), factor=zoomfac)
491

◆ clearViewer()

lsst.display.firefly.firefly.DisplayImpl.clearViewer ( self)
Reinitialize the viewer

Definition at line 517 of file firefly.py.

517 def clearViewer(self):
518 """Reinitialize the viewer
519 """
520 self._client.reinit_viewer()
521

◆ getClient()

lsst.display.firefly.firefly.DisplayImpl.getClient ( self)
Get the instance of FireflyClient for this display

Returns:
--------
`firefly_client.FireflyClient`
    Instance of FireflyClient used by this display

Definition at line 507 of file firefly.py.

507 def getClient(self):
508 """Get the instance of FireflyClient for this display
509
510 Returns:
511 --------
512 `firefly_client.FireflyClient`
513 Instance of FireflyClient used by this display
514 """
515 return self._client
516

◆ overlayFootprints()

lsst.display.firefly.firefly.DisplayImpl.overlayFootprints ( self,
catalog,
color = 'rgba(74,144,226,0.60)',
highlightColor = 'cyan',
selectColor = 'orange',
style = 'fill',
layerString = 'detection footprints ',
titleString = 'catalog footprints ' )
Overlay outlines of footprints from a catalog

Overlay outlines of LSST footprints from the input catalog. The colors
and style can be specified as parameters, and the base color and style
can be changed in the Firefly browser user interface.

Parameters:
-----------
catalog : `lsst.afw.table.SourceCatalog`
    Source catalog from which to display footprints.
color : `str`
    Color for footprints overlay. Colors can be specified as a name
    like 'cyan' or afwDisplay.RED; as an rgb value such as
    'rgb(80,100,220)'; or as rgb plus alpha (transparency) such
    as 'rgba('74,144,226,0.60)'.
highlightColor : `str`
    Color for highlighted footprints
selectColor : `str`
    Color for selected footprints
style : {'fill', 'outline'}
    Style of footprints display, filled or outline
insertColumn : `int`
    Column at which to insert the "family_id" and "category" columns
layerString: `str`
    Name of footprints layer string, to concatenate with the frame
    Re-using the layer_string will overwrite the previous table and
    footprints
titleString: `str`
    Title of catalog, to concatenate with the frame

Definition at line 549 of file firefly.py.

552 titleString='catalog footprints '):
553 """Overlay outlines of footprints from a catalog
554
555 Overlay outlines of LSST footprints from the input catalog. The colors
556 and style can be specified as parameters, and the base color and style
557 can be changed in the Firefly browser user interface.
558
559 Parameters:
560 -----------
561 catalog : `lsst.afw.table.SourceCatalog`
562 Source catalog from which to display footprints.
563 color : `str`
564 Color for footprints overlay. Colors can be specified as a name
565 like 'cyan' or afwDisplay.RED; as an rgb value such as
566 'rgb(80,100,220)'; or as rgb plus alpha (transparency) such
567 as 'rgba('74,144,226,0.60)'.
568 highlightColor : `str`
569 Color for highlighted footprints
570 selectColor : `str`
571 Color for selected footprints
572 style : {'fill', 'outline'}
573 Style of footprints display, filled or outline
574 insertColumn : `int`
575 Column at which to insert the "family_id" and "category" columns
576 layerString: `str`
577 Name of footprints layer string, to concatenate with the frame
578 Re-using the layer_string will overwrite the previous table and
579 footprints
580 titleString: `str`
581 Title of catalog, to concatenate with the frame
582 """
583 footprintTable = createFootprintsTable(catalog)
584 with BytesIO() as fd:
585 footprintTable.to_xml(fd)
586 tableval = self._client.upload_data(fd, 'UNKNOWN')
587 self._client.overlay_footprints(footprint_file=tableval,
588 title=titleString + str(self.display.frame),
589 footprint_layer_id=layerString + str(self.display.frame),
590 plot_id=str(self.display.frame),
591 color=color,
592 highlightColor=highlightColor,
593 selectColor=selectColor,
594 style=style)

◆ resetLayout()

lsst.display.firefly.firefly.DisplayImpl.resetLayout ( self)
Reset the layout of the Firefly Slate browser

Clears the display and adds Slate cells to display image in upper left,
plot area in upper right, and plots stretch across the bottom

Definition at line 522 of file firefly.py.

522 def resetLayout(self):
523 """Reset the layout of the Firefly Slate browser
524
525 Clears the display and adds Slate cells to display image in upper left,
526 plot area in upper right, and plots stretch across the bottom
527 """
528 self.clearViewer()
529 try:
530 tables_cell_id = 'tables-' + str(_fireflyClient.render_tree_id)
531 except AttributeError:
532 tables_cell_id = 'tables'
533 self._client.add_cell(row=2, col=0, width=4, height=2, element_type='tables',
534 cell_id=tables_cell_id)
535 try:
536 image_cell_id = ('image-' + str(_fireflyClient.render_tree_id) + '-' +
537 str(self.frame))
538 except AttributeError:
539 image_cell_id = 'image-' + str(self.frame)
540 self._client.add_cell(row=0, col=0, width=2, height=3, element_type='images',
541 cell_id=image_cell_id)
542 try:
543 plots_cell_id = 'plots-' + str(_fireflyClient.render_tree_id)
544 except AttributeError:
545 plots_cell_id = 'plots'
546 self._client.add_cell(row=0, col=2, width=2, height=3, element_type='xyPlots',
547 cell_id=plots_cell_id)
548

Member Data Documentation

◆ _channel

lsst.display.firefly.firefly.DisplayImpl._channel = _fireflyClient.channel
protected

Definition at line 137 of file firefly.py.

◆ _client

lsst.display.firefly.firefly.DisplayImpl._client = _fireflyClient
protected

Definition at line 136 of file firefly.py.

◆ _fireflyFitsID

lsst.display.firefly.firefly.DisplayImpl._fireflyFitsID = None
protected

Definition at line 134 of file firefly.py.

◆ _fireflyMaskOnServer

lsst.display.firefly.firefly.DisplayImpl._fireflyMaskOnServer = None
protected

Definition at line 135 of file firefly.py.

◆ _isBuffered

bool lsst.display.firefly.firefly.DisplayImpl._isBuffered = False
protected

Definition at line 131 of file firefly.py.

◆ _lastPan

list lsst.display.firefly.firefly.DisplayImpl._lastPan = None
protected

Definition at line 144 of file firefly.py.

◆ _lastStretch

lsst.display.firefly.firefly.DisplayImpl._lastStretch = None
protected

Definition at line 145 of file firefly.py.

◆ _lastZoom

lsst.display.firefly.firefly.DisplayImpl._lastZoom = None
protected

Definition at line 143 of file firefly.py.

◆ _maskDict

dict lsst.display.firefly.firefly.DisplayImpl._maskDict = {}
protected

Definition at line 140 of file firefly.py.

◆ _maskIds

list lsst.display.firefly.firefly.DisplayImpl._maskIds = []
protected

Definition at line 139 of file firefly.py.

◆ _maskPlaneColors

lsst.display.firefly.firefly.DisplayImpl._maskPlaneColors = {}
protected

Definition at line 141 of file firefly.py.

◆ _maskTransparencies

dict lsst.display.firefly.firefly.DisplayImpl._maskTransparencies = {}
protected

Definition at line 142 of file firefly.py.

◆ _regionLayerId

lsst.display.firefly.firefly.DisplayImpl._regionLayerId = self._getRegionLayerId()
protected

Definition at line 133 of file firefly.py.

◆ _regions

lsst.display.firefly.firefly.DisplayImpl._regions = []
protected

Definition at line 132 of file firefly.py.

◆ _stretchAlgorithm

lsst.display.firefly.firefly.DisplayImpl._stretchAlgorithm = algorithm
protected

Definition at line 369 of file firefly.py.

◆ _stretchMax

lsst.display.firefly.firefly.DisplayImpl._stretchMax = max
protected

Definition at line 408 of file firefly.py.

◆ _stretchMin

lsst.display.firefly.firefly.DisplayImpl._stretchMin = min
protected

Definition at line 407 of file firefly.py.

◆ _stretchUnit

lsst.display.firefly.firefly.DisplayImpl._stretchUnit = unit
protected

Definition at line 409 of file firefly.py.

◆ _url

lsst.display.firefly.firefly.DisplayImpl._url = _fireflyClient.get_firefly_url()
protected

Definition at line 138 of file firefly.py.

◆ display

lsst.afw.display.virtualDevice.DisplayImpl.display = display
inherited

Definition at line 34 of file virtualDevice.py.

◆ frame

lsst.afw.display.virtualDevice.DisplayImpl.frame
inherited

Definition at line 44 of file virtualDevice.py.

◆ verbose

lsst.afw.display.virtualDevice.DisplayImpl.verbose = verbose
inherited

Definition at line 35 of file virtualDevice.py.


The documentation for this class was generated from the following file: