Mini Tools for Gaia data

Note

astroNN only contains a limited amount of necessary tools. For a more comprehensive python tool to deal with Gaia data, please refer to Jo Bovy’s gaia_tools

astroNN.gaia module provides a handful of tools to deal with astrometry and photometry. The mission of the GAIA spacecraft is to create a dynamic, three-dimensional map of the Milky Way Galaxy by measuring the distances, positions and proper motion of stars. To do this, the spacecraft employs two telescopes, an imaging system, an instrument for measuring the brightness of stars, and a spectrograph. Launched in 2013, GAIA orbits the Sun at Lagrange point L2, 1.5 million kilometres from Earth. By the end of its five-year mission, GAIA will have mapped well over one billion stars—one percent of the Galactic stellar population.

ESA Gaia satellite: http://sci.esa.int/gaia/

Gaia Data Downloader

astroNN Gaia data downloader always act as functions that will return you the path of downloaded file(s), and download it if it does not exist locally. If the file cannot be found on server, astroNN will generally return False as the path.

Load Gaia DR2 - Apogee DR14 matches

astroNN.gaia.gaiadr2_parallax(cuts=True, keepdims=False, offset=False)[source]

Load Gaia DR2 - APOGEE DR14 matches, indices corresponds to APOGEE allstar DR14 file

Parameters
  • cuts (Union[boolean, float]) – Whether to cut bad data (negative parallax and percentage error more than 20%), or a float to set the threshold

  • keepdims (boolean) – Whether to preserve indices the same as APOGEE allstar DR14, no effect when cuts=False, set to -9999 for bad indices when cuts=True keepdims=True

  • offset (Union[boolean, float, str]) –

    Whether to correction Gaia DR2 zero point offset

    • False to assume no offset correction

    • True to assume 52.8-4.21(G-12.2)

    • ”leungbovy2019” for leung & bovy 2019 offset correction

    • a float to assume a float offset globally

Returns

numpy array of ra, dec, parallax, parallax_error

Return type

ndarrays

History

2018-Apr-26 - Written - Henry Leung (University of Toronto)

1 from astroNN.gaia import gaiadr2_parallax
2
3 # To load Gaia DR2 - APOGEE DR14 matches, indices corresponds to APOGEE allstar DR14 file
4 ra, dec, parallax, parallax_error = gaiadr2_parallax(cuts=True, keepdims=False, offset=False)

Gaia DR1 TGAS Downloader and Loader

astroNN.gaia.tgas(flag=None)[source]

Get path to the Gaia TGAS DR1 files, download if files not found

Returns

List of file path

Return type

list

History

2017-Oct-13 - Written - Henry Leung (University of Toronto)

To download TGAS DR1, moreover TGAS is only available in DR1

1 from astroNN.gaia import tgas
2
3 # To download tgas dr1 to GAIA_TOOLS_DATA and it will return the list of path to those files
4 files_paths = tgas()

To load Gaia TGAS

astroNN.gaia.tgas_load(cuts=True)[source]

To load useful parameters from multiple TGAS DR1 files

Parameters

cuts (Union[boolean, 0.2]) – Whether to cut bad data (negative parallax and percentage error more than 20%, or a custom cut percentage)

Returns

Dictionary of parameters

Return type

dict

History

2017-Dec-17 - Written - Henry Leung (University of Toronto)

 1 from astroNN.gaia import tgas_load
 2
 3 # To load the tgas DR1 files and return a dictionary of ra(J2015), dec(J2015), pmra, pmdec, parallax, parallax error, g-band mag
 4 # cuts=True to cut bad data (negative parallax and percentage error more than 20%)
 5 output = tgas_load(cuts=True)
 6
 7 # outout dictionary
 8 output['ra']  # ra(J2015)
 9 output['dec']  # dec(J2015)
10 output['pmra']  # proper motion in RA
11 output['pmdec']  # proper motion in DEC
12 output['parallax']  # parallax
13 output['parallax_err']  # parallax error
14 output['gmag']  # g-band mag

Gaia_source DR1 Downloader

No plan to support DR2 Gaia Source, please refers to Jo Bovy’s https://github.com/jobovy/gaia_tools

1 from astroNN.gaia import gaia_source
2
3 # To download gaia_source DR1 to GAIA_TOOLS_DATA and it will return the list of path to those files
4 files_paths = gaia_source(dr=1)

Anderson et al 2017 Improved Parallax from Data-driven Stars Model

Anderson2017 is described in here: https://arxiv.org/pdf/1706.05055

Please be advised starting from 26 April 2018, anderson2017 in astroNN is reduced to parallax cross matched with APOGEE DR14 only. If you see this message, anderson2017 in this astroNN version is reduced. Moreover, anderson2017 will be removed in the future

1 from astroNN.gaia import anderson_2017_parallax
2
3 # To load the improved parallax
4 # Both parallax and para_var is in mas
5 # cuts=True to cut bad data (negative parallax and percentage error more than 20%)
6 ra, dec, parallax, para_err = anderson_2017_parallax(cuts=True)

fakemag (dummy scale)

fakemag is an astroNN dummy scale primarily used to preserve the gaussian standard error from Gaia. astroNN always assume there is no error in apparent magnitude measurement.

\(L_\mathrm{fakemag} = \varpi 10^{\frac{1}{5}m_\mathrm{apparent}} = 10^{\frac{1}{5}M_\mathrm{absolute}+2}\), where \(\varpi\) is parallax in mas

You can get a sense of the fakemag scale from the following plot

_images/fakemag_scale.png

Coordinates Matching between catalogs xmatch

astroNN.datasets.xmatch.xmatch(ra1, dec1, ra2, dec2, epoch1=2000.0, epoch2=2000.0, pmra2=None, pmdec2=None, maxdist=2)[source]

Cross-matching between arrays by RA/DEC coordiantes

Parameters
  • ra1 (ndarray) – 1d array for the first catalog RA

  • dec1 (ndarray) – 1d array for the first catalog DEC

  • ra2 (ndarray) – 1d array for the second catalog RA

  • dec2 (ndarray) – 1d array for the second catalog DEC

  • epoch1 (Union([float, ndarray])) – Epoch for the first catalog, can be float or 1d array

  • epoch1 – Epoch for the second catalog, can be float or 1d array

  • pmra2 (ndarray) – RA proper motion for second catalog, only effective if epoch1 not equals epoch2

  • pmdec2 (ndarray) – DEC proper motion for second catalog, only effective if epoch1 not equals epoch2

  • maxdist (float) – Maximium distance in arcsecond

Returns

numpy array of ra, dec, separation

Return type

ndarrays

History
2018-Jan-25 - Written - Henry Leung (University of Toronto)
2021-Jan-29 - Updated - Henry Leung (University of Toronto)

Here is an example

 1 from astroNN.datasets import xmatch
 2 import numpy as np
 3
 4 # Some coordinates for cat1, J2000.
 5 cat1_ra = np.array([36.,68.,105.,23.,96.,96.])
 6 cat1_dec = np.array([72.,56.,54.,55.,88.,88.])
 7
 8 # Some coordinates for cat2, J2000.
 9 cat2_ra = np.array([23.,56.,222.,96.,245.,68.])
10 cat2_dec = np.array([36.,68.,82.,88.,26.,56.])
11
12 # Using maxdist=2 arcsecond separation threshold, because its default, so not shown here
13 # Using epoch1=2000. and epoch2=2000., because its default, so not shown here
14 # because both datasets are J2000., so no need to provide pmra and pmdec which represent proper motion
15 idx_1, idx_2, sep = xmatch(ra1=cat1_ra, dec1=cat1_dec, ra2=cat2_ra, dec2=cat2_dec)
16
17 print(idx_1)
18 >>> [1 4 5]
19 print(idx_2)
20 >>> [5 3 3]
21 print(cat1_ra[idx_1], cat2_ra[idx_2])
22 >>> [68. 96. 96.], [68. 96. 96.]
23
24 # What happens if we swap cat_1 and cat_2
25 idx_1, idx_2, sep = xmatch(ra1=cat2_ra, dec1=cat2_dec, ra2=cat1_ra, dec2=cat1_dec)
26
27 print(idx_1)
28 >>> [3 5]
29 print(idx_2)
30 >>> [4 1]
31 print(cat1_ra[idx_2], cat2_ra[idx_1])
32 >>> [96. 68.], [96. 68.]  # xmatch cant find all the match