def save_parameter_names_file(self, model): """Create the param_names file listing every parameter's label and Latex tag, which is used for *corner.py* visualization. The parameter labels are determined using the label.ini and label_format.ini config files.""" parameter_names = model.model_component_and_parameter_names parameter_labels = model.parameter_labels subscripts = model.subscripts parameter_labels_with_subscript = [ f"{label}_{subscript}" for label, subscript in zip(parameter_labels, subscripts) ] parameter_name_and_label = [] for i in range(model.prior_count): line = formatter.add_whitespace( str0=parameter_names[i], str1=parameter_labels_with_subscript[i], whitespace=70) parameter_name_and_label += [f"{line}\n"] formatter.output_list_of_strings_to_file( file=self.paths.file_param_names, list_of_strings=parameter_name_and_label)
def results_to_file(samples, filename): """Output the full model.results file, which include the most-likely model, most-probable model at 1 and 3 sigma confidence and information on the maximum log likelihood. """ results = [] if hasattr(samples, "log_evidence"): if samples.log_evidence is not None: results += [ frm.add_whitespace(str0="Bayesian Evidence ", str1="{:.8f}".format(samples.log_evidence), whitespace=90) ] results += ["\n"] results += [ frm.add_whitespace(str0="Maximum Log Likelihood ", str1="{:.8f}".format( max(samples.log_likelihood_list)), whitespace=90) ] results += ["\n"] results += [ frm.add_whitespace(str0="Maximum Log Posterior ", str1="{:.8f}".format(max( samples.log_posterior_list)), whitespace=90) ] results += ["\n"] results += ["\n", samples.model.parameterization, "\n\n"] results += ["Maximum Log Likelihood Model:\n\n"] formatter = frm.TextFormatter() for i, prior_path in enumerate(samples.model.unique_prior_paths): formatter.add( prior_path, format_str().format(samples.max_log_likelihood_vector[i])) results += [formatter.text + "\n"] if hasattr(samples, "pdf_converged"): if samples.pdf_converged: results += samples_text.summary(samples=samples, sigma=3.0, indent=4, line_length=90) results += ["\n"] results += samples_text.summary(samples=samples, sigma=1.0, indent=4, line_length=90) else: results += [ "\n WARNING: The samples have not converged enough to compute a PDF and model errors. \n " "The model below over estimates errors. \n\n" ] results += samples_text.summary(samples=samples, sigma=1.0, indent=4, line_length=90) results += ["\n\ninstances\n"] formatter = frm.TextFormatter() for t in samples.model.path_float_tuples: formatter.add(*t) results += ["\n" + formatter.text] frm.output_list_of_strings_to_file(file=filename, list_of_strings=results)