Пример #1
0
    def test_createScanByLimit(self):

        print "testPySpectra.test_createScanByLimit"

        PySpectra.cls()
        PySpectra.delete()

        PySpectra.setTitle("create scan by limits")
        scan = PySpectra.Scan(name="test1",
                              xMin=0.,
                              xMax=1.0,
                              nPts=101,
                              dType=np.float64,
                              at=(2, 2, 3),
                              lineColor='red',
                              lineStyle='solidLine')
        self.assertEqual(scan.xMin, 0.)
        self.assertEqual(scan.xMax, 1.)
        self.assertEqual(scan.nPts, 101)
        self.assertEqual(scan.dType, np.float64)
        self.assertEqual(len(scan.x), 101)
        self.assertEqual(scan.x.dtype, np.float64)
        self.assertEqual(len(scan.y), 101)
        self.assertEqual(scan.y.dtype, np.float64)

        self.assertEqual(scan.lineColor, 'red')

        PySpectra.display()
        PySpectra.processEventsLoop(1)
        print "testPySpectra.test_createScanByLimit DONE"
Пример #2
0
    def testFillData(self):
        print "testPySpectra.testFillData"
        PySpectra.cls()
        PySpectra.delete()
        PySpectra.setTitle("scan.setY()")
        scan = PySpectra.Scan(name='t1',
                              xLabel="up to 200 pts",
                              nPts=201,
                              yMin=-10.,
                              yMax=10.)
        self.assertEqual(scan.currentIndex, 200)
        #scan.y = np.tan( scan.x)

        startTime = time.time()
        for i in range(len(scan.y)):
            scan.setY(i, math.tan(float(i) / 10))
            PySpectra.display()

        diffTime = time.time() - startTime
        self.assertLess(diffTime, 12)

        PySpectra.display()
        PySpectra.processEventsLoop(1)

        print "testPySpectra.testFillData, DONE"
Пример #3
0
    def test_doty(self):

        print "testPySpectra.test_doty"

        PySpectra.cls()
        PySpectra.delete()
        PySpectra.setTitle("2 plots, the seconds has doty as the x-axis")

        scan1 = PySpectra.Scan(name="notdotyscan",
                               xMin=10.,
                               xMax=30.0,
                               nPts=101,
                               dType=np.float64,
                               lineColor='red',
                               lineStyle='solidLine')
        self.assertEqual(scan1.doty, False)

        scan2 = PySpectra.Scan(name="dotyscan",
                               xMin=10.,
                               xMax=30.0,
                               nPts=101,
                               dType=np.float64,
                               doty=True,
                               lineColor='red',
                               lineStyle='solidLine')

        self.assertEqual(scan2.doty, True)

        PySpectra.display()
        PySpectra.processEventsLoop(1)

        print "testPySpectra.test_doty DONE"
Пример #4
0
    def test_read(self):

        print "testPySpectra.test_read"

        PySpectra.cls()
        PySpectra.delete()
        PySpectra.setTitle("the graphics window should contain 24 plots")
        PySpectra.read("%s/test/data/ti_au_tio2_sio2_kat55a_0001.fio" %
                       pySpectraPath)
        lst = PySpectra.getGqeList()
        self.assertEqual(len(lst), 24)
        self.assertEqual(lst[0].name, "TI_AU_TIO2_SIO2_KAT55A_0001")
        self.assertEqual(lst[1].name, "TI_AU_TIO2_SIO2_KAT55A_0001_RING")

        PySpectra.display()
        PySpectra.processEventsLoop(1)

        PySpectra.cls()
        PySpectra.delete()
        PySpectra.setTitle("the graphics window should contain 4 plots")
        PySpectra.read("%s/test/data/SPLITTER_PXE_BL_22_2.dat" % pySpectraPath)
        lst = PySpectra.getGqeList()
        self.assertEqual(len(lst), 4)
        self.assertEqual(lst[0].name, "scan1")
        self.assertEqual(lst[1].name, "scan2")
        self.assertEqual(lst[2].name, "scan3")
        self.assertEqual(lst[3].name, "scan4")

        PySpectra.display()
        PySpectra.processEventsLoop(1)

        print "testPySpectra.test_read DONE"
Пример #5
0
    def testTextOnlyScan(self):

        print("testPySpectra.testTextOnlyScan")

        PySpectra.cls()
        PySpectra.delete()
        PySpectra.setTitle("test textOnly Scans")

        g = PySpectra.Scan(name="textContainer", textOnly=True)

        g.addText(name="testText", text="some text to be displayed")

        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, "black")
        self.assertEqual(txt.x, 0.5)
        self.assertEqual(txt.y, 0.5)
        self.assertEqual(txt.NDC, True)

        g.display()
        PySpectra.processEventsLoop(1)
        return
Пример #6
0
    def testCreateScansByGqes(self):

        print "testPySpectra.testCreateScansByGqes"
        PySpectra.cls()
        PySpectra.delete()
        PySpectra.setTitle("create scan by putData-gqes")

        x = np.linspace(0., 10., 100)
        tan = np.tan(x)
        sin = np.sin(x)
        cos = np.cos(x)

        hsh = {
            'putData': {
                'gqes': [{
                    'x': x,
                    'y': tan,
                    'name': 'tan'
                }, {
                    'x': x,
                    'y': cos,
                    'name': 'cos'
                }, {
                    'x': x,
                    'y': sin,
                    'name': 'sin',
                    'showGridY': False,
                    'symbolColor': 'blue',
                    'showGridX': True,
                    'yLog': False,
                    'symbol': '+',
                    'xLog': False,
                    'symbolSize': 5
                }]
            }
        }

        PySpectra.toPyspLocal(hsh)

        lst = PySpectra.getGqeList()
        self.assertEqual(len(lst), 3)

        self.assertEqual(lst[0].name, 'tan')
        self.assertEqual(lst[1].name, 'cos')
        self.assertEqual(lst[2].name, 'sin')

        comparison = x == lst[0].x
        self.assertTrue(comparison.all())
        comparison = tan == lst[0].y
        self.assertTrue(comparison.all())
        comparison = cos == lst[1].y
        self.assertTrue(comparison.all())
        comparison = sin == lst[2].y
        self.assertTrue(comparison.all())
        PySpectra.display()

        PySpectra.processEventsLoop(1)

        #utils.launchGui()
        print "testPySpectra.testCreateScansByGqes, DONE"
Пример #7
0
def _putData(hsh):
    '''
    a plot is created based on a dictionary 
    the use case: some data are sent pyspMonitor
    '''

    argout = 'n.n.'
    if 'title' in hsh:
        PySpectra.setTitle(hsh['title'])

    try:
        if 'columns' in hsh:
            PySpectra.delete()
            PySpectra.cls()
            argout = utils.createScansByColumns(hsh)
        elif 'gqes' in hsh:
            PySpectra.delete()
            PySpectra.cls()
            try:
                argout = utils.createScansByGqes(hsh)
            except Exception as e:
                print("zmqIfc: %s" % repr(e))
        elif 'images' in hsh:
            for h in hsh['images']:
                PySpectra.Image(**h)
            argout = "done"
        else:
            raise Exception("zmqIfc._putData", "expecting 'columns', 'gqes'")
    except Exception as e:
        argout = "zmqIfc._putData: %s" % repr(e)

    return argout
Пример #8
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()
Пример #9
0
def example_OverlayDoty():
    '''
    create 2 overlaid scans
    '''
    PySpectra.cls()
    PySpectra.delete()
    PySpectra.setTitle("2 Overlay scans, x-axis tick labels show date")
    PySpectra.setWsViewport("DINA5")
    t1 = PySpectra.Scan(name="t1",
                        xMin=0,
                        xMax=10,
                        nPts=101,
                        lineColor='blue',
                        xLabel='Position',
                        yLabel='sin',
                        doty=True)
    t1.y = np.sin(t1.x)
    t2 = PySpectra.Scan("t2",
                        xLabel='Position',
                        yLabel='cos',
                        xMin=0,
                        xMax=10,
                        nPts=101,
                        lineColor='green',
                        doty=True)
    t2.y = np.cos(t2.x)
    t2.overlay = "t1"
    PySpectra.display()
Пример #10
0
def example_CreatePDF():
    '''
    create a pdf file
    '''
    printer = os.getenv("PRINTER")
    if printer is None:
        print(
            "examplecreatePDF: environment variable PRINTER not defined, returning"
        )
        return

    PySpectra.cls()
    PySpectra.delete()

    PySpectra.setTitle("Create PDF file and send it to the printer")
    PySpectra.setWsViewport("DINA5")
    scan = PySpectra.Scan(name='PDF Output',
                          nPts=100,
                          xMin=-1.,
                          xMax=1.,
                          xLabel='Position',
                          yLabel="Counts")

    scan.y = np.sin(scan.x)

    PySpectra.setWsViewport("DINA4")
    PySpectra.display()

    PySpectra.createPDF(flagPrint=True)
    return
Пример #11
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()
Пример #12
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()
Пример #13
0
def example_Create56x3Plots():
    '''
    create 56x3 plots
    '''
    PySpectra.cls()
    PySpectra.delete()
    PySpectra.setTitle("56 x 3 Scans")
    PySpectra.setComment("Display many Scans")
    PySpectra.setWsViewport("DINA4")
    for i in range(56):
        t = PySpectra.Scan(name="t%d_a" % i,
                           lineColor='blue',
                           nPts=200,
                           yLabel='rand')
        t.y = np.random.random_sample((len(t.x), )) * 1000.
        t = PySpectra.Scan(name="t%d_b" % i,
                           lineColor='red',
                           nPts=200,
                           yLabel='rand',
                           overlay="t%d_a" % i)
        t.y = np.random.random_sample((len(t.x), )) * 1000.
        t = PySpectra.Scan(name="t%d_c" % i,
                           lineColor='green',
                           nPts=200,
                           yLabel='rand',
                           overlay="t%d_a" % i)
        t.y = np.random.random_sample((len(t.x), )) * 1000.
    PySpectra.display()
    return
Пример #14
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
Пример #15
0
def example_PlotsWithTextContainer():
    '''
    create 3 scans and a text container
    '''
    PySpectra.cls()
    PySpectra.delete()
    PySpectra.setTitle("here could be a title")
    PySpectra.setComment("this is a comment")
    PySpectra.setWsViewport("DINA5")
    textScan = PySpectra.Scan(name="textContainer", textOnly=True)
    textScan.addText(text="some information", x=0., y=0.95, color='blue')
    textScan.addText(text="and more infos", x=0., y=0.85, color='blue')
    t1 = PySpectra.Scan("t1",
                        lineColor='blue',
                        xLabel='Position',
                        yLabel='sin')
    t1.y = np.sin(t1.x)
    t2 = PySpectra.Scan("t2",
                        xLabel='Position',
                        yLabel='cos',
                        symbol='o',
                        symbolColor='red',
                        symbolSize=5)
    t2.y = np.cos(t2.x)
    t3 = PySpectra.Scan("t3",
                        xLabel='Position',
                        yLabel='tan',
                        symbol='+',
                        lineColor='cyan',
                        symbolColor='green',
                        symbolSize=5)
    t3.y = np.tan(t3.x)
    PySpectra.display()
Пример #16
0
    def testGrid( self): 
        '''
        using showGridX, showGridY
        '''
        print "testMplGraphics.testGrid"
        PySpectra.mtpltlb.graphics.cls()
        PySpectra.delete()
        PySpectra.setTitle( "check grids")

        sinus = PySpectra.Scan( name = 'sinus', 
                                xMin = 0., showGridX = True, xMax = 6.0, nPts = 101, lineColor = 'red')
        cos = PySpectra.Scan( name = 'cos', 
                                xMin = 0., showGridY = True, xMax = 6.0, nPts = 101, lineColor = 'red')
        tan = PySpectra.Scan( name = 'tan', 
                                xMin = 0., showGridY = True, showGridX = True, xMax = 6.0, nPts = 101, lineColor = 'red')
        sinus.y = np.sin( sinus.y)
        cos.y = np.cos( cos.y)
        tan.y = np.tan( tan.y)

        PySpectra.mtpltlb.graphics.display()
        PySpectra.mtpltlb.graphics.display()
        #PySpectra.show()
        PySpectra.mtpltlb.graphics.processEventsLoop( 1)

        print "testMplGraphics.testGrid, DONE"
Пример #17
0
    def testClose( self): 
        '''
        '''
        print "testGraphics.testClose"

        PySpectra.cls()
        PySpectra.delete()
        PySpectra.setTitle( "testing close()")

        sinus = PySpectra.Scan( name = 'sinus', 
                                xMin = 0., xMax = 6.0, nPts = 101, lineColor = 'red', doty = True)
        sinus.y = np.sin( sinus.y)

        PySpectra.display()
        PySpectra.processEventsLoop( 1)

        PySpectra.close()

        PySpectra.cls()
        PySpectra.delete()
        PySpectra.setTitle( "testing close(), again")

        sinus = PySpectra.Scan( name = 'sinus', 
                                xMin = 0., xMax = 6.0, nPts = 101, lineColor = 'red', doty = True)
        sinus.y = np.sin( sinus.y)

        PySpectra.display()
        PySpectra.processEventsLoop( 1)

        print "testGraphics.testClose, DONE"
Пример #18
0
    def testScanningTwoPlots( self): 
        '''
        using setX and setY
        '''
        print "testMplGraphics.testScanningTwoPlots"
        PySpectra.mtpltlb.graphics.cls()
        PySpectra.delete()

        PySpectra.setTitle( "two plots, x-axis not re-scaled")

        sinus = PySpectra.Scan( name = 'sinus', 
                                xMin = 0., xMax = 6.0, nPts = 101, 
                                autoscaleX = False, 
                                lineColor = 'red')
        cosinus = PySpectra.Scan( name = 'cosinus', 
                                  xMin = 0., xMax = 6.0, nPts = 101, 
                                  autoscaleX = False, 
                                  lineColor = 'blue')
        for i in range( sinus.nPts): 
            sinus.setX( i, i/10.)
            sinus.setY( i, math.sin( i/10.))
            cosinus.setX( i, i/10.)
            cosinus.setY( i, math.cos( i/10.))
            PySpectra.mtpltlb.graphics.display( ['sinus', 'cosinus'])
            time.sleep( 0.01)

        print "testMplGraphics.testScanningTwoPlots, DONE"
Пример #19
0
    def testClose( self): 
        '''
        '''
        print "testMplGraphics.testClose"

        PySpectra.mtpltlb.graphics.cls()
        PySpectra.delete()
        PySpectra.setTitle( "check x-axis doty")

        sinus = PySpectra.Scan( name = 'sinus', 
                                xMin = 0., xMax = 6.0, nPts = 101, lineColor = 'red', doty = True)
        sinus.y = np.sin( sinus.y)

        PySpectra.mtpltlb.graphics.display()
        PySpectra.mtpltlb.graphics.processEventsLoop( 1)

        PySpectra.mtpltlb.graphics.close()

        PySpectra.mtpltlb.graphics.cls()
        PySpectra.delete()
        PySpectra.setTitle( "check x-axis doty")

        sinus = PySpectra.Scan( name = 'sinus', 
                                xMin = 0., xMax = 6.0, nPts = 101, lineColor = 'red', doty = True)
        sinus.y = np.sin( sinus.y)

        PySpectra.mtpltlb.graphics.display()
        PySpectra.mtpltlb.graphics.processEventsLoop( 1)

        print "testMplGraphics.testClose, DONE"
Пример #20
0
    def testSetLimits(self):
        print "testPySpectra.testSetLimits"
        PySpectra.cls()
        PySpectra.delete()
        PySpectra.setTitle("test setLimits")
        scan = PySpectra.Scan(
            name='t1',
            xMin=0,
            xMax=10,
            nPts=11,
        )

        self.assertEqual(scan.xMin, 0.)
        self.assertEqual(scan.xMax, 10.)
        self.assertEqual(scan.yMin, 0.)
        self.assertEqual(scan.yMax, 10.)

        scan.xMin = -1.
        scan.xMax = -1.
        scan.yMin = -1.
        scan.yMax = -1.

        scan.setLimits()

        self.assertEqual(scan.xMin, 0.)
        self.assertEqual(scan.xMax, 10.)
        self.assertEqual(scan.yMin, 0.)
        self.assertEqual(scan.yMax, 10.5)
Пример #21
0
def example_ScanningMesh():
    '''    
    '''
    PySpectra.cls()
    PySpectra.delete()

    (xmin, xmax) = (-2., 1)
    (ymin, ymax) = (-1.5, 1.5)
    (width, height) = (20, 20)
    maxiter = 20

    r1 = np.linspace(xmin, xmax, width)
    r2 = np.linspace(ymin, ymax, height)
    n3 = np.zeros((width, height))

    m = PySpectra.Image(name="MandelbrotSet",
                        colorMap='Greys',
                        estimatedMax=20,
                        xMin=xmin,
                        xMax=xmax,
                        width=width,
                        yMin=ymin,
                        yMax=ymax,
                        height=height)

    PySpectra.setTitle("Simulate a mesh scan")
    PySpectra.setWsViewport("DINA5")
    sinus = PySpectra.Scan(name='sinus',
                           xMin=0.,
                           xMax=6.0,
                           nPts=width * height,
                           autoscaleX=False,
                           lineColor='red')
    cosinus = PySpectra.Scan(name='cosinus',
                             xMin=0.,
                             xMax=6.0,
                             nPts=width * height,
                             autoscaleX=False,
                             lineColor='red')

    PySpectra.display()

    (iI, jI) = (0, 0)
    for i in range(sinus.nPts):
        x = float(i) * 6.28 / float(sinus.nPts)
        sinus.setX(i, x)
        cosinus.setX(i, x)
        sinus.setY(i, math.sin(x))
        cosinus.setY(i, math.cos(x))
        res = mandelbrot(r1[iI] + 1j * r2[jI], maxiter)
        m.data[iI][jI] = res
        iI += 1
        if iI == width:
            iI = 0
            jI += 1
        PySpectra.display()
    PySpectra.cls()
    PySpectra.display()
    return
Пример #22
0
    def testWriteReadImage(self):
        print "testPySpectra.testWrite"
        PySpectra.cls()
        PySpectra.delete()

        (xmin, xmax) = (-2., 1)
        (ymin, ymax) = (-1.5, 1.5)
        (width, height) = (200, 200)
        maxiter = 100

        m = PySpectra.Image(name="MandelbrotSet",
                            colorMap='Greys',
                            estimatedMax=maxiter,
                            xMin=xmin,
                            xMax=xmax,
                            width=width,
                            yMin=ymin,
                            yMax=ymax,
                            height=height)

        m.zoomMb(flagDisplay=False)

        ret = PySpectra.write(['MandelbrotSet'])

        PySpectra.cls()
        PySpectra.delete()
        PySpectra.setTitle("create Mandelbrotset; write; read; display")

        self.assertEqual(os.path.exists(ret), True)

        PySpectra.read(ret)

        PySpectra.setTitle("The Mandelbrotset")
        PySpectra.display()
        PySpectra.processEventsLoop(2)

        lst = PySpectra.getGqeList()
        self.assertEqual(len(lst), 1)

        ima = lst[0]
        self.assertEqual(ima.name, "MandelbrotSet")
        self.assertEqual(type(ima), PySpectra.PySpectra.Image)
        self.assertEqual(ima.width, width)
        self.assertEqual(ima.height, height)

        self.assertEqual(ima.xMin, xmin)
        self.assertEqual(ima.xMax, xmax)
        self.assertEqual(ima.yMin, ymin)
        self.assertEqual(ima.yMax, ymax)

        ima.zoomMb(targetIX=50, targetIY=100, flagDisplay=False)
        PySpectra.display()
        PySpectra.processEventsLoop(1)

        ima.zoomMb(targetIX=50, targetIY=100, flagDisplay=False)
        PySpectra.display()
        PySpectra.processEventsLoop(1)

        return
Пример #23
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
Пример #24
0
def example_LogXScale():
    PySpectra.cls()
    PySpectra.delete()
    PySpectra.setWsViewport("DINA5")
    PySpectra.setTitle("log x-scale")
    t1 = PySpectra.Scan(name="t1",
                        xMin=0.01,
                        xMax=100.,
                        nPts=101,
                        lineColor='blue',
                        xLabel='Position',
                        yLabel='signal',
                        yLog=False,
                        xLog=True)
    PySpectra.display()
Пример #25
0
def example_Create22Plots():
    '''
    create 22 plots
    '''
    PySpectra.cls()
    PySpectra.delete()
    PySpectra.setTitle("22 Scans")
    PySpectra.setComment("and a comment")
    PySpectra.setWsViewport("DINA4")
    for i in range(22):
        t = PySpectra.Scan(name="t%d" % i,
                           lineColor='blue',
                           xLabel='Position',
                           yLabel='rand')
        t.y = np.random.random_sample((len(t.x), )) * 1000.
    PySpectra.display()
Пример #26
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
Пример #27
0
def _setTitle(line):
    '''
    set the title of the whole plot
    '''
    argout = "done"
    if not PySpectra.setTitle(line):
        argout = "trouble from PySpectra.setTitle()"
    return argout
Пример #28
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
Пример #29
0
def example_FSA_StepRealData():
    '''
    step function from P23 data
    '''

    data = [
        "-2.4298828125 37681148972.8", "-2.4048828125 38401871477.4",
        "-2.3798828125 38288686270.4", "-2.3548828125 39185991728.4",
        "-2.3298828125 38456517187.0", "-2.3048828125 39194360929.6",
        "-2.2798828125 37675200637.4", "-2.2548828125 38996830621.8",
        "-2.2298828125 38551627446.6", "-2.2048828125 37100623732.0",
        "-2.1798828125 36825602737.3", "-2.1548828125 34963557105.2",
        "-2.1298828125 32163944722.6", "-2.1048828125 29299318167.0",
        "-2.0798828125 27794769897.0", "-2.0548828125 26176477795.0",
        "-2.0298828125 24897579745.6", "-2.0048828125 22452187722.0",
        "-1.9798828125 20009478027.1", "-1.9548828125 17694863875.7",
        "-1.9298828125 15497083354.3", "-1.9048828125 12901608052.8",
        "-1.8798828125 10673203037.1", "-1.8548828125 7980209447.64",
        "-1.8298828125 5662638085.9", "-1.8048828125 3098076234.4",
        "-1.7798828125 1296338340.95", "-1.7548828125 708398132.123",
        "-1.7298828125 592764964.744", "-1.7048828125 252664555.849",
        "-1.6798828125 81626386.5509", "-1.6548828125 971789.900217",
        "-1.6298828125 3887184.77659", "-1.6048828125 0.0",
        "-1.5798828125 0.0", "-1.5548828125 3887285.48112",
        "-1.5298828125 0.0", "-1.5048828125 4858729.21921",
        "-1.4798828125 2915256.41246", "-1.4548828125 0.0", "-1.4298828125 0.0"
    ]

    xArr = []
    yArr = []
    for line in data:
        (x, y) = line.split(' ')
        xArr.append(float(x))
        yArr.append(float(y))

    PySpectra.cls()
    PySpectra.delete()
    PySpectra.setTitle("Real data")
    PySpectra.setComment(
        "See that FSA(stepm) failes but FSA(stepmssa) produces a result")
    PySpectra.setWsViewport("DINA5")

    g = PySpectra.Scan(name='realdata', x=xArr, y=yArr)

    PySpectra.display()
    return
Пример #30
0
def example_PlotWithSeveralTexts():
    '''
    create 1 scan with several texts
    '''
    PySpectra.cls()
    PySpectra.delete()
    PySpectra.setTitle("Here could be the title")
    PySpectra.setComment("comment: Sinus(), shifted up by 1.1")
    PySpectra.setWsViewport("DINA5")
    t1 = PySpectra.Scan(name="t1",
                        xMin=0.01,
                        xMax=10.,
                        nPts=101,
                        lineColor='blue',
                        xLabel='Position',
                        yLabel='sin')
    t1.addText(text="a left/center aligned text",
               x=0.05,
               y=0.8,
               hAlign='left',
               vAlign='center')
    t1.addText(text="a right/centeraligned text",
               x=0.95,
               y=0.8,
               hAlign='right',
               vAlign='center')
    t1.addText(text="a center/top aligned text, red, fontSize: 10",
               x=0.5,
               y=0.5,
               hAlign='center',
               vAlign='top',
               fontSize=10,
               color='red')
    t1.addText(text="a center/center aligned text",
               x=0.5,
               y=0.5,
               hAlign='center',
               vAlign='center')
    t1.addText(text="a center/bottom aligned text",
               x=0.5,
               y=0.5,
               hAlign='center',
               vAlign='bottom')
    t1.y = np.sin(t1.x) + 1.001
    PySpectra.display()