Пример #1
0
def test_panstarrs():
    #Test dependency
    try:
        from astroquery.vizier import Vizier
    except ImportError:
        assert True
        return

    #Test get_catalog
    coord = SkyCoord(0, 0, unit="deg")
    search_r = 30 * units.arcsec
    ps_survey = survey_utils.load_survey_by_name('Pan-STARRS', coord, search_r)
    ps_table = ps_survey.get_catalog()

    assert isinstance(ps_table, Table)
    assert len(ps_table) == 25

    #Test get_cutout
    cutout, = ps_survey.get_cutout()
    assert isinstance(cutout, Image.Image)
    assert cutout.size == (120, 120)

    #Test get_image
    imghdu = ps_survey.get_image()
    assert isinstance(imghdu, PrimaryHDU)
    assert imghdu.data.shape == (120, 120)
Пример #2
0
def getjpg(coord, imsize, dss_only=False):
    """
    Grab an SDSS or DSS image

    Args:
        coord (SkyCoord):
        imsize (Angle or Quantity):
            image size
        dss_only (bool, optional):
            Only pull from DSS

    Returns:
        PIL, bool:  Image, flag indicating if the image is B&W
    """
    sdss = survey_utils.load_survey_by_name('SDSS', coord, 0.02 * units.deg)
    # Dummy call to see if SDSS covers it
    if dss_only:
        cat = None
    else:
        cat = sdss.get_catalog()
    # Pull from DSS?
    if cat is None:
        print("No SDSS Image;  Querying DSS")
        BW = True
        url = dsshttp(coord, imsize)  # DSS
        img = images.grab_from_url(url)
    else:
        BW = False
        img, _ = sdss.get_cutout(imsize)
    # Return
    return img, BW
Пример #3
0
def test_decals():
    coord = SkyCoord('J081240.68+320809', unit=(units.hourangle, units.deg))
    search_r = 10 * units.arcsec

    decal_srvy = survey_utils.load_survey_by_name('DECaL', coord, search_r)
    decal_tbl = decal_srvy.get_catalog(print_query=True)
    #
    assert isinstance(decal_tbl, Table)
    assert len(decal_tbl) == 2
Пример #4
0
def test_first():
    coord = SkyCoord('J081240.68+320809', unit=(units.hourangle, units.deg))
    search_r = 10 * units.arcsec
    #
    first_srvy = survey_utils.load_survey_by_name('FIRST', coord, search_r)
    first_tbl = first_srvy.get_catalog()
    #
    assert isinstance(first_tbl, Table)
    assert len(first_tbl) == 1
Пример #5
0
def test_wise():
    coord = SkyCoord('J081240.68+320809', unit=(units.hourangle, units.deg))
    search_r = 10 * units.arcsec

    wise_srvy = survey_utils.load_survey_by_name('WISE', coord, search_r)
    wise_tbl = wise_srvy.get_catalog()
    #
    assert isinstance(wise_tbl, Table)
    assert len(wise_tbl) == 1
Пример #6
0
def test_sdss():
    coord = SkyCoord('J081240.68+320809', unit=(units.hourangle, units.deg))
    search_r = 10 * units.arcsec
    #
    sdss_srvy = survey_utils.load_survey_by_name('SDSS', coord, search_r)
    sdss_tbl = sdss_srvy.get_catalog()
    #
    assert isinstance(sdss_tbl, Table)
    assert len(sdss_tbl) == 2
Пример #7
0
def test_des():
    # Catalog
    coord = SkyCoord('J214425.25-403400.81', unit=(units.hourangle, units.deg))
    search_r = 10 * units.arcsec

    des_srvy = survey_utils.load_survey_by_name('DES', coord, search_r)
    des_tbl = des_srvy.get_catalog(print_query=True)
    #
    assert isinstance(des_tbl, Table)
    assert len(des_tbl) == 1
Пример #8
0
def test_psrcat():
    # Catalog
    coord = SkyCoord('J000604.8+183459', unit=(units.hourangle, units.deg))
    search_r = 10 * units.arcsec

    psrcat_srvy = survey_utils.load_survey_by_name('PSRCAT', coord, search_r)
    pulsars = psrcat_srvy.get_catalog()
    #
    assert isinstance(pulsars, Table)
    assert len(pulsars) == 1
Пример #9
0
def test_first():
    try:
        from dl import queryClient as qc, authClient as ac, helpers
    except ImportError:
        assert True
        return
    coord = SkyCoord('J081240.68+320809', unit=(units.hourangle, units.deg))
    search_r = 10 * units.arcsec
    #
    first_srvy = survey_utils.load_survey_by_name('FIRST', coord, search_r)
    first_tbl = first_srvy.get_catalog()
    #
    assert isinstance(first_tbl, Table)
    assert len(first_tbl) == 1
Пример #10
0
def test_decals():
    try:
        from dl import queryClient as qc, authClient as ac, helpers
    except ImportError:
        assert True
        return
    coord = SkyCoord('J081240.68+320809', unit=(units.hourangle, units.deg))
    search_r = 10 * units.arcsec

    decal_srvy = survey_utils.load_survey_by_name('DECaL', coord, search_r)
    decal_tbl = decal_srvy.get_catalog(print_query=True)
    #
    assert isinstance(decal_tbl, Table)
    assert len(decal_tbl) == 2
Пример #11
0
def test_des():
    try:
        from dl import queryClient as qc, authClient as ac, helpers
    except ImportError:
        assert True
        return
    # Catalog
    coord = SkyCoord('J214425.25-403400.81', unit=(units.hourangle, units.deg))
    search_r = 10 * units.arcsec

    des_srvy = survey_utils.load_survey_by_name('DES', coord, search_r)
    des_tbl = des_srvy.get_catalog(print_query=True)
    #
    assert isinstance(des_tbl, Table)
    assert len(des_tbl) == 1
Пример #12
0
def test_panstarrs():
    #Test get_catalog
    coord = SkyCoord(0, 0, unit="deg")
    search_r = 30 * units.arcsec
    ps_survey = survey_utils.load_survey_by_name('Pan-STARRS', coord, search_r)
    ps_table = ps_survey.get_catalog()

    assert isinstance(ps_table, Table)
    assert len(ps_table) == 25

    #Test get_cutout
    cutout, = ps_survey.get_cutout()
    assert isinstance(cutout, Image.Image)
    assert cutout.size == (120, 120)

    #Test get_image
    imghdu = ps_survey.get_image()
    assert isinstance(imghdu, PrimaryHDU)
    assert imghdu.data.shape == (120, 120)
Пример #13
0
def main(pargs):
    """ Run

    Parameters
    ----------
    pargs

    Returns
    -------

    """
    import warnings

    from frb.surveys import survey_utils

    from rf_meta_query import frb_cand
    from rf_meta_query import meta_io
    from rf_meta_query import dm
    from rf_meta_query import survey_defs
    from rf_meta_query import catalog_utils

    # ADD HERE
    survey_names = ['SDSS', 'NVSS', 'FIRST', 'WENSS', 'DES', 'DECaL', 'PSRCAT']

    # FRB Candidate object
    ra, dec = pargs.radec.split(',')
    frbc = frb_cand.build_frb_cand(ra, dec, 11111)

    # Load surveys
    surveys = {}
    for survey_name in survey_names:
        radius = survey_defs.realfast_params[survey_name]['radius']
        surveys[survey_name] = survey_utils.load_survey_by_name(
            survey_name, frbc['coord'], radius)

    summary_list = [
        '----------------------------------------------------------------'
    ]
    summary_list += [
        'FRB Candidate ID-{:d} towards {:s}'.format(frbc['id'],
                                                    frb_cand.jname(frbc))
    ]

    # Meta dir
    meta_dir = meta_io.meta_dir(frbc, create=pargs.write_meta)

    # Load catalog and generate simple summary
    for survey_name in surveys.keys():
        # Generate catalog (as possible)
        survey = surveys[survey_name]
        _ = survey.get_catalog()
        # Summarize
        summary_list += catalog_utils.summarize_catalog(
            frbc, survey.catalog,
            survey_defs.realfast_params[survey_name]['summary_radius'],
            survey_defs.realfast_params[survey_name]['phot_clm'],
            survey_defs.realfast_params[survey_name]['phot_mag'])
        # Write catalog?
        if pargs.write_meta and (len(survey.catalog) > 0):
            survey.write_catalog(out_dir=meta_dir)

    # DM? -- SDSS only for now
    if 'SDSS' in surveys.keys():
        survey = surveys['SDSS']
        if len(survey.catalog) > 0:
            # Closest within 5" ?
            if survey.catalog['separation'][0] < (5. / 60):
                # Valid value?
                if survey.catalog['photo_z'][0] > -9000.:
                    frbc['z'] = survey.catalog['photo_z'][0]
                    DM = dm.best_dm_from_z(frbc)
                    summary_list += [
                        'DM:  Using the photo_z of the closest galaxy within 5", DM={:0.1f}'
                        .format(DM)
                    ]

    # Cut-out
    cutout_order = ['DES', 'SDSS', 'FIRST', 'NVSS']
    if pargs.write_meta:
        for corder in cutout_order:  # Loop until we generate one
            survey = surveys[corder]
            # Query if the catalog exists.  If empty, assume a cut-out cannot be made
            if len(survey.catalog) == 0:
                print(
                    "Survey {0} catalog query found no sources. Not getting cutout."
                    .format(corder))
                continue
            else:
                print("Getting cutout for survey {0}.".format(corder))
            # Generate
            _ = survey.get_cutout(
                survey_defs.realfast_params[corder]['cutout_size'])
            # Write
            survey.write_cutout(output_dir=meta_dir)

    # Finish by writing the FRB candidate object too
    if pargs.write_meta:
        meta_io.write_frbc(frbc, meta_dir)

    # Print me
    summary_list += [
        '----------------------------------------------------------------'
    ]
    for item in summary_list:
        print(item)