예제 #1
0
def main(options):
   objName = options.srcID
   radInDeg = float(options.radius)
   outFileName = options.output
   inOnePatch = options.patch

   # Get the sources in the cut-out as a VO table 
   url = 'http://vo.astron.nl/tgssadr/q/cone/scs.xml'
   t = vo.conesearch(url, pos = vo.object2pos(objName), radius = radInDeg )

   f = open(outFileName, 'w')
   if options.patch:
      # Write all selected components as a single patch
      f.write("FORMAT = Name, Type, Patch, Ra, Dec, I, Q, U, V, MajorAxis, MinorAxis, Orientation, ReferenceFrequency='147610000.0', SpectralIndex='[]'\n\n")
      # Get the coordinates of the source
      c = SkyCoord(float(vo.object2pos(objName)[0]), float(vo.object2pos(objName)[1]), unit='deg')
      newRA = c.to_string('hmsdms').split(' ')[0].replace('h',':').replace('m',':').replace('s','')
      newDec = c.to_string('hmsdms').split(' ')[1].replace('d','.').replace('m','.').replace('s','')
      # Create the patch
      f.write(' , , Patch, {ra}, {dec}\n'.format(ra=newRA, dec=newDec))
      for item in t:
         # VO table has RA and DEC in degrees. Convert it to hmsdms format
         c = SkyCoord(float(item['RA']), float(item['DEC']), unit='deg')
         newRA = c.to_string('hmsdms').split(' ')[0].replace('h',':').replace('m',':').replace('s','')
         newDec = c.to_string('hmsdms').split(' ')[1].replace('d','.').replace('m','.').replace('s','')
	 # Determine whether source is extended
	 sratio = item['Sint']/item['Spk']
	 if sratio > 1.25:
		srctype='GAUSSIAN'
		majaxsize = (max([item['MAJAX'],25.])**2-25.**2)**0.5
		minaxsize = (max([item['MINAX'],25.])**2-25.**2)**0.5
	 else:
		srctype='POINT'
		majaxsize = ""
		minaxsize = ""
         # Write an entry for this source into the output file inside the above defined patch
         f.write("{name}, {type}, Patch, {ra}, {dec}, {i}, 0, 0, 0, {ma}, {mi}, {pa}, , [-0.8]\n".format(name=item['ID'], type=srctype, ra=newRA, dec=newDec, i=item['Sint']/1e3, ma=majaxsize, mi=minaxsize, pa=item['PA']))
   else:
      # Writes sources without a patch
      f.write("FORMAT = Name, Type, Ra, Dec, I, Q, U, V, MajorAxis, MinorAxis, Orientation, ReferenceFrequency='147610000.0', SpectralIndex='[]'\n\n")
      for item in t:
         # VO table has RA and DEC in degrees. Convert it to hmsdms format
         c = SkyCoord(float(item['RA']), float(item['DEC']), unit='deg')
         newRA = c.to_string('hmsdms').split(' ')[0].replace('h',':').replace('m',':').replace('s','')
         newDec = c.to_string('hmsdms').split(' ')[1].replace('d','.').replace('m','.').replace('s','')
	 # Determine whether source is extended
	 sratio = item['Sint']/item['Spk']
	 if sratio > 1.25:
		srctype='GAUSSIAN'
		majaxsize = (max([item['MAJAX'],25.])**2-25.**2)**0.5
		minaxsize = (max([item['MINAX'],25.])**2-25.**2)**0.5
	 else:
		srctype='POINT'
		majaxsize = ""
		minaxsize = ""
         # Write an entry for this source into the output file
         f.write("{name}, {type}, {ra}, {dec}, {i}, 0, 0, 0, {ma}, {mi}, {pa}, , [-0.8]\n".format(name=item['ID'], type=srctype, ra=newRA, dec=newDec, i=item['Sint']/1e3, ma=majaxsize, mi=minaxsize, pa=item['PA']))
   f.close()
def searchLofarPublicArchive(srcName, distance):
   # First get the coordinates of the source from NED
   try:
      t = vo.object2pos(srcName, db='NED')
   except:
      raise Exception('Error: Unable to resolve the specified target')
   ra  = t[0]
   dec = t[1]
   
   # Get a list of all the pointings in the LTA
   project = 'ALL'
   ok = context.set_project(project)
   obs_ids = set()
   query = (Pointing.rightAscension < (ra + distance)) &\
           (Pointing.rightAscension > (ra - distance)) &\
           (Pointing.declination    < (dec + distance))  &\
           (Pointing.declination    > (dec - distance))
   projectID = []
   for pointing in query:
      query_subarr = SubArrayPointing.pointing == pointing
      for subarr in query_subarr:
         query_obs = Observation.subArrayPointings.contains(subarr)
         for obs in query_obs:
            print obs.observingMode, obs.numberOfBitsPerSample, obs.numberOfSubArrayPointings
            if obs.numberOfSubArrayPointings <= 2 and \
               obs.numberOfBitsPerSample >= 8:
               #obs.observingMode == 'Interferometer':
               projectID.append( obs.get_project() )
   return projectID   
예제 #3
0
def main(options):
    # Get the list of calibrators
    calList = options.cal.split(',')
    
    # Resolve the target
    try: t = vo.object2pos(options.target, db='NED')
    except:
       print 'Unable to query the target. Terminating execution'
       sys.exit(1)
    target = SkyCoord(ra=t[0]*u.degree, dec=t[1]*u.degree)
    print "\nTarget: {} ({} {})\n".format(options.target, t[0], t[1])
    print "Calibrator\tDistance from target"
    print "==========\t===================="
    
    for cal in calList:
        try: c = vo.object2pos(cal)
        except: 
            print 'Unable to resolve target {}'.format(cal)
            continue
        calib = SkyCoord(ra=c[0]*u.degree, dec=c[1]*u.degree)
        distance = target.separation(calib)
        print "{}\t{}".format(cal, distance)
예제 #4
0
#! /usr/bin/env python
import pyvo as vo

# obtain your list of positions from somewhere
sourcenames = ["ngc4258", "m101", "m51"]
mysources = {}
for src in sourcenames:
    mysources[src] = vo.object2pos(src)

# create an output directory for cutouts
import os
if not os.path.exists("NVSSimages"):
    os.mkdir("NVSSimages")

# setup a query object for NVSS
nvss = "http://skyview.gsfc.nasa.gov/cgi-bin/vo/sia.pl?survey=nvss&"
query = vo.sia.SIAQuery(nvss)
query.size = 0.2  # degrees
query.format = 'image/fits'
for name, pos in mysources.items():
    query.pos = pos
    results = query.execute()
    for image in results:
        print "Downloading %s..." % name
        image.cachedataset(filename="NVSSimages/%s.fits" % name)
예제 #5
0
#! /usr/bin/env python
import pyvo as vo

# find archives with x-ray images
archives = vo.regsearch(servicetype='image', waveband='xray')
                        
# position of my favorite source
pos = vo.object2pos('Cas A')

# find images and list in a file
with open('cas-a.csv', 'w') as csv:
    print >> csv, "Archive short name,Archive title,Image", \
                   "title,RA,Dec,format,URL"
    for arch in archives:
        print "searching %s..." % arch.shortname
        try:
             matches = arch.search(pos=pos, size=0.25)
        except vo.DALAccessError, ex:
             print "Trouble accessing %s archive (%s)"\
                   % (arch.shortname, str(ex))
             continue
        print "...found %d images" % matches.nrecs
        for image in matches:
             print >> csv, ','.join(
              (arch.shortname, arch.title, image.title,
               str(image.ra), str(image.dec), image.format,
               image.getdataurl()) )
예제 #6
0
#! /usr/bin/env python
import pyvo as vo

# obtain your list of positions from somewhere
sourcenames = ["ngc4258", "m101", "m51"]
mysources = {}
for src in sourcenames:
    mysources[src] = vo.object2pos(src)

# create an output directory for cutouts
import os
if not os.path.exists("NVSSimages"):
    os.mkdir("NVSSimages")

# setup a query object for NVSS
nvss = "http://skyview.gsfc.nasa.gov/cgi-bin/vo/sia.pl?survey=nvss&"
query = vo.sia.SIAQuery(nvss)
query.size = 0.2                 # degrees
query.format = 'image/fits'
for name, pos in mysources.items():
    query.pos = pos
    results=query.execute()
    for image in results:
        print "Downloading %s..." % name
        image.cachedataset(filename="NVSSimages/%s.fits" % name)
예제 #7
0
#! /usr/bin/env python
import pyvo as vo

# find archives with x-ray images
archives = vo.regsearch(servicetype='image', waveband='xray')

# position of my favorite source
pos = vo.object2pos('Cas A')

# find images and list in a file
with open('cas-a.csv', 'w') as csv:
    print("Archive short name,Archive title,Image"
          "title,RA,Dec,format,URL",
          file=csv)
    for arch in archives:
        print("searching %s..." % arch.shortname)
        try:
            matches = arch.search(pos=pos, size=0.25)
        except vo.DALAccessError as ex:
            print("Trouble accessing %s archive (%s)" %
                  (arch.shortname, str(ex)))
            continue
        print("...found %d images" % matches.nrecs)
        for image in matches:
            print(','.join(
                (arch.shortname, arch.title, image.title, str(image.ra),
                 str(image.dec), image.format, image.getdataurl())),
                  file=csv)