Exemplo n.º 1
0
def example_Overlay2FirstLog():
    PySpectra.cls()
    PySpectra.delete()
    PySpectra.setTitle("2 Overlay Scans, first (red) has log scale")
    PySpectra.setComment(
        "Sadly, there are no major tick mark strings at the right axis")
    PySpectra.setWsViewport("DINA5")

    g1 = utils.createGauss(name="gauss",
                           xMin=-5.,
                           xMax=5.,
                           nPts=101,
                           lineColor='red',
                           x0=0.,
                           sigma=1.,
                           amplitude=1.)

    g1.yLog = True

    g2 = utils.createGauss(name="gauss2",
                           xMin=-5.,
                           xMax=5.,
                           nPts=101,
                           lineColor='green',
                           x0=0.5,
                           sigma=1.2,
                           amplitude=1.)

    PySpectra.overlay("gauss2", "gauss")

    PySpectra.display()
Exemplo n.º 2
0
def example_Overlay2BothLog():
    PySpectra.cls()
    PySpectra.delete()
    PySpectra.setTitle("2 Overlay Scans, both with log scale")
    PySpectra.setComment("both axes have different ranges")
    PySpectra.setWsViewport("DINA5")
    g1 = utils.createGauss(name="gauss",
                           xMin=-5.,
                           xMax=5.,
                           nPts=101,
                           lineColor='red',
                           x0=0.,
                           sigma=1.,
                           amplitude=1.)
    g1.yLog = True
    g2 = utils.createGauss(name="gauss2",
                           xMin=-5.,
                           xMax=5.,
                           nPts=101,
                           lineColor='green',
                           x0=0.5,
                           sigma=1.2,
                           amplitude=1.)
    g2.yLog = True
    g2.yMin = 0.001
    g2.yMax = 1.

    PySpectra.overlay("gauss2", "gauss")

    PySpectra.display()
Exemplo n.º 3
0
def example_GaussAndSinusOverlay():
    '''
    overlay 2 scans
    '''
    PySpectra.cls()
    PySpectra.delete()
    PySpectra.setTitle("2 Overlay Scans")
    PySpectra.setWsViewport("DINA5")
    g = utils.createGauss(name="gauss",
                          xMin=-5.,
                          xMax=5.,
                          nPts=101,
                          lineColor='red',
                          x0=0.,
                          sigma=1.,
                          amplitude=1.)
    t1 = PySpectra.Scan(name="sinus",
                        lineColor='blue',
                        xMin=-5,
                        xMax=5.,
                        yMin=-1.5,
                        yMax=1.5,
                        yLabel='sin')
    t1.y = np.sin(t1.x)
    PySpectra.overlay("sinus", "gauss")
    PySpectra.display()
Exemplo n.º 4
0
    def testAddText(self):

        print("testPySpectra.testAddText")

        PySpectra.cls()
        PySpectra.delete()
        PySpectra.setTitle("test addText")

        g = utils.createGauss()
        g.addText(name="testText",
                  x=0.2,
                  y=0.1,
                  color='magenta',
                  fontSize=20,
                  text="dies ist ein addText test text")

        self.assertEqual(len(g.textList), 1)
        txt = g.textList[0]
        self.assertEqual(txt.name, "testText")
        self.assertEqual(txt.hAlign, "left")
        self.assertEqual(txt.vAlign, "top")
        self.assertEqual(txt.color, "magenta")
        self.assertEqual(txt.fontSize, 20)
        self.assertEqual(txt.x, 0.2)
        self.assertEqual(txt.y, 0.1)
        self.assertEqual(txt.NDC, True)

        g.display()
        PySpectra.processEventsLoop(1)
        return
Exemplo n.º 5
0
    def testMotorArrowMisc(self):

        print("testPySpectra.testMotorArrowMisc")

        PySpectra.cls()
        PySpectra.delete()

        g = utils.createGauss(name="gauss",
                              xMin=-5.,
                              xMax=5.,
                              nPts=101,
                              lineColor='red',
                              x0=0.,
                              sigma=1.,
                              amplitude=1.)

        g.x += 50

        g.motorNameList = ["eh_mot66"]
        PySpectra.setComment(
            "testPySpectra.testArrowMisc: an arrow should appear at 50.3")
        g.display()
        g.setArrowMisc(50.3)

        g.display()
        time.sleep(3.0)
        return
Exemplo n.º 6
0
    def testMotorArrowCurrentAndSetPoint(self):

        print("testPySpectra.testMotorArrowCurrentAndSetPoint")

        if utils.getHostname() != definitions.hostTK:
            return

        PySpectra.cls()
        PySpectra.delete()
        PySpectra.setTitle("test arrows, current and setpoint")

        g = utils.createGauss(name="gauss",
                              xMin=-5.,
                              xMax=5.,
                              nPts=101,
                              lineColor='red',
                              x0=0.,
                              sigma=1.,
                              amplitude=1.)
        g.x += 50

        g.motorNameList = ["eh_mot66"]
        proxy = PyTango.DeviceProxy("eh_mot66")

        g.display()

        POSI = 50
        g.setArrowMisc(proxy.position)
        proxy.position = POSI
        print("testPySpectra.testArrow: moving %s to %g" %
              (proxy.name(), POSI))
        g.setArrowSetPoint(POSI)
        while proxy.state() == PyTango.DevState.MOVING:
            g.updateArrowCurrent()
            time.sleep(0.1)
        g.updateArrowCurrent()

        g.display()

        POSI = 51
        g.setArrowMisc(proxy.position)
        proxy.position = POSI
        print("testPySpectra.testArrow: moving %s to %g" %
              (proxy.name(), POSI))
        g.setArrowSetPoint(POSI)
        while proxy.state() == PyTango.DevState.MOVING:
            g.setArrowCurrent(proxy.position)
            time.sleep(0.1)
        g.setArrowCurrent(proxy.position)
        return
Exemplo n.º 7
0
    def testMoveMotorStart(self):
        print "testTangoIfc.testMoveMotorStart"

        if utils.getHostname() != definitions.hostTK:
            return

        PySpectra.cls()
        PySpectra.delete()
        PySpectra.setTitle(
            "watch arrows (setPoint, current) while moving a motor forth and back"
        )
        g = utils.createGauss(name="gauss",
                              xMin=-5.,
                              xMax=5.,
                              nPts=101,
                              lineColor='red',
                              x0=0.,
                              sigma=1.,
                              amplitude=1.)

        g.motorNameList = ["eh_mot66"]
        proxyPool = PyTango.DeviceProxy(g.motorNameList[0])
        proxy = PyTango.DeviceProxy(proxyPool.TangoDevice)
        POS = proxy.position + 1
        g.x += POS
        g.xMin += POS
        g.xMax += POS
        print("testTangoIfc.testMoveMotorNameList: move %s to %g" %
              (g.motorNameList[0], POS))
        tangoIfc.moveStart(g, POS, flagConfirm=False)
        g.display()
        g.setArrowSetPoint(POS)
        while proxy.state() != PyTango.DevState.ON:
            time.sleep(0.5)
            g.updateArrowCurrent()

        POS -= 1
        print("testTangoIfc.testMoveMotorNameList: move %s back to %g" %
              (g.motorNameList[0], POS))
        tangoIfc.moveStart(g, POS, flagConfirm=False)
        g.setArrowSetPoint(POS)
        while proxy.state() != PyTango.DevState.ON:
            time.sleep(0.5)
            g.updateArrowCurrent()

        print "testTangoIfc.testMoveMotorStart DONE"
        return
Exemplo n.º 8
0
    def testSSA(self):
        print "testPySpectra.testSSA"
        PySpectra.cls()
        PySpectra.delete()
        PySpectra.setTitle("test SSA")

        g = utils.createGauss(name="gauss",
                              xMin=-5.,
                              xMax=5.,
                              nPts=101,
                              lineColor='red',
                              x0=0.,
                              sigma=1.,
                              amplitude=1.)

        g.ssa()
        self.assertEqual(len(g.textList), 5)

        # SSA results
        # midpoint: -6.84879e-06
        # peak-x:   0
        # cms:      -9.65309e-05
        # fwhm:     2.3552
        #
        self.assertTrue(g.textList[0].text == 'SSA results')

        lst = g.textList[1].text.split(':')
        self.assertTrue(lst[0] == 'midpoint')
        self.assertTrue(abs(float(lst[1])) < 0.0001)

        lst = g.textList[2].text.split(':')
        self.assertTrue(lst[0] == 'peak-x')
        self.assertTrue(abs(float(lst[1])) < 0.0001)

        lst = g.textList[3].text.split(':')
        self.assertTrue(lst[0] == 'cms')
        self.assertTrue(abs(float(lst[1])) < 0.0001)

        lst = g.textList[4].text.split(':')
        self.assertTrue(lst[0] == 'fwhm')
        self.assertTrue(abs(float(lst[1])) < 2.356)
        self.assertTrue(abs(float(lst[1])) > 2.350)

        PySpectra.display()
        PySpectra.processEventsLoop(1)
        return
Exemplo n.º 9
0
def example_Gauss():
    '''
    gauss plot
    '''
    PySpectra.cls()
    PySpectra.delete()
    PySpectra.setTitle("A simple Gauss curve")
    PySpectra.setComment("Can be used with SSA, calculating derivative and so")
    PySpectra.setWsViewport("DINA5")
    g = utils.createGauss(name="gauss",
                          xMin=-5.,
                          xMax=5.,
                          nPts=101,
                          lineColor='red',
                          x0=0.,
                          sigma=1.,
                          amplitude=1.)
    PySpectra.display()
    return
Exemplo n.º 10
0
def example_FSA_GaussVeryNoisy():
    '''
    gauss plot
    '''
    PySpectra.cls()
    PySpectra.delete()
    PySpectra.setTitle("a very noisy Gauss at 0.12345")
    PySpectra.setComment("Input for Util->FSA/SSA")
    PySpectra.setWsViewport("DINA5")
    g = utils.createGauss(name="gauss",
                          xMin=-5.,
                          xMax=5.,
                          nPts=101,
                          lineColor='red',
                          x0=0.12345,
                          sigma=1.,
                          amplitude=1.)
    g.y += np.random.random_sample((len(g.x), )) * 0.3
    PySpectra.display()
    return
Exemplo n.º 11
0
    def testMoveMotorNameList(self):

        print "testTangoIfc.testMoveMotorNameList"

        if utils.getHostname() != definitions.hostTK:
            return

        PySpectra.cls()
        PySpectra.delete()
        PySpectra.setTitle("watch arrows while a motor is tangoIfc.move()ed")
        g = utils.createGauss(name="gauss",
                              xMin=-5.,
                              xMax=5.,
                              nPts=101,
                              lineColor='red',
                              x0=0.,
                              sigma=1.,
                              amplitude=1.)

        g.motorNameList = ["eh_mot66"]
        proxyPool = PyTango.DeviceProxy(g.motorNameList[0])
        proxy = PyTango.DeviceProxy(proxyPool.TangoDevice)
        POS = proxy.position + 1
        g.x += POS
        g.xMin += POS
        g.xMax += POS
        print("testTangoIfc.testMoveMotorNameList: move %s to %g" %
              (g.motorNameList[0], POS))
        tangoIfc.move(g, POS, flagConfirm=False)

        POS -= 1
        print("testTangoIfc.testMoveMotorNameList: move %s back to %g" %
              (g.motorNameList[0], POS))
        tangoIfc.move(g, POS, flagConfirm=False)

        print "testTangoIfc.testMoveMotorNameList DONE"

        return
Exemplo n.º 12
0
    def testFsa(self):
        print "testPySpectra.testFsa"
        PySpectra.cls()
        PySpectra.delete()
        g = utils.createGauss(name="gauss",
                              xMin=-5.,
                              xMax=5.,
                              nPts=101,
                              lineColor='red',
                              x0=0.12345,
                              sigma=1.2345,
                              amplitude=1.)

        (message, xpos, xpeak, xcms, xcen, npSig) = g.fsa()

        self.assertEqual(message, 'success')
        self.assertAlmostEqual(xpos, 0.1)
        self.assertAlmostEqual(xpeak, 0.1)
        self.assertAlmostEqual(xcms, 0.1234, 3)
        self.assertAlmostEqual(xcen, 0.1234, 3)

        self.assertTrue(g.textList[0].text.find('FSA results') == 0)

        lst = g.textList[1].text.split(':')
        self.assertTrue(lst[0] == 'xpos')

        lst = g.textList[2].text.split(':')
        self.assertTrue(lst[0] == 'xpeak')

        lst = g.textList[3].text.split(':')
        self.assertTrue(lst[0] == 'xcms')

        lst = g.textList[4].text.split(':')
        self.assertTrue(lst[0] == 'xcen')

        return