Exemplo n.º 1
0
 def fromvot(self, filename):
     addsrcs = []
     votable = vot.parse_single_table(filename, pedantic=False)
     for rec in votable.array:
         ra = rec['Ra']
         dec = rec['Dec']
         name = rec['Name']
         jys = rec['S_nu_']
         try:
             e_S_nu = rec['e_S_nu_']
         except (IndexError):
             e_S_nu = 0
         try:
             index = rec['n']
         except (IndexError):
             index = rec['index']
         addsrcs.append(
             RadioFixedBody(ra,
                            dec,
                            name=name,
                            jys=jys,
                            index=index,
                            mfreq=.150,
                            e_S_nu=e_S_nu,
                            vo_record=rec))
     self.add_srcs(addsrcs)
Exemplo n.º 2
0
 def fromvot(self,filename):
     log.info("\n"+"#"*50 + "\n This is generic_catalog.py last modified %s\n"%(lastmod,) + "#"*50)
     addsrcs = []
     votable = vot.parse_single_table(filename,pedantic=False)
     #try and find the frequency, if a single freq catalog
     default_nu = 0.15
     for prm in votable.params:
         if prm.ucd=="em.freq": 
             default_nu=prm.value
             if prm.unit=='MHz': default_nu /= 1e3
             if prm.unit=='kHz': default_nu /= 1e6
             log.info("Setting the default mfreq=%f"%default_nu)
     #find the names of the columns based on my desired ucds
     ucds = {"pos.eq.ra;meta.main":'Ra',
             "pos.eq.dec;meta.main":'Dec',
             "phot.flux.density":'S_nu_',
             "stat.error":'e_S_nu_',
             "meta.id;meta.main":'Name',
             "meta.record":'Seq',
             "spect.index":'n',
             "em.freq":'nu'}
     Jys = 1.0
     GHz = 1.0
     fluxname = None
     for field in votable.fields:
         log.info("loading field: %s ucd=%s"%(field.name,field.ucd,))
         if field.ucd is None: continue
         if field.ucd.endswith("meta.main"):
             ucds.update({field.ucd:field.name})
         else:
             ucds.update({field.ucd.split(';')[0]:field.name})
         if field.ucd.startswith('phot.flux.density'):
             if field.unit=='mJy': Jys=1.e-3
             log.info("1 Jy is %f times catalog flux"%(1./Jys,))
             if field.ucd == 'phot.flux.density;em.radio.100-200MHz':
                 fluxname = field.name
             elif fluxname is None:
                 fluxname = ucds['phot.flux.density']
             log.info("using field %s for primary flux"%(fluxname,))
         if field.ucd.startswith('em.freq'):
             if field.unit=='MHz': GHz=1e-3
             elif field.unit=='kHz': GHz=1e-6
     for rec in votable.array:
         ra = rec[ucds["pos.eq.ra;meta.main"]]*a.img.deg2rad
         dec = rec[ucds["pos.eq.dec;meta.main"]]*a.img.deg2rad
         try: name = rec[ucds["meta.id;meta.main"]]
         except(IndexError): name = pos2name(ra,dec)
         try: jys = rec[fluxname]*Jys
         except(IndexError): print fluxname,'not found in ',rec.dtype.names
         try: e_S_nu = rec[ucds["stat.error"]]
         except(IndexError): e_S_nu = 0
         try: index = rec[ucds["spect.index"]]
         except(IndexError):
             try: index = rec['index']
             except: index=-1
         try:nu = rec[ucds["em.freq"]]*GHz
         except(IndexError):nu = default_nu
         addsrcs.append(RadioFixedBody(ra, dec, name=name,
             jys=jys, index=index, mfreq=nu,e_S_nu=e_S_nu,vo_record=rec))            
     self.add_srcs(addsrcs)
Exemplo n.º 3
0
 def fromvot(self,filename):
     addsrcs = []
     votable = vot.parse_single_table(filename,pedantic=False)
     for rec in votable.array:
         ra = rec['Ra']
         dec = rec['Dec']
         name = rec['Name']
         jys = rec['S_nu_']
         try: e_S_nu = rec['e_S_nu_']
         except(IndexError): e_S_nu = 0
         try: index = rec['n']
         except(IndexError):
             index = rec['index']
         addsrcs.append(RadioFixedBody(ra, dec, name=name,
             jys=jys, index=index, mfreq=.150,e_S_nu=e_S_nu,vo_record=rec))            
     self.add_srcs(addsrcs)
Exemplo n.º 4
0
 try:
     err = src.e_S_nu
 except AttributeError:
     err = 0
 #    print "%s \t %s \t"%(src.ra,src.dec),
 #perform the cone search and make a spectrum numpy array
 if opts.vo:
     log.debug("Connecting to %s" % (opts.uri))
     conesrch = ConeSearch(opts.uri)
     log.debug("Performing conesearch")
     votable = conesrch.execute(src.ra / ephem.degree,
                                src.dec / ephem.degree, opts.sep)
     log.debug("Converting votable string to file object")
     votable_f = StringIO(votable)
     log.debug("Parsing table from votable to numpy.")
     votable_np = vot.parse_single_table(votable_f, pedantic=False)
     vodata = votable_np.array
     if len(vodata) < 2:
         print "%s \t %s \t %s \t %07.3f \t %07.3f"%\
             (name,src.ra,src.dec,src.jys,err)
         log.warning("no vo sources found within %7.3f of %s" %
                     (opts.sep, name))
         continue
     #extract a single spectrum (hope there was only one hit, throw a warning at the end if not)
     seqs = list(set(vodata['Seq']))
     if len(seqs) > 1:
         log.warning("%d vo sources found within %7.3f of %s" %
                     (len(seqs), opts.sep, name))
     seq = find_seq_of_brightest_src(vodata)
     vodata = vodata[n.argwhere(vodata['Seq'] == seq)]
     altnames = ','.join(vodata['Name'].squeeze())
Exemplo n.º 5
0
Selected cxoxb, raJ2000 and decJ2000. Then selected j2000, b1950, gal,
ecliptic coordinates computed by Vizier, in decimal degrees. 

Then ran this file.

Result is a space delimited file with columns:

raj2000, dej2000, raj200-vizier, dej2000-vizier, glon, glat,
elonj2000, elatj2000

All values are degrees.
"""
import numpy as np
from vo.table import parse_single_table
table = parse_single_table("ndwfs.vot", pedantic=False)
data = table.array

#fs = "{0:13.8f} {1:13.8f} "
#fs += "{2:10.4f} {3:10.4f} {4:13.8f} "
#fs += "{5:13.8f} {6:13.8f} {7:13.8f} {8:13.8f} "
#fs += "{9:13.8f} {10:13.8f} {11:13.8f} {12:13.8f}"

fs = "%13.8f "*10
fs = fs.rstrip()+"\n"

data_file = open("ndwfs.txt","w")

# Fields RAJ2000 and DEJ2000 are data from catalog.
# Others are calculated by Vizier.
for i in data[0::10]:
Exemplo n.º 6
0
for name,src in catA.iteritems():
    fsrc,sep = find_src_in_cat(src,catB,opts.sep)
    if fsrc is not None: continue
    try: err=src.e_S_nu
    except AttributeError: err = 0
#    print "%s \t %s \t"%(src.ra,src.dec),
    #perform the cone search and make a spectrum numpy array
    if opts.vo:
        log.debug("Connecting to %s"%(opts.uri))
        conesrch = ConeSearch(opts.uri)
        log.debug("Performing conesearch")
        votable = conesrch.execute(src.ra/ephem.degree,src.dec/ephem.degree,opts.sep)
        log.debug("Converting votable string to file object")
        votable_f = StringIO(votable)
        log.debug("Parsing table from votable to numpy.")
        votable_np = vot.parse_single_table(votable_f,pedantic=False)
        vodata = votable_np.array
        if len(vodata)<2: 
            print "%s \t %s \t %s \t %07.3f \t %07.3f"%\
                (name,src.ra,src.dec,src.jys,err)
            log.warning("no vo sources found within %7.3f of %s"%(opts.sep,name))
            continue
        #extract a single spectrum (hope there was only one hit, throw a warning at the end if not)
        seqs = list(set(vodata['Seq']))
        if len(seqs)>1: log.warning("%d vo sources found within %7.3f of %s"%(len(seqs),opts.sep,name))
        seq = find_seq_of_brightest_src(vodata)
        vodata = vodata[n.argwhere(vodata['Seq']==seq)]
        altnames = ','.join(vodata['Name'].squeeze())
        print "%s \t %s \t %s \t %07.3f \t %07.3f \t %s \t %d"%\
                (name,src.ra,src.dec,src.jys,err,altnames,int(seq))
    else:
Exemplo n.º 7
0
"""
Downloaded vot file from vizier hipparcos page for the main hipparcos
catalog. Selected, hip, ra icrs, de icrs, plx, pmra, pmdec, and then 
specified vizier calculated j2000, b1950, gal and ecl, all in degrees.

Then ran this file.
"""

import numpy as np
from vo.table import parse_single_table
table = parse_single_table("hipparcos.vot", pedantic=False)
data = table.array

fs = "{0:13.8f} {1:13.8} {2:13.8f} {3:13.8f} {4:13.8f} {5:13.8f} "
fs += "{6:13.8f} {7:13.8f} {8:13.8} {9:13.8}\n"

f = open("hip.txt", "w")
for i in data[0::100]:
    x = [j for j in i if np.isnan(j)]
    if x: continue
    f.write(
        fs.format(i['RA_ICRS_'], i['_DE_ICRS_'], i['_RAJ2000'], i['_DEJ2000'],
                  i['_RAB1950'], i['_DEB1950'], i['_Glon'], i['_Glat'],
                  i['_Elon2000'], i['_Elat2000']))
f.close()
Exemplo n.º 8
0
    P2   = exp(-(log10(s0)-log10(S))**2/(2*((ds0/s0)**2+(fds)**2)))
    P3    =exp(-(R*pi/180)**2/(2*(dr**2+cbeam**2)))
    fig = figure(56)
    clf()
    conf = 0.75
    cs1 = contour(log10(R),log10(S),P,[conf])#1-array([0.25,0.5,0.75,0.95,0.99]))
    cs2 = contour(log10(R),log10(S),P2,[conf])
    cs3 = contour(log10(R),log10(S),P3,[conf])
    contour(log10(R),log10(S),P2*P3,[conf])
    cs = contour(log10(R),log10(S),P*P2*P3,[conf],linewidths=3)
    xlabel('log radius [deg]') 
    ylabel('log flux [jy]')
    draw()
    fig.savefig('cat_prob_P_'+str(s0)+'_'+str(s0*fds)+'.png')

votable_np = vot.parse_single_table(open('../../cals/test.vot'),pedantic=False)
VO = atpy.Table('../../cals/test.vot')
VO.add_empty_column('P_dnds',dtype=float,unit='prob',description='prior prob given number counts')
VO.add_empty_column('P_r',dtype=float,unit='prob',description='radial id probability')
VO.add_empty_column('P_S',dtype=float,unit='prob',description='flux id probability')
VO.add_empty_column('P',dtype=float,unit='prob',description='total probability = P_dnds*P_r*P_S')



for exseq in list(set(votable_np.array['PAPER_seq'])):
    data = votable_np.array[n.where(votable_np.array['PAPER_seq']==exseq)[0]]
    s0 =n.max(data['S_nu_paper'])
    ds0 = n.max(data['e_S_nu_paper'])
    seqs = list(set(data['Seq']))
    print "looking for source of flux %7.3f +/- %7.3f"%(s0,ds0)
    print '\t'.join(('seq','S','dS','R','dR','P_dnds','P_S','P_r','Ptot'))
Exemplo n.º 9
0
 def fromvot(self, filename):
     log.info("\n" + "#" * 50 +
              "\n This is generic_catalog.py last modified %s\n" %
              (lastmod, ) + "#" * 50)
     addsrcs = []
     votable = vot.parse_single_table(filename, pedantic=False)
     #try and find the frequency, if a single freq catalog
     default_nu = 0.15
     for prm in votable.params:
         if prm.ucd == "em.freq":
             default_nu = prm.value
             if prm.unit == 'MHz': default_nu /= 1e3
             if prm.unit == 'kHz': default_nu /= 1e6
             log.info("Setting the default mfreq=%f" % default_nu)
     #find the names of the columns based on my desired ucds
     ucds = {
         "pos.eq.ra;meta.main": 'Ra',
         "pos.eq.dec;meta.main": 'Dec',
         "phot.flux.density": 'S_nu_',
         "stat.error": 'e_S_nu_',
         "meta.id;meta.main": 'Name',
         "meta.record": 'Seq',
         "spect.index": 'n',
         "em.freq": 'nu'
     }
     Jys = 1.0
     GHz = 1.0
     fluxname = None
     for field in votable.fields:
         log.info("loading field: %s ucd=%s" % (
             field.name,
             field.ucd,
         ))
         if field.ucd is None: continue
         if field.ucd.endswith("meta.main"):
             ucds.update({field.ucd: field.name})
         else:
             ucds.update({field.ucd.split(';')[0]: field.name})
         if field.ucd.startswith('phot.flux.density'):
             if field.unit == 'mJy': Jys = 1.e-3
             log.info("1 Jy is %f times catalog flux" % (1. / Jys, ))
             if field.ucd == 'phot.flux.density;em.radio.100-200MHz':
                 fluxname = field.name
             elif fluxname is None:
                 fluxname = ucds['phot.flux.density']
             log.info("using field %s for primary flux" % (fluxname, ))
         if field.ucd.startswith('em.freq'):
             if field.unit == 'MHz': GHz = 1e-3
             elif field.unit == 'kHz': GHz = 1e-6
     for rec in votable.array:
         ra = rec[ucds["pos.eq.ra;meta.main"]] * a.img.deg2rad
         dec = rec[ucds["pos.eq.dec;meta.main"]] * a.img.deg2rad
         try:
             name = rec[ucds["meta.id;meta.main"]]
         except (IndexError):
             name = pos2name(ra, dec)
         try:
             jys = rec[fluxname] * Jys
         except (IndexError):
             print fluxname, 'not found in ', rec.dtype.names
         try:
             e_S_nu = rec[ucds["stat.error"]]
         except (IndexError):
             e_S_nu = 0
         try:
             index = rec[ucds["spect.index"]]
         except (IndexError):
             try:
                 index = rec['index']
             except:
                 index = -1
         try:
             nu = rec[ucds["em.freq"]] * GHz
         except (IndexError):
             nu = default_nu
         addsrcs.append(
             RadioFixedBody(ra,
                            dec,
                            name=name,
                            jys=jys,
                            index=index,
                            mfreq=nu,
                            e_S_nu=e_S_nu,
                            vo_record=rec))
     self.add_srcs(addsrcs)
Exemplo n.º 10
0
"""
Downloaded vot file from vizier hipparcos page for the main hipparcos
catalog. Selected, hip, ra icrs, de icrs, plx, pmra, pmdec, and then 
specified vizier calculated j2000, b1950, gal and ecl, all in degrees.

Then ran this file.
"""

import numpy as np
from vo.table import parse_single_table
table = parse_single_table("hipparcos.vot", pedantic=False)
data = table.array

fs = "{0:13.8f} {1:13.8} {2:10.4f} {3:10.4f} {4:13.8}\n"

f = open("hip_icrs.txt","w")
for i in data[0::100]:
    x = [j for j in i if np.isnan(j)]
    if x: continue
    f.write(fs.format(
            i['RA_ICRS_'], i['_DE_ICRS_'],
            i['pmRA'],i['pmDE'],i['Plx']
            ))
f.close()