Skip to content

Data Cube VET tests failing for Keck/KCWI #1951

@tbowers7

Description

@tbowers7

While doing cleaning of pytest errors in the DevSuite (pypeit/PypeIt-development-suite#362), found an instance where several assert statements were not being properly evaluated. With the extraneous parentheses removed, these tests now fail, having too large residuals.

=================================== FAILURES ===================================
________________________________ test_residuals ________________________________

redux_out = '/tmp/REDUX_OUT'

def test_residuals(redux_out):
    """ Test the residuals of a spec2D DOMEFLAT file
    """
# Define the input files
droot = os.path.join(redux_out,
'keck_kcwi',
'small_bh2_4200',
'Science')
files = ['spec2d_KB.20191220.62342-DOMEPHLAT_KCWI_20191220T171902.438.fits']
config = ['[rdx]',
'  spectrograph = keck_kcwi']

output_filename = "DOMEFLAT_BH2_333.fits"
# Fake data table
tbl = Table()
tbl['filename'] = files

# Generate a mock coadd3dfile
coadd3dfile = inputfiles.Coadd3DFile(config=config,
file_paths=[droot],
data_table=tbl,
setup=None)
# Grab the spectrograph and parset
spec = load_spectrograph("keck_kcwi")
parset = spec.default_pypeit_par()
parset['reduce']['cube']['output_filename'] = output_filename
parset['reduce']['cube']['correct_dar'] = False
parset['reduce']['cube']['combine'] = False
parset['reduce']['cube']['align'] = False
parset['reduce']['cube']['weight_method'] = 'relative'
parset['reduce']['cube']['method'] = 'subpixel'
parset['reduce']['cube']['spat_subpixel'] = 3
parset['reduce']['cube']['spec_subpixel'] = 3
parset['reduce']['cube']['slice_subpixel'] = 3
parset['reduce']['cube']['wave_min'] = 3922.758514
parset['reduce']['cube']['wave_max'] = 4469.062985
parset['reduce']['cube']['wave_delta'] = 0.115005

# Extract the options
ra_offsets = coadd3dfile.options['ra_offset']
dec_offsets = coadd3dfile.options['dec_offset']
skysub_frame = coadd3dfile.options['skysub_frame']
scale_corr = coadd3dfile.options['scale_corr']
grating_corr = coadd3dfile.options['grating_corr']
sensfuncfile = coadd3dfile.options['sensfile']

# Instantiate CoAdd3d, and then coadd the frames
coadd = CoAdd3D.get_instance(coadd3dfile.filenames, parset, skysub_frame=skysub_frame, grating_corr=grating_corr,
scale_corr=scale_corr, sensfile=sensfuncfile,
ra_offsets=ra_offsets, dec_offsets=dec_offsets, spectrograph=spec, overwrite=True)
coadd.run()
# Check the file exists
assert(os.path.exists(output_filename))
######################################
# Check the residuals are OK for method=subpixel
cube = DataCube.from_file(output_filename)
ww = np.where(cube['bpm'] == 0)
resid = cube['flux'] * utils.inverse(cube['sig'])
# Calculate the statistics
avg, med = np.mean(resid[ww]), np.median(resid[ww])
std, mad = np.std(resid[ww]), 1.4826 * np.median(np.abs(np.median(resid[ww]) - resid[ww]))
# Check the statistics
>       assert np.abs(avg) < 0.1, 'residuals (average) is not close to zero for method=subpixel(333)'
E       AssertionError: residuals (average) is not close to zero for method=subpixel(333)
E       assert np.float32(1.7423518) < 0.1
E        +  where np.float32(1.7423518) = <ufunc 'absolute'>(np.float32(1.7423518))
E        +    where <ufunc 'absolute'> = np.abs

../PypeIt-development-suite/vet_tests/test_datacube.py:227: AssertionError

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions