forked from handley-lab/anesthetic
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request handley-lab#327 from martinit18/nested_fit
compatibility with nested_fit output files
- Loading branch information
Showing
12 changed files
with
51,450 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = '2.1.5' | ||
__version__ = '2.2.0' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
"""Read NestedSamples from Nested_Fit chains.""" | ||
import os | ||
import numpy as np | ||
from anesthetic.read.getdist import read_paramnames | ||
from anesthetic.samples import NestedSamples | ||
|
||
|
||
def read_nestedfit(root, *args, **kwargs): | ||
"""Read Nested_Fit chain files. | ||
Parameters | ||
---------- | ||
root : str | ||
root specify the directory only, no specific roots, | ||
The files read files are ``nf_output_points.txt`` | ||
and ``nf_output_diag.txt``. | ||
""" | ||
dead_file = os.path.join(root, 'nf_output_points.txt') | ||
birth_file = os.path.join(root, 'nf_output_diag.dat') | ||
data_dead = np.loadtxt(dead_file) | ||
data_birth = np.loadtxt(birth_file) | ||
weight, logL, data = np.split(data_dead, [1, 2], axis=1) | ||
logL_birth = data_birth[:, 0] | ||
root_getdist = os.path.join(root, 'nf_output_points') | ||
columns, labels = read_paramnames(root_getdist) | ||
# No specific labeling is implemented in nested_fit | ||
labels = columns | ||
columns = kwargs.pop('columns', columns) | ||
labels = kwargs.pop('labels', labels) | ||
kwargs['label'] = kwargs.get('label', os.path.basename(root)) | ||
|
||
return NestedSamples(data=data, columns=columns, | ||
logL=logL, logL_birth=logL_birth, | ||
labels=labels, *args, **kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.