def test_pathloss_corrpars(rtdata): """Test PathLossStep using correction_pars""" with dm.open(rtdata.get_data('nirspec/ifu/nrs1_flat_field.fits')) as data: pls = PathLossStep() corrected = pls.run(data) pls.use_correction_pars = True corrected_corrpars = pls.run(data) assert np.allclose(corrected.data, corrected_corrpars.data, equal_nan=True)
def test_pathloss_source_type(rtdata): """Test PathLossStep forcing source type""" with dm.open(rtdata.get_data('nirspec/ifu/nrs1_flat_field.fits')) as data: pls = PathLossStep() pls.source_type = 'extended' pls.run(data) assert np.allclose(pls.correction_pars.data, pls.correction_pars.pathloss_uniform, equal_nan=True)
def test_pathloss_inverse(rtdata): """Test PathLossStep using correction_pars""" data = dm.open(rtdata.get_data('nirspec/ifu/nrs1_flat_field.fits')) pls = PathLossStep() corrected = pls.run(data) pls.inverse = True corrected_inverse = pls.run(corrected) non_nan = ~np.isnan(corrected_inverse.data) assert np.allclose(corrected.data[non_nan], corrected_inverse.data[non_nan])
def test_pathloss_source_type(rtdata): """Test PathLossStep forcing source type""" with dm.open(rtdata.get_data('nirspec/fs/nrs1_flat_field.fits')) as data: pls = PathLossStep() pls.source_type = 'extended' pls.run(data) bad_slits = [] for idx, slit in enumerate(pls.correction_pars.slits): if slit: if not np.allclose(slit.data, slit.pathloss_uniform, equal_nan=True): bad_slits.append(idx) assert not bad_slits, f'Force to uniform failed for slits {bad_slits}'
def test_pathloss_corrpars(rtdata): """Test PathLossStep using correction_pars""" with dm.open(rtdata.get_data('nirspec/fs/nrs1_flat_field.fits')) as data: pls = PathLossStep() corrected = pls.run(data) pls.use_correction_pars = True corrected_corrpars = pls.run(data) bad_slits = [] for idx, slits in enumerate(zip(corrected.slits, corrected_corrpars.slits)): corrected_slit, corrected_corrpars_slit = slits if not np.allclose(corrected_slit.data, corrected_corrpars_slit.data, equal_nan=True): bad_slits.append(idx) assert not bad_slits, f'correction_pars failed for slits {bad_slits}'
def test_pathloss_source_type(jail, rtdata_module): """Test PathLossStep forcing source type""" rtdata = rtdata_module data = dm.open(rtdata.get_data('nirspec/mos/usf_wavecorr.fits')) pls = PathLossStep() pls.source_type = 'extended' pls.run(data) bad_slits = [] for idx, slit in enumerate(pls.correction_pars.slits): if slit: if not np.allclose( slit.data, slit.pathloss_uniform, equal_nan=True): bad_slits.append(idx) assert not bad_slits, f'Force to uniform failed for slits {bad_slits}'
def test_pathloss_inverse(rtdata): """Test PathLossStep using inversion""" data = dm.open(rtdata.get_data('nirspec/fs/nrs1_flat_field.fits')) pls = PathLossStep() corrected = pls.run(data) pls.inverse = True corrected_inverse = pls.run(corrected) bad_slits = [] for idx, slits in enumerate(zip(data.slits, corrected_inverse.slits)): data_slit, corrected_inverse_slit = slits non_nan = ~np.isnan(corrected_inverse_slit.data) if not np.allclose(data_slit.data[non_nan], corrected_inverse_slit.data[non_nan]): bad_slits.append(idx) assert not bad_slits, f'Inversion failed for slits {bad_slits}'
def test_pathloss_corrpars(jail, rtdata_module): """Test PathLossStep using correction_pars""" rtdata = rtdata_module data = dm.open(rtdata.get_data('nirspec/mos/usf_wavecorr.fits')) pls = PathLossStep() corrected = pls.run(data) pls.use_correction_pars = True corrected_corrpars = pls.run(data) bad_slits = [] for idx, slits in enumerate(zip(corrected.slits, corrected_corrpars.slits)): corrected_slit, corrected_corrpars_slit = slits if not np.allclose(corrected_slit.data, corrected_corrpars_slit.data, equal_nan=True): bad_slits.append(idx) assert not bad_slits, f'correction_pars failed for slits {bad_slits}'