def main(args): utils.mkdir(args.output_dir) for cls in Plot.registry: try: cls.make(args.dirname, args.output_dir, args.prefix, args.type) except IOError as err: print(err)
def main(args): #Read the command line arguments and load the #ini file that created the run args = parser.parse_args(args) #Make the directory for the outputs to go in. mkdir(args.outdir) outputs = {} for i, ini_filename in enumerate(args.inifile): sampler, ini = read_input(ini_filename, args.text, args.weights) processor_class = postprocessor_for_sampler(sampler) #We do not know how to postprocess everything. if processor_class is None: print "I do not know how to postprocess output from the %s sampler" % sampler sampler = None continue #Create and run the postprocessor processor = processor_class(ini, ini_filename, i, **vars(args)) #Inherit any plots from the previous postprocessor #so we can make plots with multiple datasets on processor.outputs.update(outputs) #We can load extra plots to make from a python #script here if args.extra: processor.load_extra_steps(args.extra) #Run the postprocessor and make the outputs for this chain processor.run() #Save the outputs ready for the next post-processor in case #they want to add to it (e.g. two constriants on the same axes) outputs = processor.outputs if sampler is None: return #Run any tweaks that the user specified if args.tweaks: tweaks = Tweaks.instances_from_file(args.tweaks) for tweak in tweaks: processor.apply_tweaks(tweak) #Save all the image files and close the text files processor.finalize()
def sample(self): n_grade = 2 if self.pipeline.do_fast_slow else 1 grade_dims = (ct.c_int * n_grade)() grade_frac = (ct.c_double * n_grade)() if self.pipeline.do_fast_slow: grade_dims[0] = self.pipeline.n_slow_params grade_dims[1] = self.pipeline.n_fast_params grade_frac[0] = 1 - self.fast_fraction grade_frac[1] = self.fast_fraction print( "Telling Polychord to spend fraction {} if its time in the fast subspace (adjust with fast_fraction option)" .format(self.fast_fraction)) else: grade_dims[0] = self.pipeline.nvaried grade_frac[0] = 1.0 n_nlives = 0 loglikes = (ct.c_double * n_nlives)() nlives = (ct.c_int * n_nlives)() base_dir = self.base_dir.encode('ascii') polychord_outfile_root = self.polychord_outfile_root.encode('ascii') output_to_file = len(polychord_outfile_root) > 0 if output_to_file: mkdir(self.base_dir) mkdir(os.path.join(self.base_dir, "clusters")) if self.num_repeats == 0: num_repeats = 3 * grade_dims[0] print( "Polychord num_repeats = {} (3 * n_slow_params [{}])".format( num_repeats, grade_dims[0])) else: num_repeats = self.num_repeats print("Polychord num_repeats = {} (from parameter file)".format( num_repeats)) self._run( self.wrapped_likelihood, #loglike, self.wrapped_prior, #prior, self.wrapped_output_logger, #dumper, self.live_points, #nlive num_repeats, #nrepeats self.nprior, #nprior True, #do_clustering self.feedback, #feedback self.tolerance, #precision_criterion self.log_zero, #logzero self.max_iterations, #max_ndead self.boost_posteriors, #boost_posterior self.weighted_posteriors, #posteriors self.equally_weighted_posteriors, #equals self.cluster_posteriors, #cluster_posteriors True, #write_resume - always False, #write_paramnames self.resume, #read_resume output_to_file, #write_stats output_to_file, #write_live output_to_file, #write_dead output_to_file, #write_prior self.compression_factor, #compression_factor self.ndim, #nDims self.nderived, #nDerived base_dir, #base_dir polychord_outfile_root, #file_root n_grade, #nGrade grade_frac, #grade_frac grade_dims, #grade_dims n_nlives, #n_nlives loglikes, #loglikes nlives, #nlives self.random_seed, #seed ) self.converged = True
def main(args): #Read the command line arguments and load the #ini file that created the run args = parser.parse_args(args) for ini_filename in args.inifile: if not os.path.exists(ini_filename): raise ValueError("The file (or directory) {} does not exist.".format(ini_filename)) #Make the directory for the outputs to go in. mkdir(args.outdir) outputs = {} #Deal with legends, if any if args.legend: labels = args.legend.split("|") if len(labels)!=len(args.inifile): raise ValueError("You specified {} legend names but {} files to plot".format(len(labels), len(args.inifile))) else: labels = args.inifile if len(args.inifile)>1 and args.run_max_post: raise ValueError("Can only use the --run-max-post argument with a single parameter file for now") for i,ini_filename in enumerate(args.inifile): sampler, ini = read_input(ini_filename, args.text, args.weights) processor_class = postprocessor_for_sampler(sampler.split()[-1]) #We do not know how to postprocess everything. if processor_class is None: print("I do not know how to postprocess output from the %s sampler"%sampler) sampler = None continue #Create and run the postprocessor processor = processor_class(ini, labels[i], i, **vars(args)) #Inherit any plots from the previous postprocessor #so we can make plots with multiple datasets on processor.outputs.update(outputs) #We can load extra plots to make from a python #script here if args.extra: processor.load_extra_steps(args.extra) #Optionally add a step in which we if args.run_max_post: processor.add_rerun_bestfit_step(args.run_max_post) #Run the postprocessor and make the outputs for this chain processor.run() #Save the outputs ready for the next post-processor in case #they want to add to it (e.g. two constriants on the same axes) outputs = processor.outputs if sampler is None: return #Run any tweaks that the user specified if args.tweaks: tweaks = Tweaks.instances_from_file(args.tweaks) for tweak in tweaks: processor.apply_tweaks(tweak) #Save all the image files and close the text files processor.finalize()