def test_all(timer=False):
  for file in generate_paths():
    from iotbx.detectors.pilatus_minicbf import PilatusImage
    if timer: print os.path.basename(file)
    P = PilatusImage(file)
    if timer: G = Profiler("cbflib no-opt    read")
    P.read(algorithm="cbflib")
    read1 = P.linearintdata
    if timer: G = Profiler("cbflib optimized read")
    P.linearintdata = None #won't read again without resetting first
    P.read(algorithm="cbflib_optimized")
    read2 = P.linearintdata
    if timer: G = Profiler("buffer-based read")
    P.linearintdata = None #won't read again without resetting first
    P.read(algorithm="buffer_based")
    read3 = P.linearintdata
    if timer: del G
    expected_image_size = {"Pilatus-6M":(2527,2463),
                           "Pilatus-2M":(1679,1475),
                           "Pilatus-300K":(619,487)}[P.vendortype]
    assert read1.accessor().focus() == read2.accessor().focus() == expected_image_size
    from cbflib_adaptbx import assert_equal
    #print "Equality of arrays from two decompress methods", assert_equal(read1,read2), "\n"
    assert assert_equal(read1,read2)
    assert assert_equal(read1,read3)
def test_all(dirpath, timer=False):
    for file in generate_paths(dirpath):
        from iotbx.detectors.pilatus_minicbf import PilatusImage
        if timer: print(os.path.basename(file))
        P = PilatusImage(file)
        if timer: G = Profiler("cbflib no-opt    read")
        P.read(algorithm="cbflib")
        read1 = P.linearintdata
        if timer: G = Profiler("cbflib optimized read")
        P.linearintdata = None  #won't read again without resetting first
        P.read(algorithm="cbflib_optimized")
        read2 = P.linearintdata
        if timer: G = Profiler("buffer-based read")
        P.linearintdata = None  #won't read again without resetting first
        P.read(algorithm="buffer_based")
        read3 = P.linearintdata
        if timer: del G
        expected_image_size = {
            "Pilatus-6M": (2527, 2463),
            "Pilatus-2M": (1679, 1475),
            "Pilatus-300K": (619, 487)
        }[P.vendortype]
        assert read1.accessor().focus() == read2.accessor().focus(
        ) == expected_image_size
        from cbflib_adaptbx import assert_equal
        #print "Equality of arrays from two decompress methods", assert_equal(read1,read2), "\n"
        assert assert_equal(read1, read2)
        assert assert_equal(read1, read3)
def run(file_name):
    from libtbx.test_utils import approx_equal
    py_image_obj = pyCBFImage(file_name)
    py_image_obj.read()
    c_image_obj = CBFImage(file_name)
    c_image_obj.read()
    assert_equal(py_image_obj.linearintdata, c_image_obj.linearintdata)
    assert py_image_obj.size1 == c_image_obj.size1
    assert py_image_obj.size2 == c_image_obj.size2
    assert approx_equal(py_image_obj.saturation, c_image_obj.saturation)
    assert approx_equal(py_image_obj.pixel_size, c_image_obj.pixel_size)
    assert approx_equal(py_image_obj.osc_start, c_image_obj.osc_start)
    assert approx_equal(py_image_obj.deltaphi, c_image_obj.deltaphi)
    assert approx_equal(py_image_obj.wavelength, c_image_obj.wavelength)
    assert approx_equal(py_image_obj.distance, c_image_obj.distance)
    assert approx_equal(py_image_obj.beamx, c_image_obj.beamx)
    assert approx_equal(py_image_obj.beamy, c_image_obj.beamy)
示例#4
0
def run(file_name):
  from libtbx.test_utils import approx_equal
  py_image_obj = pyCBFImage(file_name)
  py_image_obj.read()
  c_image_obj = CBFImage(file_name)
  c_image_obj.read()
  assert_equal(py_image_obj.linearintdata, c_image_obj.linearintdata)
  assert py_image_obj.size1 == c_image_obj.size1
  assert py_image_obj.size2 == c_image_obj.size2
  assert approx_equal(py_image_obj.saturation, c_image_obj.saturation)
  assert approx_equal(py_image_obj.pixel_size, c_image_obj.pixel_size)
  assert approx_equal(py_image_obj.osc_start, c_image_obj.osc_start)
  assert approx_equal(py_image_obj.deltaphi, c_image_obj.deltaphi)
  assert approx_equal(py_image_obj.wavelength, c_image_obj.wavelength)
  assert approx_equal(py_image_obj.distance, c_image_obj.distance)
  assert approx_equal(py_image_obj.beamx, c_image_obj.beamx)
  assert approx_equal(py_image_obj.beamy, c_image_obj.beamy)
def basic_tests(verbose=True):
  initial_intdata = create_random_data_with_gaussian_distribution(0.0,100.0)

  #special deltas to test the compression algorithm
  addresses = [3,6,9,12,15,18]
  deltas = [-127,128,-32767,32768,-2147483647,2147483647]
  for x in xrange(6):
    initial_intdata[addresses[x]-1]=0
    initial_intdata[addresses[x]]=deltas[x]

  if verbose: P=Profiler("compress")
  array_shape = initial_intdata.focus()
  if verbose: print array_shape
  compressed = compress(initial_intdata)
  if verbose: print len(compressed)
  if verbose: P=Profiler("uncompress")
  decompressed_dat = uncompress(packed=compressed, fast=array_shape[1], slow=array_shape[0])

  if verbose: del P
  assert assert_equal(initial_intdata, decompressed_dat)
def basic_tests(verbose=True):
    initial_intdata = create_random_data_with_gaussian_distribution(0.0, 100.0)

    #special deltas to test the compression algorithm
    addresses = [3, 6, 9, 12, 15, 18]
    deltas = [-127, 128, -32767, 32768, -2147483647, 2147483647]
    for x in range(6):
        initial_intdata[addresses[x] - 1] = 0
        initial_intdata[addresses[x]] = deltas[x]

    if verbose: P = Profiler("compress")
    array_shape = initial_intdata.focus()
    if verbose: print(array_shape)
    compressed = compress(initial_intdata)
    if verbose: print(len(compressed))
    if verbose: P = Profiler("uncompress")
    decompressed_dat = uncompress(packed=compressed,
                                  fast=array_shape[1],
                                  slow=array_shape[0])

    if verbose: del P
    assert assert_equal(initial_intdata, decompressed_dat)