Exemplo n.º 1
0
 def __init__(self, filename, index=0):
     DetectorImageBase.__init__(self, filename)
     self.vendortype = "EigerX"
     self.supports_multiple_images = True
     self.img_number = index  # 0-indexed to clients, internally 1-indexed
     if self.img_number == None: self.img_number = 0
     self.vendor_specific_null_value = -1
Exemplo n.º 2
0
 def __init__(self, filename):
     DetectorImageBase.__init__(self, filename)
     try:
         from cbflib_adaptbx import CBFAdaptor  # optional package
         self.adaptor = CBFAdaptor(filename)
         # for testing only:
         '''
   self.adaptor.read_header()
   print "     size1:", self.adaptor.size1()
   print "     size2:", self.adaptor.size2()
   print "  overload:", self.adaptor.overload()
   print "wavelength:", self.adaptor.wavelength()
   print "  distance:", self.adaptor.distance()
   print "pixel size:", self.adaptor.pixel_size()
   print "     beamx:", self.adaptor.beam_index_slow*self.adaptor.pixel_size()
   print "     beamy:", self.adaptor.beam_index_fast*self.adaptor.pixel_size()
   print " osc_start:", self.adaptor.osc_start()
   print " osc_range:", self.adaptor.osc_range()
   print self.adaptor.raster_description()
   flags = self.adaptor.transform_flags()
   print flags.transpose, flags.reverse_slow, flags.reverse_fast
   '''
     except Exception:
         from iotbx.detectors.marIP import NullAdaptor
         self.adaptor = NullAdaptor()
     self.vendortype = "CBF"
     self.readHeader()
     try:
         self.vendor_specific_null_value = int(
             self.adaptor.undefined_value())
     except RuntimeError as e:
         self.vendor_specific_null_value = 0
Exemplo n.º 3
0
 def __init__(self,filename):
   DetectorImageBase.__init__(self,filename)
   try:
     from cbflib_adaptbx import CBFAdaptor # optional package
     self.adaptor = CBFAdaptor(filename)
     # for testing only:
     '''
     self.adaptor.read_header()
     print "     size1:", self.adaptor.size1()
     print "     size2:", self.adaptor.size2()
     print "  overload:", self.adaptor.overload()
     print "wavelength:", self.adaptor.wavelength()
     print "  distance:", self.adaptor.distance()
     print "pixel size:", self.adaptor.pixel_size()
     print "     beamx:", self.adaptor.beam_index_slow*self.adaptor.pixel_size()
     print "     beamy:", self.adaptor.beam_index_fast*self.adaptor.pixel_size()
     print " osc_start:", self.adaptor.osc_start()
     print " osc_range:", self.adaptor.osc_range()
     print self.adaptor.raster_description()
     flags = self.adaptor.transform_flags()
     print flags.transpose, flags.reverse_slow, flags.reverse_fast
     '''
   except Exception:
     from iotbx.detectors.marIP import NullAdaptor
     self.adaptor = NullAdaptor()
   self.vendortype = "CBF"
   self.readHeader()
   self.vendor_specific_null_value = int(self.adaptor.undefined_value())
Exemplo n.º 4
0
    def debug_write(self, fileout, mod_data=None):
        try:
            if mod_data == None:
                mod_data = self.get_raw_data().iround()
        except AttributeError:
            pass

        DetectorImageBase.debug_write(self, fileout, mod_data)
Exemplo n.º 5
0
 def __init__(self,filename):
   DetectorImageBase.__init__(self,filename)
   try:
     from cbflib_adaptbx import Mar345Adaptor # optional package
     self.adaptor = Mar345Adaptor(filename)
   except Exception:
     self.adaptor = NullAdaptor()
   self.vendortype = "MARIP"
Exemplo n.º 6
0
  def debug_write(self,fileout,mod_data=None):
    try:
      if mod_data == None:
        mod_data = self.get_raw_data().iround()
    except AttributeError:
      pass

    DetectorImageBase.debug_write(self,fileout,mod_data)
Exemplo n.º 7
0
    def __init__(self, filename):
        DetectorImageBase.__init__(self, filename)
        try:
            from cbflib_adaptbx import Mar345Adaptor  # optional package

            self.adaptor = Mar345Adaptor(filename)
        except Exception:
            self.adaptor = NullAdaptor()
        self.vendortype = "MARIP"
Exemplo n.º 8
0
  def __init__(self,filename):
    DetectorImageBase.__init__(self,filename)
    self.vendortype = "MARCCD"

    byte_order = str(open(self.filename,"rb").read(2))
    if byte_order == 'II':
      self.endian = 0
    else:
      self.endian = 1

    assert not self.isCompressed()
Exemplo n.º 9
0
    def __init__(self, filename):
        DetectorImageBase.__init__(self, filename)
        self.vendortype = "MARCCD"

        with open(self.filename, "rb") as fh:
            byte_order = fh.read(2)
            if byte_order == b"II":
                self.endian = 0
            else:
                self.endian = 1

        assert not self.isCompressed()
Exemplo n.º 10
0
  def __init__(self, file_name):
    DetectorImageBase.__init__(self, file_name)
    raw = open(file_name, "rb").read()
    self.binary_sections = get_binary_sections(raw)
    self.header_sections = get_header_sections(raw, self.binary_sections)

    assert len(self.binary_sections)==1

    cif = iotbx.cif.fast_reader(input_string=self.header_sections)
    self.cif_model = cif.model()
    im1 = self.cif_model["image_1"]

    self.vendortype = "CBF"
    self.readHeader()
Exemplo n.º 11
0
    def __init__(self, file_name):
        DetectorImageBase.__init__(self, file_name)
        raw = open(file_name, "rb").read()
        self.binary_sections = get_binary_sections(raw)
        self.header_sections = get_header_sections(raw, self.binary_sections)

        assert len(self.binary_sections) == 1

        cif = iotbx.cif.fast_reader(input_string=self.header_sections)
        self.cif_model = cif.model()
        im1 = self.cif_model["image_1"]

        self.vendortype = "CBF"
        self.readHeader()
Exemplo n.º 12
0
def exercise_debug_write():
  #---------Write out a test file
  D = DetectorImageBase('no_file')
  D.parameters = {'SIZE1':filesize,
                  'SIZE2':filesize,
                  'PIXEL_SIZE':0.1,
                  'DISTANCE':100.0,
                  'TWOTHETA':0.0,
                  'OSC_START':0.0,
                  'OSC_RANGE':1.0,
                  'WAVELENGTH':1.0,
                  'BEAM_CENTER_X':12.5,
                  'BEAM_CENTER_Y':12.5,
  }
  def getEndian():
    return 0
  D.getEndian = getEndian
  sindata = flex.int()
  for x in xrange(filesize):
    sindata.append(min(255,abs(int(256*sinfunc(x)))))
  moddata = flex.int()
  accum = 0
  for x in xrange(filesize):
    for y in xrange(filesize):
      value = sindata[x]*sindata[y]
      moddata.append(value)
      accum+=value
  D.debug_write(filename,mod_data=moddata)

  #---------Read back the test file
  a = adsc.ADSCImage(filename)
  a.read()
  assert a.size1 == filesize
  assert a.size2 == filesize
  assert a.npixels == filesize*filesize
  assert approx_equal(a.pixel_size, 0.1)
  assert approx_equal(a.osc_start, 0)
  checkaccum = 0
  for x in xrange(a.npixels):
    if moddata[x]!=a.linearintdata[x]:
      print x,moddata[x],a.linearintdata[x]
    checkaccum+=a.linearintdata[x]
  assert accum == checkaccum
  os.remove(filename)
Exemplo n.º 13
0
Arquivo: mar.py Projeto: RAPD/RAPD
    def __init__(self, filename):
        """Initialize the instance"""

        # Make sure the image name is a string for iotbx
        try:
            image_str = unicodedata.normalize("NFKD", filename).encode("ascii", "ignore")
        except TypeError:
            image_str = filename

        DetectorImageBase.__init__(self, image_str)
        # self.vendortype = "MARCCD"

        byte_order = str(open(self.filename, "rb").read(2))
        if byte_order == "II":
            self.endian = 0
        else:
            self.endian = 1

        assert not self.isCompressed()
Exemplo n.º 14
0
def exercise_debug_write():
    #---------Write out a test file
    D = DetectorImageBase('no_file')
    D.parameters = {
        'SIZE1': filesize,
        'SIZE2': filesize,
        'PIXEL_SIZE': 0.1,
        'DISTANCE': 100.0,
        'TWOTHETA': 0.0,
        'OSC_START': 0.0,
        'OSC_RANGE': 1.0,
        'WAVELENGTH': 1.0,
        'BEAM_CENTER_X': 12.5,
        'BEAM_CENTER_Y': 12.5,
    }

    def getEndian():
        return 0

    D.getEndian = getEndian
    sindata = flex.int()
    for x in range(filesize):
        sindata.append(min(255, abs(int(256 * sinfunc(x)))))
    moddata = flex.int()
    accum = 0
    for x in range(filesize):
        for y in range(filesize):
            value = sindata[x] * sindata[y]
            moddata.append(value)
            accum += value
    D.debug_write(filename, mod_data=moddata)

    #---------Read back the test file
    a = adsc.ADSCImage(filename)
    a.read()
    assert a.size1 == filesize
    assert a.size2 == filesize
    assert a.npixels == filesize * filesize
    assert approx_equal(a.pixel_size, 0.1)
    assert approx_equal(a.osc_start, 0)
    checkaccum = 0
    for x in range(a.npixels):
        if moddata[x] != a.linearintdata[x]:
            print(x, moddata[x], a.linearintdata[x])
        checkaccum += a.linearintdata[x]
    assert accum == checkaccum
    os.remove(filename)
Exemplo n.º 15
0
 def __init__(self,filename):
   DetectorImageBase.__init__(self,filename)
   self.vendortype = "Eiger"
   self.vendor_specific_null_value = -1
Exemplo n.º 16
0
 def __init__(self, filename, source_data=None):
     DetectorImageBase.__init__(self, filename)
     self.vendortype = "npy_raw"
     self.source_data = source_data
Exemplo n.º 17
0
 def __init__(self,filename):
   DetectorImageBase.__init__(self,filename)
   self.vendortype = "ADSC"
Exemplo n.º 18
0
 def __init__(self,filename):
   DetectorImageBase.__init__(self,filename)
   Raxis.__init__(self,filename)
   self.vendortype = "RAXIS"
Exemplo n.º 19
0
 def __init__(self, filename):
     DetectorImageBase.__init__(self, filename)
     self.vendortype = "Pilatus"
     self.vendor_specific_null_value = -1
Exemplo n.º 20
0
 def __init__(self,filename):
   DetectorImageBase.__init__(self,filename)
   self.vendortype = "ADSC"
   self.open_file = open # default: open files with built-in, unless otherwise instructed by dxtbx format
Exemplo n.º 21
0
Arquivo: npy.py Projeto: dials/cctbx
 def __init__(self, filename, source_data=None):
     DetectorImageBase.__init__(self, filename)
     self.vendortype = "npy_raw"
     self.source_data = image_dict_to_unicode(source_data)
Exemplo n.º 22
0
 def __init__(self,filename):
   DetectorImageBase.__init__(self,filename)
   self.vendortype = "EIGER"
   self.supports_multiple_images = True
   self.img_number = 0 # 0-indexed to clients, internally 1-indexed
Exemplo n.º 23
0
 def __init__(self,filename):
   DetectorImageBase.__init__(self,filename)
   self.vendortype = "RigakuSaturn"
Exemplo n.º 24
0
 def __init__(self,filename):
   DetectorImageBase.__init__(self,filename)
   self.vendortype = "SMV(Generic)"
Exemplo n.º 25
0
 def __init__(self,filename):
   DetectorImageBase.__init__(self,filename)
   self.filename = filename
   self.vendortype = "MacScience"
   self.getImageSize()
Exemplo n.º 26
0
 def __init__(self,filename):
   DetectorImageBase.__init__(self,filename)
   self.filename = filename
   self.vendortype = "MacScience"
   self.getImageSize()
    def __init__(self,first,last):
      adopt_init_args(self, locals())
    def size(self): return self.last-self.first+1
  class test_divider:
    def tile_slow_interval(self,idx):
      if idx in [0,1,2]:  return test_tile(4,2043)
      if idx in [3,4,5]:  return test_tile(2052,4091)
      if idx in [6,7,8]:  return test_tile(4100,6139)
    def tile_fast_interval(self,idx):
      if idx in [0,3,6]:  return test_tile(4,2043)
      if idx in [1,4,7]:  return test_tile(2052,4091)
      if idx in [2,5,8]:  return test_tile(4100,6139)
  input_parameters = {'BEAM_CENTER_X':154.9,'BEAM_CENTER_Y':148.7,
                      'SIZE1':6144,'SIZE2':6144,'PIXEL_SIZE':0.051294}
  from iotbx.detectors.detectorbase import DetectorImageBase
  input_object = DetectorImageBase("no file")
  input_object.parameters = input_parameters
  ID = test_divider()
  S = StringIO.StringIO()
  for convention in xrange(8):
    for moduleidx in xrange(9):
      B = convert_beam_instrument_to_module(input_object,ID,moduleidx,convention)
      print >>S,"(%.1f,%.1f)"%(B[0],B[1]),
    print >>S
  assert not show_diff(S.getvalue(),
"""(154.7,148.5) (154.7,43.4) (154.7,-61.6) (49.6,148.5) (49.6,43.4) (49.6,-61.6) (-55.4,148.5) (-55.4,43.4) (-55.4,-61.6)
(148.5,154.7) (148.5,49.6) (148.5,-55.4) (43.4,154.7) (43.4,49.6) (43.4,-55.4) (-61.6,154.7) (-61.6,49.6) (-61.6,-55.4)
(154.7,166.2) (154.7,61.2) (154.7,-43.9) (49.6,166.2) (49.6,61.2) (49.6,-43.9) (-55.4,166.2) (-55.4,61.2) (-55.4,-43.9)
(148.5,160.0) (148.5,55.0) (148.5,-50.1) (43.4,160.0) (43.4,55.0) (43.4,-50.1) (-61.6,160.0) (-61.6,55.0) (-61.6,-50.1)
(160.0,148.5) (160.0,43.4) (160.0,-61.6) (55.0,148.5) (55.0,43.4) (55.0,-61.6) (-50.1,148.5) (-50.1,43.4) (-50.1,-61.6)
(166.2,154.7) (166.2,49.6) (166.2,-55.4) (61.2,154.7) (61.2,49.6) (61.2,-55.4) (-43.9,154.7) (-43.9,49.6) (-43.9,-55.4)
Exemplo n.º 28
0
 def __init__(self, filename):
     DetectorImageBase.__init__(self, filename)
     self.vendortype = "SMV(Generic)"
            if idx in [6, 7, 8]: return test_tile(4100, 6139)

        def tile_fast_interval(self, idx):
            if idx in [0, 3, 6]: return test_tile(4, 2043)
            if idx in [1, 4, 7]: return test_tile(2052, 4091)
            if idx in [2, 5, 8]: return test_tile(4100, 6139)

    input_parameters = {
        'BEAM_CENTER_X': 154.9,
        'BEAM_CENTER_Y': 148.7,
        'SIZE1': 6144,
        'SIZE2': 6144,
        'PIXEL_SIZE': 0.051294
    }
    from iotbx.detectors.detectorbase import DetectorImageBase
    input_object = DetectorImageBase("no file")
    input_object.parameters = input_parameters
    ID = test_divider()
    S = StringIO.StringIO()
    for convention in range(8):
        for moduleidx in range(9):
            B = convert_beam_instrument_to_module(input_object, ID, moduleidx,
                                                  convention)
            print >> S, "(%.1f,%.1f)" % (B[0], B[1]),
        print >> S
    assert not show_diff(
        S.getvalue(),
        """(154.7,148.5) (154.7,43.4) (154.7,-61.6) (49.6,148.5) (49.6,43.4) (49.6,-61.6) (-55.4,148.5) (-55.4,43.4) (-55.4,-61.6)
(148.5,154.7) (148.5,49.6) (148.5,-55.4) (43.4,154.7) (43.4,49.6) (43.4,-55.4) (-61.6,154.7) (-61.6,49.6) (-61.6,-55.4)
(154.7,166.2) (154.7,61.2) (154.7,-43.9) (49.6,166.2) (49.6,61.2) (49.6,-43.9) (-55.4,166.2) (-55.4,61.2) (-55.4,-43.9)
(148.5,160.0) (148.5,55.0) (148.5,-50.1) (43.4,160.0) (43.4,55.0) (43.4,-50.1) (-61.6,160.0) (-61.6,55.0) (-61.6,-50.1)
Exemplo n.º 30
0
 def __init__(self, filename):
     DetectorImageBase.__init__(self, filename)
     self.vendortype = "Hamamatsu"
Exemplo n.º 31
0
 def __init__(self,filename):
   DetectorImageBase.__init__(self,filename)
   self.vendortype = "RigakuSaturn"
Exemplo n.º 32
0
 def __init__(self, filename):
     DetectorImageBase.__init__(self, filename)
     Raxis.__init__(self, filename)
     self.vendortype = "RAXIS"
Exemplo n.º 33
0
 def __init__(self, filename, source_data = None):
   DetectorImageBase.__init__(self, filename)
   self.vendortype = "npy_raw"
   self.source_data = source_data