Detailed API documentation#

agabpylib.densityestimation.kde Module#

Provides wrappers around scikit-learn kernel density estimation methods.

Anthony Brown May 2015 - Aug 2022

Functions#

kde2d_scikitlearn(xdata, ydata[, Nx, Ny, ...])

Provide a 2D kernel density estimate for a set of data points (x_i, y_i).

kde_scikitlearn(data[, N, lims, evalOnData, ...])

Provide a kernel density estimate for a set of data points (d_i).

agabpylib.gaia.edrthree Module#

Functions for the use and analysis of Gaia EDR3 data.

Anthony Brown Dec 2020 - Aug 2022

Functions#

correct_gband(bp_rp, ...)

Correct the G-band fluxes and magnitudes for the input list of Gaia EDR3 photometry.

correct_flux_excess_factor(bp_rp, ...)

Calculate the corrected flux excess factor for the input Gaia EDR3 data.

agabpylib.gaia.ruwetools Module#

Classes and Functions for handling the tables listing the normalization factor u0 needed to calculate the renormalized unit weight error (RUWE). The tables are provided on the Gaia DR2 Known Issues pages (https://www.cosmos.esa.int/web/gaia/dr2-known-issues).

Note

This module is obsolete as the RUWE values are available as a separate table in the Gaia DR2 archive and as a field in gaia_source since Gaia EDR3.

Anthony Brown Oct 2018 - Aug 2022

Classes#

U0Interpolator()

Class which holds functions that can used to calculate u0 values given the G-band magnitude only, or the G-band magnitude and the BP-RP colour of a source.

agabpylib.mcmc.metropolis Module#

This module provides classes and functions that implement the Metropolis MCMC sampling algorithm.

Classes#

MetropolisSampler(lnprob, proposal_rvs)

Base class for Metropolis samplers.

agabpylib.numerical.astronomy.celestialmechanics Module#

Provides useful functions for basic celestial mechanics applications.

Anthony Brown May 2020 - Aug 2022

Functions#

kepler_equation_solver(e, M)

Solve the Kepler equation for the input values of eccentricity and mean anomaly.

orbital_elements_to_xyz(a, e, incl, ...)

For the given Keplerian orbital elements and the epoch t, calculate the position in (x,y,z) in the BCRS.

agabpylib.numerical.integrate.quadrature Module#

Custom quadrature methods which are not available from scipy.

Anthony Brown Aug 2017 -Aug 2022

Functions#

fixed_quad_laguerre(func, a[, args, n])

Compute a definite integral using fixed-order Gauss-Laguerre quadrature.

agabpylib.numerical.optimize.utils Module#

Optimization utility methods not available from scipy.optimize.

Anthony Brown Aug 2017 - Aug 2022

Functions#

bracket_root(func[, xa, xb, args, ...])

Bracket the root of a function.

agabpylib.numerical.special.fermidirac Module#

Implement the evaluation of the generalized Fermi-Dirac integral according to the algorithm presented by Aparicio (1998, https://ui.adsabs.harvard.edu/#abs/1998ApJS..117..627A/abstract). The code is based in part on the fortran 90 implementation by F.X. Timmes (http://cococubed.asu.edu/code_pages/fermi_dirac.shtml, as included in the MESA equation of state libraries).

Anthony Brown Aug 2017 - Aug 2022

Functions#

fd_evaluate(nu, eta, theta)

Evaluate the generalized Fermi-Dirac integral.

agabpylib.plotting.plotstyles Module#

Provides plotting style and matplotib axes configuration.

Anthony Brown Aug 2015 - Aug 2022

Functions#

useagab([usetex, fontfam, fontsize, ...])

Configure the plotting style to my liking.

apply_tufte(ax[, withgrid, minorticks, ...])

Apply the "Tufte" style to the plot axes contained in the input axis object.

agabpylib.plotting.agabcolormaps Module#

Custom colormaps collected from a variety of sources.

Anthony Brown Aug 2015 - Aug 2022

Notes

Execute

>>> agabcolormaps.show_color_maps()

to see what these colormaps look like.

Functions#

planckian_locus(tbb)

Interpolate the RGB values of the CIE colour on the Planckian locus in CIE space.

register_agab_maps()

Register the color maps defined in this module.

show_color_maps()

Show all the color maps defined in the agabColorMaps module.

agabpylib.plotting.distinct_colours Module#

Colour-blind proof distinct colours module, based on work by Paul Tol Pieter van der Meer, 2011 SRON - Netherlands Institute for Space Research

Note

This code is for an older version of Tol’s color scheme. It corresponds to the 2021 “muted” color set (see https://personal.sron.nl/~pault/).

Functions#

get_distinct(nr)

Get specified number of distinct colours in HTML hex format.

agabpylib.plotting.distributions Module#

Provides methods to visualize 1D or 2D distributions of data.

Anthony Brown May 2015 - Aug 2022

Note

The functionalities offered here are covered much better by other tools for visualization of distributions such as corner or arViz.

Functions#

plot_joint_kde_and_marginals(xdata, ydata[, ...])

Plot the joint distribution of two variables, X and Y, for which the data set {(x_i, y_i)} is available.

plot_joint_kde(xdata, ydata[, xname, yname, ...])

Plot the joint distribution of two variables, X and Y, for which the data set {(x_i, y_i)} is available.

agabpylib.plotting.inference Module#

Provides several functions that are useful for plotting in the context of inference problems.

Anthony Brown Mar 2015 - Aug 2022

Functions#

error_ellipses(mu, covmat, sigma_levels, ...)

Given a covariance matrix for a 2D Normal distribution calculate the uncertainty-ellipses and return matplotlib patches for plotting them.

convert_to_stdev_nan(logL)

Given a grid of log-likelihood values, convert them to cumulative standard deviations.

agabpylib.posteriors.meanvarnormal Module#

Functions for calculating the posterior distributions for the mean (\(\mu\)) and variance (\(\tau=\sigma^2\)) or standard deviation (\(\sigma\)) of a normal distribution, inferred from \(n\) data points \(x_i\).

Anthony Brown Jan 2015 - Aug 2022

Functions#

marginal_mean_ums_flat_prior(n, xbar, V, mu)

Calculate the marginal posterior distribution of \(\mu\) for the case of unknown mean and unknown standard deviation.

marginal_mean_ums_uninf_prior(n, xbar, V, mu)

Calculate the marginal posterior distribution of \(\mu\) for the case of unknown mean and unknown standard deviation.

marginal_mean_umv_flat_prior(n, xbar, V, mu)

Calculate the marginal posterior distribution of mu for the case of unknown mean and unknown variance and flat priors.

marginal_mean_umv_uninf_prior(n, xbar, V, mu)

Calculate the marginal posterior distribution of :math`mu` for the case of unknown mean and unknown variance and with an uninformative prior on \(\tau\).

marginal_sigma_ums_flat_prior(n, V, sigma)

Calculate the marginal posterior distribution of \(\sigma\) for the case of unknown mean and unknown standard deviation.

marginal_sigma_ums_uninf_prior(n, V, sigma)

Calculate the marginal posterior distribution of \(\sigma\) for the case of unknown mean and unknown standard deviation.

marginal_tau_umv_flat_prior(n, V, tau)

Calculate the marginal posterior distribution of tau for the case of unknown mean and unknown variance for flat priors.

marginal_tau_umv_uninf_prior(n, V, tau)

Calculate the marginal posterior distribution of \(\tau\) for the case of unknown mean and unknown variance and with an uninformative prior on \(\tau\).

ums_flat_prior(n, xbar, V, mu, sigma)

Calculate the joint posterior distribution for the unknown mean \(\mu\) and unknown standard deviation \(\sigma\) for a flat prior in both parameters.

ums_uninf_prior(n, xbar, V, mu, sigma)

Calculate the joint posterior distribution for the unknown mean \(\mu\) and unknown standard deviation \(\sigma\), for an uninformative prior in both parameters.

umv_flat_prior(n, xbar, V, mu, tau)

Calculate the joint posterior distribution for the unknown mean \(\mu\) and unknown variance \(\tau=\sigma^2\), for a flat prior in both parameters.

umv_uninf_prior(n, xbar, V, mu, tau)

Calculate the joint posterior distribution for the unknown mean \(\mu\) and unknown variance \(\tau=\sigma^2\), for an uninformative prior in both parameters.

agabpylib.simulation.starclusters.cluster Module#

Provide classes and methods for basic simulations of star clusters, where the main aim is to support kinematic modelling studies.

Note

The cluster simulations are focused on generating realistic observables and are not intended for the simulation of dynamically self-consistent clusters (i.e. where the mass distribution, potential, and kinematics are consistent).

Anthony Brown Jul 2019 - Aug 2022

Classes#

StarAPs(age, metallicity, alphafeh, vvcrit, ...)

Class that generates the astrophysical parameters (mass, Teff, luminosity, colour, etc) for the stars in the cluster.

StarCluster(n_stars, staraps, starpos, ...)

Base class for simulation of a star cluster.

agabpylib.simulation.starclusters.kinematics Module#

Provides classes and methods to simulate the kinematics of stars in clusters.

Anthony Brown Aug 2019 - Aug 2022

Classes#

Kinematics()

Abstract base class for classes representing the kinematics of stars in a cluster.

LinearVelocityField(v, s, omega, kappa)

General linear velocity field for the cluster stars which besides the mean cluster velocity can include a rotation and isotropic expansion/contraction term, both defined with respect to the cluster centre.

agabpylib.simulation.starclusters.observables Module#

Generate the Gaia observables for a given simulated cluster.

Anthony Brown Sep 2019 - Aug 2022

Classes#

Observables()

Abstract base class for classes representing the observations made of stars in a simulated cluster.

GaiaSurvey(distance_c, ra_c, dec_c[, ...])

Gaia observations.

agabpylib.simulation.starclusters.spacedistributions Module#

Provides classes and methods to simulate the space distributions of stars in clusters.

Note

The classes below only generate star positions according to a number density distribution. Only for equal mass stars will this result in a mass-distribution consistent with the number density distribution.

Anthony Brown Jul 2019 - Sep 2019

Classes#

SpaceDistribution()

Abstract base class for classes representing the space distribution of stars in a cluster.

ConstantDensitySphere(r)

Constant space density distribution.

SphericalShell(r)

Stars are distributed in a spherical shell around the cluster centre (of mass) the shell has zero thickness.

PlummerSphere(a)

Plummer density distribution.

TruncatedPlummerSphere(a, t)

Truncated Plummer density distribution.

agabpylib.simulation.imf Module#

Provide classes and methods for the simulation of initial mass functions.

Anthony Brown Sep 2017 - Aug 2022

Classes#

IMF()

Abstract base class for implementations of initial mass function simulations.

Uniform()

Uniform (constant probability density) IMF.

MultiPartPowerLaw(slopes, break_points)

Multi-part power-law IMF.

agabpylib.simulation.parallaxsurveys Module#

Provide classes and methods for simulating simple (magnitude limited) parallax surveys. These consist of measurements of the parallax and the apparent magnitude of the stars.

Anthony Brown 2011 - Aug 2022

Functions#

simDistancesConstantSpaceDensity(numStars, ...)

Simulate distances for stars distributed uniformly in space around the Sun.

simGaussianAbsoluteMagnitude(numStars, mean, ...)

Simulate absolute magnitudes following a Gaussian distribution.

showSurveyStatistics(simulatedSurvey[, ...])

Produce a plot with the survey statistics.

marginal_pdf_distance(r, rmin, rmax, mu, ...)

Calculate the expected marginal distribution of distances given the parallax survey parameters.

marginal_pdf_absMag(M, rmin, rmax, mu, ...)

Calculate the expected marginal distribution for the true absolute magnitude given the parallax survey parameters.

Classes#

ParallaxSurvey(numberOfStars, minDistance, ...)

Base class for simulating a parallax survey.

UniformSpaceDistributionSingleLuminosity(...)

Base class for simulated parallax surveys in which the stars are distributed uniformly in space between a minimum and maximum distance and with all stars having an absolute magnitude draw from the same Normal distribution.

UniformDistributionSingleLuminosityHip(...)

Simulate a parallax survey for stars distributed uniformly in space around the sun.

UniformDistributionSingleLuminosityTGAS(...)

Simulate a parallax survey for stars distributed uniformly in space around the sun.

agabpylib.stats.distributions Module#

Provides statistical distributions not available from scipy.stats.

Anthony Brown June 2019 - Aug 2022

Classes#

hoyt([momtype, a, b, xtol, badvalue, name, ...])

Hoyt distribution.

agabpylib.stats.moments Module#

Provides moments of data distributions beyond the standard examples such as mean, median, etc. For example, weighted means of multidimensional data, accounting for (correlated) uncertainties, are implemented.

Anthony Brown Aug 2021 - Aug 2022

Functions#

weighted_mean_twod(x, y, sx, sy, cxy)

Provide the weighted mean of the vectors x and y.

agabpylib.stats.robustrollingstats Module#

Provides rolling robust statistics for time series data, and data that can otherwise be split and ordered according to some attribute.

Code originally writting in 2014 during Gaia commissioning.

Anthony Brown Jan 2014 - Apr 2022

Functions#

robust_rolling_stats(series[, window])

Calculate the rolling median and RSE for the input pandas series.

cleanup_data(dframe, colname[, window])

Remove outliers from the data frame by appling a filtering based on the rolling median and RSE.

agabpylib.stats.robuststats Module#

Provides various methods for robust estimates of simple statistics such as the mean and variance, which in this case are estimated through the median and RSE.

Anthony Brown May 2015 - Aug 2022

Functions#

rse(x[, ax])

Calculate the Robust Scatter Estimate for an array of values (see GAIA-C3-TN-ARI-HL-007).

robust_stats(x[, ax])

Provide robust statistics of the values in array x (which can be of any dimension).

agabpylib.stellarmodels.io Package#

I/O for stellar models.

This module provides classes and functions for reading and writing the files associated with the various stellar models available.

Classes#

MIST(filename[, verbose])

Reads MIST CMD files.

PARSEC(filename[, verbose, colibri])

Reads PARSEC CMD files (http://stev.oapd.inaf.it/cmd).