ó
ü™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   FormatTIFFRayonixSPring8BL32XUc           B   s8   e  Z d  Z e d „  ƒ Z d „  Z d „  Z d „  Z RS(   sª   A class for reading TIFF format Rayonix images, and correctly
  constructing a model for the experiment from this, for beamline
  SPring8/BL32XU with a reversed phi axis.c         C   sŠ   t  j |  ƒ \ } } } } } d } xO | d d !j ƒ  j d ƒ D]1 } d | j ƒ  k rA t | j ƒ  d ƒ } qA qA W| d k r† t Sd S(	   sÛ   Check to see if this looks like an Rayonix TIFF format image,
    i.e. we can make sense of it. This simply checks that records which
    describe the size of the image match with the TIFF records which do
    the same.iÿÿÿÿi 	  i   s   
s   detector serial numberi   Ni   (   R   t   get_tiff_headert   stript   splitt   lowert   intt   True(   t
   image_filet   widtht   heightt   deptht   ordert   bytest   serial_numbert   record(    (    sY   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/format/FormatTIFFRayonixSPring8BL32XU.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	   (    (    sY   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/format/FormatTIFFRayonixSPring8BL32XU.pyR   '   s    c      
   C   sA  |  j  ƒ  \ } } } } |  j ƒ  } | d d k s: t ‚ | d d k sP t ‚ | d d k sf t ‚ | d d k s| t ‚ | d d k s’ t ‚ |  j ƒ  } |  j ƒ  \ } } |  j ƒ  }	 |  j |  j f }
 t j	 |  j
 |  j d d !ƒ d } d } | |	 d | |	 d f } |  j j d | | d d	 |	 |
 | | f g  ƒ	 S(
   sq   Return a model for a simple detector, which at the moment insists
    that the offsets and rotations are all 0.0.i    g        i   i   ih  il  t   CCDs   +xs   -y(   t   _get_rayonix_scan_anglest   _get_rayonix_detector_rotationsR   t   _get_rayonix_distancet   _get_rayonix_beam_xyt   _get_rayonix_pixel_sizet   _tiff_widtht   _tiff_heightt   structt   unpackt   _it   _tiff_header_bytest   _detector_factoryt   simple(   R   t   startst   endst   offsetR
   t	   rotationst   distancet   beam_xt   beam_yt
   pixel_sizet
   image_sizet   overloadt	   underloadt   beam(    (    sY   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/format/FormatTIFFRayonixSPring8BL32XU.pyt	   _detector0   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.(   R   t   _goniometer_factoryt   single_axis_reverse(   R   R#   R$   R%   R
   (    (    sY   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/format/FormatTIFFRayonixSPring8BL32XU.pyt   _goniometerP   s    (   t   __name__t
   __module__t   __doc__t   staticmethodR   R   R/   R2   (    (    (    sY   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/format/FormatTIFFRayonixSPring8BL32XU.pyR      s
   			 t   __main__i   (   t
   __future__R    R   t   dxtbx.format.FormatTIFFRayonixR   R   R3   t   syst   argvt   argR   (    (    (    sY   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/format/FormatTIFFRayonixSPring8BL32XU.pyt   <module>	   s   K