コード例 #1
0
 def test_loadData_1column(self):
     """check loading of one-column data.
     """
     d1c = numpy.arange(1, 6)
     d = loadData(loaddata01, usecols=[0], minrows=1)
     self.failUnless(numpy.array_equal(d1c, d))
     d = loadData(loaddata01, usecols=[0], minrows=2)
     self.failUnless(numpy.array_equal(d1c, d))
     d = loadData(loaddata01, usecols=[0], minrows=3)
     self.failIf(numpy.array_equal(d1c, d))
     return
コード例 #2
0
ファイル: testloaddata.py プロジェクト: mmckerns/diffpy.utils
 def test_loadData_1column(self):
     """check loading of one-column data.
     """
     d1c = numpy.arange(1, 6)
     d = loadData(loaddata01, usecols=[0], minrows=1)
     self.failUnless(numpy.array_equal(d1c, d))
     d = loadData(loaddata01, usecols=[0], minrows=2)
     self.failUnless(numpy.array_equal(d1c, d))
     d = loadData(loaddata01, usecols=[0], minrows=3)
     self.failIf(numpy.array_equal(d1c, d))
     return
コード例 #3
0
ファイル: testloaddata.py プロジェクト: diffpy/diffpy.utils
 def test_loadData_default(self):
     """check loadData() with default options
     """
     d2c = numpy.array([[3, 31], [4, 32], [5, 33]])
     self.assertRaises(IOError, loadData, 'doesnotexist')
     # the default minrows=10 makes it read from the third line
     d = loadData(loaddata01)
     self.assertTrue(numpy.array_equal(d2c, d))
     # the usecols=(0, 1) would make it read from the third line
     d = loadData(loaddata01, minrows=1, usecols=(0, 1))
     self.assertTrue(numpy.array_equal(d2c, d))
     # check the effect of usecols effect
     d = loadData(loaddata01, usecols=(0,))
     self.assertTrue(numpy.array_equal(d2c[:,0], d))
     d = loadData(loaddata01, usecols=(1,))
     self.assertTrue(numpy.array_equal(d2c[:,1], d))
     return
コード例 #4
0
 def test_loadData_default(self):
     """check loadData() with default options
     """
     d2c = numpy.array([[3, 31], [4, 32], [5, 33]])
     self.assertRaises(IOError, loadData, 'doesnotexist')
     # the default minrows=10 makes it read from the third line
     d = loadData(loaddata01)
     self.assertTrue(numpy.array_equal(d2c, d))
     # the usecols=(0, 1) would make it read from the third line
     d = loadData(loaddata01, minrows=1, usecols=(0, 1))
     self.assertTrue(numpy.array_equal(d2c, d))
     # check the effect of usecols effect
     d = loadData(loaddata01, usecols=(0, ))
     self.assertTrue(numpy.array_equal(d2c[:, 0], d))
     d = loadData(loaddata01, usecols=(1, ))
     self.assertTrue(numpy.array_equal(d2c[:, 1], d))
     return
コード例 #5
0
 def setUp(self):
     self.factory = PDFRecipeFactory()
     # cubic
     self.cifbtoc = _datafile('BaTiO3-Pm3m.cif')
     # tetragonal
     self.cifbtot = _datafile('BaTiO3-P4mm.cif')
     data = loadData(_datafile('BaTiO3.gr'))
     self.r, self.g = data.T
     return
コード例 #6
0
ファイル: helper.py プロジェクト: rohanpok/Myscripts
def load_xy(files: List[str]) -> Tuple[List[array], List[array]]:
    """
    load x and y array from a list of data files and return a list iof x array and a list of y array.
    :param files: a list of data files.
    :return: x array list, y array list.
    """
    xs, ys = [], []
    for f in files:
        x, y = loadData(f).T
        xs.append(x)
        ys.append(y)
    return xs, ys
コード例 #7
0
ファイル: helper.py プロジェクト: rohanpok/Myscripts
def load_gr(files: List[str]) -> Tuple[List[array], List[array]]:
    """
    load r and g array from a list of data files and return a list of r array and a list of g array.
    :param files: path to data files.
    :return: r array list, g array list.
    """
    rs, gs = [], []
    for f in files:
        r, g = loadData(f).T
        rs.append(r)
        gs.append(g)
    return rs, gs
コード例 #8
0
ファイル: tools.py プロジェクト: chiahaoliu/diffpy.pdfmorph
def readPDF(fname):
    """Reads an .gr file, loads r and G(r) vectors.

    fname -- name of the file we want to read.

    Returns r and gr arrays.

    """
    from diffpy.utils.parsers import loadData

    rv = loadData(fname, unpack=True)
    if len(rv) >= 2:
        return rv[:2]
    return (None, None)
コード例 #9
0
ファイル: helper.py プロジェクト: rohanpok/Myscripts
def load_fgr(
    files: List[str]
) -> Tuple[List[array], List[array], List[array], List[array]]:
    """
    load r array, g calculation array, g data array and difference between data and calculation array from a lit of
    data files and return four list of arrays.
    :param files: a list of data files.
    :return: r array list, gcalc array list, g array list, gdiff array list.
    """
    rs, gcalcs, gs, gdiffs = [], [], [], []
    for f in files:
        r, gcalc, g, _ = loadData(f).T
        gdiff = g - gcalc
        rs.append(r)
        gcalcs.append(gcalc)
        gs.append(g)
        gdiffs.append(gdiff)
    return rs, gcalcs, gs, gdiffs