예제 #1
0
def main():
    get_photometry(sys.argv[1], sys.argv[2])

    with open('NGC4621_i.cat', 'r') as catalog:
        tmp = filter(lambda line: phot_utils.no_head(line), catalog)
        tmp2 = map(lambda line: Sources.SCAMSource(line), tmp)
    ra = map(lambda line: line.ra, tmp2)
    dec = map(lambda line: line.dec, tmp2)

    i_sources = Quadtree.ScamEquatorialQuadtree(min(ra), min(dec),
                                              max(ra), max(dec))
    with open('NGC4621_i.cat', 'r') as catalog:
        tmp = filter(lambda line: phot_utils.no_head(line), catalog)
        map(lambda line: i_sources.insert(Sources.SCAMSource(line)), tmp)
        makeRegionFile.makeRegionFile('NGC4621_i.cat', 'NGC4621_i.reg', 10, 'blue')

    with open('NGC4621_g.cat', 'r') as catalog:
        tmp = filter(lambda line: phot_utils.no_head(line), catalog)
        tmp2 = map(lambda line: Sources.SCAMSource(line), tmp)
    ra = map(lambda line: line.ra, tmp2)
    dec = map(lambda line: line.dec, tmp2)

    g_sources = Quadtree.ScamEquatorialQuadtree(min(ra), min(dec),
                                              max(ra), max(dec))
    with open('NGC4621_g.cat', 'r') as catalog:
        tmp = filter(lambda line: phot_utils.no_head(line), catalog)
        map(lambda line: g_sources.insert(Sources.SCAMSource(line)), tmp)
        makeRegionFile.makeRegionFile('NGC4621_g.cat', 'NGC4621_g.reg', 10, 'blue')

    # Aaron gave me the coordinates
    m59_ucd3_i = i_sources.match(190.54601, 11.64478)
    m59_ucd3_g = g_sources.match(190.54601, 11.64478)

    print '\n'

    print "M58-UCD3's Location in catalog: ", m59_ucd3_i.name
    print "I Mag and G Mag: ",  m59_ucd3_i.mag_auto, m59_ucd3_g.mag_auto
    print 'M59-UCD3 g-i: ', m59_ucd3_g.mag_auto - m59_ucd3_i.mag_auto
    print 'M59-UCD3 FWHM: ', m59_ucd3_g.fwhm*0.2
    print "Coordinates from i-band catalog - "
    print phot_utils.convertRA(m59_ucd3_i.ra), phot_utils.convertDEC(m59_ucd3_i.dec)
    print "Coordinates from g-band catalog - "
    print phot_utils.convertRA(m59_ucd3_g.ra), phot_utils.convertDEC(m59_ucd3_g.dec)

    print '\n'
    print '\n'

    m59cO_i = i_sources.match(190.48056, 11.66771)
    m59cO_g = g_sources.match(190.48056, 11.66771)
    print "M59cO's Location in catalog: ", m59cO_i.name
    print "I Mag and G Mag: ", m59cO_i.mag_auto, m59cO_g.mag_auto
    print 'M59cO g-i: ', m59cO_g.mag_auto - m59cO_i.mag_auto
    print "Coordinates from i-band catalog - "
    print phot_utils.convertRA(m59cO_i.ra), phot_utils.convertDEC(m59cO_i.dec)
    print "Coordinates from g-band catalog - "
    print phot_utils.convertRA(m59cO_g.ra), phot_utils.convertDEC(m59cO_g.dec)

    print '\n'
예제 #2
0
def correct_mags(galaxy, catalog, band):
    print "band: ", band
    zp = calcZeropoint.calcZP(galaxy, catalog, band)
    if verbose:
        print "Zeropoint for " + band + "-band", zp

    with open(catalog, 'r') as f:
        tmp = filter(lambda line: phot_utils.no_head(line), f)

    sources = map(lambda line: Sources.SCAMSource(line), tmp)
    for source in sources:
        source.mag_aper = round(source.mag_aper + zp, 3)
        source.mag_auto = round(source.mag_auto + zp, 3)
        source.mag_best = round(source.mag_best + zp, 3)

    new_catalog = 'zpcorrected_' + catalog
    with open(new_catalog, 'w') as output:
        output.write(''.join(
            map(
                lambda source: '%5s' % source.name + '%15s' % source.flux_iso +
                '%15s' % source.fluxerr_iso + '%15s' % source.flux_aper +
                '%15s' % source.fluxerr_aper + '%15s' % source.ximg + '%15s' %
                source.yimg + '%15s' % source.ra + '%15s' % source.dec + '%15s'
                % source.mag_auto + '%15s' % source.mag_auto_err + '%15s' %
                source.mag_best + '%15s' % source.mag_best_err + '%15s' %
                source.mag_aper + '%15s' % source.mag_aper_err + '%15s' %
                source.a_world + '%15s' % source.a_world_err + '%15s' % source.
                b_world + '%15s' % source.b_world_err + '%15s' % source.
                theta_err + '%15s' % source.theta + '%15s' % source.isoarea +
                '%15s' % source.mu + '%15s' % source.flux_radius + '%15s' %
                source.flags + '%15s' % source.fwhm + '%15s' % source.elogation
                + '%15s' % source.vignet + '\n', sources)))
    return new_catalog
예제 #3
0
def fromFile(filename, outname, pixsize, color):
    with open(filename, "r") as catalog:
        sources = [Sources.SCAMSource(line) for line in catalog if phot_utils.no_head(line)]
        with open(outname, "w") as out:
            for source in sources:
                out.write("physical;circle(" + str(source.ximg) + "," +
                            str(source.yimg) + "," + str(pixsize) + ") #color=" + str(color) + "\n")
예제 #4
0
def correct_mags(galaxy, catalog, band):
    print "band: ", band
    zp = calcZeropoint.calcZP(galaxy, catalog, band)
    if verbose:
        print "Zeropoint for " + band + "-band", zp

    with open(catalog, 'r') as f:
        tmp = filter(lambda line: phot_utils.no_head(line), f)

    sources = map(lambda line: Sources.SCAMSource(line), tmp)
    for source in sources:
        source.mag_aper = round(source.mag_aper + zp, 3)
        source.mag_auto = round(source.mag_auto + zp, 3)
        source.mag_best = round(source.mag_best + zp, 3)

    new_catalog = 'zpcorrected_' + catalog
    with open(new_catalog, 'w') as output:
        output.write(''.join(map(lambda source: '%5s' % source.name + '%15s' % source.flux_iso +
                    '%15s' % source.fluxerr_iso + '%15s' % source.flux_aper +
                    '%15s' % source.fluxerr_aper + '%15s' % source.ximg + '%15s' % source.yimg +
                    '%15s' % source.ra + '%15s' % source.dec + '%15s' % source.mag_auto +
                    '%15s' % source.mag_auto_err + '%15s' % source.mag_best +
                    '%15s' % source.mag_best_err + '%15s' % source.mag_aper +
                    '%15s' % source.mag_aper_err + '%15s' % source.a_world +
                    '%15s' % source.a_world_err + '%15s' % source.b_world +
                    '%15s' % source.b_world_err + '%15s' % source.theta_err +
                    '%15s' % source.theta + '%15s' % source.isoarea + '%15s' % source.mu +
                    '%15s' % source.flux_radius + '%15s' % source.flags + '%15s' % source.fwhm +
                    '%15s' % source.elogation + '%15s' % source.vignet + '\n',  sources)))
    return new_catalog
예제 #5
0
def calcZP(galaxy, scam, band):
    """
    To calculate the zeropoint of the Subaru image match the Subaru catalog
    and the table returned from Vizier.
    """
    sdss = getSDSS(galaxy)
    column = str(band + 'mag')
    print "Column: ", column

    # Get only the brightest sources of both SDSS and Subaru.
    mag = map(lambda source: source[column], sdss)
    max_mag = np.mean(mag) + 0.25*np.mean(np.std(mag))
    sdss = filter(lambda s: phot_utils.mag_cut(s[column], 18, max_mag), sdss)

    with open(scam, 'r') as f:
        catalog = [S.SCAMSource(line) for line in f if phot_utils.no_head(line)]

    mag = map(lambda s: s.mag_best, catalog)
    max_mag = np.mean(mag) + 0.25*np.mean(np.std(mag))
    sources = filter(lambda s: phot_utils.mag_cut(s.mag_best, 18, max_mag), catalog)

    ra = [source.ra for source in catalog]
    dec = [source.dec for source in catalog]
    scam_sources = Q.ScamEquatorialQuadtree(min(ra), min(dec),
                                            max(ra), max(dec))
    map(lambda sources: scam_sources.insert(sources), sources)
    matches = associate(sdss, scam_sources)

    m_scam_sources = map(lambda source: source.mag_aper, matches)
    m_sdss_sources = map(lambda source: source.match2[column], matches)

    # Clip outliers of (m_sdss - m_scam)
    difference = []
    for m_sdss, m_scam in zip(m_sdss_sources, m_scam_sources):
        difference.append(m_sdss - m_scam)
    std =  np.std(difference)

    # Make a region file to check the matching
    makeRegionFile.fromList(matches, band + "_scam_match_source.reg", 0.1, "red")
    makeRegionFile.fromList(matches, band + "_sdss_match_source.reg", 0.1, "green")

    clipped = []
    for entry in matches:
        if entry.match2[column] - entry.mag_aper < std*3:
            clipped.append(entry)

    difference = []
    for entry in clipped:
        difference.append(entry.match2[column] - entry.mag_aper)
    m_scam = map(lambda source: source.mag_aper, clipped)

    # Look at offsets
    plt.plot(difference, m_scam, linestyle='none', marker='o')
    plt.xlabel(r'$m_{SDSS}$ - $m_{SCAM}$', fontsize=20)
    plt.ylabel(r'$m_{SCAM}$', fontsize=20, labelpad=30)
    path = os.getcwd()
    phot_utils.save(path, band + '_zp.png')

    # Take median of offset
    return  np.median(difference)
예제 #6
0
def makeRegionFile(filename, outname, pixsize, color):
    catalog = open(filename, "r")
    tmp = filter(lambda line: pu.no_head(line), catalog)

    sources = map(lambda line: S.SCAMSource(line), tmp)

    out = open(outname, "w")
    for source in sources:
        out.write("physical;circle(" + str(source.ximg) + "," +
                str(source.yimg) + "," + str(pixsize) + ") #color=" + str(color) + "\n")
예제 #7
0
def makeRegionFile(filename, outname, pixsize, color):
    catalog = open(filename, "r")
    tmp = filter(lambda line: pu.no_head(line), catalog)

    sources = map(lambda line: S.SCAMSource(line), tmp)

    out = open(outname, "w")
    for source in sources:
        out.write("physical;circle(" + str(source.ximg) + "," +
                  str(source.yimg) + "," + str(pixsize) + ") #color=" +
                  str(color) + "\n")
예제 #8
0
def make_trees(catalog):
    with open(catalog, 'r') as f:
        tmp = filter(lambda line: phot_utils.no_head(line), f)
    tmp2 = map(lambda line: Sources.SCAMSource(line), tmp)

    ra = map(lambda line: line.ra, tmp2)
    dec = map(lambda line: line.dec, tmp2)
    sources = Quadtree.ScamEquatorialQuadtree(min(ra), min(dec), max(ra),
                                              max(dec))
    map(lambda line: sources.insert(line), tmp2)

    #if verbose:
    #        makeRegionFile.makeRegionFile('NGC4621_i.cat', 'NGC4621_i.reg', 10, 'blue')

    return sources
예제 #9
0
def make_trees(catalog):
    with open(catalog, 'r') as f:
        tmp = filter(lambda line: phot_utils.no_head(line), f)
    tmp2 = map(lambda line: Sources.SCAMSource(line), tmp)

    ra = map(lambda line: line.ra, tmp2)
    dec = map(lambda line: line.dec, tmp2)
    sources = Quadtree.ScamEquatorialQuadtree(min(ra), min(dec),
                                              max(ra), max(dec))
    map(lambda line: sources.insert(line), tmp2)

    if verbose:
            makeRegionFile.makeRegionFile('NGC4621_i.cat', 'NGC4621_i.reg', 10, 'blue')

    return sources
예제 #10
0
def main():
    #get_photometry(sys.argv[1], sys.argv[2])
    catalogs = (glob.glob('NGC4621*.cat'))
    for catalog in catalogs:
        if verbose:
            print "Working on catalog: ", catalog
        corrected_catalog = correct_mags(sys.argv[1], catalog, catalog[-5])

    sys.exit()

    with open('NGC4621_g.cat', 'r') as catalog:
        tmp = filter(lambda line: phot_utils.no_head(line), catalog)
    g_sources = map(lambda source: Sources.SCAMSource(source), tmp)

    r_sources = make_trees('NGC4621_r.cat')
    i_sources = make_trees('NGC4621_i.cat')

    matches = associate(g_sources, r_sources, i_sources)

    with open('matched_gri.cat', 'w') as out:
        out.write()
예제 #11
0
def calcZP(galaxy, scam, band):
    """
    To calculate the zeropoint of the Subaru image match the Subaru catalog
    and the table returned from Vizier.
    """
    sdss = getSDSS(galaxy)

    column = str(band + 'mag')
    with open(scam, 'r') as catalog:
        tmp = filter(lambda line: phot_utils.no_head(line), catalog)
    # Do magnitude cute on data here
    tmp2 = map(lambda line: S.SCAMSource(line), tmp)
    mag = map(lambda s: s.mag_best, tmp2)
    max_mag = phot_utils.calc_average(mag) + 0.25 * phot_utils.calc_average(
        phot_utils.variance(mag))
    sources = filter(lambda s: phot_utils.mag_cut(s.mag_best, 0, max_mag),
                     tmp2)

    ra = map(lambda line: line.ra, tmp2)
    dec = map(lambda line: line.dec, tmp2)
    scam_sources = Q.ScamEquatorialQuadtree(min(ra), min(dec), max(ra),
                                            max(dec))
    map(lambda sources: scam_sources.insert(sources), sources)
    matches = associate(sdss, scam_sources)

    m_scam = map(lambda source: source.mag_aper, matches)
    m_sdss = map(lambda source: source.match2[column], matches)

    # Clip outliers of (m_sdss - m_scam)
    difference = []
    for i, entry in enumerate(m_scam):
        difference.append(m_sdss[i] - m_scam[i])
    std = np.std(difference)

    # Make a region file to check the matching
    with open("scam_match_source.reg", "w") as out:
        for source in matches:
            out.write("j2000; circle " + str(phot_utils.convertRA(source.ra)) +
                      "," + str(phot_utils.convertDEC(source.dec)) +
                      " .1' #color=red \n")

    with open("sdss_match_source.reg", "w") as out:
        for source in matches:
            out.write("j2000; circle " +
                      str(phot_utils.convertRA(source.match2['RAJ2000'])) +
                      "," +
                      str(phot_utils.convertDEC(source.match2['DEJ2000'])) +
                      " .15' #color=green \n")

    clipped = []
    for entry in matches:
        if entry.match2[column] - entry.mag_aper < std * 3:
            clipped.append(entry)

    difference = []
    for entry in clipped:
        difference.append(entry.match2[column] - entry.mag_aper)
    m_scam = map(lambda source: source.mag_aper, clipped)

    # Look at offsets
    plt.plot(difference, m_scam, linestyle='none', marker='o')
    plt.xlabel(r'$m_{SDSS}$ - $m_{SCAM}$', fontsize=20)
    plt.ylabel(r'$m_{SCAM}$', fontsize=20, labelpad=30)
    plt.show()

    # Take median of offset
    return phot_utils.calc_median(difference)
예제 #12
0
def findBestAperture(path, image, satur, seeing):
    if os.path.isdir('BestApertureFiles') == False:
        os.mkdir('BestApertureFiles')

    sname = "sign"
    nname = "noise"
    filter_file = "default.conv"
    assoc_file = "measurefluxat.txt"

    output = open(assoc_file, "w")
    for i in xrange(0, 100000):
        output.write('%.3f' % r.uniform(1, 11000) +
                     '%10.3f' % r.uniform(1, 9000) + '\n')

    sp.createSexParam(sname, False)
    sp.createSexParam(nname, True)
    sparam_file = sname + ".param"
    nparam_file = nname + ".param"

    signal = []
    noise = []
    aperture = np.linspace(0.5, 12, num=10)
    for ap in aperture:
        sc.createSexConfig(sname, filter_file, sparam_file, satur, seeing,
                           "nill", ap, False)
        call(['sex', '-c', sname + '.config', image])
        sc.createSexConfig(nname, filter_file, nparam_file, satur, seeing,
                           assoc_file, ap, True)
        call(['sex', '-c', nname + '.config', image])

        scat = open(sname + ".cat")
        stmp = filter(lambda line: pu.no_head(line), scat)
        ncat = open(nname + ".cat")
        ntmp = filter(lambda line: pu.no_head(line), ncat)

        # Background measuresments can't overlap with source detections
        ssources = q.ScamPixelQuadtree(0, 0, 12000, 10000)
        map(lambda line: ssources.insert(S.SCAMSource(line)), stmp)
        nsources = map(lambda line: S.SCAMSource(line), ntmp)

        start = time.time()
        bkgddetections = disassociate(nsources, ssources, ap)
        end = time.time()
        print("ELAPSED TIME: " + str(end - start))
        srcdetections = map(lambda line: S.SCAMSource(line), stmp)

        flux = map(lambda f: f.flux_aper, bkgddetections)
        noise.append(pu.calc_MAD(flux))

        flux = map(lambda f: f.flux_aper, srcdetections)
        signal.append(pu.calc_MAD(flux))

        with open(image[-6] + "_ap_" + str(round(ap, 2)) + "noise.txt",
                  "w") as output:
            for source in bkgddetections:
                output.write(source.line)
        call([
            'mv', image[-6] + "_ap_" + str(round(ap, 2)) + "noise.txt",
            'BestApertureFiles'
        ])

        with open(image[-6] + "_ap_" + str(round(ap, 2)) + "signal.txt",
                  "w") as output:
            for source in srcdetections:
                output.write(source.line)
        call([
            'mv', image[-6] + "_ap_" + str(round(ap, 2)) + "signal.txt",
            'BestApertureFiles'
        ])
    '''
    The files generated here aren't important and need to be
    removed for the next steps to work properly.
    '''

    try:
        os.remove('measurefluxat.txt')
    except OSError:
        pass
    noise_files = (glob.glob('noise*'))
    try:
        for f in noise_files:
            os.remove(f)
    except OSError:
        pass
    sign_files = (glob.glob('sign*'))
    try:
        for f in sign_files:
            os.remove(f)
    except OSError:
        pass

    snr = []
    for i in range(len(noise)):
        snr.append(signal[i] / noise[i])
    plt.plot(aperture, snr, linestyle='none', marker='o')
    plt.xlabel('Aperture (pix)')
    plt.ylabel('SNR')
    pu.save(path, image[-6] + '_snr')
    maxsnr = snr.index(max(snr))
    return aperture[maxsnr]
예제 #13
0
def findBestAperture(path, image, satur, seeing):
    if os.path.isdir('BestApertureFiles') == False:
        os.mkdir('BestApertureFiles')

    sname = "sign"
    nname = "noise"
    filter_file = "default.conv"
    assoc_file = "measurefluxat.txt"

    output = open(assoc_file, "w")
    for i in xrange(0,100000):
        output.write('%.3f' % r.uniform(1,11000) + '%10.3f' % r.uniform(1,9000) + '\n')

    sp.createSexParam(sname, False)
    sp.createSexParam(nname, True)
    sparam_file = sname + ".param"
    nparam_file = nname + ".param"

    signal = []
    noise = []
    aperture = np.linspace(0.5, 12, num=10)
    for ap in aperture:
        sc.createSexConfig(sname, filter_file, sparam_file, satur, seeing, "nill", ap, False)
        call(['sex', '-c', sname + '.config', image])
        sc.createSexConfig(nname, filter_file, nparam_file, satur, seeing, assoc_file, ap, True)
        call(['sex', '-c', nname + '.config', image])

        scat = open(sname + ".cat")
        stmp = filter(lambda line: pu.no_head(line), scat)
        ncat = open(nname + ".cat")
        ntmp = filter(lambda line: pu.no_head(line), ncat)

        # Background measuresments can't overlap with source detections
        ssources = q.ScamPixelQuadtree(0, 0, 12000, 10000)
        map(lambda line: ssources.insert(S.SCAMSource(line)), stmp)
        nsources = map(lambda line: S.SCAMSource(line), ntmp)

        start = time.time()
        bkgddetections = disassociate(nsources, ssources, ap)
        end = time.time()
        print("ELAPSED TIME: " + str(end-start))
        srcdetections = map(lambda line: S.SCAMSource(line), stmp)

        flux = map(lambda f: f.flux_aper, bkgddetections)
        noise.append(pu.calc_MAD(flux))

        flux = map(lambda f: f.flux_aper, srcdetections)
        signal.append(pu.calc_MAD(flux))

        with open(image[-6] + "_ap_" + str(round(ap, 2)) + "noise.txt", "w") as output:
            for source in bkgddetections:
                output.write(source.line)
        call(['mv', image[-6] + "_ap_" + str(round(ap, 2)) + "noise.txt", 'BestApertureFiles'])

        with open(image[-6] + "_ap_" + str(round(ap, 2)) + "signal.txt", "w") as output:
            for source in srcdetections:
                output.write(source.line)
        call(['mv', image[-6] + "_ap_" + str(round(ap, 2)) + "signal.txt", 'BestApertureFiles'])

    '''
    The files generated here aren't important and need to be
    removed for the next steps to work properly.
    '''

    try:
        os.remove('measurefluxat.txt')
    except OSError:
        pass
    noise_files = (glob.glob('noise*'))
    try:
        for f in noise_files:
            os.remove(f)
    except OSError:
        pass
    sign_files = (glob.glob('sign*'))
    try:
        for f in sign_files:
            os.remove(f)
    except OSError:
        pass

    snr = []
    for i in range(len(noise)):
        snr.append(signal[i]/noise[i])
    plt.plot(aperture, snr, linestyle='none', marker='o')
    plt.xlabel('Aperture (pix)')
    plt.ylabel('SNR')
    pu.save(path, image[-6]+'_snr')
    maxsnr = snr.index(max(snr))
    return aperture[maxsnr]
예제 #14
0
import random as r
import Quadtree
import Sources as S
import phot_utils

sources = Quadtree.ScamPixelQuadtree(0, 0, 15000, 15000)

with open("/Users/alexawork/Documents/GlobularClusters/Photometry/NGC4649/NGC4649_g.cat") as f:
    tmp = filter(lambda line: phot_utils.no_head(line), f)
map(lambda line: sources.insert(S.SCAMSource(line)), tmp)

sources.match(10, 15)
sources.debug()
예제 #15
0
def calcZP(galaxy, scam, band):
    """
    To calculate the zeropoint of the Subaru image match the Subaru catalog
    and the table returned from Vizier.
    """
    sdss = getSDSS(galaxy)

    column = str(band + 'mag')
    with open(scam, 'r') as catalog:
        tmp = filter(lambda line: phot_utils.no_head(line), catalog)
    # Do magnitude cute on data here
    tmp2 = map(lambda line: S.SCAMSource(line), tmp)
    mag = map(lambda s: s.mag_best, tmp2)
    max_mag = phot_utils.calc_average(mag) + 0.25*phot_utils.calc_average(phot_utils.variance(mag))
    sources = filter(lambda s: phot_utils.mag_cut(s.mag_best, 0, max_mag), tmp2)


    ra = map(lambda line: line.ra, tmp2)
    dec = map(lambda line: line.dec, tmp2)
    scam_sources = Q.ScamEquatorialQuadtree(min(ra), min(dec),
                                            max(ra), max(dec))
    map(lambda sources: scam_sources.insert(sources), sources)
    matches = associate(sdss, scam_sources)

    m_scam = map(lambda source: source.mag_aper, matches)
    m_sdss = map(lambda source: source.match2[column], matches)

    # Clip outliers of (m_sdss - m_scam)
    difference = []
    for i, entry in enumerate(m_scam):
        difference.append(m_sdss[i] - m_scam[i])
    std =  np.std(difference)

    # Make a region file to check the matching
    with open("scam_match_source.reg", "w") as out:
        for source in matches:
            out.write("j2000; circle " + str(phot_utils.convertRA(source.ra)) + "," +
                        str(phot_utils.convertDEC(source.dec)) + " .1' #color=red \n")

    with open("sdss_match_source.reg", "w") as out:
        for source in matches:
            out.write("j2000; circle " + str(phot_utils.convertRA(source.match2['RAJ2000']))
                    + "," + str(phot_utils.convertDEC(source.match2['DEJ2000'])) + " .15' #color=green \n")

    clipped = []
    for entry in matches:
        if entry.match2[column] - entry.mag_aper < std*3:
            clipped.append(entry)

    difference = []
    for entry in clipped:
        difference.append(entry.match2[column] - entry.mag_aper)
    m_scam = map(lambda source: source.mag_aper, clipped)

    # Look at offsets
    plt.plot(difference, m_scam, linestyle='none', marker='o')
    plt.xlabel(r'$m_{SDSS}$ - $m_{SCAM}$', fontsize=20)
    plt.ylabel(r'$m_{SCAM}$', fontsize=20, labelpad=30)
    plt.show()

    # Take median of offset
    return  phot_utils.calc_median(difference)
예제 #16
0
import random as r
import Quadtree
import Sources as S
import phot_utils

sources = Quadtree.ScamPixelQuadtree(0, 0, 15000, 15000)

with open(
        "/Users/alexawork/Documents/GlobularClusters/Photometry/NGC4649/NGC4649_g.cat"
) as f:
    tmp = filter(lambda line: phot_utils.no_head(line), f)
map(lambda line: sources.insert(S.SCAMSource(line)), tmp)

sources.match(10, 15)
sources.debug()
예제 #17
0
import Quadtree
import phot_utils
import _angular_dist
import _norm

def associate(list1, tree2):
    dist = 5
    with open("test.reg", "w") as out:
        for entry in list1:
            match2 = tree2.match(entry.ximg, entry.yimg)
            if match2 != None and _norm.norm(entry.ximg, entry.yimg, match2.ximg, match2.yimg) <= dist:
                out.write("physical;circle(" + str(entry.ximg) + "," + str(entry.yimg) +
                            " 10) #color=red \n")

with open('NGC4621_i.cat', 'r') as f:
    i_catalog = [Sources.SCAMSource(line) for line in f if phot_utils.no_head(line)]

with open('NGC4621_g.cat', 'r') as f:
    g_catalog = [Sources.SCAMSource(line) for line in f if phot_utils.no_head(line)]

ximg = [source.ximg for source in i_catalog]
yimg = [source.yimg for source in i_catalog]
sources = Quadtree.ScamPixelQuadtree(min(ximg), min(yimg), max(ximg), max(yimg))

#ra = [source.ra for source in i_catalog]
#dec = [source.dec for source in i_catalog]
#sources = Quadtree.ScamEquatorialQuadtree(min(ra), min(dec), max(ra), max(dec))

[sources.insert(source) for source in i_catalog]

#match = sources.match(190.7027198, 11.3355764)
예제 #18
0

def associate(list1, tree2):
    dist = 5
    with open("test.reg", "w") as out:
        for entry in list1:
            match2 = tree2.match(entry.ximg, entry.yimg)
            if match2 != None and _norm.norm(entry.ximg, entry.yimg,
                                             match2.ximg, match2.yimg) <= dist:
                out.write("physical;circle(" + str(entry.ximg) + "," +
                          str(entry.yimg) + " 10) #color=red \n")


with open('NGC4621_i.cat', 'r') as f:
    i_catalog = [
        Sources.SCAMSource(line) for line in f if phot_utils.no_head(line)
    ]

with open('NGC4621_g.cat', 'r') as f:
    g_catalog = [
        Sources.SCAMSource(line) for line in f if phot_utils.no_head(line)
    ]

ximg = [source.ximg for source in i_catalog]
yimg = [source.yimg for source in i_catalog]
sources = Quadtree.ScamPixelQuadtree(min(ximg), min(yimg), max(ximg),
                                     max(yimg))

#ra = [source.ra for source in i_catalog]
#dec = [source.dec for source in i_catalog]
#sources = Quadtree.ScamEquatorialQuadtree(min(ra), min(dec), max(ra), max(dec))