예제 #1
0
    def test_filename_increment(self):
        clear_test_data()

        exp = SweptTestExperiment()
        wr = WriteToHDF5("test_writehdf5.h5")

        edges = [(exp.voltage, wr.sink)]
        exp.set_graph(edges)

        exp.add_sweep(exp.field, np.linspace(0, 100.0, 4))
        exp.add_sweep(exp.freq, np.linspace(0, 10.0, 3))
        exp.run_sweeps()

        exp = SweptTestExperiment()
        wr = WriteToHDF5("test_writehdf5.h5")

        edges = [(exp.voltage, wr.sink)]
        exp.set_graph(edges)

        exp.add_sweep(exp.field, np.linspace(0, 100.0, 4))
        exp.add_sweep(exp.freq, np.linspace(0, 10.0, 3))
        exp.run_sweeps()

        self.assertTrue(os.path.exists("test_writehdf5-0000.h5"))
        self.assertTrue(os.path.exists("test_writehdf5-0001.h5"))

        os.remove("test_writehdf5-0000.h5")
        os.remove("test_writehdf5-0001.h5")
예제 #2
0
    def test_writehdf5_samefile(self):
        exp = SweptTestExperiment()
        clear_test_data()
        wr1 = WriteToHDF5("test_writehdf5_samefile.h5", "group1")
        wr2 = WriteToHDF5("test_writehdf5_samefile.h5", "group2")

        edges = [(exp.voltage, wr1.sink), (exp.current, wr2.sink)]
        exp.set_graph(edges)

        exp.add_sweep(exp.field, np.linspace(0,100.0,4))
        exp.add_sweep(exp.freq, np.linspace(0,10.0,3))
        exp.run_sweeps()
        self.assertTrue(os.path.exists("test_writehdf5_samefile-0000.h5"))
        with h5py.File("test_writehdf5_samefile-0000.h5", 'r') as f:
            self.assertTrue(0.0 not in f['group1']['data']['voltage'])
            self.assertTrue(np.sum(f['group1/data/field']) == 5*3*np.sum(np.linspace(0,100.0,4)) )
            self.assertTrue(np.sum(f['group1/data/freq']) == 5*4*np.sum(np.linspace(0,10.0,3)) )
            self.assertTrue(np.sum(f['group1/data/samples']) == 3*4*np.sum(np.linspace(0,4,5)) )
            self.assertTrue("Here the run loop merely spews" in f.attrs['exp_src'])
            self.assertTrue(f['group1/data'].attrs['time_val'] == 0)
            self.assertTrue(f['group1/data'].attrs['unit_freq'] == "Hz")
            self.assertTrue(0.0 not in f['group2/data/current'])
            self.assertTrue(np.sum(f['group2/data/field']) == 3*np.sum(np.linspace(0,100.0,4)) )
            self.assertTrue(np.sum(f['group2/data/freq']) == 4*np.sum(np.linspace(0,10.0,3)) )
            self.assertTrue("Here the run loop merely spews" in f.attrs['exp_src'])
            self.assertTrue(f['group2/data'].attrs['time_val'] == 0)
            self.assertTrue(f['group2/data'].attrs['unit_freq'] == "Hz")

        os.remove("test_writehdf5_samefile-0000.h5")
예제 #3
0
파일: test_write.py 프로젝트: caryan/Auspex
    def test_writehdf5_unstructured_sweep(self):
        exp = SweptTestExperiment()
        if os.path.exists("test_writehdf5_unstructured-0000.h5"):
            os.remove("test_writehdf5_unstructured-0000.h5")
        wr = WriteToHDF5("test_writehdf5_unstructured.h5")

        edges = [(exp.voltage, wr.sink)]
        exp.set_graph(edges)

        coords = [[0, 0.1], [10, 4.0], [15, 2.5], [40, 4.4], [50, 2.5],
                  [60, 1.4], [65, 3.6], [66, 3.5], [67, 3.6], [68, 1.2]]
        exp.add_sweep([exp.field, exp.freq], coords)
        exp.run_sweeps()
        self.assertTrue(os.path.exists("test_writehdf5_unstructured-0000.h5"))
        self.assertTrue(wr.points_taken == 10 * 5)

        with h5py.File("test_writehdf5_unstructured-0000.h5", 'r') as f:
            self.assertTrue(f[f['main/field+freq'][0]] == f['main/field'])
            self.assertTrue(f[f['main/field+freq'][1]] == f['main/freq'])

        data, desc = load_from_HDF5("test_writehdf5_unstructured-0000.h5",
                                    reshape=False)
        self.assertTrue(data['main']['field'][-5:].sum() == 5 * 68)

        os.remove("test_writehdf5_unstructured-0000.h5")
예제 #4
0
파일: test_write.py 프로젝트: caryan/Auspex
    def test_writehdf5(self):
        exp = SweptTestExperiment()
        if os.path.exists("test_writehdf5-0000.h5"):
            os.remove("test_writehdf5-0000.h5")
        wr = WriteToHDF5("test_writehdf5.h5")

        edges = [(exp.voltage, wr.sink)]
        exp.set_graph(edges)

        exp.add_sweep(exp.field, np.linspace(0, 100.0, 4))
        exp.add_sweep(exp.freq, np.linspace(0, 10.0, 3))
        exp.run_sweeps()
        self.assertTrue(os.path.exists("test_writehdf5-0000.h5"))
        with h5py.File("test_writehdf5-0000.h5", 'r') as f:
            self.assertTrue(0.0 not in f['main/data/voltage'])
            self.assertTrue(
                np.sum(f['main/data/field']) == 5 * 3 *
                np.sum(np.linspace(0, 100.0, 4)))
            self.assertTrue(
                np.sum(f['main/data/freq']) == 5 * 4 *
                np.sum(np.linspace(0, 10.0, 3)))
            self.assertTrue(
                np.sum(f['main/data/samples']) == 3 * 4 *
                np.sum(np.linspace(0, 4, 5)))
            self.assertTrue(
                "Here the run loop merely spews" in f.attrs['exp_src'])
            self.assertTrue(f['main/data'].attrs['time_val'] == 0)
            self.assertTrue(f['main/data'].attrs['unit_freq'] == "Hz")

        os.remove("test_writehdf5-0000.h5")
예제 #5
0
    def test_writehdf5_complex(self):
        exp = SweptTestExperiment()
        exp.is_complex = True
        clear_test_data()
        wr = WriteToHDF5("test_writehdf5_complex.h5")

        edges = [(exp.voltage, wr.sink)]
        exp.set_graph(edges)
        exp.voltage.descriptor.dtype = np.complex128
        exp.update_descriptors()
        exp.add_sweep(exp.field, np.linspace(0, 100.0, 4))
        exp.add_sweep(exp.freq, np.linspace(0, 10.0, 3))
        exp.run_sweeps()
        self.assertTrue(os.path.exists("test_writehdf5_complex-0000.h5"))
        with h5py.File("test_writehdf5_complex-0000.h5", 'r') as f:
            self.assertTrue(0.0 not in f['main/data/voltage'])
            self.assertTrue(
                np.sum(f['main/data/field']) == 5 * 3 *
                np.sum(np.linspace(0, 100.0, 4)))
            self.assertTrue(
                np.sum(f['main/data/freq']) == 5 * 4 *
                np.sum(np.linspace(0, 10.0, 3)))
            self.assertTrue(
                np.sum(f['main/data/samples']) == 3 * 4 *
                np.sum(np.linspace(0, 4, 5)))
            self.assertTrue(f['main/data'].attrs['time_val'] == 0)
            self.assertTrue(f['main/data'].attrs['unit_freq'] == "Hz")

        os.remove("test_writehdf5_complex-0000.h5")
예제 #6
0
    def test_writehdf5_multiple_streams(self):
        exp = SweptTestExperiment2()
        clear_test_data()
        wr = WriteToHDF5("test_writehdf5_mult.h5")

        edges = [(exp.voltage, wr.sink), (exp.current, wr.sink)]
        exp.set_graph(edges)
        exp.add_sweep(exp.field, np.linspace(0, 100.0, 4))
        exp.add_sweep(exp.freq, np.linspace(0, 10.0, 3))
        exp.run_sweeps()
        self.assertTrue(os.path.exists("test_writehdf5_mult-0000.h5"))
        with h5py.File("test_writehdf5_mult-0000.h5", 'r') as f:
            self.assertTrue(0.0 not in f['main/data/voltage'])
            self.assertTrue(
                np.sum(f['main/data/field']) == 5 * 3 *
                np.sum(np.linspace(0, 100.0, 4)))
            self.assertTrue(
                np.sum(f['main/data/freq']) == 5 * 4 *
                np.sum(np.linspace(0, 10.0, 3)))
            self.assertTrue(
                np.sum(f['main/data/samples']) == 3 * 4 *
                np.sum(np.linspace(0, 4, 5)))
            self.assertTrue(f['main/data'].attrs['time_val'] == 0)
            self.assertTrue(f['main/data'].attrs['unit_freq'] == "Hz")

        os.remove("test_writehdf5_mult-0000.h5")
예제 #7
0
    def test_writehdf5_adaptive_sweep(self):
        exp = SweptTestExperiment()
        clear_test_data()
        wr = WriteToHDF5("test_writehdf5_adaptive.h5")

        edges = [(exp.voltage, wr.sink)]
        exp.set_graph(edges)

        async def rf(sweep_axis, exp):
            num_points = 5
            logger.debug("Running refinement function.")
            if sweep_axis.num_points() >= num_points:
                return False
            # sweep_axis.points.append(sweep_axis.points[-1]*2)
            sweep_axis.add_points(sweep_axis.points[-1] * 2)
            return True

        exp.add_sweep(exp.field, np.linspace(0, 100.0, 11))
        exp.add_sweep(exp.freq, [1.0, 2.0], refine_func=rf)
        exp.run_sweeps()
        self.assertTrue(os.path.exists("test_writehdf5_adaptive-0000.h5"))
        self.assertTrue(wr.points_taken == 5 * 11 * 5)

        with h5py.File("test_writehdf5_adaptive-0000.h5", 'r') as f:
            self.assertTrue(
                f['main/data/freq'][:].sum() == (55 * (1 + 2 + 4 + 8 + 16)))

        os.remove("test_writehdf5_adaptive-0000.h5")
예제 #8
0
    def test_writehdf5_metadata(self):
        exp = SweptTestExperimentMetadata()
        clear_test_data()
        wr = WriteToHDF5("test_writehdf5_metadata.h5")

        edges = [(exp.voltage, wr.sink)]
        exp.set_graph(edges)

        exp.add_sweep(exp.field, np.linspace(0,100.0,4))
        exp.add_sweep(exp.freq, np.linspace(0,10.0,3))
        exp.run_sweeps()
        self.assertTrue(os.path.exists("test_writehdf5_metadata-0000.h5"))
        with h5py.File("test_writehdf5_metadata-0000.h5", 'r') as f:
            self.assertTrue(0.0 not in f['main/data']['voltage'])
            self.assertTrue(np.sum(f['main/data/field']) == 5*3*np.sum(np.linspace(0,100.0,4)) )
            self.assertTrue(np.sum(f['main/data/freq']) == 5*4*np.sum(np.linspace(0,10.0,3)) )
            self.assertTrue(np.sum(np.isnan(f['main/data/samples'])) == 3*4*2 )

            md_enum = f['main/samples_metadata_enum'][:]
            md = f['main/data/samples_metadata'][:]
            md = md_enum[md]

            self.assertTrue(np.sum(md == b'data') == 4*3*3)
            self.assertTrue("Here the run loop merely spews" in f.attrs['exp_src'])
            self.assertTrue(f['main/data'].attrs['time_val'] == 0)
            self.assertTrue(f['main/data'].attrs['unit_freq'] == "Hz")
            self.assertTrue('metadata' in f['main/samples'].attrs)
            self.assertTrue(f[f['main/samples'].attrs['metadata']] == f['main/samples_metadata'])
        os.remove("test_writehdf5_metadata-0000.h5")
예제 #9
0
    def test_writehdf5_adaptive_unstructured_sweep(self):
        exp = SweptTestExperiment()
        clear_test_data()
        wr = WriteToHDF5("test_writehdf5_adaptive_unstructured.h5")

        edges = [(exp.voltage, wr.sink)]
        exp.set_graph(edges)

        coords = [[0, 0.1], [10, 4.0], [15, 2.5], [40, 4.4], [50, 2.5],
                  [60, 1.4], [65, 3.6], [66, 3.5], [67, 3.6], [68, 1.2]]

        async def rf(sweep_axis, exp):
            logger.debug("Running refinement function.")
            if sweep_axis.num_points() >= 30:
                return False

            first_points = np.array(sweep_axis.points[-10:])
            new_points = first_points.copy()
            new_points[:, 0] += 100
            new_points[:, 1] += 10

            sweep_axis.add_points(new_points)
            logger.debug("Sweep points now: {}.".format(sweep_axis.points))
            return True

        exp.add_sweep([exp.field, exp.freq], coords, refine_func=rf)
        exp.run_sweeps()
        self.assertTrue(
            os.path.exists("test_writehdf5_adaptive_unstructured-0000.h5"))
        self.assertTrue(wr.points_taken == 10 * 5 * 3)

        os.remove("test_writehdf5_adaptive_unstructured-0000.h5")
예제 #10
0
    def test_writehdf5_with_settings(self):
        exp = SweptTestExperiment()
        clear_test_data()
        wr = WriteToHDF5("test_writehdf5.h5", save_settings=True)

        edges = [(exp.voltage, wr.sink)]
        exp.set_graph(edges)

        exp.add_sweep(exp.field, np.linspace(0, 100.0, 4))
        exp.add_sweep(exp.freq, np.linspace(0, 10.0, 3))
        exp.run_sweeps()
        self.assertTrue(os.path.exists("test_writehdf5-0000.h5"))
        with h5py.File("test_writehdf5-0000.h5", 'r') as f:
            self.assertTrue(0.0 not in f['main/data/voltage'])
            self.assertTrue(
                np.sum(f['main/data/field']) == 5 * 3 *
                np.sum(np.linspace(0, 100.0, 4)))
            self.assertTrue(
                np.sum(f['main/data/freq']) == 5 * 4 *
                np.sum(np.linspace(0, 10.0, 3)))
            self.assertTrue(
                np.sum(f['main/data/samples']) == 3 * 4 *
                np.sum(np.linspace(0, 4, 5)))
            self.assertTrue(
                "Here the run loop merely spews" in f.attrs['exp_src'])
            self.assertTrue(f['main/data'].attrs['time_val'] == 0)
            self.assertTrue(f['main/data'].attrs['unit_freq'] == "Hz")
            self.assertTrue(f['header'].attrs['settings'] == yaml_dump(
                yaml_load(configFile), flatten=True))

        os.remove("test_writehdf5-0000.h5")
예제 #11
0
파일: test_write.py 프로젝트: caryan/Auspex
    def test_writehdf5_metadata_unstructured_adaptive(self):
        exp = SweptTestExperimentMetadata()
        if os.path.exists(
                "test_writehdf5_metadata_unstructured_adaptive-0000.h5"):
            os.remove("test_writehdf5_metadata_unstructured_adaptive-0000.h5")
        wr = WriteToHDF5("test_writehdf5_metadata_unstructured_adaptive.h5")

        edges = [(exp.voltage, wr.sink)]
        exp.set_graph(edges)
        coords = [[0, 0.1], [10, 4.0], [15, 2.5], [40, 4.4], [50, 2.5],
                  [60, 1.4], [65, 3.6], [66, 3.5], [67, 3.6]]
        md = ["data"] * 9

        async def rf(sweep_axis, exp):
            logger.debug("Running refinement function.")
            if sweep_axis.num_points() >= 12:
                return False
            sweep_axis.set_metadata(
                np.append(sweep_axis.metadata_enum[sweep_axis.metadata],
                          ["a", "b", "c"]))
            sweep_axis.add_points([[np.nan, np.nan], [np.nan, np.nan],
                                   [np.nan, np.nan]])
            logger.debug("Sweep points now: {}.".format(sweep_axis.points))
            return True

        exp.add_sweep([exp.field, exp.freq],
                      coords,
                      metadata=md,
                      refine_func=rf)
        exp.run_sweeps()
        self.assertTrue(
            os.path.exists(
                "test_writehdf5_metadata_unstructured_adaptive-0000.h5"))
        with h5py.File("test_writehdf5_metadata_unstructured_adaptive-0000.h5",
                       'r') as f:
            self.assertTrue(0.0 not in f['main/data']['voltage'])
            self.assertTrue(np.sum(np.isnan(f['main/data/field'])) == 3 * 5)
            self.assertTrue(np.sum(np.isnan(f['main/data/freq'])) == 3 * 5)
            self.assertTrue(
                np.sum(np.isnan(f['main/data/samples'])) == 3 * 4 * 2)

            # This is pathological
            # md_enum = f['main/field+freq_metadata_enum'][:]
            # md = f['main/data/field+freq_metadata'][:]
            # md = md_enum[md]

            # self.assertTrue(np.sum(md == b'a') == 5)
            # self.assertTrue(np.sum(md == b'b') == 5)
            # self.assertTrue(np.sum(md == b'c') == 5)
            self.assertTrue(
                "Here the run loop merely spews" in f.attrs['exp_src'])
            self.assertTrue(f['main/data'].attrs['time_val'] == 0)
            self.assertTrue(f['main/data'].attrs['unit_freq'] == "Hz")

        os.remove("test_writehdf5_metadata_unstructured_adaptive-0000.h5")
예제 #12
0
    def test_writehdf5_1D_adaptive_sweep(self):
        exp = SweptTestExperiment()
        if os.path.exists("test_writehdf5_1D_adaptive-0000.h5"):
            os.remove("test_writehdf5_1D_adaptive-0000.h5")
        wr = WriteToHDF5("test_writehdf5_1D_adaptive.h5")

        edges = [(exp.resistance, wr.sink)]
        exp.set_graph(edges)

        async def rf(sweep_axis, exp):
            logger.debug("Running refinement function.")
            temps = wr.group['data']['temperature'][:]
            ress = wr.group['data']['resistance'][:]
            logger.debug("Temps: {}".format(temps))
            logger.debug("Ress: {}".format(ress))

            new_temps = refine_1D(temps,
                                  ress,
                                  all_points=False,
                                  criterion="difference",
                                  threshold="one_sigma")

            logger.debug("New temperature values: {}".format(new_temps))
            if new_temps.size + temps.size > 15:
                return False

            sweep_axis.add_points(new_temps)
            logger.debug("Axis points are now: {}".format(sweep_axis.points))
            return True

        exp.add_sweep(exp.temperature, np.linspace(0, 20, 5), refine_func=rf)
        exp.run_sweeps()

        self.assertTrue(os.path.exists("test_writehdf5_1D_adaptive-0000.h5"))

        expected_data = np.array([
            0., 5., 10., 15., 20., 7.5, 8.75, 9.375, 9.0625, 8.90625, 8.984375,
            12.5, 17.5, 9.0234375, 8.945312
        ])
        data, desc = load_from_HDF5(wr.filename.value, reshape=False)
        actual_data = data['main']['temperature']
        self.assertTrue(actual_data.size == expected_data.size)
        os.remove("test_writehdf5_1D_adaptive-0000.h5")
예제 #13
0
    def test_writehdf5_metadata_unstructured(self):
        exp = SweptTestExperimentMetadata()
        clear_test_data()
        wr = WriteToHDF5("test_writehdf5_metadata_unstructured.h5")

        edges = [(exp.voltage, wr.sink)]
        exp.set_graph(edges)
        coords = [[ 0, 0.1],
                  [10, 4.0],
                  [15, 2.5],
                  [40, 4.4],
                  [50, 2.5],
                  [60, 1.4],
                  [65, 3.6],
                  [66, 3.5],
                  [67, 3.6],
                  [np.nan, np.nan],
                  [np.nan, np.nan],
                  [np.nan, np.nan]]
        md = ["data"]*9 + ["a","b","c"]
        exp.add_sweep([exp.field, exp.freq], coords, metadata=md)
        exp.run_sweeps()
        self.assertTrue(os.path.exists("test_writehdf5_metadata_unstructured-0000.h5"))
        with h5py.File("test_writehdf5_metadata_unstructured-0000.h5", 'r') as f:
            self.assertTrue(0.0 not in f['main/data/voltage'])
            self.assertTrue(np.sum(np.isnan(f['main/data/field'])) == 3*5 )
            self.assertTrue(np.sum(np.isnan(f['main/data/freq'])) == 3*5 )
            self.assertTrue(np.sum(np.isnan(f['main/data/samples'])) == 3*4*2 )

            md_enum = f['main/field+freq_metadata_enum'][:]
            md = f['main/data/field+freq_metadata'][:]
            md = md_enum[md]

            self.assertTrue(np.sum(md == b'a') == 5)
            self.assertTrue(np.sum(md == b'b') == 5)
            self.assertTrue(np.sum(md == b'c') == 5)
            self.assertTrue("Here the run loop merely spews" in f.attrs['exp_src'])
            self.assertTrue(f['main/data'].attrs['time_val'] == 0)
            self.assertTrue(f['main/data'].attrs['unit_freq'] == "Hz")

        os.remove("test_writehdf5_metadata_unstructured-0000.h5")
예제 #14
0
    def test_writehdf5_no_tuples(self):
        exp = SweptTestExperiment()
        exp.samples = 1024
        exp.init_streams()

        clear_test_data()
        wr = WriteToHDF5("test_writehdf5_no_tuples.h5", store_tuples=False)

        edges = [(exp.voltage, wr.sink)]
        exp.set_graph(edges)

        exp.add_sweep(exp.field, np.linspace(0,100.0,5))
        exp.add_sweep(exp.freq, np.linspace(0,10.0,4))
        exp.run_sweeps()
        self.assertTrue(os.path.exists("test_writehdf5_no_tuples-0000.h5"))
        with h5py.File("test_writehdf5_no_tuples-0000.h5", 'r') as f:
            self.assertTrue(0.0 not in f['main/data/voltage'])
            self.assertTrue("Here the run loop merely spews" in f.attrs['exp_src'])
            self.assertTrue(f['main/data'].attrs['time_val'] == 0)
            self.assertTrue(f['main/data'].attrs['unit_freq'] == "Hz")
        os.remove("test_writehdf5_no_tuples-0000.h5")
예제 #15
0
    exp.field.value = 0.007
    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):
                "Warning: failed to stop task (this normally happens with no consequences when taking multiple samples per trigger)."
            )
            pass


if __name__ == '__main__':
    exp = nTronBERExperiment()
    exp.sample = "CSHE5 - C1R3"
    exp.comment = "nTron Bit Error Rate - P to AP - 10ns"
    exp.polarity = 1  # -1: AP to P; 1: P to AP
    exp.field.value = -0.0074
    exp.nTron_duration.value = 10e-9  # Fixed
    exp.init_instruments()

    wr = WriteToHDF5(
        "data\CSHE-Switching\CSHE-Die5-C1R3\CSHE5-C1R3-P2AP_2016-07-20_BER_10ns.h5"
    )
    edges = [(exp.daq_buffer, wr.data)]
    exp.set_graph(edges)

    attempts_list = [1 << int(x) for x in np.linspace(12, 16, 5)]
    # attempts_list = [int(6e6), int(6e6)]
    voltages_list = np.linspace(0.6, 1.0, 5)
    t1 = []  # Keep track of time
    t2 = []
    for att, vol in zip(attempts_list, voltages_list):
        print("=========================")
        print("Now at ({},{}).".format(att, vol))
        t1.append(time.time())
        exp.attempts.value = att
        exp.nTron_voltage.value = vol
예제 #17
0
        pass

    async def run(self):
        r = np.sqrt(
            np.power(self.amplitude.value, 2) +
            np.power(self.duration.value, 2))
        val = 1.0 / (1.0 + np.exp(-10.0 * (r - 5.0)))
        await self.voltage.push(val)
        await asyncio.sleep(0.01)


if __name__ == '__main__':

    exp = TestExperiment()
    fig1 = MeshPlotter(name="Plot The Mesh")
    wr = WriteToHDF5("test_mesh.h5")

    edges = [(exp.voltage, wr.sink)]
    exp.set_graph(edges)
    exp.add_direct_plotter(fig1)

    # Construct the coarse grid
    coarse_ts = np.linspace(0.0, 10.0, 7)
    coarse_vs = np.linspace(0.0, 7.5, 7)
    points = [coarse_ts, coarse_vs]
    points = list(itertools.product(*points))

    refine_func = delaunay_refine_from_file(wr,
                                            'duration',
                                            'amplitude',
                                            'voltage',
예제 #18
0
def main():

    #Tell main which globals to modify
    global CHAN_LIST
    global RES_RANGE
    global PLC
    global SAMPLE_MAP
    global BASETEMP
    global MAXTEMP
    global RNOISE
    global MAXPOINTS

    # Define Measurement Channels and sample names
    # CHAN_LIST 	= [101,102,103,104]
    CHAN_LIST = [104]
    RES_RANGE = 100
    cdPLC = 10
    TcPLC = 100
    #SAMPLE_MAP	= {101:'TOX23_NbN',102:'TOX24_NbN',103:'TOX25_NbN',104:'TOX-23_Nb'}
    #SAMPLE_MAP	= {101:'TOX23_NbN',102:'TOX24_NbN',103:'TOX25_NbN'}
    SAMPLE_MAP = {104: 'TOX-23_Nb'}

    # Define Base Temp, Mas Temp, Temp resolution, Resistance noise and max points for Tc refinement
    BASETEMP = 3.2  #Kelvin
    MAXTEMP = 20  #Kelvin
    TRES = 0.05  #Kelvin
    RNOISE = 0.009  #Ohms
    MAXPOINTS = 50

    #--------------------------User shouldn't need to edit below here--------------------------------

    names = []
    for i in CHAN_LIST:
        names.append(SAMPLE_MAP[i])

    # Define data file name and path
    sample_name = ("SAMPLES_" + '_'.join(['{}'] * len(names))).format(*names)
    date = datetime.datetime.today().strftime('%Y-%m-%d')
    path = "Tc_Data\{date:}".format(date=date)

    # Check if already at Base temp
    ls = LakeShore335("GPIB0::2::INSTR")
    ls.connect()
    t_check = ls.Temp('B')
    ls.disconnect()

    if BASETEMP < t_check:

        # Reset Global config variables
        PLC = cdPLC

        # Create Experiment Object
        cd_exp = Cooldown()

        # Setup datafile and define which data to write, plot ect.
        cd_file = "{path:}\{samp:}-Cooldown_{date:}.h5".format(
            path=path, samp=sample_name, date=date)
        wr = WriteToHDF5(cd_file)

        # Create plots for monitoring.
        #plt_Avt  = XYPlotter(name="Temperature Sense A", x_series=True, series="inner")
        #plt_Bvt  = XYPlotter(name="Temperature Sense B", x_series=True, series="inner")
        #plt_RvT  = XYPlotter(name="Sample Resistance", x_series=True, series="inner")

        edges = [(cd_exp.sheet_res, wr.sink), (cd_exp.temp_A, wr.sink),
                 (cd_exp.temp_B, wr.sink), (cd_exp.sys_time, wr.sink)]
        cd_exp.set_graph(edges)

        # Add points 10 at a time until base temp is reached
        async def while_temp(sweep_axis, exp):

            if exp.lakeshore.Temp("B") < BASETEMP:
                print("Base Temperature Reached...")
                return False

            print(
                "Running refinement loop: Temp %f, Num_points: %d, last i %d" %
                (exp.lakeshore.Temp("B"), sweep_axis.num_points(),
                 sweep_axis.points[-1]))

            last_i = sweep_axis.points[-1]
            sweep_axis.add_points(range(last_i + 1, last_i + 10))

            return True

        # Defines index as sweep axis where while_temp function determines end condition
        sweep_axis = cd_exp.add_sweep(cd_exp.index,
                                      range(3),
                                      refine_func=while_temp)

        # Run the experiment
        print("Running Cooldown Log starting from {} K".format(t_check))
        print("Writing Cooldown Data to file: {}".format(wr.filename.value))
        cd_exp.run_sweeps()
        print("Cooldown Logging Completed...")

    else:
        print(
            "Experiment at base temperature {:.3f} K, skipping Cooldown Log..."
            .format(t_check))

    # Reset Global config variables
    PLC = TcPLC

    # Create Experiment Object
    tc_exp = TcMeas()

    # Setup datafile and define which data to write, plot ect.
    tc_file = "{path:}\{samp:}-Tc_{date:}.h5".format(path=path,
                                                     samp=sample_name,
                                                     date=date)
    wr = WriteToHDF5(tc_file)
    edges = [(tc_exp.sheet_res, wr.sink), (tc_exp.temp_meas, wr.sink)]
    tc_exp.set_graph(edges)

    # Add points until max points are reached or resolution limit of refine function is hit
    async def transition(sweep_axis, exp):

        points, mean = load_tc_meas(wr.filename.value)

        newpoints = refine_1D(points,
                              mean,
                              all_points=False,
                              criterion="difference",
                              threshold="one_sigma",
                              resolution=TRES,
                              noise_level=RNOISE)

        if newpoints is None or len(points) + len(newpoints) > MAXPOINTS:

            print("Tc Refinement complete... Exiting")
            return False

        # Always remeasure BASETEMP to ensure lack of thermal hysterysis
        print("Refining Tc Measurement...")
        sweep_axis.add_points(np.insert(newpoints, 0, BASETEMP))
        return True

    # Defines index as sweep axis where transition function determines end condition
    sweep_axis = tc_exp.add_sweep(tc_exp.temp_set,
                                  range(int(BASETEMP), int(MAXTEMP), 2),
                                  refine_func=transition)

    # Run the experiment
    print("Running Tc Experiment...")
    print("Writing Tc Data to file: {}".format(wr.filename.value))
    tc_exp.run_sweeps()
    print("Tc Experiment Complete")

    #Run post processing analysis
    tc_analysis(wr.filename.value)