コード例 #1
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
コード例 #2
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
コード例 #3
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
コード例 #4
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
コード例 #5
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
コード例 #6
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
コード例 #7
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
コード例 #8
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
コード例 #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
コード例 #10
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
コード例 #11
0
ファイル: test_image_readers.py プロジェクト: antonyvam/dxtbx
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
コード例 #12
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
コード例 #13
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
コード例 #14
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
コード例 #15
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