def test_wcsgroupcat_recalc_catalog_radec(mock_fits_wcs, rect_imcat): ra, dec = mock_fits_wcs.all_pix2world(rect_imcat.catalog['x'], rect_imcat.catalog['y'], 0) refcat = Table([ra, dec], names=('RA', 'DEC')) ref = RefCatalog(refcat) wim1 = copy.deepcopy(rect_imcat) wim2 = copy.deepcopy(rect_imcat) g = WCSGroupCatalog(wim1) ra = g.catalog['RA'] dec = g.catalog['DEC'] # artificially add another image: g._images.append(wim2) g.recalc_catalog_radec() assert np.allclose(g.catalog['RA'], ra) assert np.allclose(g.catalog['DEC'], dec) g.align_to_ref(ref) mcat = g.get_matched_cat() assert len(mcat) == 5 assert np.allclose(mcat['RA'], ra) assert np.allclose(mcat['DEC'], dec) del g.catalog['RA'] del g.catalog['DEC'] with pytest.raises(RuntimeError): g.calc_tanp_xy(None)
def test_wcsgroupcat_fit2ref(mock_fits_wcs, caplog, rect_imcat): ra, dec = mock_fits_wcs.all_pix2world(rect_imcat.catalog['x'], rect_imcat.catalog['y'], 0) refcat = Table([ra, dec], names=('RA', 'DEC')) ref = RefCatalog(refcat) ref.calc_tanp_xy(rect_imcat.tpwcs) g = WCSGroupCatalog(rect_imcat) g.calc_tanp_xy(rect_imcat.tpwcs) g.match2ref(ref) g.fit2ref(ref, rect_imcat.tpwcs, fitgeom='shift') g.apply_affine_to_wcs(g[0].tpwcs, np.identity(2), np.zeros(2)) g._images = [] g.align_to_ref(ref) assert caplog.record_tuples[-1][-1].endswith("Nothing to align.")