SAIL-Labs / AMICAL

Extraction pipeline and analysis tools for Aperture Masking Interferometry mode of the last generation of instruments (ground-based and space).
https://sail-labs.github.io/AMICAL/
MIT License
9 stars 6 forks source link

Data cube with one exposure (i.e. `cube.shape[0]==1`) causes indexing or division error. #82

Open vandalt opened 2 years ago

vandalt commented 2 years ago

When using a data cube with only one exposure (i.e. cube.shape[0]==1), I encountered two errors in extract_bs():

As discussed with @DrSoulain, this should not occur often and is currently not supported. It might still be worth adding an error to catch these two cases in extract_bs and raise a more informative error message to clarify what is happening.

neutrinoceros commented 2 years ago

can you share a self-contained reproducible example ?

vandalt commented 2 years ago

Yes! extract_bs() needs a file, so I'm using one of the example files in doc/NRM_DATA. This works on my machine from the amical/doc directory:

from pathlib import Path
from astropy.io import fits
from amical import extract_bs
from amical.data_processing import select_data

eg_file = Path("NRM_DATA/t_binary_s=147.7mas_mag=6.0_dm=6.0_posang=46.6__F430M_81_flat_x11__00.fits")

data = fits.getdata(eg_file)[:1]

# Uncomment this line to get the IndexError in extract_bs
# data = select_data(data, clip=True, display=False)

extract_bs(data, eg_file, "g7")
vandalt commented 2 years ago

Would this be a good solution ?

neutrinoceros commented 2 years ago

Sorry for the delay. Yes, I believe that it would be a great way to handle things.