Пример #1
0
    def __init__(self, image_file, **kwargs):
        '''Initialise the image structure from the given file, including a
    proper model of the experiment.'''

        assert (self.understand(image_file))

        FormatSMV.__init__(self, image_file, **kwargs)
  def __init__(self, image_file):
    '''Initialise the image structure from the given file, including a
    proper model of the experiment.'''

    assert(self.understand(image_file))

    FormatSMV.__init__(self, image_file)
Пример #3
0
  def _start(self):

    FormatSMV._start(self)

    if not hasattr(self, "detectorbase") or self.detectorbase is None:
      from iotbx.detectors import SMVImage
      self.detectorbase = SMVImage(self._image_file)
      self.detectorbase.readHeader()
    def __init__(self, image_file, **kwargs):
        '''Initialise the image structure from the given file, including a
    proper model of the experiment.'''

        from dxtbx import IncorrectFormatError
        if not self.understand(image_file):
            raise IncorrectFormatError(self, image_file)

        FormatSMV.__init__(self, image_file, **kwargs)
  def __init__(self, image_file):
    '''Initialise the image structure from the given file, including a
    proper model of the experiment.'''

    assert(self.understand(image_file))

    FormatSMV.__init__(self, image_file)

    detector_prefixes = self._header_dictionary['DETECTOR_NAMES'].split()
    self._prefix = detector_prefixes[0]
    return
Пример #6
0
    def __init__(self, image_file, **kwargs):
        '''Initialise the image structure from the given file, including a
    proper model of the experiment.'''

        assert (self.understand(image_file))

        FormatSMV.__init__(self, image_file, **kwargs)

        detector_prefixes = self._header_dictionary['DETECTOR_NAMES'].split()
        self._prefix = detector_prefixes[0]
        return
Пример #7
0
    def __init__(self, image_file, **kwargs):
        '''Initialise the image structure from the given file, including a
    proper model of the experiment.'''

        from dxtbx import IncorrectFormatError
        if not self.understand(image_file):
            raise IncorrectFormatError(self, image_file)

        FormatSMV.__init__(self, image_file, **kwargs)

        detector_prefixes = self._header_dictionary['DETECTOR_NAMES'].split()
        self._prefix = detector_prefixes[0]
  def understand(image_file):
    '''Check to see if this looks like an ADSC SMV format image, i.e. we
    can make sense of it. Essentially that will be if it contains all of
    the keys we are looking for and not some we are not (i.e. that belong
    to a Rigaku Saturn.)'''

    size, header = FormatSMV.get_smv_header(image_file)

    # only recognise TimePix_SU
    if header.get('BEAMLINE') != 'TimePix_SU': return False

    # check the header contains the things we're going to use
    wanted_header_items = ['BEAM_CENTER_X', 'BEAM_CENTER_Y',
                           'DISTANCE', 'WAVELENGTH', 'PIXEL_SIZE',
                           'OSC_START', 'OSC_RANGE', 'PHI', 'SIZE1', 'SIZE2',
                           'BYTE_ORDER', 'DETECTOR_SN']
    for header_item in wanted_header_items:
      if not header_item in header:
        return False

    # check the pixel size is 55 microns
    if not float(header['PIXEL_SIZE']) == 0.055: return False

    # check there are 512*512 pixels
    if not (header['SIZE1']) == '512': return False
    if not (header['SIZE2']) == '512': return False

    return True
Пример #9
0
    def understand(image_file):
        '''Check to see if this looks like an ADSC SMV format image, i.e. we
    can make sense of it. Essentially that will be if it contains all of
    the keys we are looking for and not some we are not (i.e. that belong
    to a Rigaku Saturn.)'''

        size, header = FormatSMV.get_smv_header(image_file)

        # do not understand JHSim images
        if header.get('BEAMLINE') == 'fake': return False

        # do not understand Timepix_SU images
        if header.get('BEAMLINE', '').upper() == 'TIMEPIX_SU': return False

        # this used to include TIME
        wanted_header_items = [
            'BEAM_CENTER_X', 'BEAM_CENTER_Y', 'DISTANCE', 'WAVELENGTH',
            'PIXEL_SIZE', 'OSC_START', 'OSC_RANGE', 'SIZE1', 'SIZE2',
            'BYTE_ORDER'
        ]

        for header_item in wanted_header_items:
            if not header_item in header:
                return False

        unwanted_header_items = ['DTREK_DATE_TIME']

        for header_item in unwanted_header_items:
            if header_item in header:
                return False

        return True
  def understand(image_file):
    '''Check to see if this looks like a Rigaku d*TREK SMV format image,
    i.e. we can make sense of it. Essentially that will be if it contains
    all of the keys we are looking for.'''

    size, header = FormatSMV.get_smv_header(image_file)

    wanted_header_items = [
        'DETECTOR_NUMBER', 'DETECTOR_NAMES',
        'BYTE_ORDER', 'DIM', 'SIZE1', 'SIZE2', 'Data_type'
    ]

    for header_item in wanted_header_items:
      if not header_item in header:
        return False

    # code around CMOS1 on ALS 4.2.2

    detector_prefixes = header['DETECTOR_NAMES'].split()

    if len(detector_prefixes) == 1:
      prefix = detector_prefixes[0]
      det_desc = '%sDETECTOR_DESCRIPTION' % prefix
      if 'CMOS-1' in header.get(det_desc, ''):
        return False

    detector_prefixes = header['DETECTOR_NAMES'].split()
    try:
      detector_number = int(header['DETECTOR_NUMBER'].strip())
    except (KeyError,AttributeError,ValueError),e:
      return False
Пример #11
0
  def understand(image_file):
    '''Check to see if this looks like a Rigaku d*TREK SMV format image,
    i.e. we can make sense of it. Essentially that will be if it contains
    all of the keys we are looking for.'''

    size, header = FormatSMV.get_smv_header(image_file)

    wanted_header_items = [
        'DETECTOR_NUMBER', 'DETECTOR_NAMES',
        'BYTE_ORDER', 'DIM', 'SIZE1', 'SIZE2', 'Data_type'
    ]

    for header_item in wanted_header_items:
      if not header_item in header:
        return False

    # code around CMOS1 on ALS 4.2.2

    detector_prefixes = header['DETECTOR_NAMES'].split()

    if len(detector_prefixes) == 1:
      prefix = detector_prefixes[0]
      det_desc = '%sDETECTOR_DESCRIPTION' % prefix
      if 'CMOS-1' in header.get(det_desc, ''):
        return False

    detector_prefixes = header['DETECTOR_NAMES'].split()
    try:
      detector_number = int(header['DETECTOR_NUMBER'].strip())
    except (KeyError,AttributeError,ValueError),e:
      return False
Пример #12
0
    def understand(image_file):

        size, header = FormatSMV.get_smv_header(image_file)

        # only recognise TimePix_SU
        if header.get("BEAMLINE", "").upper() != "TIMEPIX_SU":
            return False

        # check the header contains the things we're going to use
        wanted_header_items = [
            "BEAM_CENTER_X",
            "BEAM_CENTER_Y",
            "DISTANCE",
            "WAVELENGTH",
            "PIXEL_SIZE",
            "OSC_START",
            "OSC_RANGE",
            "PHI",
            "SIZE1",
            "SIZE2",
            "BYTE_ORDER",
            "DETECTOR_SN",
        ]
        if any(item not in header for item in wanted_header_items):
            return False

        return True
Пример #13
0
    def understand(image_file):
        '''Check to see if this looks like an JHSim SMV format image, i.e. we can
    make sense of it. From JH: "The best way to identify images from any of my
    simulators is to look for BEAMLINE=fake in the header."'''

        size, header = FormatSMV.get_smv_header(image_file)

        if header.get('BEAMLINE') == 'fake':
            return True
        else:
            return False
Пример #14
0
    def understand(image_file):
        """Check to see if this looks like a CMOS1 d*TREK SMV format image,
        i.e. we can make sense of it. Essentially that will be if it contains
        all of the keys we are looking for."""

        size, header = FormatSMV.get_smv_header(image_file)

        wanted_header_items = [
            "DETECTOR_NUMBER",
            "DETECTOR_NAMES",
            "BYTE_ORDER",
            "DIM",
            "SIZE1",
            "SIZE2",
            "Data_type",
        ]

        if any(item not in header for item in wanted_header_items):
            return False

        detector_prefixes = header["DETECTOR_NAMES"].split()

        if len(detector_prefixes) != 1:
            return False

        detector_prefix = detector_prefixes[0]

        more_wanted_header_items = [
            "DETECTOR_DIMENSIONS",
            "DETECTOR_SIZE",
            "DETECTOR_VECTORS",
            "GONIO_NAMES",
            "GONIO_UNITS",
            "GONIO_VALUES",
            "GONIO_VECTORS",
        ]

        if any(
            "%s%s" % (detector_prefix, item) not in header
            for item in more_wanted_header_items
        ):
            return False

        det_desc = "%sDETECTOR_DESCRIPTION" % detector_prefix
        if "CMOS-1" in header.get(det_desc, ""):
            return True

        return False
Пример #15
0
    def get_raw_data(self):
        '''Get the pixel intensities (i.e. read the image and return as a
       flex array of integers.)'''

        # currently have no non-little-endian machines...

        from boost.python import streambuf
        from dxtbx import read_uint16
        from scitbx.array_family import flex
        assert (len(self.get_detector()) == 1)
        size = self.get_detector()[0].get_image_size()
        f = FormatSMV.open_file(self._image_file)
        f.read(self._header_size)
        raw_data = read_uint16(streambuf(f), int(size[0] * size[1]))
        image_size = self.get_detector()[0].get_image_size()
        raw_data.reshape(flex.grid(image_size[1], image_size[0]))

        return raw_data
  def get_raw_data(self):
    '''Get the pixel intensities (i.e. read the image and return as a
       flex array of integers.)'''

    # currently have no non-little-endian machines...

    from boost.python import streambuf
    from dxtbx import read_uint16
    from scitbx.array_family import flex
    assert(len(self.get_detector()) == 1)
    size = self.get_detector()[0].get_image_size()
    f = FormatSMV.open_file(self._image_file)
    f.read(self._header_size)
    raw_data = read_uint16(streambuf(f), int(size[0] * size[1]))
    image_size = self.get_detector()[0].get_image_size()
    raw_data.reshape(flex.grid(image_size[1], image_size[0]))

    return raw_data
Пример #17
0
    def understand(image_file):

        size, header = FormatSMV.get_smv_header(image_file)

        # only recognise TimePix_SU
        if header.get('BEAMLINE', '').upper() != 'TIMEPIX_SU': return False

        # check the header contains the things we're going to use
        wanted_header_items = [
            'BEAM_CENTER_X', 'BEAM_CENTER_Y', 'DISTANCE', 'WAVELENGTH',
            'PIXEL_SIZE', 'OSC_START', 'OSC_RANGE', 'PHI', 'SIZE1', 'SIZE2',
            'BYTE_ORDER', 'DETECTOR_SN'
        ]
        for header_item in wanted_header_items:
            if not header_item in header:
                return False

        return True
Пример #18
0
    def understand(image_file):
        """Check to see if this looks like an ADSC SMV format image, i.e. we
        can make sense of it. Essentially that will be if it contains all of
        the keys we are looking for and not some we are not (i.e. that belong
        to a Rigaku Saturn.)"""

        size, header = FormatSMV.get_smv_header(image_file)

        # do not understand JHSim images
        if header.get("BEAMLINE") == "fake":
            return False

        # do not understand Timepix_SU images
        if header.get("BEAMLINE", "").upper() == "TIMEPIX_SU":
            return False

        # this used to include TIME
        wanted_header_items = [
            "BEAM_CENTER_X",
            "BEAM_CENTER_Y",
            "DISTANCE",
            "WAVELENGTH",
            "PIXEL_SIZE",
            "OSC_START",
            "OSC_RANGE",
            "SIZE1",
            "SIZE2",
            "BYTE_ORDER",
        ]

        for header_item in wanted_header_items:
            if not header_item in header:
                return False

        unwanted_header_items = ["DTREK_DATE_TIME"]

        for header_item in unwanted_header_items:
            if header_item in header:
                return False

        return True
Пример #19
0
    def understand(image_file):
        """Check to see if this looks like a Rigaku d*TREK SMV format image,
        i.e. we can make sense of it. Essentially that will be if it contains
        all of the keys we are looking for."""

        size, header = FormatSMV.get_smv_header(image_file)

        wanted_header_items = [
            "DETECTOR_NUMBER",
            "DETECTOR_NAMES",
            "BYTE_ORDER",
            "DIM",
            "SIZE1",
            "SIZE2",
            "Data_type",
        ]

        if any(header_item not in header
               for header_item in wanted_header_items):
            return False

        # code around CMOS1 on ALS 4.2.2

        detector_prefixes = header["DETECTOR_NAMES"].split()

        if len(detector_prefixes) == 1:
            prefix = detector_prefixes[0]
            det_desc = "%sDETECTOR_DESCRIPTION" % prefix
            if "CMOS-1" in header.get(det_desc, ""):
                return False

        detector_prefixes = header["DETECTOR_NAMES"].split()
        try:
            detector_number = int(header["DETECTOR_NUMBER"].strip())
        except (KeyError, AttributeError, ValueError):
            return False

        if detector_number != len(detector_prefixes):
            return False

        return True
Пример #20
0
def read_smv_image(image_file):
    header_size, header_dictionary = FormatSMV.get_smv_header(image_file)

    with open(image_file, "rb") as f:
        f.seek(header_size)

        big_endian = header_dictionary["BYTE_ORDER"] == "big_endian"

        image_size = (int(header_dictionary["SIZE1"]),
                      int(header_dictionary["SIZE2"]))

        if big_endian == dxtbx.ext.is_big_endian():
            raw_data = dxtbx.ext.read_uint16(
                streambuf(f), int(image_size[0] * image_size[1]))
        else:
            raw_data = dxtbx.ext.read_uint16_bs(
                streambuf(f), int(image_size[0] * image_size[1]))

    raw_data.reshape(flex.grid(image_size[1], image_size[0]))

    return raw_data
Пример #21
0
    def understand(image_file):
        '''Check to see if this looks like a CMOS1 d*TREK SMV format image,
    i.e. we can make sense of it. Essentially that will be if it contains
    all of the keys we are looking for.'''

        size, header = FormatSMV.get_smv_header(image_file)

        wanted_header_items = [
            'DETECTOR_NUMBER', 'DETECTOR_NAMES', 'BYTE_ORDER', 'DIM', 'SIZE1',
            'SIZE2', 'Data_type'
        ]

        for header_item in wanted_header_items:
            if not header_item in header:
                return False

        detector_prefixes = header['DETECTOR_NAMES'].split()

        if len(detector_prefixes) != 1:
            return False

        detector_prefix = detector_prefixes[0]

        more_wanted_header_items = [
            'DETECTOR_DIMENSIONS', 'DETECTOR_SIZE', 'DETECTOR_VECTORS',
            'GONIO_NAMES', 'GONIO_UNITS', 'GONIO_VALUES', 'GONIO_VECTORS'
        ]

        for header_item in more_wanted_header_items:
            if not '%s%s' % (detector_prefix, header_item) in header:
                return False

        det_desc = '%sDETECTOR_DESCRIPTION' % detector_prefix
        if 'CMOS-1' in header.get(det_desc, ''):
            return True

        return False
  def understand(image_file):
    '''Check to see if this looks like a CMOS1 d*TREK SMV format image,
    i.e. we can make sense of it. Essentially that will be if it contains
    all of the keys we are looking for.'''

    size, header = FormatSMV.get_smv_header(image_file)

    wanted_header_items = [
        'DETECTOR_NUMBER', 'DETECTOR_NAMES',
        'BYTE_ORDER', 'DIM', 'SIZE1', 'SIZE2', 'Data_type'
    ]

    for header_item in wanted_header_items:
      if not header_item in header:
        return False

    detector_prefixes = header['DETECTOR_NAMES'].split()

    if len(detector_prefixes) != 1:
      return False

    detector_prefix = detector_prefixes[0]

    more_wanted_header_items = [
        'DETECTOR_DIMENSIONS', 'DETECTOR_SIZE', 'DETECTOR_VECTORS',
        'GONIO_NAMES', 'GONIO_UNITS', 'GONIO_VALUES', 'GONIO_VECTORS'
        ]

    for header_item in more_wanted_header_items:
      if not '%s%s' % (detector_prefix, header_item) in header:
        return False

    det_desc = '%sDETECTOR_DESCRIPTION' % detector_prefix
    if 'CMOS-1' in header.get(det_desc, ''):
        return True

    return False
Пример #23
0
  def understand(image_file):
    '''Check to see if this looks like an ADSC SMV format image, i.e. we
    can make sense of it. Essentially that will be if it contains all of
    the keys we are looking for and not some we are not (i.e. that belong
    to a Rigaku Saturn.)'''

    size, header = FormatSMV.get_smv_header(image_file)

    wanted_header_items = ['BEAM_CENTER_X', 'BEAM_CENTER_Y',
                           'DISTANCE', 'WAVELENGTH', 'PIXEL_SIZE',
                           'OSC_START', 'OSC_RANGE', 'SIZE1', 'SIZE2',
                           'BYTE_ORDER', 'TIME']

    for header_item in wanted_header_items:
      if not header_item in header:
        return 0

    unwanted_header_items = ['DTREK_DATE_TIME']

    for header_item in unwanted_header_items:
      if header_item in header:
        return False

    return True
Пример #24
0
 def _start(self):
     FormatSMV._start(self)
     self._header_size = int(self._header_dictionary['HEADER_BYTES'])
 def _start(self):
   FormatSMV._start(self)
   self._header_size = int(self._header_dictionary['HEADER_BYTES'])
Пример #26
0
    def _start(self):

        FormatSMV._start(self)
Пример #27
0
  def _start(self):

    FormatSMV._start(self)
Пример #28
0
 def understand(image_file):
   size, header = FormatSMV.get_smv_header(image_file)
   if header.get("BEAMLINE") != "fake": return False
   if header.get("PREFIX") is None: return False
   return header.get("PREFIX").find('batch')>=0