spacetelescope / jdaviz

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

Non-repeatable vmin vmax[BUG] #2526

Open cshanahan1 opened 1 year ago

cshanahan1 commented 1 year ago

Jdaviz component

Imviz

Description

This is a bug I noticed while reviewing https://github.com/spacetelescope/jdaviz/pull/2513, but seems to have existed before.

If you open a new instance of imviz (after restarting notebook), the initial values of vmin and vmax for display occasionally change. With the imviz example data in the notebook, sometimes they are 0 and 0.56, and sometimes they are 0.11 and 0.62. The screenshots below come from creating an imviz instance, loading data, and opening plot options to view vmin/vmax (refreshing the notebook inbetween). It is non repeatable for some reason.

Screen Shot 2023-10-20 at 1 42 48 PM Screen Shot 2023-10-20 at 1 42 48 PM

How to Reproduce

Using imviz example notebook, load data and look at vmin and vmax in plot options. Refresh and do this again a few times, and youll notice sometimes that the initial values change.

Expected behavior

For a given dataset, the initial values of vmin and vmax sound be the same every time.

Browser

Safari

astrofrog commented 1 year ago

This is due to the fact that glue will avoid loading all pixels from the data so actually only accesses a sub-sample of the data to determine the min/max. This is important because if you were to load in e.g. a 100Gb mosaic, you definitely wouldn't want to load in all the pixels just to determine the limits.

The question is, is the threshold for data size where this is happening too low? Or would you like to have some way to cache for a given filename what seed is used for the random sub-sampling of the array?

pllim commented 1 year ago

Personally, unless this is causing some analysis problems, I'd say just chuck it under Known Issues and move on. @cshanahan1 , what do you think?

astrofrog commented 1 year ago

As an aside (but somewhat related) I also wonder whether the limits need to be shown with so much precision? Changing the limits at the 5th significant figure isn't going to change the RGB values of the image in any significant way?

pllim commented 1 year ago

I agree. Maybe a .3e would be more than enough?

astrofrog commented 1 year ago

Or .3g for more readable numbers when close to 1

pllim commented 1 year ago

@astrofrog , is this something we have to patch in glue-jupyter?

pllim commented 1 year ago

Oh wait, maybe here but I dunno how to set format in the front-end. Maybe @kecnry knows.

https://github.com/spacetelescope/jdaviz/blob/d03343962807e6eff39bd1834225e9eb7bf8608c/jdaviz/configs/default/plugins/plot_options/plot_options.vue#L439-L448

kecnry commented 1 year ago

I don't know of a way with vue, we could either do it with JS/CSS or on the Python side, but we can cross that bridge when we come to it.