This issue relates to the use of masks in FitTrace - both masks on input NDData, or masks generated within FitTrace from NaNs in the data itself.
The first case is when a data array with 'masked' values set to NaN is passed in:
from specreduce.tracing import FitTracedat = fits.getdata('legac_M1_v3.11_spec2d_126153.fits')dat[39:41, :] = np.nan # set some NaNs in data along the tracefit_trace = FitTrace(dat) # no mask, but non finite values in image
This produces an individual warning for each column (in this case, 6165 messages):
UserWarning: All pixels in bin 6160 are masked. Falling to trace value from all-bin fit.
But the trace fit proceeds. Below is the image, the white pixels are those set in the image to NaN, and the blue line is the fit trace:
When this same data is passed in to FitTrace but a mask of those same pixels is also supplied, an error is raised:
mask = np.ones(dat.shape)mask[39:41, :] = 0 # mask along the entire tracenddat = NDData(data=dat, mask=mask, unit=u.DN)fit_trace = FitTrace(nddat) # passing the mask as well as image with NaN values
raises
ValueError: image is fully masked. Check for invalid values
This issue relates to the use of masks in FitTrace - both masks on input NDData, or masks generated within FitTrace from NaNs in the data itself.
The first case is when a data array with 'masked' values set to NaN is passed in:
from specreduce.tracing import FitTrace
dat = fits.getdata('legac_M1_v3.11_spec2d_126153.fits')
dat[39:41, :] = np.nan # set some NaNs in data along the trace
fit_trace = FitTrace(dat) # no mask, but non finite values in image
This produces an individual warning for each column (in this case, 6165 messages):
UserWarning: All pixels in bin 6160 are masked. Falling to trace value from all-bin fit.
But the trace fit proceeds. Below is the image, the white pixels are those set in the image to NaN, and the blue line is the fit trace:
When this same data is passed in to FitTrace but a mask of those same pixels is also supplied, an error is raised:
mask = np.ones(dat.shape)
mask[39:41, :] = 0 # mask along the entire trace
nddat = NDData(data=dat, mask=mask, unit=u.DN)
fit_trace = FitTrace(nddat) # passing the mask as well as image with NaN values
raises
ValueError: image is fully masked. Check for invalid values