Exemple #1
0
    def to_string(self):
        #0 : C:\Users\bartl_000\Desktop\Work\Modular\chemicallite\output : ensemble_output : none : all
        if self.label.startswith('Simulation'): numb = '0'
        else:
            procs = lfu.grab_mobj_names(self.parent.parent.post_processes)
            numb = str(procs.index(self.parent.label) + 1)

        plot_types = [
            item for item, out_item in zip(['vtk', 'pkl', 'txt', 'plt'], [
                self.output_vtk, self.output_pkl, self.output_txt,
                self.output_plt
            ]) if out_item
        ]
        if not plot_types: plots = 'none'
        else: plots = ', '.join(plot_types)
        targs = self.get_target_labels()
        if not self.targeted: targs = 'none'
        elif self.targeted == targs: targs = 'all'
        else: targs = ', '.join(self.targeted)
        return '\t' + ' : '.join(
            [numb, self.save_directory, self.save_filename, plots, targs])
Exemple #2
0
	def finalize(self, *args, **kwargs):

		def get_interped_y(label, data, x, x_to):
			run_y = lfu.grab_mobj_by_name(label, data)
			run_interped = lgeo.scalars(
				label = 'interpolated best result - ' + label, 
				scalars = lm.linear_interpolation(
					x.scalars, run_y.scalars, 
					x_to.scalars, 'linear'))
			return run_interped

		self.best_fits = [(met.best_measure, 
			met.data[0].scalars[met.best_measure]) 
			for met in self.metrics]
		self.handle_fitting_key()
		self.parameter_space.set_current_position(
			self.p_sp_trajectory[self.best_fits[
						self.prime_metric][0]])
		best_run_data = lis.run_system(self.ensemble)
		best_run_data = [lgeo.scalars(label = lab, scalars = dat) 
			for lab, dat in zip(self.run_targets, best_run_data)]
		best_run_data_x = lfu.grab_mobj_by_name(
			self.data_to_fit_to[0].label, best_run_data)
		best_run_data_ys = [get_interped_y(
			lab, best_run_data, best_run_data_x, self.data_to_fit_to[0]) 
				for lab in lfu.grab_mobj_names(self.data_to_fit_to[1:])]

		print 'fit routine:', self.label, 'best fit:', self.best_fits
		print '\tran using regime:', self.regime
		best_data = self.data_to_fit_to + best_run_data_ys
		lgd.quick_plot_display(best_data[0], best_data[1:], delay = 5)
		self.ensemble.data_pool.pool_names =\
			[dat.label for dat in best_data]
		self.ensemble.data_pool.batch_pool.append(best_data)
		if self.regime.startswith('coarse'):
			self.impose_coarse_result_to_p_space()
			self.ensemble.cartographer_plan.parameter_space.\
				set_current_position(self.p_sp_trajectory[
					self.best_fits[self.prime_metric][0]])
Exemple #3
0
def generate_add_remove_select_inspect_box_template(window, key, 
		labels, wheres, parent, selector_handle, memory_handle, 
		base_class, function_handles = None, verbosities = None):
	if wheres[0] is wheres[1]: whars = wheres[:-1]
	else: whars = wheres
	_add_func_ = lgb.generate_add_function(base_class, 
					parent = parent, wheres = whars)
	_sel_func_ = lgb.generate_selected_function(wheres[1], 
							lfu.grab_mobj_names(wheres[1]), 
							selector_handle, offset = 1)
	_rem_func_ = lgb.generate_remove_function(_sel_func_, 
						parent = parent, wheres = wheres)
	template = interface_template_gui(
				layout = 'grid', 
				widg_positions = [(0, 0), (0, 2), (1, 2)], 
				widg_spans = [(3, 2), None, None], 
				grid_spacing = 10, 
				widgets = ['mobj_catalog', 'button_set'], 
				verbosities = verbosities, 
				instances = [[wheres[1], memory_handle[0]], None], 
				keys = [[None, memory_handle[1]], None], 
				handles = [selector_handle, None], 
				labels = [None, labels], 
				initials = [[memory_handle[0].__dict__[
							memory_handle[1]]], None], 
				bindings = [None, [lgb.create_reset_widgets_wrapper(
												window, _add_func_), 
								lgb.create_reset_widgets_wrapper(
										window, _rem_func_)]])
	if function_handles:
		for dex, func in zip(range(3), 
			[_add_func_, _sel_func_, _rem_func_]):
				if function_handles[dex]:
					for hand in function_handles[dex]:
						hand[0].__dict__[hand[1]] = func

	return template