Exemplo n.º 1
0
def test_match():
    c1 = Catalog()
    c1['RA'] = np.arange(10, dtype=float)
    c1['DEC'] = np.arange(10, dtype=float)

    c2 = Table()
    c2['ra'] = np.arange(20, dtype=float) + 0.5 / 3600
    c2['dec'] = np.arange(20, dtype=float) - 0.5 / 3600

    match = c1.match(c2, colc2=('ra', 'dec'), full_output=False)
    assert len(match) == 10
    assert_almost_equal(match['Distance'], 0.705, decimal=2)

    # create a duplicate match
    c1['RA'][4] = c1['RA'][3] - 0.1 / 3600
    c1['DEC'][4] = c1['DEC'][3] - 0.1 / 3600

    c2['ra'][:5] = np.arange(5, dtype=float) + 0.1 / 3600
    c2['dec'][:5] = np.arange(5, dtype=float) + 0.1 / 3600

    match, nomatch1, nomatch2 = c1.match(c2,
                                         colc2=('ra', 'dec'),
                                         radius=0.5,
                                         full_output=True)
    assert len(match) == 4
    assert len(nomatch1) == 6
    assert len(nomatch2) == 16
    assert type(nomatch2) == type(c2)
Exemplo n.º 2
0
def test_meta():
    c1 = Catalog(idname='ID', raname='RA', decname='DEC')
    c1['ID'] = np.arange(10, dtype=int)
    c1['RA'] = np.arange(10, dtype=float)
    c1['DEC'] = np.arange(10, dtype=float)

    assert c1.meta['idname'] is c1.meta['IDNAME']

    c2 = Table()
    c2['id'] = np.arange(20, dtype=int)
    c2['RA'] = np.arange(20, dtype=float) + 0.5 / 3600
    c2['DEC'] = np.arange(20, dtype=float) - 0.5 / 3600
    c2.meta['idname'] = 'id'
    c2.meta['raname'] = 'RA'

    match, nomatch1, nomatch2 = c1.match(c2, full_output=True)
    assert len(match) == 10
    assert type(match.meta) == type(c1.meta)

    assert match.meta['idname'] == 'ID'
    assert match.meta['idname_1'] == 'ID'
    assert match.meta['idname_2'] == 'id'
    assert match.meta['raname'] == 'RA_1'
    assert match.meta['raname_1'] == 'RA_1'
    assert match.meta['raname_2'] == 'RA_2'

    assert nomatch1.meta['idname'] == 'ID'
    assert nomatch2.meta['idname'] == 'id'