GaiaData#
- class pyia.GaiaData(data, distance_colname='parallax', distance_error_colname='parallax_error', distance_unit=None, radial_velocity_colname='radial_velocity', radial_velocity_error_colname='radial_velocity_error', radial_velocity_unit=None, **kwargs)#
Bases:
object
The main class for loading and interacting with data from the Gaia mission. This should work with Gaia catalog data from any data release, i.e., DR1 gaia_source or TGAS, or DR2, EDR3, DR3 gaia_source tables.
- Parameters:
data (
Union
[Table
,str
,Path
,Dict
[str
,Union
[_SupportsArray
[dtype
[Any
]],_NestedSequence
[_SupportsArray
[dtype
[Any
]]],bool
,int
,float
,complex
,str
,bytes
,_NestedSequence
[Union
[bool
,int
,float
,complex
,str
,bytes
]]]]]) – The input Gaia data set, either as a pre-loaded table, data frame, or dictionary of columns, or a filename to load. The filename can point to any file format that can be read byastropy.table.Table
.distance_colname (
str
) – The name of the column to use for distance. Defaults toparallax
. This is useful if you use a non-Gaia column for distance.distance_error_colname (
str
) – The name of the column to use for distance error. Defaults toparallax_error
.distance_unit (
Union
[Unit
,str
,None
]) – The Astropy unit of the distance column. Defaults tou.mas
. For example, if you use the Bailer-Jones distances, you should set this tou.pc
.radial_velocity_colname (
str
) – The name of the column to use for radial velocity. Defaults toradial_velocity
. This is useful if you use a non-Gaia column for radial velocity, such as from a spectroscopic survey that is cross-matched to Gaia.radial_velocity_error_colname (
str
) – The name of the column to use for radial velocity error. Defaults toradial_velocity_error
.radial_velocity_unit (
Union
[Unit
,str
,None
]) – The Astropy unit of the radial velocity column. Defaults tou.km/u.s
.**kwargs (
Any
) – Any additional keyword arguments are passed toastropy.table.Table
read()
.
Attributes Summary
Assumes 1/parallax.
Distance modulus
Return an
SkyCoord
object to represent all coordinates.Tangential velocity computed using the proper motion and inverse parallax as the distance.
Methods Summary
filter
(**kwargs)Filter the data based on columns and data ranges.
from_query
(query_str[, login_info, verbose])Run the specified query and return a
GaiaData
instance with the returned data.from_source_id
(source_id[, source_id_dr, ...])Retrieve data from a DR for a given Gaia source_id in a DR.
get_BP0
(**kwargs)Return the extinction-corrected G_BP magnitude.
get_G0
(**kwargs)Return the extinction-corrected G-band magnitude.
get_RP0
(**kwargs)Return the extinction-corrected G_RP magnitude.
get_abs_mag
([mag_name])Return the absolute magnitude.
get_cov
([RAM_threshold, coords, units, ...])The Gaia data tables contain correlation coefficients and standard deviations for (ra, dec, parallax, pm_ra, pm_dec), but for most analyses we need covariance matrices.
get_distance
([min_parallax, fill_value, ...])Compute distance from parallax (by inverting the parallax) using
Distance
.get_ebv
([dustmaps_cls])Compute the E(B-V) reddening at this location
get_error_samples
([size, rng])Generate a sampling from the Gaia error distribution for each source.
get_ext
([ebv, dustmaps_cls])Compute the E(B-V) reddening at this location
get_pm
([frame])Get the 2D proper motion array in the specified frame
get_radial_velocity
([fill_value])Return radial velocity but with invalid values filled with the specified fill value.
get_ruwe
()- rtype:
get_skycoord
([distance, radial_velocity, ...])Return an
SkyCoord
object to represent all coordinates.get_uwe
()Compute and return the unit-weight error.
Attributes Documentation
- distance#
Assumes 1/parallax. Has shape (nrows,).
This attribute will raise an error when there are negative or zero parallax values. For more flexible retrieval of distance values and auto-filling bad values, use the .get_distance() method.
- distmod#
Distance modulus
- skycoord#
Return an
SkyCoord
object to represent all coordinates. Note: this requires Astropy v3.0 or higher!Use the
get_skycoord()
method for more flexible access.
- vtan#
Tangential velocity computed using the proper motion and inverse parallax as the distance. Has shape (nrows, 2)
Methods Documentation
- filter(**kwargs)#
Filter the data based on columns and data ranges.
- Parameters:
**kwargs (
Any
) – Keys should be column names, values should be tuples representing ranges to select the column values withing. For example, to select parallaxes between 0.5 and 5, passparallax=(0.5, 5)*u.mas
. Pass None to skip a filter, for exampleparallax=(None, 5*u.mas)
would select all parallax values < 5 mas.- Returns:
The same data table, but filtered.
- Return type:
GaiaData
- classmethod from_query(query_str, login_info=None, verbose=False)#
Run the specified query and return a
GaiaData
instance with the returned data.This is meant only to be used for quick queries to the main Gaia science archive. For longer queries and more customized usage, use TAP access to any of the Gaia mirrors with, e.g., astroquery or pyvo.
This requires
astroquery
to be installed.- Parameters:
- Returns:
An instance of this object.
- Return type:
- classmethod from_source_id(source_id, source_id_dr=None, data_dr=None, **kwargs)#
Retrieve data from a DR for a given Gaia source_id in a DR.
Useful if you have, e.g., a DR2 source_id and want EDR3 data.
- Parameters:
source_id (
int
) – The Gaia source_idsource_id_dr (
Optional
[str
]) – The data release slug (e.g., ‘dr2’ or ‘edr3’) for the input source_id. Defaults to the latest data release.data_dr (
Optional
[str
]) – The data release slug (e.g., ‘dr2’ or ‘edr3’) to retrieve data from. Defaults to the latest data release.**kwargs (
Any
) – Passed tofrom_query()
- Returns:
An instance of this object.
- Return type:
- get_BP0(**kwargs)#
Return the extinction-corrected G_BP magnitude. Any arguments are passed to
get_ext()
.
- get_G0(**kwargs)#
Return the extinction-corrected G-band magnitude. Any arguments are passed to
get_ext()
.
- get_RP0(**kwargs)#
Return the extinction-corrected G_RP magnitude. Any arguments are passed to
get_ext()
.
- get_abs_mag(mag_name='phot_g_mean_mag')#
Return the absolute magnitude.
- get_cov(RAM_threshold=<Quantity 1. Gbyte>, coords=None, units=None, warn_missing_corr=False)#
The Gaia data tables contain correlation coefficients and standard deviations for (ra, dec, parallax, pm_ra, pm_dec), but for most analyses we need covariance matrices. This converts the data provided by Gaia into covariance matrices.
If a radial velocity exists, this also contains the radial velocity variance. If radial velocity doesn’t exist, that diagonal element is set to inf.
The default units of the covariance matrix are [degree, degree, mas, mas/yr, mas/yr, km/s], but this can be modified by passing in a dictionary with new units. For example, to change just the default ra, dec units for the covariance matrix, you can pass in:
units=dict(ra=u.radian, dec=u.radian)
- get_distance(min_parallax=None, fill_value=nan, allow_negative=False)#
Compute distance from parallax (by inverting the parallax) using
Distance
.- Parameters:
- Returns:
A
Distance
object with the data.- Return type:
- get_ebv(dustmaps_cls=None)#
Compute the E(B-V) reddening at this location
This requires the dustmaps package to run!
- Parameters:
- Returns:
The E(B-V) reddening values.
- Return type:
- get_error_samples(size=1, rng=None, **get_cov_kwargs)#
Generate a sampling from the Gaia error distribution for each source.
This function constructs the astrometric covariance matrix for each source and generates a specified number of random samples from the error distribution for each source. This does not handle spatially-dependent correlations. Samplings generated with this method can be used to, e.g., propagate the Gaia errors through coordinate transformations or analyses.
- Parameters:
- Returns:
The same data table, but now each Gaia coordinate entry contains samples from the error distribution.
- Return type:
GaiaData
- get_ext(ebv=None, dustmaps_cls=None)#
Compute the E(B-V) reddening at this location
This requires the dustmaps package to run!
- Parameters:
- Return type:
- Returns:
- get_pm(frame='icrs')#
Get the 2D proper motion array in the specified frame
- Parameters:
frame (
Union
[str
,BaseCoordinateFrame
]) – The coordinate frame to return the proper motion vector in. Has shape (nrows, 2)- Returns:
A 2D array of proper motion values in the specified frame.
- Return type:
- get_radial_velocity(fill_value=None)#
Return radial velocity but with invalid values filled with the specified fill value.
- get_skycoord(distance=None, radial_velocity=None, ref_epoch=<Time object: scale='tt' format='jyear' value=2016.0>)#
Return an
SkyCoord
object to represent all coordinates. Note: this requires Astropy v3.0 or higher!ref_epoch is used to set the obstime attribute on the coordinate objects. This is often included in the data release tables, but ref_epoch here is used if it’s not.
- Parameters:
distance (
Optional
[Quantity
]) – IfNone
, this inverts the parallax to get the distance from the Gaia data. IfFalse
, distance information is ignored. If an astropyQuantity
orDistance
object, it sets the distance values of the outputSkyCoord
to whatever is passed in.radial_velocity (
Optional
[Quantity
]) – IfNone
, this uses radial velocity data from the input Gaia table. If an astropyQuantity
object, it sets the radial velocity values of the outputSkyCoord
to whatever is passed in.ref_epoch (
str
) – The reference epoch of the data. If not specified, this will try to read it from the input Gaia data table. If not provided, this will be set to whatever the most recent data release is, so, beware!
- Returns:
The coordinate object constructed from the input Gaia data.
- Return type: