Exemple #1
0
    def test_close(self):
        """Verify closed object by testing one of the attributes"""

        self.snew = Signal()
        self.snew.open(self.filename)

        # print out the contents of the file nicely

        report = []

        for key, val in self.snew.f.attrs.items():
            report.append("{0}: {1}".format(key, val))

        for item in self.snew.f:

            report.append("{}".format(self.snew.f[item].name))
            for key, val in self.snew.f[item].attrs.items():
                report.append("    {0}: {1}".format(key, val))

        report_string = "\n".join(report)

        print("\nObjects in file .InitLoadSaveTests_1.h5")
        print(report_string)

        # test one of the attributes

        self.assertTrue(self.snew.f.attrs['source'], 'demodulate.py')
        self.snew.close()
Exemple #2
0
    def setUp(self):
        """
        Create an trial *Signal* object
        """

        self.s = Signal(self.filename)
        self.s.load_nparray(np.arange(3), "x", "nm", 10E-6)
Exemple #3
0
    def setUp(self):
        self.f = h5py.File(self.filename, driver='core', backing_store=False)
        self.x = np.array([0, 1, 2])
        self.y = np.array([0, 2, 4])

        self.x_attrs = {
            'name': 't',
            'unit': 's',
            'label': 't [s]',
            'label_latex': '$t \\: [\\mathrm{s}]$',
            'help': 'time axis',
            'initial': 0,
            'step': 1
        }

        self.y_attrs = {
            'name': 'x',
            'unit': 'nm',
            'label': 'x [nm]',
            'label_latex': '$x \: [\mathrm{nm}]$',
            'help': 'cantilever amplitude',
            'abscissa': 'x',
            'n_avg': 1
        }

        self.f['x'] = self.x
        self.f['y'] = self.y

        update_attrs(self.f['x'].attrs, self.x_attrs)
        update_attrs(self.f['y'].attrs, self.y_attrs)

        self.s = Signal()
Exemple #4
0
 def setUp(self):
     self.x = np.array([0, 1, 2])
     self.y = np.array([0, 2, 4])
     self.s = Signal()
     self.f = h5py.File(self.filename, driver='core', backing_store=False)
     self.f['time'] = self.x
     self.f['position'] = self.y
Exemple #5
0
    def setUp(self):
        """
        Create a trial *Signal* object
        """

        self.s = Signal('.InitLoadSaveTests_1.h5')
        self.s.load_nparray(np.arange(60000), "x", "nm", 10E-6)
Exemple #6
0
 def setUp(self):
     self.s = Signal()
     self.x = np.array([0, 1, 2, 3])
     self.y = np.array([0, 1, 0, -1])
     self.s.load_nparray([0, 1, 0, -1], 'signal', 'm', 1)
     self.s.fft()
     self.s.freq_filter_Hilbert_complex()
     self.s.ifft()
     self.s.f.attrs['two'] = 2  # test attribute to verify attrs copied
     self.f_dst = h5py.File('.test2.h5', backing_store=False, driver='core')
Exemple #7
0
    def setUp(self):
        """
        Create an trial *Signal* object
        """

        fd = 50.0E3  # digitization frequency
        f0 = 5.00E3  # signal frequency
        nt = 512  # number of signal points

        self.dt = dt = 1 / fd
        t = dt * np.arange(nt)
        s = 1.0 * np.sin(2 * np.pi * f0 * t)

        self.s = Signal('.FFTTests_1.h5')
        self.s.load_nparray(s, "x", "nm", dt)
        self.s.time_mask_binarate("middle")
        self.s.time_window_cyclicize(10 * dt)
        self.s.fft()
        self.s.freq_filter_Hilbert_complex()
Exemple #8
0
 def setUp(self):
     self.s = Signal(self.filename, mode='w', backing_store=True)
     self.s.load_nparray(np.arange(3), "x", "nm", 10E-6)
     self.s.close()
Exemple #9
0
 def setUp(self):
     self.s = Signal()
     self.x = np.array([0, 1, 2, 3])
     self.y = np.array([0, 1, 0, -1])
     self.s.load_nparray([0, 1, 0, -1], 'signal', 'm', 1)
     self.f_dst = h5py.File('.test3.h5', backing_store=False, driver='core')
Exemple #10
0
 def setUp(self):
     self.x = np.array([0, 1, 0, -1, 0, 1, 0, -1, 0])
     self.s = Signal()
     self.s.load_nparray(self.x, 'x', 'nm', 1)