Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Python widgets for astronomy visualization

Python widgets for astronomy visualization

Contributed talk for Python in Astronomy 2017, held at the Lorentz Center, Leiden, NL. The talk describes the Firefly visualization system and its interfaces in Javascript and Python. Examples of interfacing Firefly to the Jupyter notebooks are shown (though the animated GIFs sadly do not show up in this PDF. Lessons learned from the widget development are outlined.

David Shupe

May 12, 2017
Tweet

Other Decks in Science

Transcript

  1. Python widgets for astronomy visualization David Shupe (Caltech/IPAC) Scientist, LSST

    and ZTF on behalf of the LSST Science User Interface & Tools team Python in Astronomy 2017
  2. Astronomy in 2020+ Context: LSST Science Platform Too much data

    to download -> Remote workspaces LSST LSST Stack DAX and Compu3ng Infrastructure Firefly Query/Visualize: xyz Analyze: xyz Data: xyz Data: xyz LSST LSST Stack Data Access, Database and Compu6ng Infrastructure Firefly X. Wu, D. Ciardi, G. Dubois-Felsmann, LSST Joint Technical Meeting
  3. Python widgets for astronomy visualization • The Firefly visualization system

    • APIs to Firefly • Example: Python interaction with the Firefly app
  4. Python widgets for astronomy visualization • The Firefly visualization system

    • APIs to Firefly • Example: Python interaction with the Firefly app • Firefly widgets for Jupyter
  5. Python widgets for astronomy visualization • The Firefly visualization system

    • APIs to Firefly • Example: Python interaction with the Firefly app • Firefly widgets for Jupyter • Resources
  6. Python widgets for astronomy visualization • The Firefly visualization system

    • APIs to Firefly • Example: Python interaction with the Firefly app • Firefly widgets for Jupyter • Resources
  7. Archive Access System Firefly Pipeline Database Disk/Tape Store Search Retrieval

    System Workspace Firefly Server Firefly Web Client T. Roby et al. SPIE 2016
  8. Table Display FITS Image
 Viewer • WCS Readout • Zoom

    • Flip/ Rotate/ Crop • Color / Stretch • Grid • Region • Magnifier • Distance tools • Markers • Fits Headers • Crop XY Plot / Histogram
  9. Table Display FITS Image
 Viewer • WCS Readout • Zoom

    • Flip/ Rotate/ Crop • Color / Stretch • Grid • Region • Magnifier • Distance tools • Markers • Fits Headers • Crop • Sort / Filter • Column Controls • Supports large tables, 1O Million+ rows • Very fast response time XY Plot / Histogram
  10. Table Display FITS Image
 Viewer • WCS Readout • Zoom

    • Flip/ Rotate/ Crop • Color / Stretch • Grid • Region • Magnifier • Distance tools • Markers • Fits Headers • Crop • Sort / Filter • Column Controls • Supports large tables, 1O Million+ rows • Very fast response time • Interactive • Column math • Zoom • Filter XY Plot / Histogram
  11. Using Firefly • Servers • Application at Infrared Science Archive


    http://irsa.ipac.caltech.edu/irsaviewer • Standalone Firefly 
 Download a single file, deploy using only Java 8
  12. Using Firefly • Servers • Application at Infrared Science Archive


    http://irsa.ipac.caltech.edu/irsaviewer • Standalone Firefly 
 Download a single file, deploy using only Java 8 • Programmatic interfaces • Javascript • Python with Firefly the single-page application • Widgets for Jupyter notebook / JupyterLab
  13. Python widgets for astronomy visualization • The Firefly visualization system

    • APIs to Firefly • Javascript • Python: firefly_client • Example: Python interaction with the Firefly app • Firefly widgets for Jupyter • Resources
  14. Contemporary JavaScript framework External and internal actions are enabled Actions

    Reducers Store View Dispatch Subscribe Actions dispatched from outside Actions monitored by the outside Control Response
  15. Javascript API falls out naturally • Dispatch actions to make

    a change
 var action= firefly.action; • To change color:
 action.dispatchColorChange({plotId:’myplot’, 
 cbarId:5}); • Zooming an image:
 action.dispatchZoom({plotId:’myplot’, 
 userZoomType:’UP’ });
 
 action.dispatchZoom({plotId:’myplot’,
 userZoomType:’LEVEL’,level: zlevel, 
 forceDelay: true });
  16. Python API tracks Javascript closely • firefly_client is a thin

    layer over Javascript API • Pip-installable • Dispatch actions, add listeners (callbacks) • Image display for a local Firefly server:
 import firefly_client
 
 fc = firefly_client.FireflyClient(‘localhost:8080’)
 
 fval = fc.upload_file(‘myfile.fits’)
 
 fc.show_fits(fval)
  17. Python widgets for astronomy visualization • The Firefly visualization system

    • APIs to Firefly • Example: Python interaction with the Firefly app • Firefly widgets for Jupyter • Resources
  18. Setup with Jupyter notebook Forced photometry with LSST stack •

    Define function for forced photometry for (ra, dec, filter) • Callback listens for row selection and point events • Extension added to Firefly to enable this button in point selection mode
  19. Python widgets for astronomy visualization • The Firefly visualization system

    • APIs to Firefly • Example: Python interaction with the Firefly app • Firefly widgets for Jupyter • Resources
  20. Eventful Python objects that have a representation in the browser

    What are widgets? ipywidgets.readthedocs.io
  21. Eventful Python objects that have a representation in the browser

    What are widgets? ipywidgets.readthedocs.io
  22. Eventful Python objects that have a representation in the browser

    What are widgets? ipywidgets.readthedocs.io
  23. Eventful Python objects that have a representation in the browser

    What are widgets? ipywidgets.readthedocs.io
  24. Firefly Widgets • Available as firefly_widgets • Interactive widgets for

    Images and Tables • Widgets currently just past experimental state github.com/Caltech-IPAC/firefly_widgets/examples
  25. Firefly Widgets • Available as firefly_widgets • Interactive widgets for

    Images and Tables • Widgets currently just past experimental state github.com/Caltech-IPAC/firefly_widgets/examples
  26. Lessons learned from widget development • Use the cookiecutter template

    for Jupyter widgets • incorporates best practices for packaging • makes installation straightforward
  27. Lessons learned from widget development • Use the cookiecutter template

    for Jupyter widgets • incorporates best practices for packaging • makes installation straightforward • Development is light on Python side,
 heavy on Javascript
  28. Lessons learned from widget development • Use the cookiecutter template

    for Jupyter widgets • incorporates best practices for packaging • makes installation straightforward • Development is light on Python side,
 heavy on Javascript • Only some actions are good candidates for widget attributes • If action is done on the client — can change quickly • If action calls the server — can be slow
  29. Python widgets for astronomy visualization • The Firefly visualization system

    • APIs to Firefly • Example: Python interaction with the Firefly app • Firefly widgets for Jupyter • Resources
  30. Resources for Firefly • Instructional videos at IRSA IPAC channel

    on YouTube • Source code repositories with example notebooks
 firefly, firefly_client, firefly_widgets
  31. Resources for Firefly • Instructional videos at IRSA IPAC channel

    on YouTube • Source code repositories with example notebooks
 firefly, firefly_client, firefly_widgets • Documentation for Javascript and Python APIs
  32. Resources for Firefly • Instructional videos at IRSA IPAC channel

    on YouTube • Source code repositories with example notebooks
 firefly, firefly_client, firefly_widgets • Documentation for Javascript and Python APIs • Demo videos made for the Large Synoptic Survey telescope
  33. Resources for Firefly • Instructional videos at IRSA IPAC channel

    on YouTube • Source code repositories with example notebooks
 firefly, firefly_client, firefly_widgets • Documentation for Javascript and Python APIs • Demo videos made for the Large Synoptic Survey telescope • See blog post at astropython.wordpress.com for links