コード例 #1
0
def make_catalogue(name,c_ra,c_dec,radius,cats,outnameprefix=''):

    # cats needs to be a list of catalogues with a filename, short
    # name, group ID and matching radius in arcsec.
    # group IDs are a set of objects -- can be anything -- such that we require at least one flux from each group. 
    # Each catalogue needs RA, DEC, Total_flux and E_Total_flux.

    t=Table.read(name,format='ascii.commented_header',header_start=-1)
    print 'Total table length is',len(t)
    if len(t)==0:
        raise RuntimeError('No sources in table from pybdsm')
    t=filter_catalogue(t,c_ra,c_dec,radius)
    print 'Filtered within',radius,'degrees:',len(t)
    if len(t)==0:
        raise RuntimeError('No sources in central part of image')
    t=t[t['Total_flux']>0.15]
    print 'Bright sources:',len(t)
    if len(t)==0:
        raise RuntimeError('No bright sources for crossmatching')

    # Filter for isolated sources
    t=select_isolated_sources(t,100)
    print 'Remove close neighbours:',len(t)
    if len(t)==0:
        raise RuntimeError('No sources in table before crossmatching')

    ctab=[]
    groups=[]
    for n,sh,group,cmrad in cats:
        tab=Table.read(n)
        ctab.append(filter_catalogue(tab,c_ra,c_dec,radius))
        groups.append(group)
        print 'Table',sh,'has',len(ctab[-1]),'entries'

    groups=set(groups)
    # now do cross-matching
    for g in groups:
        t['g_count_'+str(g)]=0
    for i,(n,sh,group,cmrad) in enumerate(cats):
        tab=ctab[i]
        match_catalogues(t,tab,cmrad,sh,group=group)
#        
#        t[sh+'_flux']=np.nan
#        t[sh+'_e_flux']=np.nan
#        for r in t:
#            dist=np.sqrt((np.cos(c_dec*np.pi/180.0)*(tab['RA']-r['RA']))**2.0+(tab['DEC']-r['DEC'])**2.0)*3600.0
#            stab=tab[dist<cmrad]
#            if len(stab)==1:
#                # got a unique match
#                r[sh+'_flux']=stab[0]['Total_flux']
#                r[sh+'_e_flux']=stab[0]['E_Total_flux']
#                r['g_count_'+str(group)]+=1
    # Now reject sources that have no match in a given group
    for g in groups:
        t=t[t['g_count_'+str(g)]>0]

    if len(t)==0:
        raise RuntimeError('No crossmatches exist after group matching')
    t.write(outnameprefix+'crossmatch-1.fits',overwrite=True)
コード例 #2
0
def crossmatch_image(lofarcat, auxcatname, options=None):
    if options is None:
        options = o
    auxcat = options[auxcatname]
    if options['restart'] and os.path.isfile(lofarcat + '_' + auxcatname +
                                             '_match.fits'):
        warn('File ' + lofarcat + '_' + auxcatname +
             '_match.fits already exists, skipping source matching step')
    else:
        t = Table.read(lofarcat)
        tab = Table.read(auxcat)
        match_catalogues(t, tab, o[auxcatname + '_matchrad'], auxcatname)
        t = t[~np.isnan(t[auxcatname + '_separation'])]
        t.write(lofarcat + '_' + auxcatname + '_match.fits')
コード例 #3
0
def crossmatch_image(lofarcat,auxcatname,options=None,catdir='.'):

    if options is None:
        options = o
    auxcat = options[auxcatname]
    crossmatchname=lofarcat + '_' + auxcatname + '_match.fits'
    if options['restart'] and os.path.isfile(crossmatchname):
        warn('File ' + crossmatchname+ ' already exists, skipping source matching step')
        t=Table.read(crossmatchname)
        matches=len(t)
        del(t)
    else:
        t=Table.read(lofarcat)
        tab=Table.read(catdir+'/'+auxcat)
        matches=match_catalogues(t,tab,o[auxcatname+'_matchrad'],auxcatname)
        t=t[~np.isnan(t[auxcatname+'_separation'])]
        t.write(lofarcat+'_'+auxcatname+'_match.fits')
    return matches
コード例 #4
0
def crossmatch_image(lofarcat,auxcatname,options=None,catdir='.'):

    if options is None:
        options = o
    auxcat = options[auxcatname]
    crossmatchname=lofarcat + '_' + auxcatname + '_match.fits'
    if options['restart'] and os.path.isfile(crossmatchname):
        warn('File ' + crossmatchname+ ' already exists, skipping source matching step')
        t=Table.read(crossmatchname)
        matches=len(t)
        del(t)
    else:
        t=Table.read(lofarcat)
        tab=Table.read(catdir+'/'+auxcat)
        matches=match_catalogues(t,tab,o[auxcatname+'_matchrad'],auxcatname)
        t=t[~np.isnan(t[auxcatname+'_separation'])]
        t.write(lofarcat+'_'+auxcatname+'_match.fits')
    return matches
コード例 #5
0
def make_catalogue(name, c_ra, c_dec, radius, cats, outnameprefix=''):

    # cats needs to be a list of catalogues with a filename, short
    # name, group ID and matching radius in arcsec.
    # group IDs are a set of objects -- can be anything -- such that we require at least one flux from each group.
    # Each catalogue needs RA, DEC, Total_flux and E_Total_flux.

    t = Table.read(name, format='ascii.commented_header', header_start=-1)
    print('Total table length is', len(t))
    if len(t) == 0:
        raise RuntimeError('No sources in table from pybdsm')
    t = filter_catalogue(t, c_ra, c_dec, radius)
    print('Filtered within', radius, 'degrees:', len(t))
    if len(t) == 0:
        raise RuntimeError('No sources in central part of image')
    t = t[t['Total_flux'] > 0.15]
    print('Bright sources:', len(t))
    if len(t) == 0:
        raise RuntimeError('No bright sources for crossmatching')

    # Filter for isolated sources
    t = select_isolated_sources(t, 100)
    print('Remove close neighbours:', len(t))
    if len(t) == 0:
        raise RuntimeError('No sources in table before crossmatching')

    ctab = []
    groups = []
    for n, sh, group, cmrad in cats:
        tab = Table.read(n)
        ctab.append(filter_catalogue(tab, c_ra, c_dec, radius))
        groups.append(group)
        print('Table', sh, 'has', len(ctab[-1]), 'entries')

    groups = set(groups)
    # now do cross-matching
    for g in groups:
        t['g_count_' + str(g)] = 0
    for i, (n, sh, group, cmrad) in enumerate(cats):
        tab = ctab[i]
        match_catalogues(t, tab, cmrad, sh, group=group)


#
#        t[sh+'_flux']=np.nan
#        t[sh+'_e_flux']=np.nan
#        for r in t:
#            dist=np.sqrt((np.cos(c_dec*np.pi/180.0)*(tab['RA']-r['RA']))**2.0+(tab['DEC']-r['DEC'])**2.0)*3600.0
#            stab=tab[dist<cmrad]
#            if len(stab)==1:
#                # got a unique match
#                r[sh+'_flux']=stab[0]['Total_flux']
#                r[sh+'_e_flux']=stab[0]['E_Total_flux']
#                r['g_count_'+str(group)]+=1
# Now reject sources that have no match in a given group
    for g in groups:
        t = t[t['g_count_' + str(g)] > 0]

    if len(t) == 0:
        raise RuntimeError('No crossmatches exist after group matching')
    t.write(outnameprefix + 'crossmatch-1.fits', overwrite=True)