示例#1
0
 def setSplit(self):
     """Sets the current masks to split bullseye masks, with the same
     center, for coma aberration determination."""
     self.maskMask = Mask.Split(
         m, n, self.lbdPar.value(), self.RPar.value(),
         self.sigmaPar.value(), self.left_center, self.right_center,
         np.float(self.arrowsModule.rotAngEdit.text()))
     self.maskMask.tilt(self.anglePar.value())
     self.maskMask.update()
     self.update()
示例#2
0
 def setHex(self):
     """Sets the current masks to hexagonal masks, with the same center,
     for trefoil aberration determination."""
     self.maskMask = Mask.Hex(m, n, self.lbdPar.value(), self.RPar.value(),
                              self.sigmaPar.value(), self.left_center,
                              self.right_center,
                              np.float(self.arrowsModule.rotAngEdit.text()))
     self.maskMask.tilt(self.anglePar.value())
     self.maskMask.update()
     self.update()
示例#3
0
 def setQuadrant(self):
     """Sets the current masks to quadrant masks, with the same center,
     for astigmatism aberration determination."""
     self.maskMask = Mask.Quad(
         m, n, self.lbdPar.value(), self.RPar.value(),
         self.sigmaPar.value(), self.left_center, self.right_center,
         np.float(self.arrowsModule.rotAngEdit.text()))
     self.maskMask.tilt(self.anglePar.value())
     self.maskMask.update()
     self.update()
示例#4
0
 def setHalf(self):
     """Sets the current masks to half masks, with the same center,
     for accurate center position determination."""
     self.maskMask = Mask.Half(
         m, n, self.lbdPar.value(), self.RPar.value(),
         self.sigmaPar.value(), self.left_center, self.right_center,
         np.float(self.arrowsModule.rotAngEdit.text()))
     self.maskMask.tilt(self.anglePar.value())
     self.maskMask.update()
     self.update()
示例#5
0
 def setGaussians(self):
     """Sets the current masks to Gaussian masks, with the same center.
     Useful for alignment."""
     """
     self.mask=Mask.Gaussians(m,n,self.lbdPar.value(),self.RPar.value(),self.sigmaPar.value());
     self.mask.tilt(self.anglePar.value()
     """
     # self.loadParamGaussian()
     self.gaussiansBool = True
     self.maskMask = Mask.Gaussians(m, n, self.lbdPar.value(),
                                    self.RPar.value(),
                                    self.sigmaPar.value(), self.left_center,
                                    self.right_center)
     self.maskMask.tilt(self.anglePar.value())
     self.maskMask.update()
     # self.maskAber.update()
     self.update()
示例#6
0
    def loadParam(self):
        """loads the parameters from a previous configuration. Depending on
        which objective is in use, load different parameter files. """
        self.gaussiansBool = False

        if (str(self.arrowsModule.objlensMenu.currentText()) == "Oil"):
            with open('informationsOil.bbn', 'rb') as f:
                depickler = pickle.Unpickler(f)
                state = depickler.load()
                mask_state = depickler.load()
            with open('informationsAberOil.bbn', 'rb') as fAber:
                depickler = pickle.Unpickler(fAber)
                stateAber = depickler.load()
        elif (str(self.arrowsModule.objlensMenu.currentText()) == "Glycerol"):
            with open('informationsGlyc.bbn', 'rb') as f:
                depickler = pickle.Unpickler(f)
                state = depickler.load()
                mask_state = depickler.load()
            with open('informationsAberGlyc.bbn', 'rb') as fAber:
                depickler = pickle.Unpickler(fAber)
                stateAber = depickler.load()
        elif (str(self.arrowsModule.objlensMenu.currentText()) ==
              "No objective"):
            print('You have to choose an objective in the drop down menu!')
            return

        self.tree.p.restoreState(state)
        print("Load mask centers:", mask_state)
        self.treeAber.p.restoreState(stateAber)

        self.fDTilt = self.treeAber.p.param("D Tilt factor")
        self.fDTip = self.treeAber.p.param("D Tip factor")
        self.fDDefocPar = self.treeAber.p.param("D Defocus factor")
        self.fDSphPar = self.treeAber.p.param("D Spherical factor")
        self.fDVertComaPar = self.treeAber.p.param("D Vertical coma factor")
        self.fDHozComaPar = self.treeAber.p.param("D Horizontal coma factor")
        self.fDVertAstPar = self.treeAber.p.param(
            "D Vertical astigmatism factor")
        self.fDOblAstPar = self.treeAber.p.param(
            "D Oblique astigmatism factor")

        self.fTHTilt = self.treeAber.p.param("TH Tilt factor")
        self.fTHTip = self.treeAber.p.param("TH Tip factor")
        self.fTHDefocPar = self.treeAber.p.param("TH Defocus factor")
        self.fTHSphPar = self.treeAber.p.param("TH Spherical factor")
        self.fTHVertComaPar = self.treeAber.p.param("TH Vertical coma factor")
        self.fTHHozComaPar = self.treeAber.p.param("TH Horizontal coma factor")
        self.fTHVertAstPar = self.treeAber.p.param(
            "TH Vertical astigmatism factor")
        self.fTHOblAstPar = self.treeAber.p.param(
            "TH Oblique astigmatism factor")

        self.DaberrationFactors = np.array([
            self.fDTilt.value(),
            self.fDTip.value(),
            self.fDDefocPar.value(),
            self.fDSphPar.value(),
            self.fDVertComaPar.value(),
            self.fDHozComaPar.value(),
            self.fDVertAstPar.value(),
            self.fDOblAstPar.value()
        ])
        self.THaberrationFactors = np.array([
            self.fTHTilt.value(),
            self.fTHTip.value(),
            self.fTHDefocPar.value(),
            self.fTHSphPar.value(),
            self.fTHVertComaPar.value(),
            self.fTHHozComaPar.value(),
            self.fTHVertAstPar.value(),
            self.fTHOblAstPar.value()
        ])

        self.left_center = mask_state["left_center"]
        self.right_center = mask_state["right_center"]

        self.maskMask = Mask.Helix_Hat(m,
                                       n,
                                       self.lbdPar.value(),
                                       self.RPar.value(),
                                       self.sigmaPar.value(),
                                       left_pos=self.left_center,
                                       right_pos=self.right_center)
        self.maskMask.tilt(self.anglePar.value())
        self.maskAber = Mask.Aberrations(m,
                                         n,
                                         self.lbdPar.value(),
                                         self.RPar.value(),
                                         self.sigmaPar.value(),
                                         self.DaberrationFactors,
                                         self.THaberrationFactors,
                                         left_pos=self.left_center,
                                         right_pos=self.right_center)
        self.update()
        print("Loaded all parameters.")
示例#7
0
    def apply(self):
        """Applies a configuration to the SLM and changes the mask displayed"""

        self.fDTilt = self.treeAber.p.param("D Tilt factor")
        self.fDTip = self.treeAber.p.param("D Tip factor")
        self.fDDefocPar = self.treeAber.p.param("D Defocus factor")
        self.fDSphPar = self.treeAber.p.param("D Spherical factor")
        self.fDVertComaPar = self.treeAber.p.param("D Vertical coma factor")
        self.fDHozComaPar = self.treeAber.p.param("D Horizontal coma factor")
        self.fDVertAstPar = self.treeAber.p.param(
            "D Vertical astigmatism factor")
        self.fDOblAstPar = self.treeAber.p.param(
            "D Oblique astigmatism factor")

        self.fTHTilt = self.treeAber.p.param("TH Tilt factor")
        self.fTHTip = self.treeAber.p.param("TH Tip factor")
        self.fTHDefocPar = self.treeAber.p.param("TH Defocus factor")
        self.fTHSphPar = self.treeAber.p.param("TH Spherical factor")
        self.fTHVertComaPar = self.treeAber.p.param("TH Vertical coma factor")
        self.fTHHozComaPar = self.treeAber.p.param("TH Horizontal coma factor")
        self.fTHVertAstPar = self.treeAber.p.param(
            "TH Vertical astigmatism factor")
        self.fTHOblAstPar = self.treeAber.p.param(
            "TH Oblique astigmatism factor")

        self.DaberrationFactors = np.array([
            self.fDTilt.value(),
            self.fDTip.value(),
            self.fDDefocPar.value(),
            self.fDSphPar.value(),
            self.fDVertComaPar.value(),
            self.fDHozComaPar.value(),
            self.fDVertAstPar.value(),
            self.fDOblAstPar.value()
        ])
        self.THaberrationFactors = np.array([
            self.fTHTilt.value(),
            self.fTHTip.value(),
            self.fTHDefocPar.value(),
            self.fTHSphPar.value(),
            self.fTHVertComaPar.value(),
            self.fTHHozComaPar.value(),
            self.fTHVertAstPar.value(),
            self.fTHOblAstPar.value()
        ])

        if self.gaussiansBool:
            self.maskMask = Mask.Gaussians(m,
                                           n,
                                           self.lbdPar.value(),
                                           self.RPar.value(),
                                           self.sigmaPar.value(),
                                           left_pos=self.left_center,
                                           right_pos=self.right_center)
        else:
            self.maskMask = Mask.Helix_Hat(m, n, self.lbdPar.value(),
                                           self.RPar.value(),
                                           self.sigmaPar.value(),
                                           self.left_center, self.right_center,
                                           self.helix_rotPar.value())
        self.maskMask.tilt(self.anglePar.value())
        self.maskAber = Mask.Aberrations(m, n, self.lbdPar.value(),
                                         self.RPar.value(),
                                         self.sigmaPar.value(),
                                         self.DaberrationFactors,
                                         self.THaberrationFactors,
                                         self.left_center, self.right_center,
                                         self.helix_rotPar.value())

        self.update()
示例#8
0
    def __init__(self, slm, *args, **kwargs):
        super().__init__(*args, **kwargs)

        # Get the parameters from the tree
        self.tree = SLMParamTree()
        self.RPar = self.tree.p.child("R")
        self.sigmaPar = self.tree.p.param("sigma")
        self.anglePar = self.tree.p.param("angle")
        self.lbdPar = self.tree.p.param('lambda depletion: (nm)')
        self.helix_rotPar = self.tree.p.param("helix clock rotation")

        # Get the parameters from the tree - for aberrations for D and TH
        self.treeAber = SLMParamTreeAber()
        self.fDTilt = self.treeAber.p.param("D Tilt factor")
        self.fDTip = self.treeAber.p.param("D Tip factor")
        self.fDDefocPar = self.treeAber.p.param("D Defocus factor")
        self.fDSphPar = self.treeAber.p.param("D Spherical factor")
        self.fDVertComaPar = self.treeAber.p.param("D Vertical coma factor")
        self.fDHozComaPar = self.treeAber.p.param("D Horizontal coma factor")
        self.fDVertAstPar = self.treeAber.p.param(
            "D Vertical astigmatism factor")
        self.fDOblAstPar = self.treeAber.p.param(
            "D Oblique astigmatism factor")

        self.fTHTilt = self.treeAber.p.param("TH Tilt factor")
        self.fTHTip = self.treeAber.p.param("TH Tip factor")
        self.fTHDefocPar = self.treeAber.p.param("TH Defocus factor")
        self.fTHSphPar = self.treeAber.p.param("TH Spherical factor")
        self.fTHVertComaPar = self.treeAber.p.param("TH Vertical coma factor")
        self.fTHHozComaPar = self.treeAber.p.param("TH Horizontal coma factor")
        self.fTHVertAstPar = self.treeAber.p.param(
            "TH Vertical astigmatism factor")
        self.fTHOblAstPar = self.treeAber.p.param(
            "TH Oblique astigmatism factor")

        self.DaberrationFactors = np.array([
            self.fDTilt.value(),
            self.fDTip.value(),
            self.fDDefocPar.value(),
            self.fDSphPar.value(),
            self.fDVertComaPar.value(),
            self.fDHozComaPar.value(),
            self.fDVertAstPar.value(),
            self.fDOblAstPar.value()
        ])
        self.THaberrationFactors = np.array([
            self.fTHTilt.value(),
            self.fTHTip.value(),
            self.fTHDefocPar.value(),
            self.fTHSphPar.value(),
            self.fTHVertComaPar.value(),
            self.fTHHozComaPar.value(),
            self.fTHVertAstPar.value(),
            self.fTHOblAstPar.value()
        ])

        self.slm = slm
        self.maskMask = Mask.Helix_Hat(m, n, self.lbdPar.value(),
                                       self.RPar.value(),
                                       self.sigmaPar.value())
        self.maskAber = Mask.Aberrations(m, n, self.lbdPar.value(),
                                         self.RPar.value(),
                                         self.sigmaPar.value(),
                                         self.DaberrationFactors,
                                         self.THaberrationFactors)

        self.maskMask.tilt(self.anglePar.value())
        self.mask = self.maskMask + self.maskAber
        self.left_center = (0, 0)
        self.right_center = (0, 0)

        self.gaussiansBool = False

        # Indicates wether each side of the mask is actually displaying
        # a mask or not
        self.black_left = False
        self.black_right = False

        self.setFrameStyle(QtGui.QFrame.Panel | QtGui.QFrame.Raised)

        self.updateButton = QtGui.QPushButton('Update')
        self.updateButton.setCheckable(True)
        self.updateButton.clicked.connect(self.update)
        self.updateButton.setSizePolicy(QtGui.QSizePolicy.Preferred,
                                        QtGui.QSizePolicy.Expanding)

        self.applyPar = self.tree.p.param('Apply')
        self.applyPar.sigStateChanged.connect(self.apply)
        self.applyAberPar = self.treeAber.p.param('Apply')
        self.applyAberPar.sigStateChanged.connect(self.apply)

        # Widget displaying the phase pattern displayed on the SLM
        imageWidget = pg.GraphicsLayoutWidget()
        self.vb = imageWidget.addViewBox(row=1, col=1)
        self.img = pg.ImageItem()
        image = self.mask.img
        image = np.fliplr(image.transpose())
        self.img.setImage(image,
                          autoLevels=False,
                          autoDownsample=True,
                          autoRange=True)
        self.vb.addItem(self.img)
        self.vb.setAspectLocked(True)
        #        print(self.mask)
        #        print(self.slm)
        self.slm.updateArray(self.mask)

        self.arrowsModule = ArrowsControl()

        # Link between the buttons in the arrow module and the functions to
        # control the SLM
        self.arrowsModule.upButton.clicked.connect(self.upClicked)
        self.arrowsModule.downButton.clicked.connect(self.downClicked)
        self.arrowsModule.leftButton.clicked.connect(self.leftClicked)
        self.arrowsModule.rightButton.clicked.connect(self.rightClicked)
        self.arrowsModule.saveButton.clicked.connect(self.saveParam)
        self.arrowsModule.loadButton.clicked.connect(self.loadParam)
        self.arrowsModule.blackButton.clicked.connect(self.setBlack)
        self.arrowsModule.gaussiansButton.clicked.connect(self.setGaussians)
        self.arrowsModule.halfButton.clicked.connect(self.setHalf)
        self.arrowsModule.quadrantButton.clicked.connect(self.setQuadrant)
        self.arrowsModule.hexButton.clicked.connect(self.setHex)
        self.arrowsModule.splitbullButton.clicked.connect(self.setSplit)

        # GUI layout
        grid = QtGui.QGridLayout()
        self.setLayout(grid)
        grid.addWidget(imageWidget, 0, 0, 1, 2)
        grid.addWidget(self.treeAber, 1, 0, 1, 1)
        grid.addWidget(self.tree, 2, 0, 1, 1)
        grid.addWidget(self.arrowsModule, 1, 1, 2, 1)

        grid.setColumnMinimumWidth(1, 100)
        grid.setColumnMinimumWidth(2, 40)
        grid.setColumnMinimumWidth(0, 100)
        grid.setRowMinimumHeight(0, 200)
        grid.setRowMinimumHeight(1, 200)
        grid.setRowMinimumHeight(2, 50)