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
23876f9b
Commit
23876f9b
authored
Jan 15, 2021
by
Moritz Huebner
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://git.ligo.org/lscsoft/bilby
Conflicts: bilby/core/prior/analytical.py
parents
a90e88cd
d5f739b5
Changes
85
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
75 changed files
with
712 additions
and
254 deletions
+712
-254
.gitlab-ci.yml
.gitlab-ci.yml
+11
-11
CHANGELOG.md
CHANGELOG.md
+9
-0
bilby/__init__.py
bilby/__init__.py
+0
-1
bilby/core/__init__.py
bilby/core/__init__.py
+0
-1
bilby/core/grid.py
bilby/core/grid.py
+0
-2
bilby/core/likelihood.py
bilby/core/likelihood.py
+0
-1
bilby/core/prior/analytical.py
bilby/core/prior/analytical.py
+1
-1
bilby/core/prior/dict.py
bilby/core/prior/dict.py
+1
-2
bilby/core/result.py
bilby/core/result.py
+7
-5
bilby/core/sampler/base_sampler.py
bilby/core/sampler/base_sampler.py
+0
-1
bilby/core/sampler/cpnest.py
bilby/core/sampler/cpnest.py
+3
-3
bilby/core/sampler/dynamic_dynesty.py
bilby/core/sampler/dynamic_dynesty.py
+0
-1
bilby/core/sampler/dynesty.py
bilby/core/sampler/dynesty.py
+14
-3
bilby/core/sampler/emcee.py
bilby/core/sampler/emcee.py
+2
-5
bilby/core/sampler/fake_sampler.py
bilby/core/sampler/fake_sampler.py
+0
-1
bilby/core/sampler/kombine.py
bilby/core/sampler/kombine.py
+2
-3
bilby/core/sampler/nestle.py
bilby/core/sampler/nestle.py
+1
-1
bilby/core/sampler/polychord.py
bilby/core/sampler/polychord.py
+0
-1
bilby/core/sampler/ptemcee.py
bilby/core/sampler/ptemcee.py
+387
-115
bilby/core/sampler/ptmcmc.py
bilby/core/sampler/ptmcmc.py
+0
-1
bilby/core/sampler/pymc3.py
bilby/core/sampler/pymc3.py
+0
-1
bilby/core/sampler/ultranest.py
bilby/core/sampler/ultranest.py
+4
-3
bilby/core/utils.py
bilby/core/utils.py
+0
-21
bilby/gw/conversion.py
bilby/gw/conversion.py
+1
-2
bilby/gw/detector/detectors/A1.interferometer
bilby/gw/detector/detectors/A1.interferometer
+13
-0
bilby/gw/detector/strain_data.py
bilby/gw/detector/strain_data.py
+135
-3
bilby/gw/likelihood.py
bilby/gw/likelihood.py
+0
-1
bilby/gw/prior.py
bilby/gw/prior.py
+90
-1
bilby/gw/result.py
bilby/gw/result.py
+8
-7
bilby/gw/sampler/__init__.py
bilby/gw/sampler/__init__.py
+0
-1
bilby/gw/source.py
bilby/gw/source.py
+13
-7
bilby/gw/utils.py
bilby/gw/utils.py
+0
-1
bilby/hyper/likelihood.py
bilby/hyper/likelihood.py
+0
-1
cli_bilby/__init__.py
cli_bilby/__init__.py
+0
-1
containers/dockerfile-template
containers/dockerfile-template
+1
-1
containers/v2-dockerfile-test-suite-python35
containers/v2-dockerfile-test-suite-python35
+1
-1
containers/v2-dockerfile-test-suite-python36
containers/v2-dockerfile-test-suite-python36
+1
-1
containers/v2-dockerfile-test-suite-python37
containers/v2-dockerfile-test-suite-python37
+1
-1
containers/v2-dockerfile-test-suite-python38
containers/v2-dockerfile-test-suite-python38
+1
-1
examples/core_examples/gaussian_example.py
examples/core_examples/gaussian_example.py
+0
-1
examples/core_examples/grid_example.py
examples/core_examples/grid_example.py
+0
-1
examples/core_examples/hyper_parameter_example.py
examples/core_examples/hyper_parameter_example.py
+4
-5
examples/core_examples/linear_regression.py
examples/core_examples/linear_regression.py
+0
-1
examples/core_examples/linear_regression_grid.py
examples/core_examples/linear_regression_grid.py
+0
-1
examples/core_examples/linear_regression_pymc3.py
examples/core_examples/linear_regression_pymc3.py
+0
-1
examples/core_examples/linear_regression_pymc3_custom_likelihood.py
...ore_examples/linear_regression_pymc3_custom_likelihood.py
+0
-1
examples/core_examples/linear_regression_unknown_noise.py
examples/core_examples/linear_regression_unknown_noise.py
+0
-1
examples/core_examples/multidimensional_gaussian.py
examples/core_examples/multidimensional_gaussian.py
+1
-1
examples/core_examples/multivariate_gaussian_prior.py
examples/core_examples/multivariate_gaussian_prior.py
+0
-1
examples/core_examples/occam_factor_example.py
examples/core_examples/occam_factor_example.py
+0
-1
examples/core_examples/radioactive_decay.py
examples/core_examples/radioactive_decay.py
+0
-1
examples/core_examples/starting_mcmc_chains_near_to_the_peak.py
...es/core_examples/starting_mcmc_chains_near_to_the_peak.py
+0
-1
examples/gw_examples/data_examples/GW150914.py
examples/gw_examples/data_examples/GW150914.py
+0
-1
examples/gw_examples/data_examples/GW150914_advanced.py
examples/gw_examples/data_examples/GW150914_advanced.py
+0
-1
examples/gw_examples/data_examples/GW170817.py
examples/gw_examples/data_examples/GW170817.py
+0
-1
examples/gw_examples/data_examples/get_LOSC_event_data.py
examples/gw_examples/data_examples/get_LOSC_event_data.py
+0
-1
examples/gw_examples/injection_examples/australian_detector.py
...les/gw_examples/injection_examples/australian_detector.py
+0
-1
examples/gw_examples/injection_examples/binary_neutron_star_example.py
...xamples/injection_examples/binary_neutron_star_example.py
+0
-1
examples/gw_examples/injection_examples/bns_eos_example.py
examples/gw_examples/injection_examples/bns_eos_example.py
+0
-1
examples/gw_examples/injection_examples/calibration_example.py
...les/gw_examples/injection_examples/calibration_example.py
+0
-1
examples/gw_examples/injection_examples/change_sampled_parameters.py
..._examples/injection_examples/change_sampled_parameters.py
+0
-1
examples/gw_examples/injection_examples/create_your_own_source_model.py
...amples/injection_examples/create_your_own_source_model.py
+0
-1
examples/gw_examples/injection_examples/custom_proposal_example.py
...gw_examples/injection_examples/custom_proposal_example.py
+0
-1
examples/gw_examples/injection_examples/eccentric_inspiral.py
...ples/gw_examples/injection_examples/eccentric_inspiral.py
+0
-1
examples/gw_examples/injection_examples/fake_sampler_example.py
...es/gw_examples/injection_examples/fake_sampler_example.py
+0
-1
examples/gw_examples/injection_examples/fast_tutorial.py
examples/gw_examples/injection_examples/fast_tutorial.py
+0
-1
examples/gw_examples/injection_examples/how_to_specify_the_prior.py
...w_examples/injection_examples/how_to_specify_the_prior.py
+0
-1
examples/gw_examples/injection_examples/marginalized_likelihood.py
...gw_examples/injection_examples/marginalized_likelihood.py
+0
-1
examples/gw_examples/injection_examples/non_tensor.py
examples/gw_examples/injection_examples/non_tensor.py
+0
-1
examples/gw_examples/injection_examples/plot_skymap.py
examples/gw_examples/injection_examples/plot_skymap.py
+0
-1
examples/gw_examples/injection_examples/plot_time_domain_data.py
...s/gw_examples/injection_examples/plot_time_domain_data.py
+0
-1
examples/gw_examples/injection_examples/roq_example.py
examples/gw_examples/injection_examples/roq_example.py
+0
-1
examples/gw_examples/injection_examples/sine_gaussian_example.py
...s/gw_examples/injection_examples/sine_gaussian_example.py
+0
-1
examples/gw_examples/injection_examples/standard_15d_cbc_tutorial.py
..._examples/injection_examples/standard_15d_cbc_tutorial.py
+0
-1
examples/gw_examples/injection_examples/using_gwin.py
examples/gw_examples/injection_examples/using_gwin.py
+0
-1
No files found.
.gitlab-ci.yml
View file @
23876f9b
...
...
@@ -43,7 +43,7 @@ basic-3.7:
# test example on python 3.7
python-3.7
:
stage
:
test
image
:
bilbydev/v2-dockerfile-test-suite-python37
image
:
quay.io/
bilbydev/v2-dockerfile-test-suite-python37
script
:
-
python -m pip install .
...
...
@@ -69,7 +69,7 @@ python-3.7:
# test example on python 3.8
python-3.8
:
stage
:
test
image
:
bilbydev/v2-dockerfile-test-suite-python38
image
:
quay.io/
bilbydev/v2-dockerfile-test-suite-python38
script
:
-
python -m pip install .
...
...
@@ -78,7 +78,7 @@ python-3.8:
# test example on python 3.6
python-3.6
:
stage
:
test
image
:
bilbydev/v2-dockerfile-test-suite-python36
image
:
quay.io/
bilbydev/v2-dockerfile-test-suite-python36
script
:
-
python -m pip install .
...
...
@@ -87,7 +87,7 @@ python-3.6:
# test samplers on python 3.7
python-3.7-samplers
:
stage
:
test
image
:
bilbydev/v2-dockerfile-test-suite-python37
image
:
quay.io/
bilbydev/v2-dockerfile-test-suite-python37
script
:
-
python -m pip install .
...
...
@@ -97,7 +97,7 @@ python-3.7-samplers:
# test samplers on python 3.6
python-3.6-samplers
:
stage
:
test
image
:
bilbydev/v2-dockerfile-test-suite-python36
image
:
quay.io/
bilbydev/v2-dockerfile-test-suite-python36
script
:
-
python -m pip install .
...
...
@@ -106,7 +106,7 @@ python-3.6-samplers:
# Test containers are up to date
containers
:
stage
:
test
image
:
bilbydev/v2-dockerfile-test-suite-python37
image
:
quay.io/
bilbydev/v2-dockerfile-test-suite-python37
script
:
-
cd containers
-
python write_dockerfiles.py
...
...
@@ -117,7 +117,7 @@ containers:
# Tests run at a fixed schedule rather than on push
scheduled-python-3.7
:
stage
:
test
image
:
bilbydev/v2-dockerfile-test-suite-python37
image
:
quay.io/
bilbydev/v2-dockerfile-test-suite-python37
only
:
-
schedules
script
:
...
...
@@ -129,7 +129,7 @@ scheduled-python-3.7:
plotting
:
stage
:
test
image
:
bilbydev/
bilby
-test-suite-python37
image
:
quay.io/
bilbydev/
v2-dockerfile
-test-suite-python37
only
:
-
schedules
script
:
...
...
@@ -140,7 +140,7 @@ plotting:
authors
:
stage
:
test
image
:
bilbydev/
bilby
-test-suite-python37
image
:
quay.io/
bilbydev/
v2-dockerfile
-test-suite-python37
script
:
-
python test/check_author_list.py
...
...
@@ -162,7 +162,7 @@ pages:
deploy_release
:
stage
:
deploy
image
:
bilbydev/v2-dockerfile-test-suite-python37
image
:
quay.io/
bilbydev/v2-dockerfile-test-suite-python37
variables
:
TWINE_USERNAME
:
$PYPI_USERNAME
TWINE_PASSWORD
:
$PYPI_PASSWORD
...
...
@@ -177,7 +177,7 @@ deploy_release:
precommits-py3.7
:
stage
:
test
image
:
bilbydev/v2-dockerfile-test-suite-python37
image
:
quay.io/
bilbydev/v2-dockerfile-test-suite-python37
script
:
-
source activate python37
-
mkdir -p .pip37
...
...
CHANGELOG.md
View file @
23876f9b
# All notable changes will be documented in this file
## [1.0.3] 2020-11-23
Version 1.0.4 release of bilby
### Added
-
Added a chirp-mass and mass-ratio prior which are uniform in component masses (!891)
### Changes
-
Fixed issue in the CI
## [1.0.3] 2020-10-23
Version 1.0.3 release of bilby
...
...
bilby/__init__.py
View file @
23876f9b
...
...
@@ -16,7 +16,6 @@ https://lscsoft.docs.ligo.org/bilby/installation.html.
"""
from
__future__
import
absolute_import
import
sys
from
.
import
core
,
gw
,
hyper
...
...
bilby/core/__init__.py
View file @
23876f9b
from
__future__
import
absolute_import
from
.
import
grid
,
likelihood
,
prior
,
result
,
sampler
,
series
,
utils
bilby/core/grid.py
View file @
23876f9b
from
__future__
import
division
import
numpy
as
np
import
os
import
json
...
...
bilby/core/likelihood.py
View file @
23876f9b
from
__future__
import
division
,
print_function
import
copy
import
numpy
as
np
...
...
bilby/core/prior/analytical.py
View file @
23876f9b
...
...
@@ -389,7 +389,7 @@ class Cosine(Prior):
boundary: str
See superclass
"""
super
(
Cosine
,
self
).
__init__
(
minimum
=
minimum
,
maximum
=
maximum
,
name
=
name
,
super
(
Cosine
,
self
).
__init__
(
minimum
=
minimum
,
maximum
=
maximum
,
name
=
name
,
latex_label
=
latex_label
,
unit
=
unit
,
boundary
=
boundary
)
def
rescale
(
self
,
val
):
...
...
bilby/core/prior/dict.py
View file @
23876f9b
...
...
@@ -3,7 +3,6 @@ from io import open as ioopen
import
json
import
os
from
future.utils
import
iteritems
from
matplotlib.cbook
import
flatten
import
numpy
as
np
...
...
@@ -185,7 +184,7 @@ class PriorDict(dict):
def
from_dictionary
(
self
,
dictionary
):
eval_dict
=
dict
(
inf
=
np
.
inf
)
for
key
,
val
in
iteritems
(
dictionary
):
for
key
,
val
in
dictionary
.
items
(
):
if
isinstance
(
val
,
Prior
):
continue
elif
isinstance
(
val
,
(
int
,
float
)):
...
...
bilby/core/result.py
View file @
23876f9b
from
__future__
import
division
import
inspect
import
os
from
collections
import
OrderedDict
,
namedtuple
...
...
@@ -238,8 +236,9 @@ class Result(object):
sampler_kwargs
=
None
,
injection_parameters
=
None
,
meta_data
=
None
,
posterior
=
None
,
samples
=
None
,
nested_samples
=
None
,
log_evidence
=
np
.
nan
,
log_evidence_err
=
np
.
nan
,
log_noise_evidence
=
np
.
nan
,
log_bayes_factor
=
np
.
nan
,
log_likelihood_evaluations
=
None
,
log_evidence_err
=
np
.
nan
,
information_gain
=
np
.
nan
,
log_noise_evidence
=
np
.
nan
,
log_bayes_factor
=
np
.
nan
,
log_likelihood_evaluations
=
None
,
log_prior_evaluations
=
None
,
sampling_time
=
None
,
nburn
=
None
,
num_likelihood_evaluations
=
None
,
walkers
=
None
,
max_autocorrelation_time
=
None
,
use_ratio
=
None
,
...
...
@@ -269,6 +268,8 @@ class Result(object):
An array of the output posterior samples and the unweighted samples
log_evidence, log_evidence_err, log_noise_evidence, log_bayes_factor: float
Natural log evidences
information_gain: float
The Kullback-Leibler divergence
log_likelihood_evaluations: array_like
The evaluations of the likelihood for each sample point
num_likelihood_evaluations: int
...
...
@@ -321,6 +322,7 @@ class Result(object):
self
.
use_ratio
=
use_ratio
self
.
log_evidence
=
log_evidence
self
.
log_evidence_err
=
log_evidence_err
self
.
information_gain
=
information_gain
self
.
log_noise_evidence
=
log_noise_evidence
self
.
log_bayes_factor
=
log_bayes_factor
self
.
log_likelihood_evaluations
=
log_likelihood_evaluations
...
...
@@ -573,7 +575,7 @@ class Result(object):
'log_noise_evidence'
,
'log_bayes_factor'
,
'priors'
,
'posterior'
,
'injection_parameters'
,
'meta_data'
,
'search_parameter_keys'
,
'fixed_parameter_keys'
,
'constraint_parameter_keys'
,
'sampling_time'
,
'sampler_kwargs'
,
'use_ratio'
,
'sampling_time'
,
'sampler_kwargs'
,
'use_ratio'
,
'information_gain'
,
'log_likelihood_evaluations'
,
'log_prior_evaluations'
,
'num_likelihood_evaluations'
,
'samples'
,
'nested_samples'
,
'walkers'
,
'nburn'
,
'parameter_labels'
,
'parameter_labels_with_unit'
,
...
...
bilby/core/sampler/base_sampler.py
View file @
23876f9b
from
__future__
import
absolute_import
import
datetime
import
distutils.dir_util
import
numpy
as
np
...
...
bilby/core/sampler/cpnest.py
View file @
23876f9b
from
__future__
import
absolute_import
import
array
import
copy
...
...
@@ -89,8 +88,8 @@ class Cpnest(NestedSampler):
prior_samples
=
self
.
priors
.
sample
()
self
.
_update_bounds
()
point
=
LivePoint
(
self
.
names
,
array
.
array
(
'f'
,
[
prior_samples
[
name
]
for
name
in
self
.
names
])
)
self
.
names
,
array
.
array
(
'd'
,
[
prior_samples
[
name
]
for
name
in
self
.
names
])
)
return
point
self
.
_resolve_proposal_functions
()
...
...
@@ -132,6 +131,7 @@ class Cpnest(NestedSampler):
self
.
result
.
nested_samples
[
'weights'
]
=
np
.
exp
(
log_weights
)
self
.
result
.
log_evidence
=
out
.
NS
.
state
.
logZ
self
.
result
.
log_evidence_err
=
np
.
sqrt
(
out
.
NS
.
state
.
info
/
out
.
NS
.
state
.
nlive
)
self
.
result
.
information_gain
=
out
.
NS
.
state
.
info
return
self
.
result
def
_verify_kwargs_against_default_kwargs
(
self
):
...
...
bilby/core/sampler/dynamic_dynesty.py
View file @
23876f9b
from
__future__
import
absolute_import
import
os
import
dill
as
pickle
...
...
bilby/core/sampler/dynesty.py
View file @
23876f9b
...
...
@@ -6,7 +6,7 @@ import pickle
import
signal
import
time
import
tqdm
from
tqdm.auto
import
tqdm
import
matplotlib.pyplot
as
plt
import
numpy
as
np
from
pandas
import
DataFrame
...
...
@@ -224,7 +224,7 @@ class Dynesty(NestedSampler):
self
.
kwargs
[
'update_interval'
]
=
int
(
0.6
*
self
.
kwargs
[
'nlive'
])
if
self
.
kwargs
[
'print_func'
]
is
None
:
self
.
kwargs
[
'print_func'
]
=
self
.
_print_func
self
.
pbar
=
tqdm
.
tqdm
(
file
=
sys
.
stdout
)
self
.
pbar
=
tqdm
(
file
=
sys
.
stdout
)
Sampler
.
_verify_kwargs_against_default_kwargs
(
self
)
def
_print_func
(
self
,
results
,
niter
,
ncall
=
None
,
dlogz
=
None
,
*
args
,
**
kwargs
):
...
...
@@ -401,6 +401,7 @@ class Dynesty(NestedSampler):
sorted_samples
=
self
.
result
.
samples
)
self
.
result
.
log_evidence
=
out
.
logz
[
-
1
]
self
.
result
.
log_evidence_err
=
out
.
logzerr
[
-
1
]
self
.
result
.
information_gain
=
out
.
information
[
-
1
]
def
_run_nested_wrapper
(
self
,
kwargs
):
""" Wrapper function to run_nested
...
...
@@ -612,7 +613,7 @@ class Dynesty(NestedSampler):
fig
=
dyplot
.
traceplot
(
self
.
sampler
.
results
,
labels
=
labels
)[
0
]
fig
.
tight_layout
()
fig
.
savefig
(
filename
)
except
(
RuntimeError
,
np
.
linalg
.
linalg
.
LinAlgError
,
ValueError
)
as
e
:
except
(
RuntimeError
,
np
.
linalg
.
linalg
.
LinAlgError
,
ValueError
,
OverflowError
,
Exception
)
as
e
:
logger
.
warning
(
e
)
logger
.
warning
(
'Failed to create dynesty state plot at checkpoint'
)
finally
:
...
...
@@ -690,6 +691,16 @@ class Dynesty(NestedSampler):
"""
return
self
.
priors
.
rescale
(
self
.
_search_parameter_keys
,
theta
)
def
calc_likelihood_count
(
self
):
if
self
.
likelihood_benchmark
:
if
hasattr
(
self
,
'sampler'
):
self
.
result
.
num_likelihood_evaluations
=
\
getattr
(
self
.
sampler
,
'ncall'
,
0
)
else
:
self
.
result
.
num_likelihood_evaluations
=
0
else
:
return
None
def
sample_rwalk_bilby
(
args
):
""" Modified bilby-implemented version of dynesty.sampling.sample_rwalk """
...
...
bilby/core/sampler/emcee.py
View file @
23876f9b
from
__future__
import
absolute_import
,
print_function
from
collections
import
namedtuple
import
os
import
signal
...
...
@@ -12,8 +10,7 @@ from pandas import DataFrame
from
distutils.version
import
LooseVersion
import
dill
as
pickle
from
..utils
import
(
logger
,
get_progress_bar
,
check_directory_exists_and_if_not_mkdir
)
from
..utils
import
logger
,
check_directory_exists_and_if_not_mkdir
from
.base_sampler
import
MCMCSampler
,
SamplerError
...
...
@@ -353,7 +350,7 @@ class Emcee(MCMCSampler):
self
.
pos0
=
self
.
sampler
.
chain
[:,
-
1
,
:]
def
run_sampler
(
self
):
tqdm
=
get_progress_bar
()
from
tqdm.auto
import
tqdm
sampler_function_kwargs
=
self
.
sampler_function_kwargs
iterations
=
sampler_function_kwargs
.
pop
(
'iterations'
)
iterations
-=
self
.
_previous_iterations
...
...
bilby/core/sampler/fake_sampler.py
View file @
23876f9b
from
__future__
import
absolute_import
import
numpy
as
np
from
.base_sampler
import
Sampler
...
...
bilby/core/sampler/kombine.py
View file @
23876f9b
from
__future__
import
absolute_import
,
print_function
from
..utils
import
logger
,
get_progress_bar
from
..utils
import
logger
import
numpy
as
np
import
os
from
.emcee
import
Emcee
...
...
@@ -141,7 +140,7 @@ class Kombine(Emcee):
logger
.
info
(
"Kombine auto-burnin complete. Removing {} samples from chains"
.
format
(
self
.
nburn
))
self
.
_set_pos0_for_resume
()
tqdm
=
get_progress_bar
()
from
tqdm.auto
import
tqdm
sampler_function_kwargs
=
self
.
sampler_function_kwargs
iterations
=
sampler_function_kwargs
.
pop
(
'iterations'
)
iterations
-=
self
.
_previous_iterations
...
...
bilby/core/sampler/nestle.py
View file @
23876f9b
from
__future__
import
absolute_import
import
numpy
as
np
from
pandas
import
DataFrame
...
...
@@ -74,6 +73,7 @@ class Nestle(NestedSampler):
sorted_samples
=
self
.
result
.
samples
)
self
.
result
.
log_evidence
=
out
.
logz
self
.
result
.
log_evidence_err
=
out
.
logzerr
self
.
result
.
information_gain
=
out
.
h
self
.
calc_likelihood_count
()
return
self
.
result
...
...
bilby/core/sampler/polychord.py
View file @
23876f9b
from
__future__
import
absolute_import
import
numpy
as
np
...
...
bilby/core/sampler/ptemcee.py
View file @
23876f9b
This diff is collapsed.
Click to expand it.
bilby/core/sampler/ptmcmc.py
View file @
23876f9b
from
__future__
import
absolute_import
,
print_function
import
glob
import
shutil
...
...
bilby/core/sampler/pymc3.py
View file @
23876f9b
from
__future__
import
absolute_import
,
print_function
from
collections
import
OrderedDict
from
distutils.version
import
StrictVersion
...
...
bilby/core/sampler/ultranest.py
View file @
23876f9b
from
__future__
import
absolute_import
import
datetime
import
distutils.dir_util
...
...
@@ -61,7 +60,7 @@ class Ultranest(NestedSampler):
log_interval
=
None
,
dlogz
=
None
,
max_iters
=
None
,
update_interval_
iter
_fraction
=
0.2
,
update_interval_
volume
_fraction
=
0.2
,
viz_callback
=
None
,
dKL
=
0.5
,
frac_remain
=
0.01
,
...
...
@@ -232,7 +231,7 @@ class Ultranest(NestedSampler):
]
else
:
keys
=
[
"update_interval_
iter
_fraction"
,
"update_interval_
volume
_fraction"
,
"update_interval_ncall"
,
"log_interval"
,
"show_status"
,
...
...
@@ -366,6 +365,8 @@ class Ultranest(NestedSampler):
self
.
result
.
nested_samples
=
nested_samples
self
.
result
.
log_evidence
=
out
[
"logz"
]
self
.
result
.
log_evidence_err
=
out
[
"logzerr"
]
if
self
.
kwargs
[
"num_live_points"
]
is
not
None
:
self
.
result
.
information_gain
=
np
.
power
(
out
[
"logzerr"
],
2
)
*
self
.
kwargs
[
"num_live_points"
]
self
.
result
.
outputfiles_basename
=
self
.
outputfiles_basename
self
.
result
.
sampling_time
=
datetime
.
timedelta
(
seconds
=
self
.
total_sampling_time
)
bilby/core/utils.py
View file @
23876f9b
from
__future__
import
division
from
distutils.spawn
import
find_executable
import
logging
...
...
@@ -508,26 +507,6 @@ def get_version_information():
print
(
"No version information file '.version' found"
)
def
get_progress_bar
(
module
=
'tqdm'
):
"""
TODO: Write proper docstring
"""
if
module
in
[
'tqdm'
]:
try
:
from
tqdm
import
tqdm
except
ImportError
:
def
tqdm
(
x
,
*
args
,
**
kwargs
):
return
x
return
tqdm
elif
module
in
[
'tqdm_notebook'
]:
try
:
from
tqdm
import
tqdm_notebook
as
tqdm
except
ImportError
:
def
tqdm
(
x
,
*
args
,
**
kwargs
):
return
x
return
tqdm
def
spherical_to_cartesian
(
radius
,
theta
,
phi
):
""" Convert from spherical coordinates to cartesian.
...
...
bilby/gw/conversion.py
View file @
23876f9b
from
__future__
import
division
import
sys
import
multiprocessing
from
tqdm
import
tqdm
from
tqdm
.auto
import
tqdm
import
numpy
as
np
from
pandas
import
DataFrame
...
...
bilby/gw/detector/detectors/A1.interferometer
0 → 100644
View file @
23876f9b
# LIGO India Aundha at Aplus sensitvity.
# LIGO-T2000158
# https://dcc.ligo.org/LIGO-T2000012/public
name = 'A1'
power_spectral_density = PowerSpectralDensity(asd_file='Aplus_asd.txt')
minimum_frequency = 20
maximum_frequency = 2048
length = 4
latitude = 19 + 36. / 60 + 47.9017 / 3600
longitude = 77 + 1. / 60 + 51.0997 / 3600
elevation = 440.0
xarm_azimuth = 117.6157
yarm_azimuth = 207.6165
bilby/gw/detector/strain_data.py
View file @
23876f9b
...
...
@@ -31,7 +31,7 @@ class InterferometerStrainData(object):
time_array
=
PropertyAccessor
(
'_times_and_frequencies'
,
'time_array'
)
def
__init__
(
self
,
minimum_frequency
=
0
,
maximum_frequency
=
np
.
inf
,
roll_off
=
0.2
):
roll_off
=
0.2
,
notch_list
=
None
):
""" Initiate an InterferometerStrainData object
The initialised object contains no data, this should be added using one
...
...
@@ -46,11 +46,14 @@ class InterferometerStrainData(object):
roll_off: float
The roll-off (in seconds) used in the Tukey window, default=0.2s.
This corresponds to alpha * duration / 2 for scipy tukey window.
notch_list: bilby.gw.detector.strain_data.NotchList
A list of notches
"""
self
.
minimum_frequency
=
minimum_frequency
self
.
maximum_frequency
=
maximum_frequency
self
.
notch_list
=
notch_list
self
.
roll_off
=
roll_off
self
.
window_factor
=
1
...
...
@@ -122,18 +125,46 @@ class InterferometerStrainData(object):
self
.
_maximum_frequency
=
maximum_frequency
self
.
_frequency_mask_updated
=
False
@
property
def
notch_list
(
self
):
return
self
.
_notch_list
@
notch_list
.
setter
def
notch_list
(
self
,
notch_list
):
""" Set the notch_list
Parameters
----------
notch_list: list, bilby.gw.detector.strain_data.NotchList
A list of length-2 tuples of the (max, min) frequency for the
notches or a pre-made bilby NotchList.
"""
if
notch_list
is
None
:
self
.
_notch_list
=
NotchList
(
None
)
elif
isinstance
(
notch_list
,
list
):
self
.
_notch_list
=
NotchList
(
notch_list
)
elif
isinstance
(
notch_list
,
NotchList
):
self
.
_notch_list
=
notch_list
else
:
raise
ValueError
(
"notch_list {} not understood"
.
format
(
notch_list
))
self
.
_frequency_mask_updated
=
False
@
property
def
frequency_mask
(
self
):
"""Masking array for limiting the frequency band.
"""
Masking array for limiting the frequency band.
Returns
-------
array_like: An array of boolean values
mask: np.ndarray
An array of boolean values
"""
if
not
self
.
_frequency_mask_updated
:
frequency_array
=
self
.
_times_and_frequencies
.
frequency_array
mask
=
((
frequency_array
>=
self
.
minimum_frequency
)
&
(
frequency_array
<=
self
.
maximum_frequency
))
for
notch
in
self
.
notch_list
:
mask
[
notch
.
get_idxs
(
frequency_array
)]
=
False
self
.
_frequency_mask
=
mask
self
.
_frequency_mask_updated
=
True
return
self
.
_frequency_mask
...
...
@@ -683,3 +714,104 @@ class InterferometerStrainData(object):
strain
=
strain
.
resample
(
sampling_frequency
)
self
.
set_from_gwpy_timeseries
(
strain
)
class
Notch
(
object
):
def
__init__
(
self
,
minimum_frequency
,
maximum_frequency
):
""" A notch object storing the maximum and minimum frequency of the notch
Parameters
----------
minimum_frequency, maximum_frequency: float
The minimum and maximum frequency of the notch
"""
if
0
<
minimum_frequency
<
maximum_frequency
<
np
.
inf
:
self
.
minimum_frequency
=
minimum_frequency
self
.
maximum_frequency
=
maximum_frequency
else
:
msg
=
(
"Your notch minimum_frequency {} and maximum_frequency {} are invalid"
.
format
(
minimum_frequency
,
maximum_frequency
))
raise
ValueError
(
msg
)
def
get_idxs
(
self
,
frequency_array
):
""" Get a boolean mask for the frequencies in frequency_array in the notch
Parameters
----------
frequency_array: np.ndarray
An array of frequencies
Returns
-------
idxs: np.ndarray
An array of booleans which are True for frequencies in the notch
"""
lower
=
(
frequency_array
>
self
.
minimum_frequency
)
upper
=
(
frequency_array
<
self
.
maximum_frequency
)
return
lower
&
upper
def
check_frequency
(
self
,
freq
):
""" Check if freq is inside the notch
Parameters
----------
freq: float
The frequency to check
Returns
-------
True/False:
If freq inside the notch, return True, else False
"""
if
self
.
minimum_frequency
<
freq
<
self
.
maximum_frequency
:
return
True
else
:
return
False
class
NotchList
(
list
):
def
__init__
(
self
,
notch_list
):
""" A list of notches