Example #1
0
File: cbf.py Project: harumome/kamo
def load_xds_special(cbfin):
    h = pycbf.cbf_handle_struct()
    h.read_file(cbfin, pycbf.MSG_DIGEST)
    h.require_category("array_data")
    h.find_column("header_contents")
    header = h.get_value()

    M = cbf_binary_adaptor(cbfin)
    data = M.uncompress_implementation("buffer_based").uncompress_data()
    #print "slow, fast=", M.dim_slow(), M.dim_fast() # can be obtained after getting data
    return header, data, M.dim_slow(), M.dim_fast()
Example #2
0
def load_xds_special(cbfin):
    h = pycbf.cbf_handle_struct()
    h.read_file(cbfin, pycbf.MSG_DIGEST)
    h.require_category("array_data")
    h.find_column("header_contents")
    header = h.get_value()

    M = cbf_binary_adaptor(cbfin)
    data = M.uncompress_implementation("buffer_based").uncompress_data()
    #print "slow, fast=", M.dim_slow(), M.dim_fast() # can be obtained after getting data
    return header, data, M.dim_slow(), M.dim_fast()
Example #3
0
    def read(self):
        T = self.adaptor.transform_flags()

        #future: use these tests to trigger in-place column & row swaps
        assert T.reverse_fast == False
        assert T.reverse_slow == False

        from cbflib_adaptbx import cbf_binary_adaptor
        M = cbf_binary_adaptor(self.filename)
        data = M.uncompress_implementation("buffer_based").uncompress_data()
        if T.transpose == True:
            #very inefficient; 0.09 sec for 3K x 3K uncompression
            #              yet 0.54 sec for in-place transpose
            # other options not tried: a) alloc & set new matrix; b) use data as is
            data.matrix_transpose_in_place()

        self.bin_safe_set_data(data)
Example #4
0
  def read(self):
    T = self.adaptor.transform_flags()

    #future: use these tests to trigger in-place column & row swaps
    assert T.reverse_fast == False
    assert T.reverse_slow == False

    from cbflib_adaptbx import cbf_binary_adaptor
    M = cbf_binary_adaptor( self.filename )
    data = M.uncompress_implementation("buffer_based").uncompress_data()
    if T.transpose==True:
      #very inefficient; 0.09 sec for 3K x 3K uncompression
      #              yet 0.54 sec for in-place transpose
      # other options not tried: a) alloc & set new matrix; b) use data as is
      data.matrix_transpose_in_place()

    self.bin_safe_set_data(data)
Example #5
0
    def read(self, algorithm="buffer_based"):
        self.readHeader()
        if self.linearintdata != None and self.linearintdata.size() == self.size1 * self.size2:
            # data has already been read
            return
        if self.bin == 2:
            raise ImageException("2-by-2 binning not supported for miniCBF")
        try:
            from cbflib_adaptbx import cbf_binary_adaptor  # optional package

            self.adaptor = cbf_binary_adaptor(self.filename)

            # assert algorithm in ["cbflib","cbflib_optimized","buffer_based"]

            data = self.adaptor.uncompress_implementation(algorithm).uncompress_data(self.size1, self.size2)
            self.bin_safe_set_data(data)

        except Exception, e:
            raise ImageException('unable to read miniCBF data; contact authors; error="%s"' % str(e).strip())
Example #6
0
    def read(self, algorithm="buffer_based"):
        self.readHeader()
        if self.linearintdata != None and\
          self.linearintdata.size()==self.size1*self.size2:
            #data has already been read
            return
        if self.bin == 2:
            raise ImageException("2-by-2 binning not supported for miniCBF")
        try:
            from cbflib_adaptbx import cbf_binary_adaptor  # optional package
            self.adaptor = cbf_binary_adaptor(self.filename)

            # assert algorithm in ["cbflib","cbflib_optimized","buffer_based"]

            data = self.adaptor.uncompress_implementation(
                algorithm).uncompress_data(self.size1, self.size2)
            self.bin_safe_set_data(data)

        except Exception:
            raise ImageException(
                "unable to read miniCBF data; contact authors")
Example #7
0
def load_cbf_as_flex(filein): # This can also read XDS special cbf
    M = cbf_binary_adaptor(filein)
    data = M.uncompress_implementation("buffer_based").uncompress_data()
    nslow, nfast = M.dim_slow(), M.dim_fast() # can be obtained after getting data
    return data, nfast, nslow
Example #8
0
File: cbf.py Project: harumome/kamo
def load_cbf_as_flex(filein): # This can also read XDS special cbf
    M = cbf_binary_adaptor(filein)
    data = M.uncompress_implementation("buffer_based").uncompress_data()
    nslow, nfast = M.dim_slow(), M.dim_fast() # can be obtained after getting data
    return data, nfast, nslow