def test_multi_det(self): """ Test AutoFocus Spectrometer with multiple detectors """ # Note: a full procedure would start by setting the slit to the smallest position # (cf optical path mode "spec-focus") and activating an energy source specline_mul = [self.specline_ccd, self.specline_spccd] self.focus.moveAbs({"z": self._good_focus + 400e-6}).result() data = tiff.read_data( os.path.join(TEST_IMAGE_PATH, "brightlight-off-slit-spccd-simple.ome.tiff")) new_img = img.ensure2DImage(data[0]) self.spccd.set_image(new_img) f = Sparc2AutoFocus("spec-focus", self.optmngr, specline_mul, True) time.sleep(5) data = tiff.read_data( os.path.join(TEST_IMAGE_PATH, "brightlight-on-slit-spccd-simple.ome.tiff")) new_img = img.ensure2DImage(data[0]) self.spccd.set_image(new_img) res = f.result(timeout=900) for (g, d), fpos in res.items(): self.assertIn(d.role, (self.ccd.role, self.spccd.role)) if d.role is self.ccd.role: self.assertAlmostEqual(fpos, self._good_focus, 3) if d.role is self.spccd.role: self.assertAlmostEqual(fpos, self._good_focus, 3) # We expect an entry for each combination grating/detector self.assertEqual(len(res.keys()), len(self.spgr_ded.axes["grating"].choices))
def test_cancel(self): """ Test cancelling does cancel (relatively quickly) """ self.focus.moveAbs({"z": self._good_focus - 200e-6}).result() data = tiff.read_data( os.path.join(TEST_IMAGE_PATH, "brightlight-off-slit-spccd-simple.ome.tiff")) new_img = img.ensure2DImage(data[0]) self.spccd.set_image(new_img) f = Sparc2AutoFocus("spec-focus", self.optmngr, [self.specline_ccd], True) time.sleep(5) data = tiff.read_data( os.path.join(TEST_IMAGE_PATH, "brightlight-on-slit-spccd-simple.ome.tiff")) new_img = img.ensure2DImage(data[0]) self.spccd.set_image(new_img) cancelled = f.cancel() self.assertTrue(cancelled) self.assertTrue(f.cancelled()) with self.assertRaises(CancelledError): res = f.result(timeout=900)
def test_one_det(self): """ Test AutoFocus Spectrometer on CCD """ self.focus.moveAbs({"z": self._good_focus - 200e-6}).result() data = tiff.read_data( os.path.join(TEST_IMAGE_PATH, "brightlight-off-slit-spccd-simple.ome.tiff")) new_img = img.ensure2DImage(data[0]) self.spccd.set_image(new_img) f = Sparc2AutoFocus("spec-focus", self.optmngr, [self.specline_ccd], True) time.sleep(5) data = tiff.read_data( os.path.join(TEST_IMAGE_PATH, "brightlight-on-slit-spccd-simple.ome.tiff")) new_img = img.ensure2DImage(data[0]) self.spccd.set_image(new_img) res = f.result(timeout=900) for (g, d), fpos in res.items(): self.assertEqual(d.role, self.ccd.role) self.assertAlmostEqual(fpos, self._good_focus, 3) self.assertEqual(len(res.keys()), len(self.spgr_ded.axes["grating"].choices))
def test_ded_spectrograph(self): """ Test AutoFocus Spectrometer on CCD """ f = Sparc2AutoFocus("spec-fiber-focus", self.optmngr, [self.specline_spccd], True) res = f.result(timeout=900) for (g, d), fpos in res.items(): self.assertIn(d.role, {"sp-ccd2", "sp-ccd3"}) self.assertEqual(len(res.keys()), 2*len(self.spgr_ded.axes["grating"].choices))
def test_cancel(self): """ Test cancelling does cancel (relatively quickly) """ self.focus.moveAbs({"z": self._good_focus - 200e-6}).result() f = Sparc2AutoFocus("spec-focus", self.optmngr, [self.specline_ccd], True) time.sleep(5) cancelled = f.cancel() self.assertTrue(cancelled) self.assertTrue(f.cancelled()) with self.assertRaises(CancelledError): res = f.result(timeout=900)