ó
ŭxTc           @   s   d  d l  m Z d  d l Z d  d l m Z d e f d     YZ e d k r d  d l Z x& e j d D] Z	 e j
 e	  GHqh Wn  d S(   i˙˙˙˙(   t   divisionN(   t   FormatTIFFRayonixt   FormatTIFFRayonixESRFc           B   s8   e  Z d  Z e d    Z d   Z d   Z d   Z RS(   sr   A class for reading TIFF format Rayonix images, and correctly
  constructing a model for the experiment from this.c         C   s=  t  j |   \ } } } } } d d l } d d l m } d d l m } m }	 i d | 6d |	 6| }
 d } | | j |
 d | | d	 | d
 !  } d | } d | | j |
 d | | d | d !  } d | | j |
 d | | d | d !  } | d | d } | d d k o<| d d k o<| d k  S(   s   Check to see if this looks like an Rayonix TIFF format image,
    i.e. we can make sense of it.  Returns true if the beam center is specified
    in pixels.i˙˙˙˙N(   t   col(   t   LITTLE_ENDIANt
   BIG_ENDIANt   <t   >i   t   iiiP   iX   g      à?gíµ ÷Ĉ°>i  i  güİñÒMbP?i  i  i    i   (	   R   t   get_tiff_headert   structt   scitbx.matrixR   t   dxtbx.format.FormatTIFFHelpersR   R   t   unpack(   t
   image_filet   widtht   heightt   deptht   ordert   bytesR
   R   R   R   t   formatt   offsett   detector_size_pixelst   detector_center_pxt   detector_pixel_sz_mmt   header_beam_centert   disagreement(    (    sP   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/format/FormatTIFFRayonixESRF.pyt
   understand   s     +
)) c         C   s)   |  j  |  s t  t j |  |  d S(   sc   Initialise the image structure from the given file, including a
    proper model of the experiment.N(   R   t   AssertionErrorR   t   __init__(   t   selfR   (    (    sP   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/format/FormatTIFFRayonixESRF.pyR   3   s    c         C   s%   |  j    \ } } } } |  j j   S(   s°   Return a model for goniometer corresponding to the values stored
    in the image header. In the first instance assume this is a single
    axis annd raise exception otherwise.(   t   _get_rayonix_scan_anglest   _goniometer_factoryt   single_axis(   R   t   startst   endsR   R   (    (    sP   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/format/FormatTIFFRayonixESRF.pyt   _goniometer<   s    c         C   sl   t  j |  j |  j d d ! d  \ } } t  j |  j |  j d d ! d  \ } } | d | | d | f S(   s
  Get the beam x, y positions which are defined in the standard
    to be in pixels. X and Y are not defined by the documentation, so
    taking as a given that these are horizontal and vertical. N.B.
    the documentation states that the horizontal direction is fast.i  i  i   i  i  iè  (   R
   R   t   _iit   _tiff_header_bytes(   R   t   beam_xt   beam_yt   pixel_xt   pixel_y(    (    sP   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/format/FormatTIFFRayonixESRF.pyt   _get_rayonix_beam_xyP   s
    ##(   t   __name__t
   __module__t   __doc__t   staticmethodR   R   R$   R+   (    (    (    sP   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/format/FormatTIFFRayonixESRF.pyR      s
   			t   __main__i   (   t
   __future__R    R
   t   dxtbx.format.FormatTIFFRayonixR   R   R,   t   syst   argvt   argR   (    (    (    sP   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/format/FormatTIFFRayonixESRF.pyt   <module>   s   K