Components#

Components classes are related via the inheritance diagram,

Inheritance diagram of FromParticle, Stream, GrowingDisk, Mixture

For each subclass, this API lists public methods are new or newly re-implemted for that subclass e.g. a docstring for evaluate_ybar appears for Component, ParametricComponent and Mixture as they have their own implementations, while it does not appear for FromParticle which inherits evaluate_ybar from Component.

Component#

class popkinmocks.components.Component(cube=None, log_p_tvxz=None)#

A galaxy component specified by the (log) joint density p(t,v,x,z)

Sub-classes of Component correspond to specific choices of p(t,x,v,z). Main methods are get_p to evaluate probability functions and get_mean, get_variance, get_skewness, get_kurtosis to get moments.

Parameters:
  • cube – a pkm.mock_cube.mockCube.

  • log_p_txvz (array) – 5D array of natural log of mass-weighted probabilty density i.e. log p(t,v,x1,x2,z)

dill_dump(fname, direc=None)#

Save the component using dill

Makes the directory if it does not already exist. Saves component there using dill.

Parameters:
  • fname (string) – filename

  • direc (string, optional) – directory name

evaluate_ybar(batch='none')#

Evaluate the datacube for this component

This evaluates the full integral assuming a 5D joint density i.e.:

\[\bar{y}(x, \omega) = \int S(\omega-v ; t,z) p(t,v,x,z) dv dt dz\]

where omega is log lambda. This integral is a convolution over velocity v, which we evaluate using FFTs. FFTs of SSP templates are stored in`ssps.FXw` while FFTs of (the velocity part of) the density p(t,v,x,z) are evaluated here. Sets the result to self.ybar.

Parameters:

batch (bool, optional) – evaluate datacube row by row, default False

get_central_moment(which_dist, j, light_weighted=False)#

Get central moment of a 1D distribution

See full docstring of self.get_mean for restrictions on which_dist and meaning of output.

Parameters:
  • which_dist (string) – which distribution to take central moment of.

  • j (int) – moment order

  • light_weighted (bool) – whether to return light-weighted (True) or mass-weighted (False) quantity

Returns:

the central moment or conditional central moment

Return type:

float/array

get_correlation(which_dist, light_weighted=False)#

Get correlation or conditional correlation of a 2D distribution

\[\mathbb{Cor}(a,b|c) = \frac{\mathbb{Cov}(a,b|c)}{\sqrt{\mathbb{Var}(a|c)\mathbb{Var}(b|c)}}\]
Parameters:
  • which_dist (string) – a bivariate distribution to take covariance of

  • light_weighted (bool) – whether to return light-weighted (True) or mass-weighted (False) quantity

Returns:

the correlation or conditional correlation

Return type:

float/array

get_covariance(which_dist, light_weighted=False)#

Get covariance or conditional covariance of a 2D distribution

For two variables a,b out of (‘t’, ‘v’, ‘x’, ‘z’) get their covariance

\[\mathbb{Cov}(a,b)=\int p(a,b)(a-\mathbb{E}(a))(b-\mathbb{E}(b))\;da\;db\]

or conditional covariance given a third variable c,

\[\mathbb{Cov}(a,b|c)=\int p(a,b|c)(a-\mathbb{E}(a|c))(b-\mathbb{E}(b|c))\;da\;db\]

where integrals estimated via summation over discretisation bins in a/b.

Parameters:
  • which_dist (string) – a bivariate distribution to take covariance of

  • light_weighted (bool) – whether to return light-weighted (True) or mass-weighted (False) quantity

Returns:

the covariance or conditional covariance

Return type:

float/array

get_excess_kurtosis(which_dist, light_weighted=False)#

Get excess kurtosis of a 1D distribution

See full docstring of self.get_mean for restrictions on which_dist and meaning of output.

Parameters:
  • which_dist (string) – which distribution to take ex-kurtosis of.

  • light_weighted (bool) – whether to return light-weighted (True) or mass-weighted (False) quantity

Returns:

the ex-kurtosis or conditional ex-kurtosis

Return type:

float/array

get_kurtosis(which_dist, light_weighted=False)#

Get kurtosis of a 1D distribution

See full docstring of self.get_mean for restrictions on which_dist and meaning of output.

Parameters:
  • which_dist (string) – which distribution to take kurtosis of.

  • light_weighted (bool) – whether to return light-weighted (True) or mass-weighted (False) quantity

Returns:

the kurtosis or conditional kurtosis

Return type:

float/array

get_log_p(which_dist, density=True, light_weighted=False)#

Evaluate log probability functions for this component

Evaluate marginal or conditional distributions over stellar age t, 2D position x, velocity v and metallicity z. The argument which_dist specifies which distribution to evaluate, where an underscore (if present) represents conditioning e.g.:

  • which_dist = ‘tv’ –> p(t,v),

  • which_dist = ‘tz_x’ –> p(t,z|x) etc

Variables in which_dist must be provided in alphabetical order (on either side of the underscore if present).

Parameters:
  • which_dist (string) – valid string for the distribution to evaluate

  • density (bool) – whether to return probabilty density (True) or the volume-element weighted probabilty (False)

  • light_weighted (bool) – whether to return light-weighted (True) or mass-weighted (False) quantity

Returns:

the desired distribution. Array dimensions correspond to the

order of variables as provided in which_dist string e.g. which_dist = tz_x returns p(t,z|x) as a 4D array with dimensions corresponding to [t,z,x1,x2].

Return type:

array

get_mean(which_dist, light_weighted=False)#

Get mean or conditional mean of a 1D distribution

The which_dist string specifies which distribution to mean. If which_dist contains no underscore, this returns the mean of the appropriate marginal distribution. If which_dist contains an underscore, this returns the mean of the conditional distribution e.g.:

  • which_dist = ‘v’ returns E(v) = int v p(v) dv

  • which_dist = ‘v_x’ returns E(v|x) = int v p(v|x) dv

Only works for distributions of one argument.

Parameters:
  • which_dist (string) – which distribution to mean. See full docstring.

  • light_weighted (bool) – whether to return light-weighted (True) or mass-weighted (False) quantity

Returns:

if the variable to mean is t, v or z, returns an array

with shape equal to the shape of the conditioners e.g. which_dist = ‘v_tz’ returns array shape (nt, nz) and a float if conditional. For x, the returned array has extra initial dimension of size 2 for the 2 spatial dimensions.

Return type:

float/array

get_noncentral_moment(which_dist, j, mu, light_weighted=False)#

Get noncentral moment of 1D distributions

See full docstring of self.get_mean for restrictions on which_dist and meaning of output.

Parameters:
  • which_dist (string) – which distribution to take central moment of.

  • mu (array) – center about which to take moment about, with shape broadcastable with conditioners of which_dist (if present)

  • j (int) – moment order

  • light_weighted (bool) – whether to return light-weighted (True) or mass-weighted (False) quantity

Returns:

the central moment or conditional central moment

Return type:

float/array

get_p(which_dist, density=True, light_weighted=False)#

Evaluate probability functions for this component

Evaluate marginal or conditional distributions over stellar age t, 2D position x, velocity v and metallicity z. The argument which_dist specifies which distribution to evaluate, where an underscore (if present) represents conditioning e.g.:

  • which_dist = ‘tv’ –> p(t,v),

  • which_dist = ‘tz_x’ –> p(t,z|x) etc

Variables in which_dist must be provided in alphabetical order (on either side of the underscore if present).

Parameters:
  • which_dist (string) – valid string for the distribution to evaluate

  • density (bool) – whether to return probabilty density (True) or the volume-element weighted probabilty (False)

  • light_weighted (bool) – whether to return light-weighted (True) or mass-weighted (False) quantity

Returns:

the desired distribution. Array dimensions correspond to the

order of variables as provided in which_dist string e.g. which_dist = tz_x returns p(t,z|x) as a 4D array with dimensions corresponding to [t,z,x1,x2].

Return type:

array

get_skewness(which_dist, light_weighted=False)#

Get skewness of a 1D distribution

See full docstring of self.get_mean for restrictions on which_dist and meaning of output.

Parameters:
  • which_dist (string) – which distribution to take skewness of.

  • light_weighted (bool) – whether to return light-weighted (True) or mass-weighted (False) quantity

Returns:

the variance or conditional skewness

Return type:

float/array

get_variance(which_dist, light_weighted=False)#

Get variance of a 1D distribution

See full docstring of self.get_mean for restrictions on which_dist and meaning of output.

Parameters:
  • which_dist (string) – which distribution to take variance of.

  • light_weighted (bool) – whether to return light-weighted (True) or mass-weighted (False) quantity

Returns:

the variance or conditional variance

Return type:

float/array

save_numpy(fname, yobs=None, direc=None)#

Save the component in npz format. Deprecated for dill_dump.

Saves various quantities about the cube and component in a npz file. The density p(t,v,x,z) is rearranged to p(x,v,z,t) for backward compatibility with v0.0.

Parameters:
  • fname (string) – filename

  • direc (string, optional) – directory name

  • yobs (array, optional) – the observed datacube, i.e. including noise

FromParticle#

class popkinmocks.components.FromParticle(cube, t, v, x1, x2, z, mass_weights=None)#

A component from star particle data from simulations

This is a wrapper around base.Component which makes a 5D histogram of the particle data in (t, v, x, z) space. Particles should be mass-weighted, else provide the mass_weights argument which should. All particle data should be provided as 1D arrays of the same length and ordering.

Parameters:
  • cube – a pkm.mock_cube.mockCube.

  • t (array) – ages of star particles (Gyr)

  • v (array) – line-of-sight velocities of star particles (km/s)

  • x1 (array) – x1 position of star particles (units consistent with cube)

  • x2 (array) – x2 position of star particles (units consistent with cube)

  • z (array) – metallicty of star particles ([M/H])

  • mass_weights (array) – optional, provide if particles are not equal-mass

ParametricComponent#

class popkinmocks.components.ParametricComponent(cube=None, center=(0, 0), rotation=0.0)#

Abstract class for parametrised galaxy components

The mass-weighted density factorises as

\[p(t,x,v,z) = p(t) p(x|t) p(v|t,x) p(z|t,x)\]

where:

  • p(t) : beta distribution (see set_p_t),

  • p(x|t) : function to be implemented in subclass’s set_p_x_t method

  • p(v|t,x) = Normal(v ; mu_v(t,x), sig_v(t,x)) where subclasses provide specific implementations in their set_mu_v and set_sig_v methods,

  • p(z|t,x) = Normal(z ; mu_z(t, t_dep(x)), sig_z(t, t_dep(x))) i.e. chemical enrichment depends on a spatially varying depletion timescale t_dep(x) to be implemented in the set_t_dep method of subclass.

The functions mu_z(t,t_dep) and sig_z(t,t_dep) are from equations 3-10 of Zhu et al. 20.

Parameters:
  • cube – a pkm.mock_cube.mockCube.

  • center (x0,y0) – co-ordinates of the component center.

  • rotation – angle (radians) between x-axes of component and cube.

evaluate_chemical_enrichment_model(t_dep)#

Evaluate chemical enrichment model for a single t_dep

Hacky wrapper around self.evaluate_chemical_enrichment_model

evaluate_chemical_enrichment_model_base(t_dep)#

Evaluate chemical enrichment model for a t_dep(x)

Evaluates the chemical evolution model defined in equations 3-10 of Zhu et al 2020, parameterised by a spatially varying depletion timescale created by set_t_dep.

evaluate_ybar(batch='none')#

Evaluate the datacube for this component

Evaluate the integral

\[\bar{y}(x,\omega) = \int S(\omega-v;t,z) p(t,x,z) p(v|t,x) dvdtdz\]

This integral is a convolution over velocity v, which we evaluate using Fourier transforms (FT). FTs of SSP templates are stored in`ssps.FXw` while FTs of the velocity factor p(v|t,x) are evaluated using analytic expressions of the FT of the normal distribution. Sets the result to self.ybar.

Parameters:

batch (string, optional) – one of ‘none’, ‘column’, ‘spaxel’ to evaluate datacube altogether, column-by-column or spaxel-by-spaxel

get_beta_a_b_from_lmd_phi(lmd, phi)#

Convert from (total, mean) to (a,b) parameters of beta distribution

Parameters:
  • lmd – beta distribution total parameter, lmd>0

  • phi – beta distribution mean parameter, 0<phi<1

Returns:

shape parameters

Return type:

(a,b)

get_central_moment_v(j, mu, light_weighted=False)#

Get j’th central moment of p(v)

int (v - E(v))^j p(v) dv

Parameters:
  • j (int) – order of moment

  • light_weighted (bool) – whether to return light-weighted (True) or

  • mass-weighted (False) –

Returns:

float

get_central_moment_v_t(j, light_weighted=False)#

Get j’th central moment of p(v|t)

int (v - E(v|t))^j p(v|t) dv

Parameters:
  • j (int) – order of moment

  • light_weighted (bool) – whether to return light-weighted (True) or

  • mass-weighted (False) –

Returns:

array size (nt,)

get_central_moment_v_tx(j, light_weighted=False)#

Get j’th central moment of p(v|t,x)

Uses analytic formula for moments of a mixture

Parameters:
  • j (int) – order of moment

  • light_weighted (bool) – whether to return light-weighted (True) or

  • mass-weighted (False) –

Returns:

array size (nt, nx1, nx2)

get_central_moment_v_txz(j, light_weighted=False)#

Get j’th central moment of p(v|t,x,z)

int (v - E(v|t,x,z))^j p(v|t,x,z) dv

Parameters:
  • j (int) – order of moment

  • mu (array) – arbitrary moment center, broadcastable with (nt,nx1,nx2,nz)

  • light_weighted (bool) – whether to return light-weighted (True) or

  • mass-weighted (False) –

Returns:

array size (nt,nx1,nx2,nz)

get_central_moment_v_tz(j, mu, light_weighted=False)#

Get j’th central moment of p(v|t,z)

int (v - E(v|t,z))^j p(v|t,z) dv

Parameters:
  • j (int) – order of moment

  • light_weighted (bool) – whether to return light-weighted (True) or

  • mass-weighted (False) –

Returns:

array size (nt,nz)

get_central_moment_v_x(j, light_weighted=False)#

Get j’th central moment of p(v|x)

int (v - E(v|x))^j p(v|x) dv

Parameters:
  • j (int) – order of moment

  • light_weighted (bool) – whether to return light-weighted (True) or

  • mass-weighted (False) –

Returns:

array size (nx1, nx2)

get_central_moment_v_xz(j, mu, light_weighted=False)#

Get j’th central moment of p(v|x,z)

int (v - E(v|x,z))^j p(v|x,z) dv

Parameters:
  • j (int) – order of moment

  • light_weighted (bool) – whether to return light-weighted (True) or

  • mass-weighted (False) –

Returns:

array size (nx1,nx2,nz)

get_central_moment_v_z(j, mu, light_weighted=False)#

Get j’th central moment of p(v|z)

int (v - E(v|z))^j p(v|z) dv

Parameters:
  • j (int) – order of moment

  • light_weighted (bool) – whether to return light-weighted (True) or

  • mass-weighted (False) –

Returns:

array size (nz,)

get_mean_v(light_weighted=False)#

Get expectation E(v)

Returns:

float

get_mean_v_t(light_weighted=False)#

Get conditional expectation E(v|t)

Returns:

array size (nt,)

get_mean_v_tx(light_weighted=False)#

Get conditional expectation E(v|t,x)

Returns:

array size (nt, nx1, nx2)

get_mean_v_txz(light_weighted=False)#

Get conditional expectation E(v|t,x,z)

Returns:

array size (nt, nx1, nx2, nz)

get_mean_v_tz(light_weighted=False)#

Get conditional expectation E(v|t,z)

Returns:

array size (nt, nz)

get_mean_v_x(light_weighted=False)#

Get conditional expectation E(v|x)

Returns:

array size (nx1, nx2)

get_mean_v_xz(light_weighted=False)#

Get conditional expectation E(v|x,z)

Returns:

array size (nx1, nx2, nz)

get_mean_v_z(light_weighted=False)#

Get conditional expectation E(v|z)

Returns:

array size (nz,)

get_noncentral_moment_v(j, mu, light_weighted=False)#

Get j’th noncentral moment of p(v) about arbitrary center mu

int (v - mu)^j p(v) dv

Parameters:
  • j (int) – order of moment

  • mu (float) – arbitrary moment center

  • light_weighted (bool) – whether to return light-weighted (True) or

  • mass-weighted (False) –

Returns:

float

get_noncentral_moment_v_t(j, mu, light_weighted=False)#

Get j’th noncentral moment of p(v|t) about arbitrary center mu

int (v - mu(t))^j p(v|t) dv

Parameters:
  • j (int) – order of moment

  • mu (array) – arbitrary moment center, broadcastable with (nt,)

  • light_weighted (bool) – whether to return light-weighted (True) or

  • mass-weighted (False) –

Returns:

array size (nt,)

get_noncentral_moment_v_tx(j, mu, light_weighted=False)#

Get j’th noncentral moment of p(v|t,x) about arbitrary center mu

int v (v - mu(t,x))^j p(v|t,x) dx

Parameters:
  • mu (array) – arbitrary moment center, broadcastable with (nt,nx,ny)

  • j (int) – order of moment

  • light_weighted (bool) – whether to return light-weighted (True) or

  • mass-weighted (False) –

Returns:

array size (nt, nx1, nx2)

get_noncentral_moment_v_txz(j, mu, light_weighted=False)#

Get j’th noncentral moment of p(v|t,x,z) about arbitrary center mu

int (v - mu(t,x,z))^j p(v|t,x,z) dv

Parameters:
  • j (int) – order of moment

  • mu (array) – arbitrary moment center, broadcastable with (nt,nx1,nx2,nz)

  • light_weighted (bool) – whether to return light-weighted (True) or

  • mass-weighted (False) –

Returns:

array size (nt,nx1,nx2,nz)

get_noncentral_moment_v_tz(j, mu, light_weighted=False)#

Get j’th noncentral moment of p(v|t,z) about arbitrary center mu

int (v - mu(t,z))^j p(v|t,z) dv

Parameters:
  • j (int) – order of moment

  • mu (array) – arbitrary moment center, broadcastable with (nt,nz)

  • light_weighted (bool) – whether to return light-weighted (True) or

  • mass-weighted (False) –

Returns:

array size (nt,nz)

get_noncentral_moment_v_x(j, mu, light_weighted=False)#

Get j’th noncentral moment of p(v|x) about arbitrary center mu

int (v - mu(x))^j p(v|x) dv

Parameters:
  • j (int) – order of moment

  • mu (array) – arbitrary moment center, broadcastable with (nx,ny)

  • light_weighted (bool) – whether to return light-weighted (True) or

  • mass-weighted (False) –

Returns:

array size (nx1, nx2)

get_noncentral_moment_v_xz(j, mu, light_weighted=False)#

Get j’th noncentral moment of p(v|x,z) about arbitrary center mu

int (v - mu(x,z))^j p(v|x,z) dv

Parameters:
  • j (int) – order of moment

  • mu (array) – arbitrary moment center, broadcastable with (nx1,nx2,nz)

  • light_weighted (bool) – whether to return light-weighted (True) or

  • mass-weighted (False) –

Returns:

array size (nx1,nx2,nz)

get_noncentral_moment_v_z(j, mu, light_weighted=False)#

Get j’th noncentral moment of p(v|z) about arbitrary center mu

int (v - mu(z))^j p(v|z) dv

Parameters:
  • j (int) – order of moment

  • mu (array) – arbitrary moment center, broadcastable with (nz,)

  • light_weighted (bool) – whether to return light-weighted (True) or

  • mass-weighted (False) –

Returns:

array size (nz,)

get_z_interpolation_grid(t_dep_lim=(0.1, 10.0), n_t_dep=1000, n_z=1000)#

Store a grid used for interpolating age-metallicity relations

Parameters:
  • t_dep_lim – (lo,hi) allowed values of depletion timescale in Gyr

  • n_t_dep (int) – number of steps to use for interpolating t_dep

  • n_z (int) – number of steps to use for interpolating metallicity

linear_interpolate_t(f_end, f_start)#

Linearly interpolate f against t given boundary [f_start, f_end]

Parameters:
  • f_end – value of f at end of disk build up i.e. more recently

  • f_start – value of f at start of disk build up i.e. more in the past

Returns:

f interpolated to the t array of SSP models, set to constant values outside start/end times

Return type:

array

abstract set_mu_v()#

Set spatially and age dependent mean velocity

Should set an attribute self.mu_v, a 3D array of size [nt, nx1, nx2]

set_p_t(lmd=None, phi=None, cdf_start_end=(0.05, 0.95))#

Set the mass-weighted star formation history p(t)

p(t) = Beta(t; lmd, phi), where (lmd, phi) are (total, mean) parameters. Additionally this sets self.t_pars which is used for interpolating quantities against t. Any time varying quantity (e.g. disk size) is varied between start and end times as specified by CDF p(t).

Parameters:
  • lmd – beta distribution total parameter, lmd>0.

  • phi – beta distribution mean parameter, 0<phi<1.

  • cdf_start_end (tuple) – CDF values of p(t) defining start and end

  • up (times of disk build) –

Returns:

Description of returned object.

Return type:

type

abstract set_p_x_t()#

Set the age dependent spatial density p(x|t)

Should set an attribute self.log_p_x_t 3D array of the log density of size [nx1,nx2,nt]

set_p_z_tx()#

Set p(z|t,x) given enrichment model and spatially varying t_dep

Evaluates the chemical evolution model defined in equations 3-10 of Zhu et al 2020, parameterised by a spatially varying depletion timescale created by set_t_dep.

abstract set_sig_v()#

Set spatially and age dependent velocity dispersions

Should set an attribute self.sig_v, a 3D array of size [nt, nx1, nx2]

abstract set_t_dep()#

Set spatially varying depletion timescale

Should set an attribute self.t_dep, a 2D array of depletion time vs 2D position, of size [nx1, nx2] and end with self.set_p_z_tx().

GrowingDisk#

class popkinmocks.components.GrowingDisk(cube=None, center=(0, 0), rotation=0.0)#

A growing disk with age-and-space dependent velocities and enrichments

The mass-weighted density factorises as

p(t,x,v,z) = p(t) p(x|t) p(v|t,x) p(z|t,x)

where:

  • p(t) : beta distribution (see set_p_t),

  • p(x|t) : cored power-law in elliptical radius with age-varying core-size, flattening and slope (see set_p_x_t)

  • p(v|t,x) = Normal(v ; mu_v(t,x), sig_v(t,x)) where mu_v resembles a rotating disk (see set_mu_v) while dispersion varies from inner to outer values (see set_sig_v)

  • t_dep(x) varies from inner to outer value (see set_t_dep)

Parameters:
  • cube – a pkm.mock_cube.mockCube.

  • center (x0,y0) – co-ordinates of the component center.

  • rotation – angle (radians) between x-axes of component and cube.

set_mu_v(q_lims=(0.5, 0.5), rmax_lims=(0.1, 1.0), vmax_lims=(50.0, 250.0))#

Set age/space dependent mean velocities which resemble rotating disks

Mean velocity maps have rotation-curves along x-axis peaking at v_max at r_max then falling to 0 for r->inf. Given by the equation

\[\mathbb{E}[p(v|t,r,\theta)] = \cos(\theta) \frac{Kr}{(r+rc)^3}\]

where

\[r^2 = x_1^2 + \left( \frac{x_2}{q} \right)^2, \;\; \theta=\arctan \frac{qx_1}{x_2}\]

Parameters K and rc are chosen to give peak velocity vmax at x_1 = rmax. The quantities q, rmax and vmax vary linearly with t between the values specified for (young, old) stars.

Parameters:
  • q_lims – (young,old) value of y/x axis ratio of mu(v) equicontours.

  • rmax_lims – (young,old) distance of maximum velocity along x-axis.

  • vmax_lims – (young,old) maximum velocity.

set_p_x_t(q_lims=(0.5, 0.1), rc_lims=(0.5, 0.1), alpha_lims=(0.5, 2.0))#

Set the density p(x|t) as cored power-law in elliptical radius

Desnities are cored power-laws stratified on elliptical radius r, r^2 = x^2 + (y/q)^2 p(x|t) = (r+rc)^-alpha where the disk axis ratio q(t), slope alpha(t) and core radius rc(t) vary linearly with t between values specified for (young, old) stars.

Parameters:
  • q_lims – (young,old) value of disk y/x axis ratio

  • rc_lims – (young,old) value of disk core-size in elliptical radii

  • alpha_lims – (young,old) value of power-law slope

set_sig_v(q_lims=(0.5, 0.1), alpha_lims=(1.5, 2.5), sig_v_in_lims=(50.0, 250.0), sig_v_out_lims=(10.0, 50), sigma_max=500.0, sigma_min=10.0)#

Set age-and-space dependent velocity dispersion maps

Dispersion maps vary as power-laws between central value sig_v_in, outer value sig_v_out, with slopes alpha. Velocity dispersion is constant on ellipses with y/x axis-ratio = q. The quantities q, alpha, sig_v_in, sig_v_out vary linearly with stellar age between values specified for (young,old) stars.

Parameters:
  • q_lims – (young,old) values of y/x axis-ratio of sigma equicontours.

  • alpha_lims – (young,old) value of power-law slope.

  • sig_v_in_lims – (young,old) value of central dispersion.

  • sig_v_out_lims – (young,old) value of outer dispersion.

set_t_dep(q=0.1, alpha=1.5, t_dep_in=0.5, t_dep_out=6.0, t_dep_min=0.1, t_dep_max=13.0)#

Set spatially-varying depletion timescale

t_dep varies as power law in eliptical radius with axis ratio q with power-law slope alpha, from central value t_dep_in to outer value t_dep_out.

Parameters:
  • q – y/x axis ratio of ellipses of t_dep equicontours

  • alpha – exponent >0 for varying t_dep

  • t_dep_in – central value of t_dep

  • t_dep_out – outer value of t_dep

  • t_dep_min – min value of t_dep, default 0.1 Gyr

  • t_dep_max – max value of t_dep, default 13. Gyr

Stream#

class popkinmocks.components.Stream(cube=None, center=(0, 0), rotation=0.0)#

Stream with age-independent kinematics and spatially-uniform enrichment

The mass-weighted density factorises as

p(t,x,v,z) = p(t) p(x|t) p(v|t,x) p(z|t,x)

where:

  • p(t) : beta distribution (see set_p_t),

  • p(x|t) = p(x) : a curved line with constant thickness (see set_p_x),

  • p(v|t,x) = p(v|x) = Normal(v ; mu_v(x), sig_v(x)) where mean varies along stream (see set_mu_v) and dispersion is constant (see set_sig_v)

  • t_dep(x) = constant (see set_t_dep)

Parameters:
  • cube – a pkm.mock_cube.mockCube.

  • center (x0,y0) – co-ordinates of the component center.

  • rotation – angle (radians) between x-axes of component and cube.

set_mu_v(mu_v_lims=[-100, 100])#

Set mean velocity linearly varying with stream angle

Parameters:

mu_v_lims – (start, end) values of stream velocity

set_p_x_t(theta_lims=[0.0, 1.5707963267948966], mu_r_lims=[0.7, 0.1], sig=0.03, nsmp=75)#

Define the stream track p(x)

Defined in polar co-ordinates (theta,r). Stream extends between angles theta_lims between radii in mu_r_lims. Density is constant with varying theta. The track has a constant width on the sky, sig.

Parameters:
  • theta_lims – (start, end) values of stream angle in radians. Must be

  • x-axis (in -pi to pi. To cross negative) –

  • when (set non-zero rotation) –

  • component. (instantiating the stream) –

  • mu_r_lims – (start, end) values of stream distance from center.

  • sig (float) – stream thickness.

  • nsmp (int) – number of points to sample the angle theta (increase if stream looks discretised.

Returns:

Description of returned object.

Return type:

type

set_sig_v(sig_v=100.0)#

Set constant velocity dispersion

Parameters:

sig_v (float) – constant std dev of velocity distribution

set_t_dep(t_dep=3.0)#

Set constant depletion timescale

Parameters:

t_dep (float) – constant tepletion

Mixture#

class popkinmocks.components.Mixture(cube=None, component_list=None, weights=None)#

A mixture component

The mass-weighted density is a mixture, i.e.

\[p(t,x,v,z) = \sum_i w_i \; p_i(t,v,x,z)\]

where the w_i are weights (non-zero, sum-to-one) and p_i are the corresponding components.

Parameters:
  • cube – a pkm.mock_cube.mockCube.

  • component_list (list) – a list of pkm.component objects

  • weights (array) – weights, must be non-negative and sum-to-one, and same length as component_list

evaluate_ybar()#

Evaluate the datacube for this component as a mixture

Since observation operator is linear, ybar is a mixture of the component ybar’s i.e.

\[\bar{y}(x, \omega) = \sum_i w_i \; \bar{y}_i(x, \omega)\]
get_central_moment(which_dist, j, light_weighted=False)#

Get central moment or conditional central moment of a 1D distribution

Uses exact formula for mixture models. See full docstring of self.get_mean for restrictions on which_dist and meaning of output.

Parameters:
  • which_dist (string) – which distribution to take central moment of.

  • light_weighted (bool) – whether to return light-weighted (True) or mass-weighted (False) quantity

Returns:

the central moment or conditional central moment

Return type:

float/array

get_log_p(which_dist, collapse_cmps=True, density=True, light_weighted=False)#

Evaluate log probability functions for this component

Evaluate marginal or conditional distributions over stellar age t, 2D position x, velocity v and metallicity z. The argument which_dist specifies which distribution to evaluate, where an underscore (if present) represents conditioning e.g.:

  • which_dist = ‘tv’ –> p(t,v),

  • which_dist = ‘tz_x’ –> p(t,z|x) etc

Variables in which_dist must be provided in alphabetical order (on either side of the underscore if present).

Parameters:
  • which_dist (string) – valid string for the distribution to evaluate

  • density (bool) – whether to return probabilty density (True) or the volume-element weighted probabilty (False)

  • light_weighted (bool) – whether to return light-weighted (True) or mass-weighted (False) quantity

Returns:

the desired distribution. Array dimensions correspond to the

order of variables as provided in which_dist string e.g. which_dist = tz_x returns p(t,z|x) as a 4D array with dimensions corresponding to [t,z,x1,x2]. If collapse_cmps = False the first dimension will index over mixture components.

Return type:

array

get_mean(which_dist, light_weighted=False)#

Get mean/conditional mean using exact formula for mixtures.

The which_dist string specifies which distribution to mean. If which_dist contains no underscore, this returns the mean of the appropriate marginal distribution. If which_dist contains an underscore, this returns the mean of the conditional distribution e.g.:

  • which_dist = ‘v’ returns E(v) = int v p(v) dv

  • which_dist = ‘v_x’ returns E(v|x) = int v p(v|x) dv

Only works for distributions of one argument.

Parameters:
  • which_dist (string) – which distribution to mean. See full docstring.

  • light_weighted (bool) – whether to return light-weighted (True) or mass-weighted (False) quantity

Returns:

if the variable to mean is t, v or z, returns an array

with shape equal to the shape of the conditioners e.g. which_dist = ‘v_tz’ returns array shape (nt, nz) and a float if conditional. For x, the returned array has extra initial dimension of size 2 for the 2 spatial dimensions.

Return type:

float/array

get_p(which_dist, collapse_cmps=True, density=True, light_weighted=False)#

Evaluate probability functions for this component

Evaluate marginal or conditional distributions over stellar age t, 2D position x, velocity v and metallicity z. The argument which_dist specifies which distribution to evaluate, where an underscore (if present) represents conditioning e.g.:

  • which_dist = ‘tv’ –> p(t,v),

  • which_dist = ‘tz_x’ –> p(t,z|x) etc

Variables in which_dist must be provided in alphabetical order (on either side of the underscore if present).

Parameters:
  • which_dist (string) – valid string for the distribution to evaluate

  • density (bool) – whether to return probabilty density (True) or the volume-element weighted probabilty (False)

  • light_weighted (bool) – whether to return light-weighted (True) or mass-weighted (False) quantity

Returns:

the desired distribution. Array dimensions correspond to the

order of variables as provided in which_dist string e.g. which_dist = tz_x returns p(t,z|x) as a 4D array with dimensions corresponding to [t,z,x1,x2]. If collapse_cmps = False the first dimension will index over mixture components.

Return type:

array