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
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
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())
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)
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"
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)
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"
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()
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()
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()
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()
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 __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()
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 __init__(self,filename): DetectorImageBase.__init__(self,filename) self.vendortype = "Eiger" self.vendor_specific_null_value = -1
def __init__(self, filename, source_data=None): DetectorImageBase.__init__(self, filename) self.vendortype = "npy_raw" self.source_data = source_data
def __init__(self,filename): DetectorImageBase.__init__(self,filename) self.vendortype = "ADSC"
def __init__(self,filename): DetectorImageBase.__init__(self,filename) Raxis.__init__(self,filename) self.vendortype = "RAXIS"
def __init__(self, filename): DetectorImageBase.__init__(self, filename) self.vendortype = "Pilatus" self.vendor_specific_null_value = -1
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
def __init__(self, filename, source_data=None): DetectorImageBase.__init__(self, filename) self.vendortype = "npy_raw" self.source_data = image_dict_to_unicode(source_data)
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
def __init__(self,filename): DetectorImageBase.__init__(self,filename) self.vendortype = "RigakuSaturn"
def __init__(self,filename): DetectorImageBase.__init__(self,filename) self.vendortype = "SMV(Generic)"
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)
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)
def __init__(self, filename): DetectorImageBase.__init__(self, filename) self.vendortype = "Hamamatsu"
def __init__(self, filename): DetectorImageBase.__init__(self, filename) Raxis.__init__(self, filename) self.vendortype = "RAXIS"
def __init__(self, filename, source_data = None): DetectorImageBase.__init__(self, filename) self.vendortype = "npy_raw" self.source_data = source_data