Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions python/lsst/display/firefly/firefly.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from past.builtins import long

import tempfile
import os

import lsst.afw.display.interface as interface
import lsst.afw.display.virtualDevice as virtualDevice
Expand Down Expand Up @@ -78,8 +79,8 @@ def __handleCallbacks(event):
if data.get('type') == "POINT":
lsst.log.debug("Event Received: %s" % data.get('id'))

def __init__(self, display, verbose=False, host="localhost", port=8080,
name="afw", basedir="firefly", *args, **kwargs):
def __init__(self, display, verbose=False, host="localhost", port=8080, name="afw",
basedir="firefly", *args, **kwargs):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

is name the channel name? if so we need to think of how to not this conflict. Such as hostname + 'afw' or something like that. If firefly is sharing these on the same server they would start updating each other.

virtualDevice.DisplayImpl.__init__(self, display, verbose)

if self.verbose:
Expand All @@ -98,7 +99,7 @@ def __init__(self, display, verbose=False, host="localhost", port=8080,
_fireflyClient.add_listener(self.__handleCallbacks)
except Exception as e:
raise RuntimeError("Cannot add listener. Browser must be connected" +
"to %s:%d/%s/;wsch=%s: %s" %
"to %s:%d/%s/lsst-api-triview.html;wsch=%s: %s" %
(host, port, basedir, name, e))

self._isBuffered = False
Expand All @@ -120,7 +121,7 @@ def _mtv(self, image, mask=None, wcs=None, title=""):
if image:
self._erase()

with tempfile.NamedTemporaryFile() as fd:
with tempfile.NamedTemporaryFile(suffix='.fits') as fd:
displayLib.writeFitsImage(fd.name, image, wcs, title)
fd.flush()
fd.seek(0,0)
Expand All @@ -132,7 +133,7 @@ def _mtv(self, image, mask=None, wcs=None, title=""):
raise RuntimeError("Display of image failed")

if mask:
with tempfile.NamedTemporaryFile() as fdm:
with tempfile.NamedTemporaryFile(suffix='.fits') as fdm:
displayLib.writeFitsImage(fdm.name, mask, wcs, title)
fdm.flush()
fdm.seek(0,0)
Expand Down Expand Up @@ -207,6 +208,19 @@ def _dot(self, symb, c, r, size, ctype, fontFamily="helvetica", textAngle=None):
"""
self._uploadTextData(ds9Regions.dot(symb, c, r, size, ctype, fontFamily, textAngle))

def _overlayCatalog(self, sourceCat, **kwargs):
""" Upload a catalog and overlay on image display """
table = sourceCat.asAstropy()
table['ra'] = table['coord_ra'].to('deg')
table['dec'] = table['coord_dec'].to('deg')
with tempfile.NamedTemporaryFile(delete=False,
suffix='.csv') as fd:
table.write(fd.name, format='csv')

tbl_val = _fireflyClient.upload_file(fd.name)
os.remove(fd.name)
_fireflyClient.show_table(tbl_val)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

We might need to pass meta data eventually. We would need to change firefly_client to take is as a parameter


def _drawLines(self, points, ctype):
"""Connect the points, a list of (col,row)
Ctype is the name of a colour (e.g. 'red')"""
Expand Down