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
def get_single_well_data(self): # THIS FUNCTION WILL JUST RETURN THE SELECTED WELLS PLOT DATA od_dex = self.get_selected_well() time_ = self.data.data[0] od = self.data.data[od_dex] dbl = self._doubling_times_[od_dex] gro = self._growth_rates_[od_dex] lo, hi = self._thresholds_[od_dex] #od.scalars = od.scalars y_low = lgeo.scalars('__skip__', [lo]*2, color = 'black') # [self.OD_threshold_low]*2, color = 'black') y_high = lgeo.scalars('__skip__', [hi]*2, color = 'black') # [self.OD_threshold_high]*2, color = 'black') x_stack = lgeo.scalars('__skip__', [time_.scalars.min(), time_.scalars.max()]) # CALCULATE THE DOUBLING TIME AND ADD VERTICAL LINES FOR THE POINTS USED # MAKE ALL THESE FLAT LINES DASHED OR SOMETHING #pdb.set_trace() data = lfu.data_container( domains = [time_, x_stack, x_stack], codomains = [od, y_low, y_high], doubling = dbl, growth_rate = gro, thresholds = (lo, hi)) return data
def initialize(self, *args, **kwargs): if not self.cooling_curve: self.final_iteration =\ self.fitted_criteria[0].max_iterations lam = -1.0 * np.log(self.max_temperature)/\ self.final_iteration cooling_domain = np.array(range(self.final_iteration)) cooling_codomain = self.max_temperature*np.exp( lam*cooling_domain) self.cooling_curve = lgeo.scalars( label = 'cooling curve', scalars = cooling_codomain) fit_routine.initialize(self, *args, **kwargs) self.data.extend(lgeo.scalars_from_labels( ['annealing temperature'])) self.temperature = self.cooling_curve.scalars[self.iteration] self.parameter_space.initial_factor = self.temperature
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]])
def on_write_data(self, *args, **kwargs): if not self.domain: self.domain = ["x"] self.codomains = ["y1", "y2", "y3"] self.domain_data = np.linspace(0, 10, 100) self.codomain_datas = [ np.exp(self.domain_data) / np.exp(self.domain_data[-1]), np.sin(self.domain_data), np.cos(2 * self.domain_data), ] print "USED FAKE TEST DATA!!" # the data should be normalized -1, 1 on both axes x = self.domain_data ys = self.codomain_datas [plt.plot(x, y) for y in ys] plt.show() self.out_data = lfu.data_container( data=[ lgeo.scalars(label=lab, scalars=dat) for lab, dat in zip(self.domain + self.codomains, [self.domain_data] + self.codomain_datas) ] ) lf.save_pkl_object(self.out_data, self.out_filename)
def on_write_data(self, *args, **kwargs): if not self.domain: self.domain = ['x'] self.codomains = ['y1', 'y2', 'y3'] self.domain_data = np.linspace(0, 10, 100) self.codomain_datas = [ np.exp(self.domain_data) / np.exp(self.domain_data[-1]), np.sin(self.domain_data), np.cos(2 * self.domain_data) ] print 'USED FAKE TEST DATA!!' #the data should be normalized -1, 1 on both axes x = self.domain_data ys = self.codomain_datas [plt.plot(x, y) for y in ys] plt.show() self.out_data = lfu.data_container(data=[ lgeo.scalars(label=lab, scalars=dat) for lab, dat in zip(self.domain + self.codomains, [self.domain_data] + self.codomain_datas) ]) lf.save_pkl_object(self.out_data, self.out_filename)