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_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}'