from astropy.table import Table
from astropy import log
log.setLevel('WARNING')
import sys
(par exemple une liste provenant d'un fichier)
def mem_list_position():
listpos = []
with open("list.txt","r") as fd:
for line in fd:
listpos.append(line.strip())
return listpos
for pos in mem_list_position():
print("!position {}".format(pos))
url = "http://vizier.u-strasbg.fr/viz-bin/votable?-source=II/246/out&-c.rs=30&-c={}".format(pos)
try:
table = Table.read(url)
except Exception as e:
sys.stderr.write(str(e)+"\n")
continue
for rec in table["_2MASS"]:
print ("o 2MASS {}".format(rec))
from string import Template
template_2mass_string = '''
o 2MASS ${name}
a i 2MASS ${name}
!c c ${ra} ${dec} (NIR) B [70 70 90] 2003yCat.2246....0C
!c m J ${jmag} [${e_jmag}] C 2003yCat.2246....0C
'''
template_2mass = Template(template_2mass_string)
def print_gsc4sim_2mass_out(table):
for record in table:
data = {'name': record["_2MASS"],
'ra': record["RAJ2000"],
'dec': record["DEJ2000"],
'jmag': record["Jmag"],
'e_jmag': record["e_Jmag"]}
print (template_2mass.substitute(data))
import numpy
for pos in mem_list_position():
print("!position {}".format(pos))
url = "http://vizier.u-strasbg.fr/viz-bin/votable?-source=II/246/out&-c.rs=30&-c={}".format(pos)
try:
table = Table.read(url)
except Exception as e:
sys.stderr.write(str(e)+"\n")
continue
ind = numpy.where(table["Jmag"]<15)
print_gsc4sim_2mass_out(table[ind])
import find_2mass
def query_2mass_2(position, radius=10):
process = find_2mass.QueryCatVizieR()
process.position = position
process.radius = radius
process.query_cat(limit=10)
try:
return process.get()
except:
return None
process = find_2mass.QueryCatVizieR()
for pos in mem_list_position():
print("!position {}".format(pos))
process.position = pos
process.radius = 30
process.query_cat(limit=10)
try:
table = process.get()
except Exception as e:
sys.stderr.write(str(e)+"\n")
continue
print (table)