Example #1
0
def get_polygon_moc(row):
    print('{} ({} {}) {}'.format(row['obs_id'], row['s_ra'], row['s_dec'], row['s_region']))
    lon = u.Quantity(row['coords']['ra'] * u.deg)
    lat = u.Quantity(row['coords']['dec'] * u.deg)
    temp_moc = MOC.from_polygon(lon, lat, max_depth=MAX_DEPTH)

    return temp_moc
def moc_watchlist(watchlist, max_depth):
    """
    Take a "watchlist" dictionary and builds a MOC at given max_depth, by approximating the
    disk around a source as a hexagon.
    """
    s = 0.5 * math.sqrt(3)
    moc = None
    ralist = watchlist['ra']  # ra list of the watchlist, degrees
    delist = watchlist['de']  # dec list of the watchlist, degrees
    radius = watchlist['radius']  # radius list in degrees
    for i in range(len(ralist)):
        ra = ralist[i]
        de = delist[i]
        q = radius[i]
        r = q / math.cos(de * math.pi / 180)

        # make a hexagon
        lon = [
            ra + q, ra + 0.5 * r, ra - 0.5 * r, ra - r, ra - 0.5 * r,
            ra + 0.5 * r
        ] * u.deg
        lat = [de, de + s * q, de + s * q, de, de - s * q, de - s * q] * u.deg

        # make a moc from the hexagon
        newmoc = MOC.from_polygon(lon, lat, max_depth=max_depth)

        # union with previous hexagons
        if moc: moc = moc.union(newmoc)
        else: moc = newmoc
    return moc
Example #3
0
def get_polygon_moc(row):
    print('{} ({} {}) {}'.format(row['obs_id'], row['s_ra'], row['s_dec'],
                                 row['s_region']))
    lon = u.Quantity(row['coords']['ra'] * u.deg)
    lat = u.Quantity(row['coords']['dec'] * u.deg)
    temp_moc = MOC.from_polygon(lon, lat, max_depth=MAX_DEPTH)  #,
    # inside=SkyCoord(ra=row['s_ra'] * u.deg, dec=row['s_dec'] * u.deg))

    print(temp_moc.serialize('json'))

    return temp_moc
Example #4
0
def test_polygon2_issue_44():
    from astropy import units as u
    from mocpy import MOC
    import numpy as np

    ra = [
        174.75937396073138, 185.24062603926856, 184.63292896369916,
        175.3670710363009
    ]
    dec = [
        -49.16744206799886, -49.16744206799887, -42.32049830486584,
        -42.32049830486584
    ]

    moc = MOC.from_polygon(ra * u.deg, dec * u.deg)

    assert not moc.empty()