Open vandalt opened 2 years ago
can you share a self-contained reproducible example ?
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")
Would this be a good solution ?
select_data
shows a warning if it clears a data cube of all its exposures (to let users know, even in cases where nothing is done with the cube after. An empty cube is probably not desirable, but not critical in the sense that users can just check for this and skip empty cubesextract_bs()
check both cases (length 1 or empty) and raises and error. The two cases are critical for extraction, and result in error in private functions called by extract_bs()
Sorry for the delay. Yes, I believe that it would be a great way to handle things.
When using a data cube with only one exposure (i.e.
cube.shape[0]==1
), I encountered two errors inextract_bs()
:An
IndexError
if clipping had been done before and rejected the only frame in in the cube andextract_bs()
had an empty input.Error message
bs = amical.extract_bs( File "/home/vandal/projects/amical/amical/mf_pipeline/bispect.py", line 1138, in extract_bs ft_arr, n_ps, npix = _construct_ft_arr(cube) File "/home/vandal/projects/amical/amical/mf_pipeline/bispect.py", line 227, in _construct_ft_arr n_pix = cube.shape[1] IndexError: tuple index out of rangeA
ZeroDivisionError
if no clipping was done andextract_bs()
received a cube with one frame.Error message
bs = amical.extract_bs( File "/home/vandal/projects/amical/amical/mf_pipeline/bispect.py", line 1242, in extract_bs v2_quantities = _compute_v2_quantities(v2_arr_unbiased, bias_arr, n_blocks) File "/home/vandal/projects/amical/amical/mf_pipeline/bispect.py", line 537, in _compute_v2_quantities ind2 = (k + 1) * n_ps // (n_blocks - 1) ZeroDivisionError: integer division or modulo by zeroAs 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.