Skip to content
Snippets Groups Projects
Commit cde7d148 authored by Gregory Ashton's avatar Gregory Ashton
Browse files

Genereal clean up of the saved result

1. Removes the samples - these are duplicates of the posterior data
frame
2. Adds option to save the results. For large MC runs, it's not always
neccersery to save the output.
3.
parent 0df6090e
No related branches found
No related tags found
1 merge request!120Clean up saved output
......@@ -370,6 +370,8 @@ class Result(dict):
if conversion_function is not None:
data_frame = conversion_function(data_frame, likelihood, priors)
self.posterior = data_frame
# We save the samples in the posterior and remove the array of samples
del self.samples
def construct_cbc_derived_parameters(self):
""" Construct widely used derived parameters of CBCs """
......
......@@ -902,7 +902,7 @@ class Ptemcee(Emcee):
def run_sampler(likelihood, priors=None, label='label', outdir='outdir',
sampler='dynesty', use_ratio=None, injection_parameters=None,
conversion_function=None, plot=False, default_priors_file=None,
clean=None, meta_data=None, **kwargs):
clean=None, meta_data=None, save=True, **kwargs):
"""
The primary interface to easy parameter estimation
......@@ -941,6 +941,8 @@ def run_sampler(likelihood, priors=None, label='label', outdir='outdir',
saving. For example, if `meta_data={dtype: 'signal'}`. Warning: in case
of conflict with keys saved by tupak, the meta_data keys will be
overwritten.
save: bool
If true, save the results to disk.
**kwargs:
All kwargs are passed directly to the samplers `run` function
......@@ -1010,10 +1012,11 @@ def run_sampler(likelihood, priors=None, label='label', outdir='outdir',
result.samples_to_posterior(likelihood=likelihood, priors=priors,
conversion_function=conversion_function)
result.kwargs = sampler.kwargs
result.save_to_file()
if save:
result.save_to_file()
logger.info("Results saved to {}/".format(outdir))
if plot:
result.plot_corner()
logger.info("Sampling finished, results saved to {}/".format(outdir))
logger.info("Summary of results:\n{}".format(result))
return result
else:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment