def refine_func(sweep_axis): points, mean = sw.load_switching_data(wr.filename) new_points = refine.refine_scalar_field(points, mean, all_points=False, criterion="integral", threshold="one_sigma") if len(points) + len(new_points) > max_points: print("Reached maximum points ({}).".format(max_points)) return False print("Reached {} points.".format(len(points) + len(new_points))) sweep_axis.add_points(new_points) # Plot previous mesh x = [list(el) for el in points[mesh.simplices, 0]] y = [list(el) for el in points[mesh.simplices, 1]] val = [np.mean(vals) for vals in mean[mesh.simplices]] desc = DataStreamDescriptor() desc.add_axis(sweep_axis) exp.push_to_plot(fig1, desc, points) time.sleep(1) return True
exp.push_to_plot(fig1, desc, points) time.sleep(1) return True sweep_axis = exp.add_sweep([exp.pulse_duration, exp.pulse_voltage], points, refine_func=refine_func) # Borrow the descriptor from the main sweep and use it for our direct plotter exp.add_plotter(fig1, desc) exp.run_sweeps() points, mean = sw.load_switching_data(wr.filename) mesh, scale_factors = sw.scaled_Delaunay(points) fig_mesh = sw.phase_diagram_mesh(points, mean, shading='gouraud') plt.triplot(mesh.points[:, 0] / scale_factors[0], mesh.points[:, 1] / scale_factors[1], mesh.simplices.copy()) plt.show() # t1 = time.time() # for i in range(exp.iterations): # exp.reset() # exp.run_sweeps() # points, mean = sw.load_switching_data(wr.filename) # figs.append(sw.phase_diagram_mesh(points, mean, title="Iteration={}".format(i))) # new_points = refine.refine_scalar_field(points, mean, all_points=False, # criterion="integral", threshold = "one_sigma")