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)
Ejemplo n.º 3
0
        linearintdata = flex.int(
            self.object.linearintdata[start_index:stop_index])
        linearintdata.reshape(flex.grid((195, 2463)))
        del self.object  #once the data are copied, no need to keep the original
        return linearintdata

    def read(self):
        if self.already_read_data: return
        self.bin_safe_set_data(self.slice_callback())
        self.already_read_data = True


if __name__ == '__main__':
    import sys
    full_path_to_file = sys.argv[1]
    a = PilatusImage(testing_file)
    a.read()
    print a
    print a.parameters
    print a.rawdata, len(a.rawdata), a.size1 * a.size2
    for dataitem in [
            'bin', 'filename', 'header', 'headerlines', 'linearintdata',
            'parameters', 'vendortype'
    ]:
        print dataitem,
        exec("print a.%s" % dataitem)
    print pilatus_slice_from_object_and_slicenumber(a, 5)

    P = pilatus_slice_from_file_url(url="file://%s?slice=5" %
                                    full_path_to_file)
Ejemplo n.º 4
0
    return linearintdata

  def slice_callback_with_object_data(self):
    self.object.read()
    start_index = 2463*((195+17)*self.sliceindex)
    stop_index = start_index + 2463*195
    linearintdata = flex.int(self.object.linearintdata[start_index:stop_index])
    linearintdata.reshape(flex.grid((195,2463)))
    del self.object #once the data are copied, no need to keep the original
    return linearintdata

  def read(self):
    if self.already_read_data: return
    self.bin_safe_set_data( self.slice_callback() )
    self.already_read_data = True

if __name__=='__main__':
  import sys
  full_path_to_file = sys.argv[1]
  a = PilatusImage(testing_file)
  a.read()
  print a
  print a.parameters
  print a.rawdata, len(a.rawdata), a.size1*a.size2
  for dataitem in ['bin', 'filename', 'header', 'headerlines', 'linearintdata', 'parameters', 'vendortype']:
    print dataitem,
    exec("print a.%s"%dataitem)
  print pilatus_slice_from_object_and_slicenumber(a,5)

  P = pilatus_slice_from_file_url(url="file://%s?slice=5"%full_path_to_file)