def test_roa_select_overlay_va(self): sem = simsem.SimSEM(**CONFIG_SEM) for child in sem.children.value: if child.name == CONFIG_SCANNER["name"]: ebeam = child # Simulate a stage move ebeam.updateMetadata({model.MD_POS: (1e-3, -0.2e-3)}) # but it should be a simple miccanvas cnvs = miccanvas.DblMicroscopeCanvas(self.panel) self.add_control(cnvs, wx.EXPAND, proportion=1, clear=True) roa = model.TupleVA(UNDEFINED_ROI) rsol = wol.RepetitionSelectOverlay(cnvs, roa=roa, scanner=ebeam) rsol.activate() cnvs.add_world_overlay(rsol) cnvs.scale = 100000 cnvs.update_drawing() # Undefined ROA => sel = None roi_back = rsol.get_physical_sel() self.assertEqual(roi_back, None) # Full FoV roa.value = (0, 0, 1, 1) test.gui_loop(0.1) # Expect the whole SEM FoV fov = compute_scanner_fov(ebeam) ebeam_rect = get_fov_rect(ebeam, fov) roi_back = rsol.get_physical_sel() for o, b in zip(ebeam_rect, roi_back): self.assertAlmostEqual(o, b, msg="ebeam FoV (%s) != ROI (%s)" % (ebeam_rect, roi_back)) # Hald the FoV roa.value = (0.25, 0.25, 0.75, 0.75) test.gui_loop(0.1) # Expect the whole SEM FoV fov = compute_scanner_fov(ebeam) fov = (fov[0] / 2, fov[1] / 2) ebeam_rect = get_fov_rect(ebeam, fov) roi_back = rsol.get_physical_sel() for o, b in zip(ebeam_rect, roi_back): self.assertAlmostEqual(o, b, msg="ebeam FoV (%s) != ROI (%s)" % (ebeam_rect, roi_back)) test.gui_loop() sem.terminate()
def test_camera_fov(self): # Move a little bit out of the origin, to make it less easy self.stage.moveAbsSync({"x": 1e-3, "y": 5e-3}) fov = compute_camera_fov(self.ccd) rect = get_fov_rect(self.ccd, fov) # Compare to the actual FoV of an acquired image im = self.ccd.data.get() pxs_im = im.metadata[model.MD_PIXEL_SIZE] fov_im = im.shape[1] * pxs_im[0], im.shape[0] * pxs_im[1] self.assertEqual(fov, fov_im) center_im = im.metadata[model.MD_POS] rect_im = (center_im[0] - fov_im[0] / 2, center_im[1] - fov_im[1] / 2, center_im[0] + fov_im[0] / 2, center_im[1] + fov_im[1] / 2) self.assertEqual(rect, rect_im)
def test_camera_fov(self): # Move a little bit out of the origin, to make it less easy self.stage.moveAbsSync({"x": 1e-3, "y": 5e-3}) fov = compute_camera_fov(self.ccd) rect = get_fov_rect(self.ccd, fov) # Compare to the actual FoV of an acquired image im = self.ccd.data.get() pxs_im = im.metadata[model.MD_PIXEL_SIZE] fov_im = im.shape[1] * pxs_im[0], im.shape[0] * pxs_im[1] self.assertEqual(fov, fov_im) center_im = im.metadata[model.MD_POS] rect_im = (center_im[0] - fov_im[0] / 2, center_im[1] - fov_im[1] / 2 , center_im[0] + fov_im[0] / 2, center_im[1] + fov_im[1] / 2) self.assertEqual(rect, rect_im)