Esempio n. 1
0
    def test_only_SEM_streams_with_zstack(self):
        sems = stream.SEMStream("sem", self.sed, self.sed.data, self.ebeam)
        self.streams = [sems]

        zlevels = {}

        est_time = acqmng.estimateZStackAcquisitionTime(self.streams, zlevels)
        # only one sem stream, so should be greater than or equal to 1 sec
        self.assertGreaterEqual(est_time, 1)

        # start the acquisition
        f = acqmng.acquireZStack(self.streams, zlevels)
        f.add_update_callback(self._on_progress_update)

        data, exp = f.result()
        self.assertIsNone(exp)

        for d in data:
            self.assertIsInstance(d, model.DataArray)
            # even if zstack, it's only SEM, so the center has 2 components
            self.assertEqual(len(d.metadata[model.MD_POS]), 2)
            # even if zstack, it's SEM, so the pixel size has 2 components
            self.assertEqual(len(d.metadata[model.MD_PIXEL_SIZE]), 2)

        # 1 streams, so 1 acquisitions
        self.assertEqual(len(data), 1)

        # 1 streams, 1 updates per stream, so 1 updates
        self.assertGreaterEqual(self._nb_updates, 1)
Esempio n. 2
0
    def test_FM_and_SEM_with_zstack(self):
        s1 = stream.FluoStream("fluo1",
                               self.ccd,
                               self.ccd.data,
                               self.light,
                               self.light_filter,
                               focuser=self.fm_focuser)
        s1.excitation.value = sorted(s1.excitation.choices)[0]

        sems = stream.SEMStream("sem", self.sed, self.sed.data, self.ebeam)

        self.streams = [s1, sems]

        zlevels_list = generate_zlevels(self.fm_focuser, [-2e-6, 2e-6], 1e-6)
        zlevels = {}
        for s in self.streams:
            if isinstance(s, stream.FluoStream):
                zlevels[s] = list(zlevels_list)

        est_time = acqmng.estimateZStackAcquisitionTime(self.streams, zlevels)
        # about 5 seconds for fm streams, and 1 sec for sem stream, so should be
        # greater than or equal 5 sec
        self.assertGreaterEqual(est_time, 4)

        # start the acquisition
        f = acqmng.acquireZStack(self.streams, zlevels)
        f.add_update_callback(self._on_progress_update)

        data, exp = f.result()
        self.assertIsNone(exp)

        for i, d in enumerate(data):
            self.assertIsInstance(d, model.DataArray)
            if d.ndim > 2 and d.shape[-3] > 1:  # 3D data (FM)
                # if zstack, so the center has 3 components
                self.assertEqual(len(d.metadata[model.MD_POS]), 3)
                # if zstack, so the pixel size has 3 components
                self.assertEqual(len(d.metadata[model.MD_PIXEL_SIZE]), 3)
            else:  # 2D data (SEM)
                # even if zstack, it's SEM, so the center has 2 components
                self.assertEqual(len(d.metadata[model.MD_POS]), 2)
                # even if zstack, it's SEM, so the pixel size has 2 components
                self.assertEqual(len(d.metadata[model.MD_PIXEL_SIZE]), 2)

        # 2 streams, so 2 acquisitions
        self.assertEqual(len(data), 2)

        # 2 streams, 2 updates per stream, so >= 2 updates
        self.assertGreaterEqual(self._nb_updates, 2)
Esempio n. 3
0
    def test_only_FM_streams_with_zstack(self):
        # create streams
        s1 = stream.FluoStream("fluo1",
                               self.ccd,
                               self.ccd.data,
                               self.light,
                               self.light_filter,
                               focuser=self.fm_focuser)
        s1.excitation.value = sorted(s1.excitation.choices)[0]
        s2 = stream.FluoStream("fluo2", self.ccd, self.ccd.data, self.light,
                               self.light_filter)
        s2._focuser = self.fm_focuser
        s2.excitation.value = sorted(s2.excitation.choices)[-1]
        self.streams = [s1, s2]

        zlevels_list = generate_zlevels(self.fm_focuser, [-2e-6, 2e-6], 1e-6)
        zlevels = {}
        for s in self.streams:
            zlevels[s] = list(zlevels_list)

        # there are about 5 zlevels, so should be greater than 2 seconds
        est_time = acqmng.estimateZStackAcquisitionTime(self.streams, zlevels)
        self.assertGreaterEqual(est_time, 2)

        # start the acquisition
        f = acqmng.acquireZStack(self.streams, zlevels)
        f.add_update_callback(self._on_progress_update)

        # get the data
        data, exp = f.result()
        self.assertIsNone(exp)

        for d in data:
            self.assertIsInstance(d, model.DataArray)
            # since zstack, the center has 3 components
            self.assertEqual(len(d.metadata[model.MD_POS]), 3)
            # since zstack, the pixel size has 3 components
            self.assertEqual(len(d.metadata[model.MD_PIXEL_SIZE]), 3)

        # 2 streams, so 2 acquisitions
        self.assertEqual(len(data), 2)

        # 2 streams, 2 updates per stream, so 2 updates at least
        self.assertGreaterEqual(self._nb_updates, 2)