示例#1
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
示例#2
0
    def testLissajous( self):
        '''

        '''
        print "testGraphics.testLissayous"

        PySpectra.cls()
        PySpectra.delete()
        scan = PySpectra.Scan( name = 'Lissajous', nPts = 1000, xMin = -1., xMax = 1.)

        x  = np.linspace( 0., 6.5, 1000)
        y  = np.linspace( 0., 6.5, 1000)

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

        PySpectra.display()

        startTime = time.time()
        for i in range( 500):
            x = x + 0.005
            scan.plotDataItem.setData(np.cos( x), np.sin( y))
            PySpectra.processEvents()

        diffTime = time.time() - startTime

        self.assertLess( diffTime, 20.)
        print "testGraphics.testLissajous, DONE"
示例#3
0
def createHardCopy(printer=None, flagPrint=False, format='DINA4'):
    '''
    create postscript/pdf file and send it to the printer
    '''
    fName = None
    if spectraInstalled and useSpectra:
        Spectra.gra_command(" set 0.1/border=1")
        if flagPrint:
            if printer is None:
                raise ValueError(
                    "graPyspIfc.createHardCopy: flagPrint == True but no printer"
                )

            Spectra.gra_command(
                " postscript/%s/redisplay/nolog/nocon/print/lp=%s" %
                (format, printer))
        else:
            Spectra.gra_command(" postscript/%s/redisplay/nolog/nocon/print" %
                                (format))
        Spectra.gra_command(" set 0.1/border=0")
        Spectra.gra_command(" postscript/redisplay/nolog/nocon/print/lp=%s" %
                            printer)
    else:
        fName = PySpectra.createPDF(flagPrint=flagPrint, format=format)
        #
        # necessary to bring pqt and mpl again in-sync, mind lastIndex
        #
        PySpectra.cls()
        PySpectra.display()

    return fName
示例#4
0
    def testDisplayTwo( self): 

        print "testGraphics.testDisplayTwo"

        PySpectra.cls()
        PySpectra.delete()

        sinus = PySpectra.Scan( name = 'sinus', xMin = 0., 
                                xMax = 6.0, nPts = 101, dType = np.float64,
                                lineWidth = 5., 
                                lineColor = 'red', lineStyle = 'dashed')
        sinus.y = np.sin( sinus.y)

        cosinus = PySpectra.Scan( name = "cosinus", xMin = 0., 
                                  xMax = 6.0, nPts = 101, dType = np.float64,
                                  lineWidth = 3., 
                                  lineColor = 'blue', 
                                  lineStyle = 'dotted')
        cosinus.y = np.cos( cosinus.y)

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

        print "testGraphics.testDisplayTwo, DONE"
示例#5
0
    def testFastDisplay_v2( self):
        '''
        version 2: directly use the plotDataItem.setData() function
        '''
        print "testGraphics.testDisplay_v2"

        PySpectra.cls()
        PySpectra.delete()
        scan1 = PySpectra.Scan( name = 't1', nPts = 1000, yMin = -1., yMax = 1.)
        scan2 = PySpectra.Scan( name = 't2', nPts = 1000, yMin = -1., yMax = 1.)

        data = np.random.normal(size=(10,1000))
        x  = np.linspace( 0., 10., 1000)
        ptr = 0

        scan1.x = x
        scan2.x = x
        
        scan1.y = data[0]
        scan2.y = data[0]
        PySpectra.display()

        startTime = time.time()
        for i in range( 200):
            scan1.plotDataItem.setData(x, data[ptr%10])
            scan2.plotDataItem.setData(x, data[ptr%10])
            ptr += 1
            PySpectra.processEvents()

        diffTime = time.time() - startTime

        self.assertLess( diffTime, 7.)
        self.assertGreater( diffTime, 1.5)
        print "testGraphics.testDisplay_v2, DONE"
示例#6
0
def example_GaussManyOverlay():
    '''
    gauss plot
    '''
    PySpectra.cls()
    PySpectra.delete()
    PySpectra.setWsViewport("DINA5")
    g = PySpectra.Scan(name="gauss", xMin=-10., xMax=10., nPts=101)
    #mu = 0.
    #sigma = 1.
    #g.y = 1/(sigma*np.sqrt(2.*np.pi))*np.exp( -(g.y-mu)**2/(2*sigma**2))
    mu1 = 0.
    sigma1 = 1.
    mu2 = 6.5
    sigma2 = 1.2
    g.y = 1./(sigma1*np.sqrt(2.*np.pi))*np.exp( -(g.y-mu1)**2/(2*sigma1**2)) + \
          2./(sigma2*np.sqrt(2.*np.pi))*np.exp( -(g.y-mu2)**2/(2*sigma2**2))
    g.autoscaleX = False
    g.autoscaleY = False
    g.xMax = 11
    g.xMin = -4
    g.yMin = 0
    g.yMax = 2
    for i in range(1, 50):  # don't want i == 0
        gqe = PySpectra.Scan(name="gauss%d" % i, xMin=-5., xMax=5., nPts=101)
        gqe.x = g.x + 0.02 * i
        gqe.y = g.y + 0.02 * i
        PySpectra.overlay("gauss%d" % i, "gauss")
        gqe.useTargetWindow = True

    PySpectra.display()
    return
示例#7
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()
示例#8
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"
示例#9
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)
示例#10
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"
示例#11
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"
示例#12
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"
示例#13
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"
示例#14
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
示例#15
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
示例#16
0
    def test_create(self):

        print "testIFC.test_create"

        PySpectra.cls()
        PySpectra.delete()
        PySpectra.command("create s1")
        lst = PySpectra.getGqeList()
        self.assertEqual(len(lst), 1)
        self.assertEqual(lst[0].name, "s1")
        PySpectra.command("display s1")

        PySpectra.command("derivative s1")
        lst = PySpectra.getGqeList()
        self.assertEqual(lst[1].name, "s1_derivative")
        self.assertEqual(len(lst), 2)

        PySpectra.command("antiderivative s1")
        lst = PySpectra.getGqeList()
        self.assertEqual(lst[2].name, "s1_antiderivative")
        self.assertEqual(len(lst), 3)

        PySpectra.command("delete s1")
        PySpectra.command("delete s1_derivative")
        PySpectra.command("delete s1_antiderivative")
        lst = PySpectra.getGqeList()
        self.assertEqual(len(lst), 0)
        print "testIFC.test_create DONE"

        return
示例#17
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()
示例#18
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
示例#19
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()
示例#20
0
def example_ImageMB():

    PySpectra.setWsViewport('DINA5S')

    PySpectra.cls()
    PySpectra.delete()

    (xmin, xmax) = (-2., 0.5)
    (ymin, ymax) = (-1.25, 1.25)
    (width, height) = (750, 750)
    maxiter = 512

    m = PySpectra.Image(name="MandelbrotSet",
                        flagAxes=True,
                        maxIter=maxiter,
                        xMin=xmin,
                        xMax=xmax,
                        width=width,
                        yMin=ymin,
                        yMax=ymax,
                        height=height)
    m.flagZoomMbSlow = False
    m.zoomMb()
    PySpectra.cls()
    PySpectra.display()
    return
示例#21
0
    def testScanningTwoPlots( self): 
        '''
        using setX and setY
        '''
        print "testGraphics.testScanningTwoPlots"
        PySpectra.cls()
        PySpectra.delete()

        PySpectra.setTitle( "two plot, x-axis is 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.display( ['sinus', 'cosinus'])
            time.sleep( 0.01)

        print "testGraphics.testScanningTwoPlots, DONE"
示例#22
0
def example_ImageRandom():

    import random

    PySpectra.setWsViewport('DINA5S')

    PySpectra.cls()
    PySpectra.delete()

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

    r1 = np.linspace(xmin, xmax, width)
    r2 = np.linspace(ymin, ymax, height)
    n3 = np.empty((width, height))
    for i in range(width):
        for j in range(height):
            n3[i, j] = i + random.random() * j + 100.

    m = PySpectra.Image(name="ImageRandom",
                        data=n3,
                        xMin=xmin,
                        xMax=xmax,
                        width=width,
                        yMin=ymin,
                        yMax=ymax,
                        height=height,
                        xLabel="x-Axis",
                        yLabel="y-Axis")

    PySpectra.cls()
    PySpectra.display()
    return
示例#23
0
    def testFastDisplay_v1( self):
        '''
        version 1: set the scan data and call display
        '''

        print "testGraphics.testDisplay_v1"

        PySpectra.cls()
        PySpectra.delete()
        scan1 = PySpectra.Scan( name = 't1', nPts = 100, yMin = -1., yMax = 1.)
        scan2 = PySpectra.Scan( name = 't2', nPts = 100, yMin = -1., yMax = 1.)

        PySpectra.display()

        data = np.random.normal(size=(10,100))
        x  = np.linspace( 0., 10., 100)
        ptr = 0

        scan1.x = x
        scan2.x = x
        
        startTime = time.time()
        for i in range( 100):
            PySpectra.cls()
            scan1.y = data[ptr%10]
            scan2.y = data[ptr%10]
            PySpectra.display()
            ptr += 1
            PySpectra.processEvents()

        diffTime = time.time() - startTime
        self.assertLess( diffTime, 8.)
        self.assertGreater( diffTime, 3.)

        print "testGraphics.testDisplay_v1, DONE"
示例#24
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()
示例#25
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"
示例#26
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()
示例#27
0
    def test_ssa(self):
        '''
        overlay 2 scans
        '''
        PySpectra.cls()
        PySpectra.delete()
        g = PySpectra.Scan(name="gauss",
                           xMin=-5.,
                           xMax=5.,
                           nPts=101,
                           lineColor='red')
        mu = 0.
        sigma = 1.
        g.y = 1 / (sigma * np.sqrt(2. * np.pi)) * np.exp(-(g.y - mu)**2 /
                                                         (2. * sigma**2))

        hsh = HasyUtils.ssa(g.x, g.y)
        self.assertEqual(hsh['status'], 1)
        self.assertEqual(hsh['midpoint'], 0.)
        self.assertAlmostEqual(hsh['l_back'], 2.521e-5)
        self.assertAlmostEqual(hsh['r_back'], 2.521e-5)
        self.assertAlmostEqual(hsh['integral'], 0.9997473505)
        self.assertEqual(hsh['reason'], 0)
        self.assertEqual(hsh['peak_x'], 0)
        self.assertAlmostEqual(hsh['peak_y'], 0.3989170740)
        self.assertAlmostEqual(hsh['cms'], 1.2989313e-16)
        self.assertAlmostEqual(hsh['fwhm'], 2.35522977)
        self.assertAlmostEqual(hsh['back_int'], 0.0002520637)

        print repr(hsh)
示例#28
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
示例#29
0
def _cls(line):
    '''
    clears the graphics screen
    '''
    PySpectra.cls()

    return "done"
示例#30
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