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

RDI using 4D cubes raises NoneType error #641

Closed m-vegap closed 1 month ago

m-vegap commented 2 months ago

Calling psfsub.pca_fullfr.pca providing a reference cube to trigger RDI raises a NoneType error for the final_residuals_cube. However, this variable is not called in the "4D cube, but no mSDI desired, (ADI+)RDI" part of the pca_fullfr.py script (lines 488 to 532).

Input

cube = open_fits('ird2022_science-center_im_small.fits')
refcube = open_fits('ird2022_ref-center_im_small_cleaned.fits')
angs = open_fits('ird_convert_recenter_dc2021-IRD_SCIENCE_PARA_ROTATION_CUBE-rotnth-vip.fits')

FITS HDU-0 data successfully loaded. Data shape: (2, 96, 256, 256)
FITS HDU-0 data successfully loaded. Data shape: (2, 40, 256, 256)
FITS HDU-0 data successfully loaded. Data shape: (96,)

ncomp = 5
imlib = 'vip-fft'
interpolation = None
pca_rdi = pca(cube=cube, angle_list=angs, cube_ref=refcube, ncomp=ncomp, mask_center_px=5, nproc=1, full_output=False, verbose=True)

Output

Starting time: 2024-06-25 01:47:23
System total memory = 8.168 GB
System available memory = 2.148 GB
Done vectorizing the frames. Matrix shape: (96, 65536)
Done vectorizing the frames. Matrix shape: (40, 65536)
Done SVD/PCA with numpy SVD (LAPACK)
Running time: 0:00:00.629145

Done de-rotating and combining
Running time: 0:01:28.264319

Done vectorizing the frames. Matrix shape: (96, 65536)
Done vectorizing the frames. Matrix shape: (40, 65536)
Done SVD/PCA with numpy SVD (LAPACK)
Running time: 0:01:28.674925

Done de-rotating and combining
Running time: 0:02:44.744405

---------------------------------------------------------------------------

TypeError Traceback (most recent call last)
Cell In[4], line 5
2 imlib = 'vip-fft'
3 interpolation = None
----> 5 pca_rdi = pca(cube=cube, angle_list=angs, cube_ref=refcube, ncomp=ncomp, mask_center_px=5,
6 nproc=1, full_output=False, verbose=True)
File ~/anaconda3/lib/python3.11/site-packages/vip_hci/psfsub/pca_fullfr.py:608, in pca(*all_args, **all_kwargs)
606 if len(residuals_cube_) > 0:
607 residuals_cube_ = np.array(residuals_cube_)
--> 608 if len(final_residuals_cube) > 0:
609 final_residuals_cube = np.array(final_residuals_cube)
610 if len(recon_cube) > 0:
TypeError: object of type 'NoneType' has no len()
VChristiaens commented 1 month ago

Thanks for raising this up @m-vegap. This is now fixed with https://github.com/vortex-exoplanet/VIP/pull/642