-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Auto-levels fail when NaN is in data #549
Comments
Update: I think this has something to do with how Ginga is "slicing" the data. >>> import numpy as np
>>> from astropy.io import fits
>>> dat = fits.getdata('NGC_628_NA_MOM2_THINGS.FITS')
>>> dat.shape
(1, 1, 1024, 1024)
>>> np.nanmin(dat), np.nanmax(dat)
(0.0, 40194.199) |
I am stumped. I manually ran the logic block that deals with NaN in Update: Although Update to the update: When the file is read into |
@pllim, I've run into these issues before and dealt with them in each kind of auto cut in |
Do you get the same problem using other methods like "zscale", "stddev" or "minmax"? |
This might be significant: "RuntimeWarning: All-NaN axis encountered". Is there really an axis that has all NaNs? |
If there is a slice that is all NaNs, I'm not sure how it could calculate cuts--to ignore them all is to have nothing. |
That's the weird thing. It is a 4-D data but not really a cube because two of the dimensions have size 1. Like I mentioned above, I couldn't find out why I even see that error when I ran the suspected logic block manually with the same data. Perhaps you can download the data and see if you can re-produce it on your end? |
@pllim, if you open The issue is that these two methods have an optimization to prevent long calculation times by using a crop of the image by default. I think with this particular image there are too many NaNs in the crop. |
- fixes an issue (#549) where some images with too many NaNs in the crop could not calculate the cut levels correctly. This checks for the percentage of usable data in the crop and falls back to the full image for calculation if there is less than 50% usable pixels in the crop
Much better now. Thanks! |
For image with NaNs in the data (e.g., use data file given in astropy/astropy#6485), auto-levels fail with the following traceback and defaults to
(0, 0)
. The correct behavior should be to grab only valid data (e.g., usingnp.isfinite()
) and calculate from that (EDIT: Althoughnanmax
andnanmin
should have caught that, so not sure why they don't seem to work properly here).The text was updated successfully, but these errors were encountered: