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

        graPyspIfc.setSpectra(False)

        graPyspIfc.cls()
        graPyspIfc.delete()

        scan = graPyspIfc.Scan(name="s1", lineColor="red", nPts=201)
        self.assertEqual(scan.xMin, 0.)
        self.assertEqual(scan.xMax, 10.)
        self.assertEqual(scan.lineColor, "red")
        self.assertEqual(scan.nPts, 201)
        scan.display()

        PySpectra.processEventsLoop(1)

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

        graPyspIfc.setSpectra(True)

        graPyspIfc.cls()
        graPyspIfc.delete()

        scan = graPyspIfc.Scan(name="s1", lineColor="blue", nPts=201)

        self.assertEqual(scan.xMin, 0.)
        self.assertEqual(scan.xMax, 10.)
        self.assertEqual(scan.lineColor, "blue")
        self.assertEqual(scan.nPts, 201)
        scan.display()
        time.sleep(1)
        graPyspIfc.close()
Пример #2
0
    def testFillScan(self):

        graPyspIfc.setSpectra(False)

        graPyspIfc.cls()
        graPyspIfc.delete()

        scan = graPyspIfc.Scan(name="s1", color="blue", nPts=101)

        scan.y = numpy.random.normal(size=(101))
        scan.x = numpy.linspace(0., 10., 101)

        scan.display()
        PySpectra.processEventsLoop(1)

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

        graPyspIfc.setSpectra(True)

        graPyspIfc.cls()
        graPyspIfc.delete()

        scan = graPyspIfc.Scan(name="s1", color="blue", nPts=101)

        scan.y = numpy.random.normal(size=(101))
        scan.x = numpy.linspace(0., 10., 101)

        scan.display()
        time.sleep(1)

        graPyspIfc.close()
Пример #3
0
    def testWrite(self):

        print("testGraPyspIfc.testWrite")

        graPyspIfc.cls()
        graPyspIfc.delete()

        graPyspIfc.setSpectra(False)

        (xMin, xMax, nPts) = (0., 10., 20)
        x = numpy.linspace(xMin, xMax, nPts)
        y = numpy.random.random_sample(nPts)

        rand = graPyspIfc.Scan(name="rand",
                               lineColor='blue',
                               x=x,
                               y=y,
                               nPts=nPts)

        graPyspIfc.write(names="rand")
        graPyspIfc.close()

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

        graPyspIfc.setSpectra(True)

        (xMin, xMax, nPts) = (0., 10., 20)
        x = numpy.linspace(xMin, xMax, nPts)
        y = numpy.random.random_sample(nPts)

        rand = graPyspIfc.Scan(name="rand",
                               lineColor='blue',
                               x=x,
                               y=y,
                               nPts=nPts)

        with self.assertRaises(ValueError) as context:
            graPyspIfc.write()
        #print("testSetXY: %s" %  repr( context.exception))
        self.assertTrue(
            "graPyspIfc.write: expecting a string containing the name" in
            context.exception)

        with self.assertRaises(ValueError) as context:
            graPyspIfc.write(["rand"])
        #print("testSetXY: %s" %  repr( context.exception))
        self.assertTrue(
            "graPyspIfc.write: input must no be a list" in context.exception)

        scan = graPyspIfc.getGqe("rand")
        self.assertEqual(scan, 1)
        graPyspIfc.write("rand")

        graPyspIfc.close()

        print("testGraPyspIfc.testMisc DONE")

        return
Пример #4
0
    def testDelete(self):

        print("testGraPyspIfc.testDelete")
        graPyspIfc.setSpectra(False)

        graPyspIfc.cls()
        graPyspIfc.delete()

        (xMin, xMax, nPts) = (0., 10., 20)
        x = numpy.linspace(xMin, xMax, nPts)
        y = numpy.random.random_sample(nPts)

        rand = graPyspIfc.Scan(name="sinus",
                               lineColor='blue',
                               x=x,
                               y=y,
                               nPts=nPts)

        scan = graPyspIfc.getGqe("sinus")
        self.assertEqual(scan.name, "sinus")

        graPyspIfc.deleteScan(rand)

        scan = graPyspIfc.getGqe("sinus")
        self.assertEqual(scan, None)

        graPyspIfc.close()

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

        graPyspIfc.setSpectra(True)

        (xMin, xMax, nPts) = (0., 10., 20)
        x = numpy.linspace(xMin, xMax, nPts)
        y = numpy.random.random_sample(nPts)

        rand = graPyspIfc.Scan(name="sinus",
                               lineColor='blue',
                               x=x,
                               y=y,
                               nPts=nPts)

        scan = graPyspIfc.getGqe("sinus")
        self.assertEqual(scan, 1)

        graPyspIfc.deleteScan(rand)

        scan = graPyspIfc.getGqe("sinus")
        self.assertEqual(scan, 0)

        graPyspIfc.close()

        print("testGraPyspIfc.testDelete DONE")

        return
Пример #5
0
    def testSinusScan(self):

        graPyspIfc.setSpectra(False)

        graPyspIfc.cls()
        graPyspIfc.delete()
        sinus = graPyspIfc.Scan(name="sinus",
                                lineColor='blue',
                                xMin=-5,
                                xMax=5.,
                                yMin=-1.5,
                                yMax=1.5,
                                nPts=21,
                                yLabel='sin')

        sinus.y = numpy.sin(sinus.x)

        sinus.display()
        self.assertEqual(sinus.getCurrent(), 20)
        PySpectra.processEventsLoop(1)

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

        graPyspIfc.setSpectra(True)

        graPyspIfc.cls()
        graPyspIfc.delete()

        sinus = graPyspIfc.Scan(name="sinus",
                                lineColor='blue',
                                xMin=-5,
                                xMax=5.,
                                yMin=-1.5,
                                yMax=1.5,
                                nPts=21,
                                yLabel='sin')

        sinus.y = numpy.sin(sinus.x)

        sinus.display()

        time.sleep(2)

        self.assertEqual(sinus.getCurrent(), 20)

        graPyspIfc.close()
Пример #6
0
    def testCreateHardCopy(self):

        print("testGraPyspIfc.testCreateHardCopy")
        graPyspIfc.setSpectra(False)

        graPyspIfc.cls()
        graPyspIfc.delete()

        (xMin, xMax, nPts) = (0., 10., 20)
        x = numpy.linspace(xMin, xMax, nPts)
        y = numpy.random.random_sample(nPts)

        rand = graPyspIfc.Scan(name="sinus",
                               lineColor='blue',
                               x=x,
                               y=y,
                               nPts=nPts)

        graPyspIfc.createHardCopy()
        graPyspIfc.createHardCopy(printer='hasps01', flagPrint=True)

        graPyspIfc.close()

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

        graPyspIfc.setSpectra(True)

        (xMin, xMax, nPts) = (0., 10., 20)
        x = numpy.linspace(xMin, xMax, nPts)
        y = numpy.random.random_sample(nPts)

        rand = graPyspIfc.Scan(name="sinus",
                               lineColor='blue',
                               x=x,
                               y=y,
                               nPts=nPts)

        graPyspIfc.createHardCopy()
        graPyspIfc.createHardCopy(printer='hasps01', flagPrint=True)

        graPyspIfc.close()

        print("testGraPyspIfc.testCreateHardCopy DONE")

        return
Пример #7
0
    def readMCAs(self):
        for mca in self.selectedMCAs:
            mca['proxy'].read()
            if 'scanGQE' in mca:
                if len(mca['scanGQE'].x) != mca['proxy'].DataLength:
                    graPyspIfc.deleteScan(mca['scanGQE'])
                    mca['scanGQE'] = graPyspIfc.Scan(name=mca['name'],
                                                     y=mca['proxy'].data)
                    graPyspIfc.display()
                else:
                    mca['scanGQE'].smartUpdateDataAndDisplay(
                        y=numpy.copy(mca['proxy'].data))
            else:
                mca['scanGQE'] = graPyspIfc.Scan(name=mca['name'],
                                                 y=mca['proxy'].data)
                graPyspIfc.display()

        return
Пример #8
0
    def testReUse(self):

        graPyspIfc.setSpectra(False)

        graPyspIfc.cls()
        graPyspIfc.delete()

        (xMin, xMax, nPts) = (0., 10., 20)
        x = numpy.linspace(xMin, xMax, nPts)
        y = numpy.random.random_sample(nPts)

        rand = graPyspIfc.Scan(name="sinus",
                               lineColor='blue',
                               x=x,
                               y=y,
                               nPts=nPts)

        graPyspIfc.setComment("using normal update")

        for i in range(5):
            rand.y = numpy.random.random_sample(len(x))
            graPyspIfc.cls()
            graPyspIfc.display()
            PySpectra.processEventsLoop(1)

        graPyspIfc.setComment("using smart update")
        graPyspIfc.cls()
        graPyspIfc.display()

        for i in range(100):
            rand.smartUpdateDataAndDisplay(y=numpy.random.random_sample(nPts))

        graPyspIfc.setComment("")

        graPyspIfc.close()

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

        graPyspIfc.setSpectra(True)

        graPyspIfc.cls()
        graPyspIfc.delete()

        (xMin, xMax, nPts) = (0., 10., 20)
        x = numpy.linspace(xMin, xMax, nPts)
        y = numpy.random.random_sample(nPts)

        rand = graPyspIfc.Scan(name="sinus",
                               lineColor='blue',
                               x=x,
                               y=y,
                               nPts=nPts)

        for i in range(10):
            rand.smartUpdateDataAndDisplay(y=numpy.random.random_sample(nPts))
            time.sleep(0.5)

        graPyspIfc.close()

        return