def test_final_variance_runs(self): exp = VarianceExperiment() printer_final = Print(name="Final") avgr = Averager('repeats', name="TestAverager") var_buff = DataBuffer(name='Variance Buffer') mean_buff = DataBuffer(name='Mean Buffer') edges = [(exp.chan1, avgr.sink), (avgr.final_variance, printer_final.sink), (avgr.final_variance, var_buff.sink), (avgr.source, mean_buff.sink)] exp.set_graph(edges) exp.run_sweeps() # var_data = var_buff.get_data()['Variance'].reshape(var_buff.descriptor.data_dims()) # mean_data = mean_buff.get_data()['chan1'].reshape(mean_buff.descriptor.data_dims()) var_data = var_buff.output_data.reshape( var_buff.descriptor.data_dims()) mean_data = mean_buff.output_data.reshape( mean_buff.descriptor.data_dims()) orig_data = exp.vals.reshape(exp.chan1.descriptor.data_dims()) self.assertTrue( np.abs(np.sum(mean_data - np.mean(orig_data, axis=0))) <= 1e-3) self.assertTrue( np.abs(np.sum(var_data - np.var(orig_data, axis=0, ddof=1))) <= 1e-3)
def test_final_average_runs(self): exp = TestExperiment() printer_final = Print(name="Final") avgr = Averager('trials', name="TestAverager") edges = [(exp.chan1, avgr.sink), (avgr.source, printer_final.sink)] exp.set_graph(edges) exp.run_sweeps()
def test_sameness(self): exp = TestExperiment() printer_partial = Print(name="Partial") printer_final = Print(name="Final") avgr = Averager(name="TestAverager", axis='freq_1') edges = [(exp.chan1, avgr.sink), (avgr.partial_average, printer_partial.sink), (avgr.source, printer_final.sink)] exp.set_graph(edges) exp.add_sweep(exp.freq_1, np.linspace(0, 9, 10)) exp.run_sweeps()
exp.polarity = 1 # 1: AP to P; -1: P to AP exp.measure_current = 3e-6 exp.reset_amplitude = 0.78 exp.reset_duration = 5.0e-9 exp.settle_delay = 200e-6 exp.pspl_atten = 3 max_points = 100 sample_name = "CSHE-Die7-C6R7" date = datetime.datetime.today().strftime('%Y-%m-%d') pol = "APtoP" if exp.polarity < 0 else "PtoAP" file_path = "data\CSHE-Switching\{samp:}\{samp:}-PulseSwitching-{pol:}_{date:}.h5".format( pol=pol, samp=sample_name, date=date) wr = WriteToHDF5(file_path) avg = Averager('sample') edges = [(exp.voltage, avg.sink), (avg.final_average, wr.sink)] exp.set_graph(edges) # Construct the coarse grid coarse_ts = np.linspace(0.1, 10.0, 7) * 1e-9 coarse_vs = np.linspace(0.40, 0.90, 7) points = [coarse_ts, coarse_vs] points = list(itertools.product(*points)) # Add an extra plotter fig1 = MeshPlotter(name="Switching Phase Diagram") def refine_func(sweep_axis): points, mean = sw.load_switching_data(wr.filename)
return "<SweptTestExperiment>" def run(self): for _ in range(500): time.sleep(0.01) data = np.zeros((100, 100)) data[25:75, 25:75] = 1.0 data = data + 25 * np.random.random((100, 100)) self.voltage.push(data.flatten()) if __name__ == '__main__': exp = TestExperiment() avg = Averager("repeats", name="Averager") pl1 = Plotter(name="Partial", plot_dims=2, plot_mode="real", palette="Spectral11") pl2 = Plotter(name="Final", plot_dims=2, plot_mode="real", palette="Spectral11") edges = [(exp.voltage, avg.sink), (avg.partial_average, pl1.sink), (avg.source, pl2.sink)] avg.update_interval = 0.2 pl1.update_interval = 0.2 pl2.update_interval = 0.2
if __name__ == '__main__': exp = TestExperiment() channelizer = Channelizer(frequency=10e6, bandwidth=5e6, decimation_factor=8, name="Demod") ki = KernelIntegrator(kernel="", bias=0, simple_kernel=True, box_car_start=0, box_car_stop=64e-9, frequency=0, name="KI") avg1 = Averager("round_robins", name="Average channelizer RRs") avg2 = Averager("round_robins", name="Average KI RRs") pl1 = Plotter(name="2D Scope", plot_dims=2, palette="Spectral11") pl2 = Plotter(name="Demod", plot_dims=2, plot_mode="quad", palette="Spectral11") pl3 = Plotter(name="KI", plot_dims=1, plot_mode='real') # pl4 = Plotter(name="KI", plot_dims=2, palette="Spectral11") edges = [(exp.voltage, channelizer.sink), (channelizer.source, avg1.sink), (channelizer.source, ki.sink), (ki.source, avg2.sink), (avg1.final_average, pl2.sink), (avg2.final_average, pl3.sink)] exp.set_graph(edges)