Esempio n. 1
0
    def readObs(self, filename):
        """Load experimental PDF data from PDFGetX2 or PDFGetN gr file.

        filename -- file to read from

        returns self
        """
        PDFDataSet.read(self, filename)
        self._updateRcalcRange()
        return self
Esempio n. 2
0
    def readObs(self, filename):
        """Load experimental PDF data from PDFGetX2 or PDFGetN gr file.

        filename -- file to read from

        returns self
        """
        PDFDataSet.read(self, filename)
        self._updateRcalcRange()
        return self
Esempio n. 3
0
class TestPDFDataSet(unittest.TestCase):

    def setUp(self):
        self.pdfds = PDFDataSet('test data set')
        return

    def tearDown(self):
        self.pdfds = None
        return

#   def test___init__(self):
#       """check PDFDataSet.__init__()
#       """
#       return
#
#   def test_clear(self):
#       """check PDFDataSet.clear()
#       """
#       return
#
#   def test_setvar(self):
#       """check PDFDataSet.setvar()
#       """
#       return
#
#   def test_getvar(self):
#       """check PDFDataSet.getvar()
#       """
#       return
#
    def test_read(self):
        """check PDFDataSet.read()
        """
        # neutron data -------------------------------------------------
        fn_550K = datafile('550K.gr')
        self.pdfds.read(fn_550K)
        self.assertEqual('N', self.pdfds.stype)
        self.assertEqual(32.0, self.pdfds.qmax)
        # there are 2000 points in the file
        npts = len(self.pdfds.robs)
        self.assertEqual(2000, npts)
        # drobs are all zero
        self.assertEqual(npts*[0.0], self.pdfds.drobs)
        # dGobs should be defined
        self.failUnless(min(self.pdfds.dGobs) > 0)
        # x-ray data ---------------------------------------------------
        fx_Ni = datafile('Ni_2-8.chi.gr')
        self.pdfds.read(fx_Ni)
        self.assertEqual('X', self.pdfds.stype)
        self.assertEqual(40.0, self.pdfds.qmax)
        # there are 2000 points in the file
        npts = len(self.pdfds.robs)
        self.assertEqual(2000, npts)
        # drobs are all zero
        self.assertEqual(npts*[0.0], self.pdfds.drobs)
        # dGobs should be defined
        self.failUnless(min(self.pdfds.dGobs) > 0)
        return

    def test_readStr(self):
        """check PDFDataSet.readStr()
        """
        # read Ni xray data, but invalidate the last dGobs
        fx_Ni = datafile('Ni_2-8.chi.gr')
        sNi = open(fx_Ni).read()
        lastdGobs = sNi.rstrip().rindex(' ')
        sNi_no_dGobs = sNi[:lastdGobs] + " -1.3e-3"
        self.pdfds.readStr(sNi_no_dGobs)
        # there are 2000 points in the file
        npts = len(self.pdfds.robs)
        self.assertEqual(2000, npts)
        # dGobs should be all zero
        self.assertEqual(npts*[0.0], self.pdfds.dGobs)
        return
Esempio n. 4
0
class TestPDFDataSet(unittest.TestCase):

    def setUp(self):
        self.pdfds = PDFDataSet('test data set')
        return

    def tearDown(self):
        self.pdfds = None
        return

#   def test___init__(self):
#       """check PDFDataSet.__init__()
#       """
#       return
#
#   def test_clear(self):
#       """check PDFDataSet.clear()
#       """
#       return
#
#   def test_setvar(self):
#       """check PDFDataSet.setvar()
#       """
#       return
#
#   def test_getvar(self):
#       """check PDFDataSet.getvar()
#       """
#       return
#
    def test_read(self):
        """check PDFDataSet.read()
        """
        # neutron data -------------------------------------------------
        fn_550K = datafile('550K.gr')
        self.pdfds.read(fn_550K)
        self.assertEqual('N', self.pdfds.stype)
        self.assertEqual(32.0, self.pdfds.qmax)
        # there are 2000 points in the file
        npts = len(self.pdfds.robs)
        self.assertEqual(2000, npts)
        # drobs are all zero
        self.assertEqual(npts*[0.0], self.pdfds.drobs)
        # dGobs should be defined
        self.assertTrue(min(self.pdfds.dGobs) > 0)
        # x-ray data ---------------------------------------------------
        fx_Ni = datafile('Ni_2-8.chi.gr')
        self.pdfds.read(fx_Ni)
        self.assertEqual('X', self.pdfds.stype)
        self.assertEqual(40.0, self.pdfds.qmax)
        # there are 2000 points in the file
        npts = len(self.pdfds.robs)
        self.assertEqual(2000, npts)
        # drobs are all zero
        self.assertEqual(npts*[0.0], self.pdfds.drobs)
        # dGobs should be defined
        self.assertTrue(min(self.pdfds.dGobs) > 0)
        return

    def test_readStr(self):
        """check PDFDataSet.readStr()
        """
        # read Ni xray data, but invalidate the last dGobs
        fx_Ni = datafile('Ni_2-8.chi.gr')
        sNi = open(fx_Ni).read()
        lastdGobs = sNi.rstrip().rindex(' ')
        sNi_no_dGobs = sNi[:lastdGobs] + " -1.3e-3"
        self.pdfds.readStr(sNi_no_dGobs)
        # there are 2000 points in the file
        npts = len(self.pdfds.robs)
        self.assertEqual(2000, npts)
        # dGobs should be all zero
        self.assertEqual(npts*[0.0], self.pdfds.dGobs)
        return