Package pylal :: Module bayespputils
[hide private]
[frames] | no frames]

Module bayespputils

source code

This module contains classes and functions for post-processing the output of the Bayesian parameter estimation codes.


Date: 2017-12-05 15:29:36 +0000

Author: Ben Aylott <benjamin.aylott@ligo.org>, Ben Farr <bfarr@u.northwestern.edu>, Will M. Farr <will.farr@ligo.org>, John Veitch <john.veitch@ligo.org>, Vivien Raymond <vivien.raymond@ligo.org>

Classes [hide private]
  PosteriorOneDPDF
A data structure representing one parameter in a chain of posterior samples.
  Posterior
Data structure for a table of posterior samples .
  BurstPosterior
Data structure for a table of posterior samples .
  KDTree
A kD-tree.
  KDTreeVolume
A kD-tree suitable for splitting parameter spaces and counting hypervolumes.
  KDSkeleton
object to store the structure of a kd tree
  PosteriorSample
A single parameter sample object, suitable for inclusion in a kD-tree.
  AnalyticLikelihood
Return analytic likelihood values.
  htmlChunk
A base class for representing web content using ElementTree .
  htmlPage
A concrete class for generating an XHTML(1) document.
  htmlSection
Represents a block of html fitting within a htmlPage.
  htmlCollapseSection
Represents a block of html fitting within a htmlPage.
  RALocator
RA tick locations with some intelligence
  DecLocator
Dec tick locations with some intelligence
  RAFormatter
  DecFormatter
  ACLError
  PEOutputParser
A parser for the output of Bayesian parameter estimation codes.
  VOT2HTML
Functions [hide private]
 
replace_column(table, old, new)
Workaround for missing astropy.table.Table.replace_column method, which was added in Astropy 1.1.
source code
 
as_array(table)
Workaround for missing astropy.table.Table.as_array method, which was added in Astropy 1.0.
source code
 
get_prior(name) source code
 
plot_label(param)
A lookup table for plot labels.
source code
 
_skyhist_cart_slow(skycarts, sky_samples) source code
 
_sky_hist(skypoints, samples) source code
 
_calculate_confidence_levels(hist, points, injBin, NSamples)
Returns (injectionconf, toppoints), where injectionconf is the confidence level of the injection, contained in the injBin and toppoints is a list of (pointx, pointy, ptindex, frac), with pointx and pointy the (x,y) coordinates of the corresponding element of the points array, ptindex the index of the point in the array, and frac the cumulative fraction of points with larger posterior probability.
source code
 
_greedy_bin(greedyHist, greedyPoints, injection_bin_index, bin_size, Nsamples, confidence_levels)
An interal function representing the common, dimensionally-independent part of the greedy binning algorithms.
source code
 
skyArea(bounds) source code
 
random_split(items, fraction) source code
 
addSample(tree, coordinates) source code
 
kdtree_bin_sky_volume(posterior, confidence_levels) source code
 
kdtree_bin_sky_area(posterior, confidence_levels, samples_per_bin=10)
takes samples and applies a KDTree to them to return confidence levels returns confidence_intervals - dictionary of user_provided_CL:calculated_area b - ordered list of KD leaves injInfo - if injection values provided then returns [Bounds_of_inj_kd_leaf ,number_samples_in_box, weight_of_box,injection_CL ,injection_CL_area] Not quite sure that the repeated samples case is fixed, posibility of infinite loop.
source code
 
kdtree_bin(posterior, coord_names, confidence_levels, initial_boundingbox=None, samples_per_bin=10)
takes samples and applies a KDTree to them to return confidence levels returns confidence_intervals - dictionary of user_provided_CL:calculated_volume b - ordered list of KD leaves initial_boundingbox - list of lists [upperleft_coords,lowerright_coords] injInfo - if injection values provided then returns [Bounds_of_inj_kd_leaf ,number_samples_in_box, weight_of_box,injection_CL ,injection_CL_volume] Not quite sure that the repeated samples case is fixed, posibility of infinite loop.
source code
 
kdtree_bin2Step(posterior, coord_names, confidence_levels, initial_boundingbox=None, samples_per_bin=10, injCoords=None, alternate=False, fraction=0.5, skyCoords=False)
input: posterior class instance, list of confidence levels, optional choice of inital parameter space, samples per box in kdtree note initial_boundingbox is [[lowerbound of each param][upper bound of each param]], if not specified will just take limits of samples fraction is proportion of samples used for making the tree structure.
source code
 
greedy_bin_two_param(posterior, greedy2Params, confidence_levels)
Determine the 2-parameter Bayesian Confidence Intervals using a greedy binning algorithm.
source code
 
pol2cart(long, lat)
Utility function to convert longitude,latitude on a unit sphere to cartesian co-ordinates.
source code
 
sph2cart(r, theta, phi)
Utiltiy function to convert r,theta,phi to cartesian co-ordinates.
source code
 
cart2sph(x, y, z)
Utility function to convert cartesian coords to r,theta,phi.
source code
 
greedy_bin_sky(posterior, skyres, confidence_levels)
Greedy bins the sky posterior samples into a grid on the sky constructed so that sky boxes have roughly equal size (determined by skyres).
source code
 
plot_sky_map(hpmap, outdir, inj=None, nest=True)
Plots a sky map from a healpix map, optionally including an injected position.
source code
 
skymap_confidence_areas(hpmap, cls)
Returns the area (in square degrees) for each confidence level with a greedy binning algorithm for the given healpix map.
source code
 
skymap_inj_pvalue(hpmap, inj, nest=True)
Returns the greedy p-value estimate for the given injection.
source code
 
mc2ms(mc, eta)
Utility function for converting mchirp,eta to component masses.
source code
 
q2ms(mc, q)
Utility function for converting mchirp,q to component masses.
source code
 
q2eta(mc, q)
Utility function for converting mchirp,q to eta.
source code
 
mc2q(mc, eta)
Utility function for converting mchirp,eta to new mass ratio q (m2/m1).
source code
 
ang_dist(long1, lat1, long2, lat2)
Find the angular separation of (long1,lat1) and (long2,lat2), which are specified in radians.
source code
 
array_dot(vec1, vec2)
Calculate dot products between vectors in rows of numpy arrays.
source code
 
array_ang_sep(vec1, vec2)
Find angles between vectors in rows of numpy arrays.
source code
 
array_polar_ang(vec)
Find polar angles of vectors in rows of a numpy array.
source code
 
rotation_matrix(angle, direction)
Compute general rotation matrices for a given angles and direction vectors.
source code
 
rotate_vector(R, vec)
Rotate vectors using the given rotation matrices.
source code
 
ROTATEZ(angle, vx, vy, vz) source code
 
ROTATEY(angle, vx, vy, vz) source code
 
orbital_momentum(fref, m1, m2, inclination)
Calculate orbital angular momentum vector.
source code
 
orbital_momentum_mag(fref, m1, m2, eta) source code
 
component_momentum(m, a, theta, phi)
Calculate BH angular momentum vector.
source code
 
symm_tidal_params(lambda1, lambda2, eta)
Calculate best tidal parameters
source code
 
spin_angles(fref, mc, eta, incl, a1, theta1, phi1, a2=None, theta2=None, phi2=None)
Calculate physical spin angles.
source code
 
chi_precessing(m1, a1, tilt1, m2, a2, tilt2)
Calculate the magnitude of the effective precessing spin following convention from Phys.
source code
 
calculate_redshift(distance, h=0.6790, om=0.3065, ol=0.6935, w0=-1.0)
Calculate the redshift from the luminosity distance measurement using the Cosmology Calculator provided in LAL.
source code
 
source_mass(mass, redshift)
Calculate source mass parameter for mass m as: m_source = m / (1.0 + z) For a parameter m.
source code
 
physical2radiationFrame(theta_jn, phi_jl, tilt1, tilt2, phi12, a1, a2, m1, m2, fref)
Wrapper function for SimInspiralTransformPrecessingNewInitialConditions().
source code
 
plot_one_param_pdf_kde(fig, onedpos) source code
 
plot_one_param_pdf_line_hist(fig, pos_samps) source code
 
plot_one_param_pdf(posterior, plot1DParams, analyticPDF=None, analyticCDF=None, plotkde=False)
Plots a 1D histogram and (gaussian) kernel density estimate of the distribution of posterior samples for a given parameter.
source code
 
formatRATicks(locs, accuracy='auto')
Format locs, ticks to RA angle with given accuracy accuracy can be 'hour', 'min', 'sec', 'all' returns (locs, ticks) 'all' does no rounding, just formats the tick strings 'auto' will use smallest appropriate units
source code
 
formatDecTicks(locs, accuracy='auto')
Format locs to Dec angle with given accuracy accuracy can be 'deg', 'arcmin', 'arcsec', 'all' 'all' does no rounding, just formats the tick strings
source code
 
roundRadAngle(rads, accuracy='all')
round given angle in radians to integer hours, degrees, mins or secs accuracy can be 'hour'.
source code
 
getRAString(radians, accuracy='auto') source code
 
getDecString(radians, accuracy='auto') source code
 
plot_corner(posterior, levels, parnames=None)
Make a corner plot using the triangle module (See http://github.com/dfm/corner.py)
source code
 
plot_two_param_kde_greedy_levels(posteriors_by_name, plot2DkdeParams, levels, colors_by_name, line_styles=__default_line_styles, figsize=(4,3), dpi=250, figposition=[0.2,0.2,0.48,0.75], legend='right', hatches_by_name=None, Npixels=50)
Plots a 2D kernel density estimate of the 2-parameter marginal posterior.
source code
 
plot_two_param_kde(posterior, plot2DkdeParams)
Plots a 2D kernel density estimate of the 2-parameter marginal posterior.
source code
 
get_inj_by_time(injections, time)
Filter injections to find the injection with end time given by time +/- 0.1s
source code
 
histogram2D(posterior, greedy2Params, confidence_levels)
Returns a 2D histogram and edges for the two parameters passed in greedy2Params, plus the actual discrete confidence levels imposed by the finite number of samples.
source code
 
plot_two_param_greedy_bins_contourf(posteriors_by_name, greedy2Params, confidence_levels, colors_by_name, figsize=(7,6), dpi=120, figposition=[0.3,0.3,0.5,0.5], legend='right', hatches_by_name=None)
@param posteriors_by_name A dictionary of posterior objects indexed by name
source code
 
fix_axis_names(plt, par1_name, par2_name)
Fixes names of axes
source code
 
plot_two_param_greedy_bins_contour(posteriors_by_name, greedy2Params, confidence_levels, colors_by_name, line_styles=__default_line_styles, figsize=(4,3), dpi=250, figposition=[0.2,0.2,0.48,0.75], legend='right')
Plots the confidence level contours as determined by the 2-parameter greedy binning algorithm.
source code
 
plot_two_param_greedy_bins_hist(posterior, greedy2Params, confidence_levels)
Histograms of the ranked pixels produced by the 2-parameter greedy binning algorithm colured by their confidence level.
source code
 
greedy_bin_one_param(posterior, greedy1Param, confidence_levels)
Determine the 1-parameter Bayesian Confidence Interval using a greedy binning algorithm.
source code
 
contigious_interval_one_param(posterior, contInt1Params, confidence_levels)
Calculates the smallest contigious 1-parameter confidence interval for a set of given confidence levels.
source code
 
burnin(data, spin_flag, deltaLogP, outputfile) source code
 
autocorrelation(series)
Returns an estimate of the autocorrelation function of a given series.
source code
 
autocorrelation_length_estimate(series, acf=None, M=5, K=2)
Attempts to find a self-consistent estimate of the autocorrelation length of a given series.
source code
 
effectiveSampleSize(samples, Nskip=1)
Compute the effective sample size, calculating the ACL using only the second half of the samples to avoid ACL overestimation due to chains equilibrating after adaptation.
source code
 
readCoincXML(xml_file, trignum) source code
 
find_ndownsample(samples, nDownsample)
Given a list of files, threshold value, and a desired number of outputs posterior samples, return the skip number to achieve the desired number of posterior samples.
source code
 
parse_converge_output_section(fo) source code
 
vo_nest2pos(nsresource, Nlive=None)
Parse a VO Table RESOURCE containing nested sampling output and return a VOTable TABLE element with posterior samples in it.
source code
 
_cl_width(cl_bound)
Returns (high - low), the width of the given confidence bounds.
source code
 
_cl_count(cl_bound, samples)
Returns the number of samples within the given confidence bounds.
source code
 
confidence_interval_uncertainty(cl, cl_bounds, posteriors)
Returns a tuple (relative_change, fractional_uncertainty, percentile_uncertainty) giving the uncertainty in confidence intervals from multiple posteriors.
source code
 
plot_waveform(pos=None, siminspiral=None, event=0, path=None, ifos=['H1','L1','V1']) source code
 
plot_psd(psd_files, outpath=None, f_min=30.) source code
 
cred_interval(x, cl=.9, lower=True)
Return location of lower or upper confidence levels Args: x: List of samples.
source code
 
spline_angle_xform(delta_psi)
Returns the angle in degrees corresponding to the spline calibration parameters delta_psi.
source code
 
plot_spline_pos(logf, ys, nf=100, level=0.9, color='k', label=None, xform=None)
Plot calibration posterior estimates for a spline model in log space.
source code
 
plot_calibration_pos(pos, level=.9, outpath=None) source code
 
plot_burst_waveform(pos=None, simburst=None, event=0, path=None, ifos=['H1','L1','V1']) source code
 
make_1d_table(html, legend, label, pos, pars, noacf, GreedyRes, onepdfdir, sampsdir, savepdfs, greedy, analyticLikelihood, nDownsample) source code
Variables [hide private]
  hostname_short = 'Unknown'
  logParams = ['logl', 'loglh1', 'loglh2', 'logll1', 'loglv1', '...
  relativePhaseParams = [a+ b+ '_relative_phase' for a, b in com...
  snrParams = ['snr', 'optimal_snr', 'matched_filter_snr']+ ['%s...
  calAmpParams = ['calamp_%s' %(ifo) for ifo in ['h1', 'l1', 'v1']]
  calPhaseParams = ['calpha_%s' %(ifo) for ifo in ['h1', 'l1', '...
  calParams = calAmpParams+ calPhaseParams
  massParams = ['m1', 'm2', 'chirpmass', 'mchirp', 'mc', 'eta', ...
  spinParamsPrec = ['a1', 'a2', 'phi1', 'theta1', 'phi2', 'theta...
  spinParamsAli = ['spin1', 'spin2', 'a1z', 'a2z']
  spinParamsEff = ['chi', 'effectivespin', 'chi_eff', 'chi_tot',...
  spinParams = spinParamsPrec+ spinParamsEff+ spinParamsAli
  cosmoParam = ['m1_source', 'm2_source', 'mtotal_source', 'mc_s...
  ppEParams = ['ppEalpha', 'ppElowera', 'ppEupperA', 'ppEbeta', ...
  tigerParams = ['dchi%i' %(i) for i in range(8)]+ ['dchi%il' %(...
  bransDickeParams = ['omegaBD', 'ScalarCharge1', 'ScalarCharge2']
  massiveGravitonParams = ['lambdaG']
  tidalParams = ['lambda1', 'lambda2', 'lam_tilde', 'dlam_tilde'...
  energyParams = ['e_rad', 'l_peak']
  strongFieldParams = ppEParams+ tigerParams+ bransDickeParams+ ...
  distParams = ['distance', 'distMPC', 'dist']
  incParams = ['iota', 'inclination', 'cosiota']
  polParams = ['psi', 'polarisation', 'polarization']
  skyParams = ['ra', 'rightascension', 'declination', 'dec']
  phaseParams = ['phase', 'phi0', 'phase_maxl']
  timeParams = ['time', 'time_mean']
  endTimeParams = ['l1_end_time', 'h1_end_time', 'v1_end_time']
  statsParams = ['logprior', 'logl', 'deltalogl', 'deltaloglh1',...
  calibParams = ['calpha_l1', 'calpha_h1', 'calpha_v1', 'calamp_...
  confidenceLevels = [0.67, 0.9, 0.95, 0.99]
  greedyBinSizes = {'mc': 0.025, 'm1': 0.1, 'm2': 0.1, 'mass1': ...
  __default_line_styles = ['solid', 'dashed', 'dashdot', 'dotted']
  __default_color_lst = ['r', 'b', 'y', 'g', 'c', 'm']
  __default_css_string = ...
  __default_javascript_string = ...
  xmlns = 'http://www.ivoa.net/xml/VOTable/v1.1'
  cred_level = lambda cl, x:
Function Details [hide private]

replace_column(table, old, new)

source code 

Workaround for missing astropy.table.Table.replace_column method, which was added in Astropy 1.1.

FIXME: remove this function when LALSuite depends on Astropy >= 1.1.

as_array(table)

source code 

Workaround for missing astropy.table.Table.as_array method, which was added in Astropy 1.0.

FIXME: remove this function when LALSuite depends on Astropy >= 1.0.

_skyhist_cart_slow(skycarts, sky_samples)

source code 

Deprecated: This is a pure python version of the C extension function pylal._bayespputils._skyhist_cart .

_sky_hist(skypoints, samples)

source code 

Deprecated: This is an old pure python version of the C extension function pylal._bayespputils._skyhist_cart .

_calculate_confidence_levels(hist, points, injBin, NSamples)

source code 

Returns (injectionconf, toppoints), where injectionconf is the confidence level of the injection, contained in the injBin and toppoints is a list of (pointx, pointy, ptindex, frac), with pointx and pointy the (x,y) coordinates of the corresponding element of the points array, ptindex the index of the point in the array, and frac the cumulative fraction of points with larger posterior probability.

The hist argument should be a one-dimensional array that contains counts of sample points in each bin.

The points argument should be a 2-D array storing the sky location associated with each bin; the first index runs from 0 to NBins - 1, while the second index runs from 0 to 1.

The injBin argument gives the bin index in which the injection is found.

The NSamples argument is used to normalize the histogram counts into fractional probability.

kdtree_bin2Step(posterior, coord_names, confidence_levels, initial_boundingbox=None, samples_per_bin=10, injCoords=None, alternate=False, fraction=0.5, skyCoords=False)

source code 

input: posterior class instance, list of confidence levels, optional choice of inital parameter space, samples per box in kdtree note initial_boundingbox is [[lowerbound of each param][upper bound of each param]], if not specified will just take limits of samples fraction is proportion of samples used for making the tree structure. returns: confidence_intervals, sorted list of kd objects, initial_boundingbox, injInfo where injInfo is [bounding box injection is found within, samples in said box, weighting of box (in case of repeated samples),inj_confidence, inj_confidence_area]

greedy_bin_two_param(posterior, greedy2Params, confidence_levels)

source code 

Determine the 2-parameter Bayesian Confidence Intervals using a greedy binning algorithm.

Parameters:
  • posterior - an instance of the Posterior class.
  • greedy2Params - a dict - {param1Name:param1binSize,param2Name:param2binSize} .
  • confidence_levels - A list of floats of the required confidence intervals [(0-1)].

greedy_bin_sky(posterior, skyres, confidence_levels)

source code 

Greedy bins the sky posterior samples into a grid on the sky constructed so that sky boxes have roughly equal size (determined by skyres).

Parameters:
  • posterior - Posterior class instance containing ra and dec samples.
  • skyres - Desired approximate size of sky pixel on one side.
  • confidence_levels - List of desired confidence levels [(0-1)].

plot_sky_map(hpmap, outdir, inj=None, nest=True)

source code 
Plots a sky map from a healpix map, optionally including an
injected position.

:param hpmap: An array representing a healpix map (in nested
  ordering if ``nest = True``).

:param outdir: The output directory.

:param inj: If not ``None``, then ``[ra, dec]`` of the injection
  associated with the posterior map.

:param nest: Flag indicating the pixel ordering in healpix.

mc2ms(mc, eta)

source code 

Utility function for converting mchirp,eta to component masses. The masses are defined so that m1>m2. The rvalue is a tuple (m1,m2).

q2ms(mc, q)

source code 

Utility function for converting mchirp,q to component masses. The masses are defined so that m1>m2. The rvalue is a tuple (m1,m2).

q2eta(mc, q)

source code 

Utility function for converting mchirp,q to eta. The rvalue is eta.

orbital_momentum(fref, m1, m2, inclination)

source code 

Calculate orbital angular momentum vector. Note: The units of Lmag are different than what used in lalsimulation. Mc must be called in units of Msun here.

Note that if one wants to build J=L+S1+S2 with L returned by this function, S1 and S2 must not get the Msun^2 factor.

chi_precessing(m1, a1, tilt1, m2, a2, tilt2)

source code 

Calculate the magnitude of the effective precessing spin following convention from Phys. Rev. D 91, 024043 -- arXiv:1408.1810 note: the paper uses naming convention where m1 < m2 (and similar for associated spin parameters) and q > 1

calculate_redshift(distance, h=0.6790, om=0.3065, ol=0.6935, w0=-1.0)

source code 

Calculate the redshift from the luminosity distance measurement using the Cosmology Calculator provided in LAL. By default assuming cosmological parameters from arXiv:1502.01589 - 'Planck 2015 results. XIII. Cosmological parameters' Using parameters from table 4, column 'TT+lowP+lensing+ext' This corresponds to Omega_M = 0.3065, Omega_Lambda = 0.6935, H_0 = 67.90 km s^-1 Mpc^-1 Returns an array of redshifts

physical2radiationFrame(theta_jn, phi_jl, tilt1, tilt2, phi12, a1, a2, m1, m2, fref)

source code 

Wrapper function for SimInspiralTransformPrecessingNewInitialConditions(). Vectorizes function for use in append_mapping() methods of the posterior class.

plot_one_param_pdf(posterior, plot1DParams, analyticPDF=None, analyticCDF=None, plotkde=False)

source code 

Plots a 1D histogram and (gaussian) kernel density estimate of the distribution of posterior samples for a given parameter.

Parameters:
  • posterior - an instance of the Posterior class.
  • plot1DParams - a dict; {paramName:Nbins}
  • analyticPDF - an analytic probability distribution function describing the distribution.
  • analyticCDF - an analytic cumulative distribution function describing the distribution.

roundRadAngle(rads, accuracy='all')

source code 

round given angle in radians to integer hours, degrees, mins or secs accuracy can be 'hour'. 'deg', 'min', 'sec', 'all', all does nothing 'arcmin', 'arcsec'

plot_corner(posterior, levels, parnames=None)

source code 

Make a corner plot using the triangle module (See http://github.com/dfm/corner.py)

Parameters:
  • posterior - The Posterior object
  • levels - a list of confidence levels
  • parnames - list of parameters to include

plot_two_param_kde_greedy_levels(posteriors_by_name, plot2DkdeParams, levels, colors_by_name, line_styles=__default_line_styles, figsize=(4,3), dpi=250, figposition=[0.2,0.2,0.48,0.75], legend='right', hatches_by_name=None, Npixels=50)

source code 

Plots a 2D kernel density estimate of the 2-parameter marginal posterior.

Parameters:
  • posterior - an instance of the Posterior class.
  • plot2DkdeParams - a dict {param1Name:Nparam1Bins,param2Name:Nparam2Bins}

plot_two_param_kde(posterior, plot2DkdeParams)

source code 

Plots a 2D kernel density estimate of the 2-parameter marginal posterior.

Parameters:
  • posterior - an instance of the Posterior class.
  • plot2DkdeParams - a dict {param1Name:Nparam1Bins,param2Name:Nparam2Bins}

histogram2D(posterior, greedy2Params, confidence_levels)

source code 

Returns a 2D histogram and edges for the two parameters passed in greedy2Params, plus the actual discrete confidence levels
imposed by the finite number of samples.
   H,xedges,yedges,Hlasts = histogram2D(posterior,greedy2Params,confidence_levels)
@param posterior: Posterior instance
@param greedy2Params: a dict ;{param1Name:param1binSize,param2Name:param2binSize}
@param confidence_levels: a list of the required confidence levels to plot on the contour map.

plot_two_param_greedy_bins_contourf(posteriors_by_name, greedy2Params, confidence_levels, colors_by_name, figsize=(7,6), dpi=120, figposition=[0.3,0.3,0.5,0.5], legend='right', hatches_by_name=None)

source code 

@param posteriors_by_name A dictionary of posterior objects indexed by name

Parameters:
  • greedy2Params - a dict ;{param1Name:param1binSize,param2Name:param2binSize}
  • confidence_levels - a list of the required confidence levels to plot on the contour map.

plot_two_param_greedy_bins_contour(posteriors_by_name, greedy2Params, confidence_levels, colors_by_name, line_styles=__default_line_styles, figsize=(4,3), dpi=250, figposition=[0.2,0.2,0.48,0.75], legend='right')

source code 

Plots the confidence level contours as determined by the 2-parameter greedy binning algorithm.

Parameters:
  • posteriors_by_name - A dict containing Posterior instances referenced by some id.
  • greedy2Params - a dict ;{param1Name:param1binSize,param2Name:param2binSize}
  • confidence_levels - a list of the required confidence levels to plot on the contour map.
  • colors_by_name - A dict of colors cross-referenced to the above Posterior ids.
  • legend - Argument for legend placement or None for no legend ('right', 'upper left', 'center' etc)

plot_two_param_greedy_bins_hist(posterior, greedy2Params, confidence_levels)

source code 

Histograms of the ranked pixels produced by the 2-parameter greedy binning algorithm colured by their confidence level.

Parameters:
  • toppoints - Nx2 array of 2-parameter posterior samples.
  • posterior - an instance of the Posterior class.
  • greedy2Params - a dict ;{param1Name:param1binSize,param2Name:param2binSize}

greedy_bin_one_param(posterior, greedy1Param, confidence_levels)

source code 

Determine the 1-parameter Bayesian Confidence Interval using a greedy binning algorithm.

Parameters:
  • posterior - an instance of the posterior class.
  • greedy1Param - a dict; {paramName:paramBinSize}.
  • confidence_levels - A list of floats of the required confidence intervals [(0-1)].

contigious_interval_one_param(posterior, contInt1Params, confidence_levels)

source code 

Calculates the smallest contigious 1-parameter confidence interval for a set of given confidence levels.

Parameters:
  • posterior - an instance of the Posterior class.
  • contInt1Params - a dict {paramName:paramBinSize}.
  • confidence_levels - Required confidence intervals.

autocorrelation(series)

source code 

Returns an estimate of the autocorrelation function of a given series. Returns only the positive-lag portion of the ACF, normalized so that the zero-th element is 1.

autocorrelation_length_estimate(series, acf=None, M=5, K=2)

source code 

Attempts to find a self-consistent estimate of the autocorrelation length of a given series.

If C(tau) is the autocorrelation function (normalized so C(0) = 1, for example from the autocorrelation procedure in this module), then the autocorrelation length is the smallest s such that

1 + 2*C(1) + 2*C(2) + ... + 2*C(M*s) < s

In words: the autocorrelation length is the shortest length so that the sum of the autocorrelation function is smaller than that length over a window of M times that length.

The maximum window length is restricted to be len(series)/K as a safety precaution against relying on data near the extreme of the lags in the ACF, where there is a lot of noise. Note that this implies that the series must be at least M*K*s samples long in order to get a reliable estimate of the ACL.

If no such s can be found, raises ACLError; in this case it is likely that the series is too short relative to its true autocorrelation length to obtain a consistent ACL estimate.

vo_nest2pos(nsresource, Nlive=None)

source code 

Parse a VO Table RESOURCE containing nested sampling output and return a VOTable TABLE element with posterior samples in it. This can be added to an existing tree by the user. Nlive will be read from the nsresource, unless specified

confidence_interval_uncertainty(cl, cl_bounds, posteriors)

source code 

Returns a tuple (relative_change, fractional_uncertainty, percentile_uncertainty) giving the uncertainty in confidence intervals from multiple posteriors.

The uncertainty in the confidence intervals is the difference in length between the widest interval, formed from the smallest to largest values among all the cl_bounds, and the narrowest interval, formed from the largest-small and smallest-large values among all the cl_bounds. Note that neither the smallest nor the largest confidence intervals necessarily correspond to one of the cl_bounds.

The relative change relates the confidence interval uncertainty to the expected value of the parameter, the fractional uncertainty relates this length to the length of the confidence level from the combined posteriors, and the percentile uncertainty gives the change in percentile over the combined posterior between the smallest and largest confidence intervals.

@param cl The confidence level (between 0 and 1).

@param cl_bounds A list of (low, high) pairs giving the confidence interval associated with each posterior.

@param posteriors A list of PosteriorOneDPDF objects giving the posteriors.

cred_interval(x, cl=.9, lower=True)

source code 
Return location of lower or upper confidence levels
Args:
    x: List of samples.
    cl: Confidence level to return the bound of.
    lower: If ``True``, return the lower bound, otherwise return the upper bound.

plot_spline_pos(logf, ys, nf=100, level=0.9, color='k', label=None, xform=None)

source code 
Plot calibration posterior estimates for a spline model in log space.
Args:
    logf: The (log) location of spline control points.
    ys: List of posterior draws of function at control points ``logf``
    nx: Number of points to evaluate spline at for plotting.
    level: Credible level to fill in.
    color: Color to plot with.
    label: Label for plot.
    xform: Function to transform the spline into plotted values.


Variables Details [hide private]

logParams

Value:
['logl', 'loglh1', 'loglh2', 'logll1', 'loglv1', 'deltalogl', 'deltalo\
glh1', 'deltalogll1', 'deltaloglv1', 'logw', 'logprior', 'logpost', 'n\
ulllogl', 'chain_log_evidence', 'chain_delta_log_evidence', 'chain_log\
_noise_evidence', 'chain_log_bayes_factor']

relativePhaseParams

Value:
[a+ b+ '_relative_phase' for a, b in combinations(['h1', 'l1', 'v1'], \
2)]

snrParams

Value:
['snr', 'optimal_snr', 'matched_filter_snr']+ ['%s_optimal_snr' %(i) f\
or i in ['h1', 'l1', 'v1']]+ ['%s_cplx_snr_amp' %(i) for i in ['h1', '\
l1', 'v1']]+ ['%s_cplx_snr_arg' %(i) for i in ['h1', 'l1', 'v1']]+ rel\
ativePhaseParams

calPhaseParams

Value:
['calpha_%s' %(ifo) for ifo in ['h1', 'l1', 'v1']]

massParams

Value:
['m1', 'm2', 'chirpmass', 'mchirp', 'mc', 'eta', 'q', 'massratio', 'as\
ym_massratio', 'mtotal', 'mf']

spinParamsPrec

Value:
['a1', 'a2', 'phi1', 'theta1', 'phi2', 'theta2', 'costilt1', 'costilt2\
', 'costheta_jn', 'cosbeta', 'tilt1', 'tilt2', 'phi_jl', 'theta_jn', '\
phi12', 'af']

spinParamsEff

Value:
['chi', 'effectivespin', 'chi_eff', 'chi_tot', 'chi_p']

cosmoParam

Value:
['m1_source', 'm2_source', 'mtotal_source', 'mc_source', 'redshift', '\
mf_source']

ppEParams

Value:
['ppEalpha', 'ppElowera', 'ppEupperA', 'ppEbeta', 'ppElowerb', 'ppEupp\
erB', 'alphaPPE', 'aPPE', 'betaPPE', 'bPPE']

tigerParams

Value:
['dchi%i' %(i) for i in range(8)]+ ['dchi%il' %(i) for i in [5, 6]]+ [\
'dxi%d' %(i+ 1) for i in range(6)]+ ['dalpha%i' %(i+ 1) for i in range\
(5)]+ ['dbeta%i' %(i+ 1) for i in range(3)]+ ['dsigma%i' %(i+ 1) for i\
 in range(4)]

tidalParams

Value:
['lambda1', 'lambda2', 'lam_tilde', 'dlam_tilde', 'lambdat', 'dlambdat\
']

strongFieldParams

Value:
ppEParams+ tigerParams+ bransDickeParams+ massiveGravitonParams+ tidal\
Params+ energyParams

statsParams

Value:
['logprior', 'logl', 'deltalogl', 'deltaloglh1', 'deltalogll1', 'delta\
loglv1', 'deltaloglh2', 'deltaloglg1']

calibParams

Value:
['calpha_l1', 'calpha_h1', 'calpha_v1', 'calamp_l1', 'calamp_h1', 'cal\
amp_v1']

greedyBinSizes

Value:
{'mc': 0.025, 'm1': 0.1, 'm2': 0.1, 'mass1': 0.1, 'mass2': 0.1, 'mtota\
l': 0.1, 'mc_source': 0.025, 'm1_source': 0.1, 'm2_source': 0.1, 'mtot\
al_source': 0.1, 'eta': 0.001, 'q': 0.01, 'asym_massratio': 0.01, 'iot\
a': 0.01, 'cosiota': 0.02, 'time': 1e-4, 'time_mean': 1e-4, 'distance'\
: 1.0, 'dist': 1.0, 'redshift': 0.01, 'mchirp': 0.025, 'chirpmass': 0.\
025, 'spin1': 0.04, 'spin2': 0.04, 'a1z': 0.04, 'a2z': 0.04, 'a1': 0.0\
2, 'a2': 0.02, 'phi1': 0.05, 'phi2': 0.05, 'theta1': 0.05, 'theta2': 0\
.05, 'ra': 0.05, 'dec': 0.05, 'chi': 0.05, 'chi_eff': 0.05, 'chi_tot':\
...

__default_css_string

Value:
"""
p,h1,h2,h3,h4,h5
{
font-family:"Trebuchet MS", Arial, Helvetica, sans-serif;
}

p
{
...

__default_javascript_string

Value:
'''
//<![CDATA[
function toggle_visibility(tbid,lnkid)
{

  if(document.all){document.getElementById(tbid).style.display = docum\
ent.getElementById(tbid).style.display == 'block' ? 'none' : 'block';}

...