API documentation

Mock clusters

class kinesis.mock.Cluster(v0, sigmav, omegas=None, ws=None, k=0, b0=None, T=None)

Make a cluster with mean velocity v0 and dispersion sigma.

All length units are assumed to be pc. All velocity units are assumed to be km/s. All angular frequency units are in km/s/kpc = m/s/pc.

Parameters
  • v0 (array-like, (3,)) – Mean velocity vector in km/s

  • sigmav (float, array-like) – dispersion If float, interpreted as the isotropic velocity dispersion. If (3,) array, interpreted as \((\sigma_x, \sigma_y, \sigma_z)\). If (3,3) array, interpreted as the covariance matrix in \(( {\rm km} /{\rm s} )^2\)

  • omegas (array-like, (3,), optional) – Angular frequencies of rotation around x, y, z axis

  • ws (array-like, (5,), optional) – Non-isotropic dilation.

  • k (float, optional) – Isotropic expansion (or contraction).

  • b0 (array-like, (3,), optional) – Reference position vector where velocity field v = v0. Only matters when at least one of omegas, ws and k is non-zero.

members

Use sample_sphere or sample_at to populate the cluster.

Type

None or ClusterMembers instance

b0

center of cluster in pc

Type

array-like, [x, y, z]

v0

mean velocity of cluster in km/s

Type

array-like, [vx, vy, vz]

sigmav

velocity dispersion

Type

float, array-like

property N

Size of the cluster

property Sigma

(3, 3) dispersion matrix \(\Sigma\)

classmethod from_coord(cluster_coord, sigmav, omegas=None, ws=None)

Make a cluster from astropy coordinates cluster_coord

Parameters

cluster_coord (BaseCoordinateFrame) – coordinates containing cluster position and velocity

The rest of the arguments are the same as Cluster.

property icrs

astropy coordinate object for the cluster reference position, b0

observe(*args, **kwargs)

Add noise to cluster members. See Cluster.members.observe.

sample_at(positions)

Sample cluster members at given positions

Parameters

positions (BaseCoordinateFrame) – positions of member stars

Returns

self with members attribute populated.

sample_sphere(N=1, Rmax=10)

Sample cluster members around mean position with uniform density

Parameters
  • N (int) – number of stars

  • Rmax (float) – maximum radius from the mean position in pc

Returns

self with members attribute populated.

class kinesis.mock.ClusterMembers(coordinates)

Initialize cluster members with coordinates

Parameters
  • coordinates (BaseCoordinateFrame) – must contain positions and velocities

  • N (int) – number of members

  • icrs (ICRS) – ICRS coordinates with spherical representation

  • df (DataFrame) – simulated data without noise with Gaia-like columns

  • data (DataFrame) – simulated data with noise with Gaia-like columns

observe(cov=None, error_from=None, rv_error=None)

Add noise to cluster members using either covariance matrices or randomly assigning Gaia dataframe.

Parameters
  • cov (array) – covariance matrix. If cov is one covariance matrix (3, 3) of parallax, pmra, pmdec, this is the covariance assumed for all members. Otherwise it must be (N, 3, 3).

  • error_from (DataFrame) – Take errors from this Gaia DataFrame. gaia_source table containing error and correlation (e.g., ‘pmra_pmdec_corr’) columns. Members are assigned errors from this table randomly.

  • rv_error (array) – Radial velocity errors in km/s. NaN is treated as missing.

Models

class kinesis.models.AllCombined(recompile=False)
class kinesis.models.Basic(recompile=False)
kinesis.models.get_model(model_name, recompile=False)

Get compiled StanModel This will compile the stan model if a cached pickle does not exist.

Parameters
  • model_name (str) – model name without .stan

  • recompile (bool) – Force force recompilation.

Utilities

kinesis.utils.cov_from_gaia_table(df)

Returns array of covariance matrix of parallax, pmra, pmdec with shape (N, 3, 3).

kinesis.utils.load_stanfit(filename)

Load stanfit object from a pickle file

kinesis.utils.save_stanfit(stanfit, outfile)

Save stanfit object as pickle

stanfit (pystan.StanFit4Model): fit object outfile (str): path to output file