Esempio n. 1
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()
Esempio n. 2
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()
Esempio n. 3
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
Esempio n. 4
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()
Esempio n. 5
0
def _overlay(line):
    '''
    overlay <s1> <s2>
      s1 is plotted in the viewport of s2
    '''
    lst = line.split(' ')
    if len(lst) != 2:
        raise ValueError("ifc.overlay: expecting two scan names")
    PySpectra.overlay(lst[0], lst[1])
    return "done"
Esempio n. 6
0
def sl2(line):
    '''
    scan list 1, creates some scans, fill them with data
    '''
    PySpectra.cls()
    PySpectra.delete()
    t1 = PySpectra.Scan( name = "t1", color = 'blue', yLabel = 'sin')
    t1.y = np.sin( t1.x)
    t2 = PySpectra.Scan( "t2", yLabel = 'cos')
    t2.y = np.cos( t2.x)
    t3 = PySpectra.Scan( name = "t3", color = 'green', yLabel = 'tan')
    t3.y = np.tan( t3.x)
    t4 = PySpectra.Scan( name = "t4", color = 'cyan', yLabel = 'random')
    t4.y = np.random.random_sample( (len( t4.y), ))
    t5 = PySpectra.Scan( name = "t5", color = 'magenta', yLabel = 'x**2')
    t5.y = t5.x * t5.x
    PySpectra.overlay( 't5', 't3')
Esempio n. 7
0
    def testOverlay2BothLog( self):
        '''

        '''
        print "testGrphics.testOverly2BothLog"

        PySpectra.mtpltlb.graphics.cls()
        PySpectra.delete()
        PySpectra.setTitle( "2 Overlay Scans, with log scale")
        g1 = PySpectra.Scan( name = "gauss", xMin = -5., xMax = 5., yLog = True, nPts = 101, lineColor = 'red')
        mu = 0.
        sigma = 1.
        g1.y = 1/(sigma*np.sqrt(2.*np.pi))*np.exp( -(g1.y-mu)**2/(2.*sigma**2))
        g2 = PySpectra.Scan( name = "gauss2", xMin = -5., xMax = 5., yMin = 0.001, yLog = True, 
                             yMax = 1., nPts = 101, lineColor = 'green')
        mu = 0.5
        sigma = 1.2
        g2.y = 1/(sigma*np.sqrt(2.*np.pi))*np.exp( -(g2.y-mu)**2/(2.*sigma**2))
        
        PySpectra.overlay( "gauss2", "gauss")
        PySpectra.mtpltlb.graphics.display()
        PySpectra.mtpltlb.graphics.processEventsLoop( 1)
Esempio n. 8
0
def example_Create5Plots():
    '''
    create 5 scans, different colors, demonstrate overlay feature
    '''
    PySpectra.cls()
    PySpectra.delete()
    PySpectra.setTitle("5 Scans, t5 is overlaid to t3")
    PySpectra.setComment("Notice that sin has autoscalY == False")
    PySpectra.setWsViewport("DINA5")
    t1 = PySpectra.Scan(name="t1",
                        lineColor='blue',
                        yLabel='sin',
                        yMin=-2,
                        yMax=2,
                        autoscaleY=False)
    t1.y = np.sin(t1.x)
    t2 = PySpectra.Scan("t2", xLabel='Position', yLabel='cos', symbol='+')
    t2.y = np.cos(t2.x)
    t3 = PySpectra.Scan(name="t3",
                        lineColor='green',
                        xLabel='Position',
                        yLabel='tan')
    t3.y = np.tan(t3.x)
    t4 = PySpectra.Scan(name="t4",
                        lineColor='NONE',
                        xLabel='Position',
                        yLabel='random',
                        symbol='+',
                        symbolColor='CYAN')
    t4.y = np.random.random_sample((len(t4.y), ))
    t5 = PySpectra.Scan(name="t5",
                        lineColor='magenta',
                        xLabel='Position',
                        yLabel='x**2')
    t5.y = t5.x * t5.x
    PySpectra.overlay('t5', 't3')
    PySpectra.display()
Esempio n. 9
0
    def testDerivativeAntiDerivative( self):

        print "testCalc.testDerivativeAntiDerivative"

        PySpectra.cls()
        PySpectra.delete()
        scan = PySpectra.Scan( name = "t1", xMin = 0., xMax = 10.0, nPts = 201)
        scan.y = np.sin( scan.y)
        derivative = calc.derivative( name = scan.name, nameNew = "t1_d")
        stamm = calc.antiderivative( name = derivative.name, nameNew = "t1_ad")

        self.assertEqual( len( scan.y), len( stamm.y))
        self.assertEqual( len( scan.x), len( stamm.x))
        
        for i in range( len( scan.y)):
            self.assertEqual( scan.x[i], stamm.x[i])
        
        diff = 0.
        for i in range( len( scan.y) - 1):
            diff = diff + math.fabs( scan.y[i] - stamm.y[i])

        self.assertLess( diff, 0.08)

        stamm.lineColor = 'blue'
        PySpectra.delete( "t1_d")

        PySpectra.overlay( "t1_ad", "t1") 

        PySpectra.cls()
        PySpectra.display()

        #PySpectra.launchGui()
        PySpectra.processEventsLoop( 3)

        print "testCalc.testDerivativeAntiDerivative, DONE"

        return