FilFinder icon indicating copy to clipboard operation
FilFinder copied to clipboard

fil.create_mask in example script not working

Open mbhaswati opened this issue 3 years ago • 2 comments

I am simply trying to reproduce the results of the example script in the FilFinder Tutorial and it gets stuck at:

fil.create_mask(verbose=True, border_masking=False, size_thresh=400 * u.pix**2, glob_thresh=0.0267)

The error is:

astropy.units.core.UnitConversionError: 'Unit("K")' is not a scaled version of 'Unit(dimensionless)'

raise TypeError('only dimensionless scalar quantities can be ' TypeError: only dimensionless scalar quantities can be converted to Python scalars

mbhaswati avatar Aug 16 '22 10:08 mbhaswati

I am also having this issue

TomHilder avatar Mar 09 '23 03:03 TomHilder

The issue seems to arise in this line of the create_mask function (line 491 of filfinder2D.py),

p.imshow(self.flat_img.value, interpolation='nearest',
                     origin="lower", cmap='binary', vmin=vmin, vmax=vmax)

Since vmin and vmax are defined by,

vmin = np.percentile(self.flat_img[np.isfinite(self.flat_img)], 20)
vmax = np.percentile(self.flat_img[np.isfinite(self.flat_img)], 90)

they retain units from self.flat_img, and don't work as limits (which need to be dimensionless in this case). Just changing vmin=vmin, vmax=vmax to vmin=vmin.value, vmax=vmax.value in lines 491 and 545 of filfinder2D.py (for medskel plotting) did the trick for me.

akhil-lasrado avatar Jul 26 '23 10:07 akhil-lasrado