[Pythoneers] astroquery

Leonard Burtscher burtscher at mpe.mpg.de
Tue Mar 10 17:08:50 CET 2015


Sorry, one line was missing:

from astroquery.ned import Ned

There are also a lot of other interfaces, check the astroquery webpage for the list.

> Am 10.03.2015 um 17:07 schrieb Leonard Burtscher <burtscher at mpe.mpg.de>:
> 
> Hi pythoneers,
> 
> In case you need to query an astronomical database for a number of targets, e.g. get coordinates for a list of objects, this may be handy:
> 
> crs=open("Desktop/sources.txt","r")
> 
> for source in crs:
>    obj=Ned.query_object(source)
>    print("insert into sources values(\"{source}\",\"{name}\",\"{ra}\",\"{dec}\",\"{z}\");".format(source=source.strip(),name=obj[0]['Object Name'].decode(),ra=obj[0]['RA(deg)'],dec=obj[0]['DEC(deg)'],z=obj[0]['Redshift']))
> 
> The return then looks like:
> insert into sources values("ESO137-G034","ESO 137- G 034","248.80879","-58.08003","0.009144");
> insert into sources values("ESO093-G003","ESO 093- G 003","164.85846","-66.33281","0.006106");
> insert into sources values("ESO208-G021","ESO 208- G 021","113.48438","-50.44303","0.003619");
> insert into sources values("IC4653","IC 4653","261.77991","-60.87958","0.006404");
> ...
> 
> In this case, I formatted the answer as an SQL insert statement.
> 
> You need to install astroquery (pip install astroquery) for that to work.
> 
> Ciao,
> Leonard
> 
> 
> _______________________________________________
> Pythoneers mailing list
> Pythoneers at lists.mpe.mpg.de
> https://lists.mpe.mpg.de/cgi-bin/mailman/listinfo/pythoneers




More information about the Pythoneers mailing list