Ejemplo n.º 1
0
def aegean_format(catalogue, out):
    """
    Save a catalogue in a format that Aegean will recognize
    :param catalogue: Catalogue
    :param out: Output filename
    :return:
    """
    sources = []
    for i, c in enumerate(catalogue):
        src = SimpleSource()
        src.ra, src.dec, src.peak_flux = c
        src.uuid = "injected_{0:04d}".format(i)
        src.pa = 0
        src.a = src.b = 0.0326580516349937 * 3600
        sources.append(src)
    save_catalog(out, sources)
    print("Wrote to file {0}".format(out))
    return
Ejemplo n.º 2
0
def test_sky_dist():
    src1 = SimpleSource()
    src1.ra = 0
    src1.dec = 0
    src2 = SimpleSource()
    src2.ra = 0
    src2.dec = 1/3600.
    if not cluster.sky_dist(src1, src1) == 0.:
        raise AssertionError()
    if not cluster.sky_dist(src1, src2) == 1/3600.:
        raise AssertionError()
Ejemplo n.º 3
0
def test_write_ann():
    """Test that write_ann *doesn't* do anything"""
    cat.writeAnn('out.ann', [], fmt='fail')
    if os.path.exists('out.ann'):
        raise AssertionError("Shoudn't have written anything")

    src = ComponentSource()
    # remove the parameter a to hit a checkpoint
    del src.a
    cat.writeAnn('out.reg', [src], fmt='reg')
    if not os.path.exists('out_comp.reg'):
        raise AssertionError()
    os.remove('out_comp.reg')

    # write regular and simple sources for .ann files
    cat.writeAnn('out.ann', [ComponentSource()], fmt='ann')
    if not os.path.exists('out_comp.ann'):
        raise AssertionError()

    os.remove('out_comp.ann')
    cat.writeAnn('out.ann', [SimpleSource()], fmt='ann')
    if not os.path.exists('out_simp.ann'):
        raise AssertionError()

    os.remove('out_simp.ann')
    # same but for .reg files
    cat.writeAnn('out.reg', [ComponentSource()], fmt='reg')
    if not os.path.exists('out_comp.reg'):
        raise AssertionError()

    os.remove('out_comp.reg')
    cat.writeAnn('out.reg', [SimpleSource()], fmt='reg')
    if not os.path.exists('out_simp.reg'):
        raise AssertionError()

    os.remove('out_simp.reg')
    cat.writeAnn('out.reg', [IslandSource()], fmt='reg')
    if not os.path.exists('out_isle.reg'):
        raise AssertionError()

    os.remove('out_isle.reg')
    cat.writeAnn('out.ann', [IslandSource()], fmt='ann')
    cat.writeAnn('out.reg', [IslandSource()], fmt='fail')
Ejemplo n.º 4
0
def test_write_ann():
    # write regular and simple sources for .ann files
    cat.writeAnn('out.ann', [OutputSource()], fmt='ann')
    if not os.path.exists('out_comp.ann'):
        raise AssertionError()

    os.remove('out_comp.ann')
    cat.writeAnn('out.ann', [SimpleSource()], fmt='ann')
    if not os.path.exists('out_simp.ann'):
        raise AssertionError()

    os.remove('out_simp.ann')
    # same but for .reg files
    cat.writeAnn('out.reg', [OutputSource()], fmt='reg')
    if not os.path.exists('out_comp.reg'):
        raise AssertionError()

    os.remove('out_comp.reg')
    cat.writeAnn('out.reg', [SimpleSource()], fmt='reg')
    if not os.path.exists('out_simp.reg'):
        raise AssertionError()

    os.remove('out_simp.reg')
Ejemplo n.º 5
0
def test_write_comp_isl_simp():
    catalog = [OutputSource(), IslandSource(), SimpleSource()]
    catalog[0].galactic = True
    out = 'a.csv'
    cat.write_catalog(out, catalog)
    if not os.path.exists('a_isle.csv'):
        raise AssertionError()

    os.remove('a_isle.csv')
    if not os.path.exists('a_comp.csv'):
        raise AssertionError()

    os.remove('a_comp.csv')
    if not os.path.exists('a_simp.csv'):
        raise AssertionError()

    os.remove('a_simp.csv')
Ejemplo n.º 6
0
def test_pairwise_elliptical_binary():
    """Test pairwise_elliptical_binary distance"""
    src1 = SimpleSource()
    src1.ra = 0
    src1.dec = 0
    src1.a = 1.
    src1.b = 1.
    src1.pa = 0.
    src2 = deepcopy(src1)
    src2.dec = 1 / 3600.
    src3 = deepcopy(src1)
    src3.dec = 50
    mat = cluster.pairwise_ellpitical_binary([src1, src2, src3], eps=0.5)
    if not np.all(mat == [[False, True, False], [True, False, False],
                          [False, False, False]]):
        raise AssertionError()
Ejemplo n.º 7
0
def test_write_comp_isl_simp():
    """Test the writing of components/islands/simples to csv format files"""
    catalog = [ComponentSource(), IslandSource(), SimpleSource()]
    catalog[0].galactic = True
    out = 'a.csv'
    cat.write_catalog(out, catalog)
    if not os.path.exists('a_isle.csv'):
        raise AssertionError()

    os.remove('a_isle.csv')
    if not os.path.exists('a_comp.csv'):
        raise AssertionError()

    os.remove('a_comp.csv')
    if not os.path.exists('a_simp.csv'):
        raise AssertionError()

    os.remove('a_simp.csv')
Ejemplo n.º 8
0
 def to_ss(x):
     "Convert numpy.rec to SimpleSource"
     out = SimpleSource()
     for f in Xr.dtype.names:
         setattr(out, f, getattr(x, f))
     return out
Ejemplo n.º 9
0
def test_norm_dist():
    """Test norm_dist"""
    src1 = SimpleSource()
    src1.ra = 0
    src1.dec = 0
    src1.a = 1.
    src1.b = 1.
    src1.pa = 0.
    src2 = SimpleSource()
    src2.ra = 0
    src2.dec = 1 / 3600.
    src2.a = 1
    src2.b = 1
    src2.pa = 0.
    if not cluster.norm_dist(src1, src1) == 0:
        raise AssertionError()
    if not cluster.norm_dist(src1, src2) == 1 / math.sqrt(2):
        raise AssertionError()