def testGf(self):
        importOp("Gf")
        from math import pi, exp
        v = Vec(1025, False)
        v.ones()
        dwell = 1.0 / 1000.0
        v.setDwellTime(dwell)

        gf = 0.5
        gfs = 0.1
        fPoint = 1.0

        op = Gf(gf, gfs, fPoint)
        op.eval(v)
 def genSpectrum(self, size=1024):
     importOp("Gen")
     importOp("Ft")
     v = Vec(size, True)
     sw = 1000.0
     dwell = 1.0 / sw
     v.setDwellTime(dwell)
     freq = sw / 4.0
     lw = 10.0
     amp = 100
     ph = 0.0
     op = Gen(freq, lw, amp, ph)
     op.eval(v)
     op = Ft(False, False)
     op.eval(v)
     return v
    def testExpdInverse(self):
        importOp("Expd")
        from math import pi, exp
        v = Vec(1025, False)
        v.ones()
        dwell = 1.0 / 1000.0
        v.setDwellTime(dwell)

        lb = 2.0
        fPoint = 1.0

        op = Expd(lb, fPoint, False)
        op.eval(v)
        iop = op.getInverseOp()
        iop.eval(v)
        self.isAlmostEqualTo(v.getList(), 1.0)
    def testExpd(self):
        importOp("Expd")
        from math import pi, exp
        v = Vec(1025, False)
        v.ones()
        dwell = 1.0 / 1000.0
        v.setDwellTime(dwell)

        lb = 2.0
        fPoint = 1.0
        op = Expd(lb, fPoint, False)
        op.eval(v)
        decay = pi * lb

        for index, val in enumerate(v.getList()):
            testVal = exp(-1.0 * index * decay * dwell)
            self.assertAlmostEqual(val, testVal)
    def testGmbInverse(self):
        importOp("Gmb")
        from math import pi, exp
        v = Vec(1025, False)
        v.ones()
        dwell = 1.0 / 1000.0
        v.setDwellTime(dwell)

        gb = 0.1
        lb = 2.0
        fPoint = 1.0

        op = Gmb(gb, lb, fPoint)
        op.eval(v)
        iop = op.getInverseOp()
        iop.eval(v)

        self.isAlmostEqualTo(v.getList(), 1.0)
    def testGfInverse(self):
        importOp("Gf")
        from math import pi, exp
        v = Vec(1025, False)
        v.ones()
        dwell = 1.0 / 1000.0
        v.setDwellTime(dwell)

        gf = 0.5
        gfs = 0.1
        fPoint = 1.0

        op = Gf(gf, gfs, fPoint)
        op.eval(v)
        iop = op.getInverseOp()
        iop.eval(v)

        self.isAlmostEqualTo(v.getList(), 1.0)
    def testGen(self):
        importOp("Gen")
        size = 1024
        v = Vec(size, True)
        sw = 1000.0
        dwell = 1.0 / sw
        v.setDwellTime(dwell)
        freq = sw / 4.0
        lw = 10.0
        amp = 100
        ph = 0.0
        op = Gen(freq, lw, amp, ph)
        op.eval(v)
        values = v.getList()
        # check amplitude is amp
        self.assertAlmostEqual(values[0], amp)

        v.zeros()
        op = Gen(freq, lw, amp, 90.0)
        op.eval(v)
        values = v.getList()
        # check imaginary  amplitude is amp when phase is 90
        self.assertAlmostEqual(values[0].imag, amp)

        v.zeros()
        op = Gen(freq, lw, amp, 0.0)
        op.eval(v)
        v.ft()
        peakCenter = size * 3 / 4
        values = v.getList()
        # check if expected peak position is max
        self.assert_(v[peakCenter - 1].real < v[peakCenter].real)
        self.assert_(v[peakCenter + 1].real < v[peakCenter].real)
        # check if peak is symmetrical
        self.assertAlmostEqual(values[peakCenter - 2].real,
                               values[peakCenter + 2].real)

        v.zeros()
        op = Gen(freq, lw, amp, 0.0)
        op.eval(v)
        op.eval(v)
        values = v.getList()
        # check if additive (successive calls don't zero first)
        self.assertAlmostEqual(values[0].real, 2.0 * amp)
 def testIft(self):
     importOp("Ft")
     importOp("Ift")
     importOp("Gen")
     size = 1024
     v = Vec(size, True)
     vSave = Vec(size, True)
     sw = 1000.0
     dwell = 1.0 / sw
     v.setDwellTime(dwell)
     op = Gen(1000.0, 10.0, 100.0, 0.0)
     op.eval(v)
     v.copy(vSave)
     op = Ft(False, False)
     op.eval(v)
     op = Ift()
     op.eval(v)
     v.subtract(vSave)
     self.isAlmostEqualTo(v.getList(), 0.0)