Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
Michael Williams
bilby
Commits
6681ce04
Commit
6681ce04
authored
Feb 22, 2021
by
Colm Talbot
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'update-docs' into 'master'
Improve docs See merge request
lscsoft/bilby!915
parents
31439b55
83f856d3
Changes
68
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
68 changed files
with
1420 additions
and
1703 deletions
+1420
-1703
.gitlab-ci.yml
.gitlab-ci.yml
+23
-6
bilby/core/grid.py
bilby/core/grid.py
+19
-19
bilby/core/likelihood.py
bilby/core/likelihood.py
+14
-14
bilby/core/prior/analytical.py
bilby/core/prior/analytical.py
+88
-88
bilby/core/prior/base.py
bilby/core/prior/base.py
+20
-20
bilby/core/prior/conditional.py
bilby/core/prior/conditional.py
+118
-45
bilby/core/prior/dict.py
bilby/core/prior/dict.py
+41
-39
bilby/core/prior/interpolated.py
bilby/core/prior/interpolated.py
+8
-8
bilby/core/prior/joint.py
bilby/core/prior/joint.py
+22
-22
bilby/core/prior/slabspike.py
bilby/core/prior/slabspike.py
+11
-11
bilby/core/result.py
bilby/core/result.py
+53
-53
bilby/core/sampler/__init__.py
bilby/core/sampler/__init__.py
+2
-2
bilby/core/sampler/base_sampler.py
bilby/core/sampler/base_sampler.py
+24
-24
bilby/core/sampler/cpnest.py
bilby/core/sampler/cpnest.py
+2
-2
bilby/core/sampler/dnest4.py
bilby/core/sampler/dnest4.py
+2
-2
bilby/core/sampler/dynamic_dynesty.py
bilby/core/sampler/dynamic_dynesty.py
+2
-2
bilby/core/sampler/dynesty.py
bilby/core/sampler/dynesty.py
+11
-11
bilby/core/sampler/emcee.py
bilby/core/sampler/emcee.py
+3
-4
bilby/core/sampler/fake_sampler.py
bilby/core/sampler/fake_sampler.py
+1
-1
bilby/core/sampler/kombine.py
bilby/core/sampler/kombine.py
+2
-3
bilby/core/sampler/nestle.py
bilby/core/sampler/nestle.py
+4
-4
bilby/core/sampler/polychord.py
bilby/core/sampler/polychord.py
+1
-1
bilby/core/sampler/proposal.py
bilby/core/sampler/proposal.py
+12
-11
bilby/core/sampler/ptemcee.py
bilby/core/sampler/ptemcee.py
+6
-6
bilby/core/sampler/ptmcmc.py
bilby/core/sampler/ptmcmc.py
+9
-6
bilby/core/sampler/pymc3.py
bilby/core/sampler/pymc3.py
+2
-2
bilby/core/sampler/pymultinest.py
bilby/core/sampler/pymultinest.py
+2
-2
bilby/core/sampler/ultranest.py
bilby/core/sampler/ultranest.py
+2
-2
bilby/core/series.py
bilby/core/series.py
+5
-5
bilby/core/utils.py
bilby/core/utils.py
+78
-71
bilby/gw/conversion.py
bilby/gw/conversion.py
+68
-68
bilby/gw/cosmology.py
bilby/gw/cosmology.py
+2
-2
bilby/gw/detector/__init__.py
bilby/gw/detector/__init__.py
+10
-10
bilby/gw/detector/calibration.py
bilby/gw/detector/calibration.py
+6
-6
bilby/gw/detector/geometry.py
bilby/gw/detector/geometry.py
+17
-17
bilby/gw/detector/interferometer.py
bilby/gw/detector/interferometer.py
+37
-37
bilby/gw/detector/networks.py
bilby/gw/detector/networks.py
+17
-17
bilby/gw/detector/psd.py
bilby/gw/detector/psd.py
+20
-14
bilby/gw/detector/strain_data.py
bilby/gw/detector/strain_data.py
+28
-28
bilby/gw/eos/eos.py
bilby/gw/eos/eos.py
+43
-33
bilby/gw/eos/tov_solver.py
bilby/gw/eos/tov_solver.py
+0
-23
bilby/gw/likelihood.py
bilby/gw/likelihood.py
+38
-36
bilby/gw/prior.py
bilby/gw/prior.py
+44
-41
bilby/gw/result.py
bilby/gw/result.py
+7
-7
bilby/gw/source.py
bilby/gw/source.py
+89
-86
bilby/gw/utils.py
bilby/gw/utils.py
+89
-71
bilby/gw/waveform_generator.py
bilby/gw/waveform_generator.py
+10
-10
bilby/hyper/likelihood.py
bilby/hyper/likelihood.py
+3
-3
bilby/hyper/model.py
bilby/hyper/model.py
+1
-1
docs/conf.py
docs/conf.py
+17
-6
docs/conversion.txt
docs/conversion.txt
+0
-17
docs/faq.txt
docs/faq.txt
+2
-7
docs/gw_eos.txt
docs/gw_eos.txt
+0
-20
docs/gw_likelihood.txt
docs/gw_likelihood.txt
+0
-21
docs/gw_prior.txt
docs/gw_prior.txt
+0
-32
docs/index.txt
docs/index.txt
+24
-2
docs/likelihood.txt
docs/likelihood.txt
+5
-15
docs/prior.txt
docs/prior.txt
+3
-31
docs/samplers.txt
docs/samplers.txt
+12
-74
docs/templates/custom-class-template.rst
docs/templates/custom-class-template.rst
+33
-0
docs/templates/custom-module-template.rst
docs/templates/custom-module-template.rst
+73
-0
docs/transient-gw-data.txt
docs/transient-gw-data.txt
+3
-8
docs/writing-documentation.txt
docs/writing-documentation.txt
+6
-14
examples/tutorials/basic_ptmcmc_tutorial.ipynb
examples/tutorials/basic_ptmcmc_tutorial.ipynb
+20
-220
examples/tutorials/compare_samplers.ipynb
examples/tutorials/compare_samplers.ipynb
+53
-33
examples/tutorials/fitting_with_x_and_y_errors.ipynb
examples/tutorials/fitting_with_x_and_y_errors.ipynb
+3
-40
examples/tutorials/making_priors.ipynb
examples/tutorials/making_priors.ipynb
+49
-148
examples/tutorials/visualising_the_results.ipynb
examples/tutorials/visualising_the_results.ipynb
+1
-19
No files found.
.gitlab-ci.yml
View file @
6681ce04
...
...
@@ -10,11 +10,12 @@
# before the next stage begins
stages
:
-
initial
-
test
-
deploy
.test-python
:
&test-python
stage
:
test
stage
:
initial
image
:
python
before_script
:
# this is required because pytables doesn't use a wheel on py37
...
...
@@ -55,15 +56,30 @@ python-3.7:
-
coverage html
-
coverage-badge -o coverage_badge.svg -f
artifacts
:
paths
:
-
coverage_badge.svg
-
htmlcov/
docs
:
stage
:
initial
image
:
quay.io/bilbydev/v2-dockerfile-test-suite-python37
script
:
# Make the documentation
-
apt-get -yqq install pandoc
-
python -m pip install .
-
cd docs
-
pip install ipykernel ipython jupyter
-
cp ../examples/tutorials/*.ipynb ./
-
rm basic_ptmcmc_tutorial.ipynb
-
rm compare_samplers.ipynb
-
rm visualising_the_results.ipynb
-
jupyter nbconvert --to notebook --execute *.ipynb --inplace
-
make clean
-
make html
artifacts
:
paths
:
-
htmlcov/
-
coverage_badge.svg
-
docs/_build/html/
# test example on python 3.8
...
...
@@ -105,7 +121,7 @@ python-3.6-samplers:
# Test containers are up to date
containers
:
stage
:
test
stage
:
initial
image
:
quay.io/bilbydev/v2-dockerfile-test-suite-python37
script
:
-
cd containers
...
...
@@ -139,7 +155,7 @@ plotting:
-
pytest test/gw/plot_test.py
authors
:
stage
:
test
stage
:
initial
image
:
quay.io/bilbydev/v2-dockerfile-test-suite-python37
script
:
-
python test/check_author_list.py
...
...
@@ -147,6 +163,7 @@ authors:
pages
:
stage
:
deploy
dependencies
:
-
docs
-
python-3.7
script
:
-
mkdir public/
...
...
@@ -176,7 +193,7 @@ deploy_release:
precommits-py3.7
:
stage
:
test
stage
:
initial
image
:
quay.io/bilbydev/v2-dockerfile-test-suite-python37
script
:
-
source activate python37
...
...
bilby/core/grid.py
View file @
6681ce04
...
...
@@ -14,7 +14,7 @@ def grid_file_name(outdir, label, gzip=False):
""" Returns the standard filename used for a grid file
Parameters
----------
==========
outdir: str
Name of the output directory
label: str
...
...
@@ -23,7 +23,7 @@ def grid_file_name(outdir, label, gzip=False):
Set to True to append `.gz` to the extension for saving in gzipped format
Returns
-------
=======
str: File name of the output file
"""
if
gzip
:
...
...
@@ -39,7 +39,7 @@ class Grid(object):
"""
Parameters
----------
==========
likelihood: bilby.likelihood.Likelihood
priors: bilby.prior.PriorDict
grid_size: int, list, dict
...
...
@@ -112,7 +112,7 @@ class Grid(object):
Marginalize over a list of parameters.
Parameters
----------
==========
log_array: array_like
A :class:`numpy.ndarray` of log likelihood/posterior values.
parameters: list, str
...
...
@@ -123,7 +123,7 @@ class Grid(object):
the set of parameter to *not* marginalize over.
Returns
-------
=======
out_array: array_like
An array containing the marginalized log likelihood/posterior.
"""
...
...
@@ -162,7 +162,7 @@ class Grid(object):
Marginalize the log likelihood/posterior over a single given parameter.
Parameters
----------
==========
log_array: array_like
A :class:`numpy.ndarray` of log likelihood/posterior values.
name: str
...
...
@@ -171,7 +171,7 @@ class Grid(object):
A list of parameter names that have not been marginalized over.
Returns
-------
=======
out: array_like
An array containing the marginalized log likelihood/posterior.
"""
...
...
@@ -218,14 +218,14 @@ class Grid(object):
ln likelihood will be fully marginalized over.
Parameters
----------
==========
parameters: str, list, optional
Name of, or list of names of, the parameter(s) to marginalize over.
not_parameters: str, optional
Name of, or list of names of, the parameter(s) to not marginalize over.
Returns
-------
=======
array-like:
The marginalized ln likelihood.
"""
...
...
@@ -239,14 +239,14 @@ class Grid(object):
ln posterior will be fully marginalized over.
Parameters
----------
==========
parameters: str, list, optional
Name of, or list of names of, the parameter(s) to marginalize over.
not_parameters: str, optional
Name of, or list of names of, the parameter(s) to not marginalize over.
Returns
-------
=======
array-like:
The marginalized ln posterior.
"""
...
...
@@ -260,14 +260,14 @@ class Grid(object):
likelihood will be fully marginalized over.
Parameters
----------
==========
parameters: str, list, optional
Name of, or list of names of, the parameter(s) to marginalize over.
not_parameters: str, optional
Name of, or list of names of, the parameter(s) to not marginalize over.
Returns
-------
=======
array-like:
The marginalized likelihood.
"""
...
...
@@ -283,14 +283,14 @@ class Grid(object):
posterior will be fully marginalized over.
Parameters
----------
==========
parameters: str, list, optional
Name of, or list of names of, the parameter(s) to marginalize over.
not_parameters: str, optional
Name of, or list of names of, the parameter(s) to not marginalize over.
Returns
-------
=======
array-like:
The marginalized posterior.
"""
...
...
@@ -375,7 +375,7 @@ class Grid(object):
Writes the Grid to a file.
Parameters
----------
==========
filename: str, optional
Filename to write to (overwrites the default)
overwrite: bool, optional
...
...
@@ -418,7 +418,7 @@ class Grid(object):
""" Read in a saved .json grid file
Parameters
----------
==========
filename: str
If given, try to load from this filename
outdir, label: str
...
...
@@ -429,11 +429,11 @@ class Grid(object):
extension)
Returns
-------
=======
grid: bilby.core.grid.Grid
Raises
-------
=======
ValueError: If no filename is given and either outdir or label is None
If no bilby.core.grid.Grid is found in the path
...
...
bilby/core/likelihood.py
View file @
6681ce04
...
...
@@ -13,7 +13,7 @@ class Likelihood(object):
"""Empty likelihood class to be subclassed by other likelihoods
Parameters
----------
==========
parameters: dict
A dictionary of the parameter names and associated values
"""
...
...
@@ -28,7 +28,7 @@ class Likelihood(object):
"""
Returns
-------
=======
float
"""
return
np
.
nan
...
...
@@ -37,7 +37,7 @@ class Likelihood(object):
"""
Returns
-------
=======
float
"""
return
np
.
nan
...
...
@@ -46,7 +46,7 @@ class Likelihood(object):
"""Difference between log likelihood and noise log likelihood
Returns
-------
=======
float
"""
return
self
.
log_likelihood
()
-
self
.
noise_log_likelihood
()
...
...
@@ -71,7 +71,7 @@ class ZeroLikelihood(Likelihood):
""" A special test-only class which already returns zero likelihood
Parameters
----------
==========
likelihood: bilby.core.likelihood.Likelihood
A likelihood object to mimic
...
...
@@ -98,7 +98,7 @@ class Analytical1DLikelihood(Likelihood):
parameters are inferred from the arguments of function
Parameters
----------
==========
x, y: array_like
The data to analyse
func:
...
...
@@ -174,7 +174,7 @@ class GaussianLikelihood(Analytical1DLikelihood):
parameters are inferred from the arguments of function
Parameters
----------
==========
x, y: array_like
The data to analyse
func:
...
...
@@ -235,7 +235,7 @@ class PoissonLikelihood(Analytical1DLikelihood):
inferred from the arguments of function, which provides a rate.
Parameters
----------
==========
x: array_like
A dependent variable at which the Poisson rates will be calculated
...
...
@@ -291,7 +291,7 @@ class ExponentialLikelihood(Analytical1DLikelihood):
An exponential likelihood function.
Parameters
----------
==========
x, y: array_like
The data to analyse
...
...
@@ -338,7 +338,7 @@ class StudentTLikelihood(Analytical1DLikelihood):
https://en.wikipedia.org/wiki/Student%27s_t-distribution#Generalized_Student's_t-distribution
Parameters
----------
==========
x, y: array_like
The data to analyse
func:
...
...
@@ -410,7 +410,7 @@ class Multinomial(Likelihood):
"""
Parameters
----------
==========
data: array-like
The number of objects in each class
n_dimensions: int
...
...
@@ -454,7 +454,7 @@ class AnalyticalMultidimensionalCovariantGaussian(Likelihood):
with known analytic solution.
Parameters
----------
==========
mean: array_like
Array with the mean values of distribution
cov: array_like
...
...
@@ -484,7 +484,7 @@ class AnalyticalMultidimensionalBimodalCovariantGaussian(Likelihood):
with known analytic solution.
Parameters
----------
==========
mean_1: array_like
Array with the mean value of the first mode
mean_2: array_like
...
...
@@ -523,7 +523,7 @@ class JointLikelihood(Likelihood):
set consistently
Parameters
----------
==========
*likelihoods: bilby.core.likelihood.Likelihood
likelihoods to be combined parsed as arguments
"""
...
...
bilby/core/prior/analytical.py
View file @
6681ce04
...
...
@@ -13,7 +13,7 @@ class DeltaFunction(Prior):
"""Dirac delta function prior, this always returns peak.
Parameters
----------
==========
peak: float
Peak value of the delta function
name: str
...
...
@@ -33,11 +33,11 @@ class DeltaFunction(Prior):
"""Rescale everything to the peak with the correct shape.
Parameters
----------
==========
val: Union[float, int, array_like]
Returns
-------
=======
float: Rescaled probability, equivalent to peak
"""
self
.
test_valid_for_rescaling
(
val
)
...
...
@@ -47,11 +47,11 @@ class DeltaFunction(Prior):
"""Return the prior probability of val
Parameters
----------
==========
val: Union[float, int, array_like]
Returns
-------
=======
Union[float, array_like]: np.inf if val = peak, 0 otherwise
"""
...
...
@@ -69,7 +69,7 @@ class PowerLaw(Prior):
"""Power law with bounds and alpha, spectral index
Parameters
----------
==========
alpha: float
Power law exponent parameter
minimum: float
...
...
@@ -97,12 +97,12 @@ class PowerLaw(Prior):
This maps to the inverse CDF. This has been analytically solved for this case.
Parameters
----------
==========
val: Union[float, int, array_like]
Uniform probability
Returns
-------
=======
Union[float, array_like]: Rescaled probability
"""
self
.
test_valid_for_rescaling
(
val
)
...
...
@@ -116,11 +116,11 @@ class PowerLaw(Prior):
"""Return the prior probability of val
Parameters
----------
==========
val: Union[float, int, array_like]
Returns
-------
=======
float: Prior probability of val
"""
if
self
.
alpha
==
-
1
:
...
...
@@ -134,11 +134,11 @@ class PowerLaw(Prior):
"""Return the logarithmic prior probability of val
Parameters
----------
==========
val: Union[float, int, array_like]
Returns
-------
=======
float:
"""
...
...
@@ -170,7 +170,7 @@ class Uniform(Prior):
"""Uniform prior with bounds
Parameters
----------
==========
minimum: float
See superclass
maximum: float
...
...
@@ -195,12 +195,12 @@ class Uniform(Prior):
This maps to the inverse CDF. This has been analytically solved for this case.
Parameters
----------
==========
val: Union[float, int, array_like]
Uniform probability
Returns
-------
=======
Union[float, array_like]: Rescaled probability
"""
self
.
test_valid_for_rescaling
(
val
)
...
...
@@ -210,11 +210,11 @@ class Uniform(Prior):
"""Return the prior probability of val
Parameters
----------
==========
val: Union[float, int, array_like]
Returns
-------
=======
float: Prior probability of val
"""
return
((
val
>=
self
.
minimum
)
&
(
val
<=
self
.
maximum
))
/
(
self
.
maximum
-
self
.
minimum
)
...
...
@@ -223,11 +223,11 @@ class Uniform(Prior):
"""Return the log prior probability of val
Parameters
----------
==========
val: Union[float, int, array_like]
Returns
-------
=======
float: log probability of val
"""
return
xlogy
(
1
,
(
val
>=
self
.
minimum
)
&
(
val
<=
self
.
maximum
))
-
xlogy
(
1
,
self
.
maximum
-
self
.
minimum
)
...
...
@@ -246,7 +246,7 @@ class LogUniform(PowerLaw):
"""Log-Uniform prior with bounds
Parameters
----------
==========
minimum: float
See superclass
maximum: float
...
...
@@ -278,7 +278,7 @@ class SymmetricLogUniform(Prior):
maximum].
Parameters
----------
==========
minimum: float
See superclass
maximum: float
...
...
@@ -303,12 +303,12 @@ class SymmetricLogUniform(Prior):
This maps to the inverse CDF. This has been analytically solved for this case.
Parameters
----------
==========
val: Union[float, int, array_like]
Uniform probability
Returns
-------
=======
Union[float, array_like]: Rescaled probability
"""
self
.
test_valid_for_rescaling
(
val
)
...
...
@@ -330,11 +330,11 @@ class SymmetricLogUniform(Prior):
"""Return the prior probability of val
Parameters
----------
==========
val: Union[float, int, array_like]
Returns
-------
=======
float: Prior probability of val
"""
val
=
np
.
abs
(
val
)
...
...
@@ -345,11 +345,11 @@ class SymmetricLogUniform(Prior):
"""Return the logarithmic prior probability of val
Parameters
----------
==========
val: Union[float, int, array_like]
Returns
-------
=======
float:
"""
...
...
@@ -375,7 +375,7 @@ class Cosine(Prior):
"""Cosine prior with bounds
Parameters
----------
==========
minimum: float
See superclass
maximum: float
...
...
@@ -406,11 +406,11 @@ class Cosine(Prior):
"""Return the prior probability of val. Defined over [-pi/2, pi/2].
Parameters
----------
==========
val: Union[float, int, array_like]
Returns
-------
=======
float: Prior probability of val
"""
return
np
.
cos
(
val
)
/
2
*
self
.
is_in_prior_range
(
val
)
...
...
@@ -430,7 +430,7 @@ class Sine(Prior):
"""Sine prior with bounds
Parameters
----------
==========
minimum: float
See superclass
maximum: float
...
...
@@ -461,11 +461,11 @@ class Sine(Prior):
"""Return the prior probability of val. Defined over [0, pi].
Parameters
----------
==========
val: Union[float, int, array_like]
Returns
-------
=======
Union[float, array_like]: Prior probability of val
"""
return
np
.
sin
(
val
)
/
2
*
self
.
is_in_prior_range
(
val
)
...
...
@@ -484,7 +484,7 @@ class Gaussian(Prior):
"""Gaussian prior with mean mu and width sigma
Parameters
----------
==========
mu: float
Mean of the Gaussian prior
sigma:
...
...
@@ -507,7 +507,7 @@ class Gaussian(Prior):
'Rescale' a sample from the unit line element to the appropriate Gaussian prior.
Parameters
----------
==========
val: Union[float, int, array_like]
This maps to the inverse CDF. This has been analytically solved for this case.
...
...
@@ -519,11 +519,11 @@ class Gaussian(Prior):
"""Return the prior probability of val.
Parameters
----------
==========
val: Union[float, int, array_like]
Returns
-------
=======
Union[float, array_like]: Prior probability of val
"""
return
np
.
exp
(
-
(
self
.
mu
-
val
)
**
2
/
(
2
*
self
.
sigma
**
2
))
/
(
2
*
np
.
pi
)
**
0.5
/
self
.
sigma
...
...
@@ -532,11 +532,11 @@ class Gaussian(Prior):
"""Return the Log prior probability of val.
Parameters
----------
==========
val: Union[float, int, array_like]
Returns
-------
=======
Union[float, array_like]: Prior probability of val