- changed status to resolved
Input of a single target image leading to crash in parallelized.py
I’ve been playing around with pyKLIP for some JWST simulations and in one of my cases I’m looking to perform RDI using a PSF library on a single target image (i.e. one PA). In these single target image cases I get an IndexError, full error message appended to the bottom of the issue.
After some digging it seems this occurs due to a variation in the output data format of np.corrcoef() on line #477 of parallelized.py (within _klip_section_multifile()) when ref_psfs_smoothed is only a single array. At present I’ve identified two ways to fix this:
- Ensure corr_smooth is set to 0 for all of my single target image runs of pyKLIP
- Repeat an adjusted version of lines 449-451 after line 477 to convert the output data into a format that can be understood by
corr_psfs[np.where(np.isnan(corr_psfs))]
if ref_psfs_mean_sub.shape[0] == 1:
# EDGE CASE: if there's only 1 image, we need to reshape the correlation matrix into a 2D matrix
corr_psfs = corr_psfs.reshape((1,1))
The remaining questions are: is on of these better than the other, and if option 1) then should it be automatically set within pyKLIP instead of provided on the user end? and does this occur anywhere else in the code that I might not be using with my current setup?
Thanks!
Error Message:
/Users/acarter/anaconda3/envs/pancake_dev/lib/python3.7/site-packages/numpy/lib/arraysetops.py:583: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison
mask |= (ar1 == a)
Traceback (most recent call last):
File "testing.py", line 21, in <module>
pancake.analysis2.contrast_curve(results, target='Target', references='Reference', subtraction='RDI', filters='all', target_rolls=0)#, klip_numbasis=[10,20])
File "/Users/acarter/Documents/DIRECT_IMAGING/PANCAKE/CODE/pancake_dev/jwst_pancake/analysis2.py", line 261, in contrast_curve
subtracted_images = klip_subtracted_images(pancake_results, target, references=references, subtraction=subtraction, filters=filters, target_rolls=target_rolls, target_primary_source=target_primary_source, reference_primary_sources=reference_primary_sources, reference_rolls=reference_rolls, klip_annuli=klip_annuli, klip_subsections=klip_subsections, klip_numbasis=klip_numbasis, klip_movement=klip_movement, outputdir=outputdir, save_prefix=save_prefix)
File "/Users/acarter/Documents/DIRECT_IMAGING/PANCAKE/CODE/pancake_dev/jwst_pancake/analysis2.py", line 232, in klip_subtracted_images
parallelized.klip_dataset(target_dataset, outputdir="./", fileprefix=save_prefix, annuli=klip_annuli, subsections=klip_subsections, numbasis=klip_numbasis, mode=subtraction, psf_library=psflib, movement=klip_movement, verbose=False)
File "/Users/acarter/anaconda3/envs/pancake_dev/lib/python3.7/site-packages/pyklip/pyklip/parallelized.py", line 1646, in klip_dataset
dataset.IWA, **pyklip_args)
File "/Users/acarter/anaconda3/envs/pancake_dev/lib/python3.7/site-packages/pyklip/pyklip/parallelized.py", line 1340, in klip_parallelized
for phistart,phiend in phi_bounds
File "/Users/acarter/anaconda3/envs/pancake_dev/lib/python3.7/site-packages/pyklip/pyklip/parallelized.py", line 1341, in <listcomp>
for radstart, radend in rad_bounds]
File "/Users/acarter/anaconda3/envs/pancake_dev/lib/python3.7/site-packages/pyklip/pyklip/parallelized.py", line 486, in _klip_section_multifile
corr_psfs[np.where(np.isnan(corr_psfs))] = 0
IndexError: too many indices for array: array is 0-dimensional, but 1 were indexed
Comments (1)
-
- Log in to comment
Fixed in PR #39. Thanks Aarynn!