spacetelescope / jdaviz

JWST astronomical data analysis tools in the Jupyter platform
https://jdaviz.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
134 stars 72 forks source link

Provide combined api for adding/viewing data #112

Open nmearl opened 4 years ago

nmearl commented 4 years ago

83 added api access to the application, but it was suggested that there ought to be a combined way to add and plot data in a single command. This would effectively do the same as

app.add_data(my_data, data_label="My New Data")
app.add_viewer_data('flux-viewer', data_label="My New Data")
havok2063 commented 4 years ago

Related to my comments in #120 , currently to load data programmatically you need to specify the extension directly,

app.add_data_to_viewer('image-viewer', 'jw00626-o030_s00000_nirspec_f170lp-g235m_s2d[SCI]')

Could we improve this to accept the full filename with an optional extension keyword?

data2= '/Users/bcherinka/Downloads/jw00626-o030_s00000_nirspec_f170lp-g235m_s2d.fits'
app.add_data_to_viewer('image-viewer', data2, ext='SCI')

I think this is a bit more user friendly and how people usually deal with filenames in their notebooks. There's no filename parsing involved.