Ejemplo n.º 1
0
    def setUp(self):
        tfile = open(TESTA_T7, "r")
        tdata = t7data.readFromImpactFile(tfile)
        tfile.close()

        (edata, hdata) = t7data.convertToFMData(tdata)

        efile = open(TESTB_E_DAT, "w")
        fmdata.writeToDatFile(edata, efile, field="E", punits="mm", funits="V/m", pscale=1000, fscale=(1.0/2.2))
        efile.close()

        hfile = open(TESTB_H_DAT, "w")
        fmdata.writeToDatFile(hdata, hfile, field="H", punits="mm", funits="A/m", pscale=1000, fscale=(1.0/2.2))
        hfile.close()

        efileA = open(TESTA_E_DAT, "r")
        self.edataA = fmdata.readFromDatFile(efileA, pscale=0.001, fscale=2.2)
        efileA.close()

        hfileA = open(TESTA_H_DAT, "r")
        self.hdataA = fmdata.readFromDatFile(hfileA, pscale=0.001, fscale=2.2)
        hfileA.close()

        efileB = open(TESTB_E_DAT, "r")
        self.edataB = fmdata.readFromDatFile(efileB, pscale=0.001, fscale=2.2)
        efileB.close()

        hfileB = open(TESTB_H_DAT, "r")
        self.hdataB = fmdata.readFromDatFile(hfileB, pscale=0.001, fscale=2.2)
        hfileB.close()
Ejemplo n.º 2
0
    def setUp(self):
        efile = open(TESTA_E_DAT, "r")
        edata = fmdata.readFromDatFile(efile, pscale=0.001, fscale=2.2)
        efile.close()

        hfile = open(TESTA_H_DAT, "r")
        hdata = fmdata.readFromDatFile(hfile, pscale=0.001, fscale=2.2)
        hfile.close()

        tdata = t7data.convertFromFMData(edata, hdata)

        tfile = open(TESTB_T7, "w")
        t7data.writeToImpactFile(tdata, tfile)
        tfile.close()

        tfileA = open(TESTA_T7, "r")
        self.tdataA = t7data.readFromImpactFile(tfileA)
        tfileA.close()

        tfileB = open(TESTB_T7, "r")
        self.tdataB = t7data.readFromImpactFile(tfileB)
        tfileB.close()
    def test_convertFromFMData(self):

        with  open(TESTA_E_DAT, "r") as efileA:
            edataA = fmdata.readFromDatFile(efileA, pscale=self.PSCALE, fscale=self.FSCALE)

        ldataA = lrfdata.convertFromFMData(edataA)

        with open(TESTA_LRF, "r") as lfileB:
            ldataB = lrfdata.readFromImpactFile(lfileB)

        n = ldataB.n
        
        for z in xrange(n):
            self.assertTrue(numpy.allclose(ldataA.p[z], ldataB.p[z]),
                msg="Incorrect position at %d: %g: expecting %g" % (z, ldataA.p[z], ldataB.p[z]))
            self.assertTrue(numpy.allclose(ldataA.f[z], ldataB.f[z]),
                msg="Incorrect electric field at %d: %g: expecting %g" % (z, ldataA.f[z], ldataB.f[z]))
            self.assertTrue(numpy.allclose(ldataA.df[z], ldataB.df[z]),
                msg="Incorrect electric field derivative at %d: %g: expecting %g" % (z, ldataA.df[z], ldataA.df[z]))
    def setUp(self):
        efile = open(TESTA_E_DAT, "r")
        edata = fmdata.readFromDatFile(efile, pscale=0.001, fscale=2.2)
        efile.close()

        self.lrfdata = lrfdata.convertFromFMData(edata)