This module contains classes and functions for post-processing the
output of the Bayesian parameter estimation codes.
|
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
|
|
|
|
|
plot_label(param)
A lookup table for plot labels. |
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
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
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_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
|
|
|
|
|
|
|
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
|
|
|
|
|
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
|
|
|
|
|
greedy_bin_one_param(posterior,
greedy1Param,
confidence_levels)
Determine the 1-parameter Bayesian Confidence Interval using a greedy
binning algorithm. |
source code
|
|
|
|
|
burnin(data,
spin_flag,
deltaLogP,
outputfile) |
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
|
|
|
|
|
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
|
|
|
|
|
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
|
|
|
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:
|