Пример #1
0
 def test_to_hdf(self):
     c = columnfile.columnfile("test.col")
     columnfile.colfile_to_hdf(c, "testcolfile.hdf")
     h = columnfile.columnfile("testcolfile.hdf")
     for t in c.titles:
         assert ((c.getcolumn(t) == h.getcolumn(t)).all())
         assert t in h.titles
Пример #2
0
def main():
    colf = columnfile.columnfile(sys.argv[1])
    colf.filter(colf.Number_of_pixels > 3)
    print("Read", colf.nrows, "peaks")
    p = parameters.read_par_file(sys.argv[2])
    # input a sample radius to use for computing ranges
    radius = int(sys.argv[3])
    omegastep = guess_omega_step(colf)
    print("Guess omega step as", omegastep)
    colf.updateGeometry(p)

    for i, t in enumerate(colf.titles):
        print("\n", t, end=" ")
        for j in (0, 1, 2, colf.nrows // 2, colf.nrows // 2 + 1,
                  colf.nrows // 2 + 2, colf.nrows - 3, colf.nrows - 2,
                  colf.nrows - 1):
            print(colf.bigarray[i, j], end=" ")
    print()

    modXL = np.sqrt(colf.xl * colf.xl + colf.yl * colf.yl + colf.zl * colf.zl)
    modXLmean = modXL.mean()
    dangle = np.degrees(np.arctan2(radius, modXLmean))
    print("Angle precision is about ", dangle, "for average distance",
          modXLmean, "and sample size ", radius)

    mergecolf = findpairs_2d(colf, dangle, omegastep)
    columnfile.colfile_to_hdf(mergecolf, sys.argv[4])
Пример #3
0
            raise
        c.updateGeometry(p)
        if titles is None:
            titles = [t for t in c.titles]
        for told, tnew in zip(titles, c.titles):
            assert told == tnew, "titles do not match %s %s %s" % (f, told,
                                                                   tnew)
        ars.append(c.bigarray)
    c.bigarray = concatenate(ars, axis=1)
    c.nrows = c.bigarray.shape[1]
    c.set_attributes()
    return c


if __name__ == "__main__":
    try:
        p = read_par_file(sys.argv[1])
        motor = sys.argv[2]
        out = sys.argv[3]

        if os.path.exists(out):
            print(help)
            print("File exists already, try again")

    except:
        print(help)
        raise

    c = merge_flts(p, sorted(sys.argv[4:]), motor)
    colfile_to_hdf(c, out)
Пример #4
0
import sys
"""
Script for repairing use of incorrect spline file
"""
import h5py, tqdm, numpy as np
from ImageD11 import columnfile, blobcorrector

spline = sys.argv[1]
cor = blobcorrector.correctorclass(spline)
h5in = sys.argv[2]
pks = sys.argv[3]
outname = sys.argv[4]

with h5py.File(h5in, 'r') as hin:
    print(list(hin), pks)
    g = hin[pks]
    cd = {name: g[name][:] for name in list(g)}
    cd['sc'] = np.zeros_like(cd['s_raw'])
    cd['fc'] = np.zeros_like(cd['f_raw'])

inc = columnfile.colfile_from_dict(cd)

for i in tqdm.tqdm(range(inc.nrows)):
    inc.sc[i], inc.fc[i] = cor.correct(inc.s_raw[i], inc.f_raw[i])

columnfile.colfile_to_hdf(inc, outname)