Extensions and Callback#
[1]:
from firefly_client import __version__ as v
v
[1]:
'3.4.0'
[2]:
from firefly_client import FireflyClient
# FireflyClient._debug = True # enable for debug logging
[3]:
# pick some host
local_host = 'http://127.0.0.1:8080/firefly'
irsa = 'https://irsa.ipac.caltech.edu/irsaviewer'
fd = 'https://fireflydev.ipac.caltech.edu/firefly'
data_lsst_host = 'https://data.lsst.cloud/portal/app/'
host = local_host
using_lab = False
fc = FireflyClient.make_lab_client() if using_lab else FireflyClient.make_client(host)
fc.get_firefly_url()
[3]:
'http://127.0.0.1:8080/firefly/?__wsch=anNpbmdoYWwyMDI1LTEyLTIy'
[4]:
fc.show_fits_image(file_input="http://web.ipac.caltech.edu.s3-us-west-2.amazonaws.com/staff/roby/demo/wise-00.fits", plot_id='x2')
[4]:
{'success': True}
[5]:
fc.set_stretch('x1', stype='zscale')
[5]:
{'success': True,
'rv_string': '91,1.000000,91,1.000000,NaN,2.000000,44,25,600,120,0,NaN,1.000000'}
[6]:
# Extensions can be made but there is no web socket connections until a listener is added
fc.add_extension(ext_type='POINT', title='Output Selected Point', shortcut_key='ctrl-p')
fc.add_extension(ext_type='LINE_SELECT', title='Output Selected line', shortcut_key='meta-b')
fc.add_extension(ext_type='AREA_SELECT', title='Output Selected Area', shortcut_key='a')
[6]:
{'success': True}
[7]:
# A Web socket should not be made until this cell is executed
def example_listener(ev):
if False: # set to True to see all events
print(ev)
if 'data' not in ev:
print('no data found in ev')
return
data = ev['data']
if 'payload' in data:
print(data['payload'])
if 'type' in data:
print(data['type'])
if data['type'] == 'POINT':
print(' image point: %s' % data['ipt'])
print(' world point: %s' % data['wpt'])
if data['type'] == 'LINE_SELECT' or data['type'] == 'AREA_SELECT':
print(' image points: %s to %s' % (data['ipt0'], data['ipt1']))
print(' world points: %s to %s' % (data['wpt0'], data['wpt1']))
fc.add_listener(example_listener)
{'anNpbmdoYWwyMDI1LTEyLTIy': ['1ad', '1af', '1b0']}
app_data.wsConnUpdated
POINT
image point: 188.09900990093206;112.15841584156112
world point: 202.50072514443582;47.26622697944404;EQ_J2000
AREA_SELECT
image points: 173.7454031117884;130.18387553038747 to 210.1301272982422;95.1343705799178
world points: 202.50875172959275;47.27314011276992;EQ_J2000 to 202.4883768975841;47.25968005990187;EQ_J2000
LINE_SELECT
image points: 67.5954738330976;70.0990099009901 to 144.70438472418672;97.47100424328147
world points: 202.56865416307835;47.25038336191467;EQ_J2000 to 202.52519055730875;47.260701294534044;EQ_J2000
[ ]: