jdaviz icon indicating copy to clipboard operation
jdaviz copied to clipboard

[FEAT] Turning off certain features in plugins

Open jzuhone opened this issue 1 year ago • 4 comments

Jdaviz component

Imviz

What is the problem this feature will solve?

The context: I am thinking about developing a new prototype exposure time calculator for X-ray missions. What I would like to have in this calculator is a way to display images generated from mocks (that we already have the software to make) and extract spectra from those images (that we can already do) that would be displayed in the Jdaviz plugins. After experimenting with Jdaviz it seems like I should be using this to build some components of it and not reinventing the wheel--even though we'd have to manipulate the X-ray data behind the scenes, it would work very nicely.

The issue is that by default plugins like Imviz have a lot of options in the menus that would not be useful for such a use case, like catalogs, etc., since the data are mocks. I was wondering if there was an easy way to turn them off--simply to reduce the number of options to what the user expects to find useful. I saw that there are YAML config files in the code base, and that there are methods like Application.load_configuration, but it doesn't look like I can turn off menu / tray items this way with the current API.

If there's a way to do it with the current API, great--but if not and there's some way I can do this by subclassing Imviz or something else, that would also be fine (more than happy to submit a PR if whatever I come up with ends up being generally useful).

Describe the desired outcome

Being able to hide/remove options that are not relevant to the use case.

Additional context

No response

jzuhone avatar Feb 09 '24 17:02 jzuhone

Thanks for reaching out! There is no easy way right now, except for subclassing and defining your own config (as you suspected). See this test for example:

https://github.com/spacetelescope/jdaviz/blob/6e08521445cd6b92635c27513193bd8bf26fb369/jdaviz/tests/test_app.py#L22

I know @bmorris3 been investigating reusing Cubeviz for Roman ramp cubes (different viewer config but same underlying problem conceptually), so maybe he can advise.

pllim avatar Feb 09 '24 21:02 pllim

p.s. If you are talking about image cube and wanting to extract spectra from them "in real time," maybe Cubeviz is a better fit for you than Imviz. For instance: https://jdaviz.readthedocs.io/en/latest/cubeviz/plugins.html#spectral-extraction

pllim avatar Feb 09 '24 21:02 pllim

@pllim thanks for the explanation, I think I will try this route and see how it goes. '

As far as your second recommendation, I will have a look at it, but the real issue is that X-ray data is typically stored in FITS table data lists of photon events, given how few photons there are compared to longer-wavelength bands. So one then bins up these events into images and/or spectra from these primary data products. But for Cubeviz I think the idea is that you have the spectral cube already. X-ray data is unfortunately a long way away from having enough data that it makes sense to store it in a cube, though maybe creating a virtual in-memory cube for cubeviz is feasible.

jzuhone avatar Feb 09 '24 21:02 jzuhone

If you just want to remove plugins from the sidebar that aren't relevant, you can do that fairly easily without modifying source code (although note that this isn't technically considered public API and so could break in the future):

imviz.app.state.tray_items = [ti for ti in imviz.app.state.tray_items if ti['label'] not in ('Metadata', 'Catalog Search')]

kecnry avatar Feb 12 '24 13:02 kecnry