vortex-exoplanet / VIP

VIP is a python package/library for angular, reference star and spectral differential imaging for exoplanet/disk detection through high-contrast imaging.
http://vip.readthedocs.io/
MIT License
70 stars 57 forks source link

Bug: normalize_psf fails silently if PSF.ndim = 4 #623

Closed lwelzel closed 1 month ago

lwelzel commented 10 months ago

Description

Calling vip_hci.fm.fakecomp.normalize_psf with a psf that has 4 dimensions fails to normalize the psf, does not raise an error and returns None instead. This occurs even if debug and verbose are set to True and no output is printed.

To Reproduce


import numpy as np
from vip_hci.fm.fakecomp import normalize_psf

psf = np.zeros((39, 4, 64, 64))  # e.g. some IFS PSF cubes

norm_psf_result = normalize_psf(psf, fwhm='fit', size=63, full_output=True, force_odd=True, debug=False, verbose=False, )
print(norm_psf_result)  # None

# with debug=True and verbose=True
norm_psf_result = normalize_psf(psf, fwhm='fit', size=63, full_output=True, force_odd=True, debug=True, verbose=True, )
# no output
print(norm_psf_result)  # None

psfn, flux_st, fwhm = normalize_psf(psf, fwhm='fit', size=63, full_output=True, force_odd=True, debug=False, verbose=False, )
# TypeError: cannot unpack non-iterable NoneType object

Expected behavior

Either the function should raise an error or normalize the PSFs separately

VChristiaens commented 1 month ago

Thanks for raising this up @lwelzel! This was fixed in 57803545360af09b8f66451dd427bacfdb7d5084 (some time ago now, but I forgot to reply and close the issue).