Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bilby
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Marc Arene
bilby
Commits
02f5818b
Commit
02f5818b
authored
6 years ago
by
Gregory Ashton
Browse files
Options
Downloads
Patches
Plain Diff
More bug fixing
parent
d807cb4e
Branches
386-change-interpolation-order-for-distance-marginalisation
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
bilby/core/sampler/emcee.py
+9
-8
9 additions, 8 deletions
bilby/core/sampler/emcee.py
bilby/core/sampler/ptemcee.py
+3
-1
3 additions, 1 deletion
bilby/core/sampler/ptemcee.py
with
12 additions
and
9 deletions
bilby/core/sampler/emcee.py
+
9
−
8
View file @
02f5818b
...
...
@@ -201,6 +201,11 @@ class Emcee(MCMCSampler):
"""
Returns the log-prior stored on disk
"""
return
self
.
stored_chain
[
'
log_p
'
]
def
_init_chain_file
(
self
):
with
open
(
self
.
checkpoint_info
.
chain_file
,
"
w+
"
)
as
ff
:
ff
.
write
(
'
walker
\t
{}
\t
log_l
\t
log_p
\n
'
.
format
(
'
\t
'
.
join
(
self
.
search_parameter_keys
)))
@property
def
checkpoint_info
(
self
):
"""
Defines various things related to checkpointing and storing data
...
...
@@ -219,14 +224,8 @@ class Emcee(MCMCSampler):
self
.
label
))
check_directory_exists_and_if_not_mkdir
(
out_dir
)
sampler_file
=
os
.
path
.
join
(
out_dir
,
'
sampler.pickle
'
)
# Initialise chain file
chain_file
=
os
.
path
.
join
(
out_dir
,
'
chain.dat
'
)
if
not
os
.
path
.
isfile
(
chain_file
):
with
open
(
chain_file
,
"
w
"
)
as
ff
:
ff
.
write
(
'
walker
\t
{}
\t
log_l
\t
log_p
\n
'
.
format
(
'
\t
'
.
join
(
self
.
search_parameter_keys
)))
sampler_file
=
os
.
path
.
join
(
out_dir
,
'
sampler.pickle
'
)
chain_template
=
\
'
{:d}
'
+
'
\t
{:.9e}
'
*
(
len
(
self
.
search_parameter_keys
)
+
2
)
+
'
\n
'
...
...
@@ -262,6 +261,7 @@ class Emcee(MCMCSampler):
def
_initialise_sampler
(
self
):
import
emcee
self
.
_sampler
=
emcee
.
EnsembleSampler
(
**
self
.
sampler_init_kwargs
)
self
.
_init_chain_file
()
@property
def
sampler
(
self
):
...
...
@@ -288,7 +288,8 @@ class Emcee(MCMCSampler):
def
write_chains_to_file
(
self
,
sample
):
chain_file
=
self
.
checkpoint_info
.
chain_file
temp_chain_file
=
chain_file
+
'
.temp
'
copyfile
(
chain_file
,
temp_chain_file
)
if
os
.
path
.
isfile
(
chain_file
):
copyfile
(
chain_file
,
temp_chain_file
)
if
self
.
prerelease
:
points
=
np
.
hstack
([
sample
.
coords
,
sample
.
blobs
])
...
...
This diff is collapsed.
Click to expand it.
bilby/core/sampler/ptemcee.py
+
3
−
1
View file @
02f5818b
...
...
@@ -72,6 +72,7 @@ class Ptemcee(Emcee):
self
.
_sampler
=
ptemcee
.
Sampler
(
dim
=
self
.
ndim
,
logl
=
self
.
log_likelihood
,
logp
=
self
.
log_prior
,
**
self
.
sampler_init_kwargs
)
self
.
_init_chain_file
()
def
print_tswap_acceptance_fraction
(
self
):
logger
.
info
(
"
Sampler per-chain tswap acceptance fraction = {}
"
.
format
(
...
...
@@ -80,8 +81,9 @@ class Ptemcee(Emcee):
def
write_chains_to_file
(
self
,
pos
,
loglike
,
logpost
):
chain_file
=
self
.
checkpoint_info
.
chain_file
temp_chain_file
=
chain_file
+
'
.temp
'
if
os
.
path
.
isfile
(
chain_file
):
copyfile
(
chain_file
,
temp_chain_file
)
copyfile
(
chain_file
,
temp_chain_file
)
with
open
(
temp_chain_file
,
"
a
"
)
as
ff
:
loglike
=
np
.
squeeze
(
loglike
[
0
,
:])
logprior
=
np
.
squeeze
(
logpost
[
0
,
:])
-
loglike
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment