Exemple #1
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)
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)
        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)
(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)
      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)
(160.0,166.2) (160.0,61.2) (160.0,-43.9) (55.0,166.2) (55.0,61.2) (55.0,-43.9) (-50.1,166.2) (-50.1,61.2) (-50.1,-43.9)