示例#1
0
from gaia_tools import query
import matplotlib
matplotlib.use("AGG")
import matplotlib.pyplot as plt

globquery="""select ra, dec, l, b, pmra, pmdec from gaiadr2.gaia_source where abs(l-305.35370)<0.1 and a\
bs(b-(-40.47324))<0.1 limit 100"""

out=query.query(globquery,local=True,timeit=True)

plt.figure()
plt.scatter(out['l'], out['b'])
plt.show()
示例#2
0
skip = 17  # divisor of len(source_id), such that we get all
cnt = 0
for tmin, tmax in zip(source_id_min[::skip], source_id_max[skip - 1::skip]):
    tmass_filename = os.path.join(
        'tmass_best_neighbour', 'csv',
        'tmass_best_neighbour_{}_{}.csv.gz'.format(tmin, tmax))
    if os.path.exists(tmass_filename):
        continue
    print("Working on source_id between {} and {}".format(tmin, tmax))
    sql_query = """SELECT tmass_match.*, tmass.designation, tmass.ra, tmass.dec, tmass.j_m, tmass.j_msigcom, tmass.h_m, tmass.h_msigcom, tmass.ks_m, tmass.ks_msigcom, tmass.ext_key, tmass.ph_qual
FROM gaiadr2.tmass_best_neighbour AS tmass_match
INNER JOIN gaiadr1.tmass_original_valid AS tmass ON tmass.tmass_oid = tmass_match.tmass_oid
WHERE tmass_match.source_id BETWEEN {} AND {};""".format(tmin, tmax)
    while True:
        try:
            data = query.query(sql_query, use_cache=False, verbose=True)
        except:
            # Wait a while, try again ...
            time.sleep(60)
            continue
        else:
            break
    data['original_ext_source_id'] = data['original_ext_source_id'].astype(str)
    data['designation'] = data['ph_qual'].astype(str)
    data['ph_qual'] = data['ph_qual'].astype(str)
    # Save
    ascii.write(data, tmass_filename.replace('csv.gz', 'csv'), delimiter=',')
    try:
        subprocess.check_call(
            ['gzip', tmass_filename.replace('csv.gz', 'csv')])
    except: