ó
þ™xTc           @   s‹   d  d l  m Z d  d l m 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
 ƒ GHql Wn  d S(	   iÿÿÿÿ(   t   division(   t   matrix(   t   FormatSMVRigakuSaturnt   FormatSMVRigakuSaturnSN07400090c           B   s&   e  Z d  Z e d „  ƒ Z d „  Z RS(   sç   A class for reading SMV format Rigaku Saturn images, and correctly
  constructing a model for the experiment from this. This is the custom
  version for instrument with serial number 07400090 on Diamond Light Source
  beamline I19.c         C   sj   t  j |  ƒ \ } } | d j ƒ  d j ƒ  } y | d | } Wn t k
 rU t SX| d k rf t St S(   sÒ   Check to see if this looks like a Rigaku Saturn 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. Also checks the serial number.t   DETECTOR_NAMESi    s   %sSERIAL_NUMBERt   07400090(   R   t   get_smv_headert   splitt   stript   KeyErrort   Falset   True(   t
   image_filet   sizet   headert   detector_prefixt   serial_number(    (    sZ   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/format/FormatSMVRigakuSaturnSN07400090.pyt
   understand   s    c         C   s  |  j  d j ƒ  d j ƒ  } t t |  j  d | j ƒ  ƒ } t j d ƒ j d d t ƒ} | t j t	 | d  ƒ ƒ } | t j t	 | d ƒ ƒ } t t |  j  d | j ƒ  d	  ƒ } t t |  j  d | j ƒ  d	 ƒ } t t
 |  j  d
 | j ƒ  ƒ } | d | d | | d | d | }	 t t |  j  d | j ƒ  ƒ }
 t t |  j  d | j ƒ  ƒ } |  j  d | j ƒ  } t
 |  j  d | ƒ } g  } g  } xÈ t | ƒ D]º \ } } t j |
 d | d | d !ƒ } | d k r"| j | j | | d t ƒƒ | j t j d ƒ ƒ q¯| d k r\| j t j d ƒ ƒ | j | | | ƒ q¯t d | ‚ q¯W| j ƒ  | j ƒ  xL t | ƒ D]> } | | | } | | | } | | |	 }	 | | |	 }	 qŽWt
 |  j  d ƒ } d } |  j j d |	 j | j | j | | | | f ƒ S(   s  Return a model for the detector, allowing for two-theta offsets
    and the detector position. This will be rather more complex... and
    overloads the definition for the general Rigaku Saturn detector by
    rotating the detector by -90 degrees about the beam.R   i    s   %sDETECTOR_VECTORSi   i¦ÿÿÿt   degi   s   %sSPATIAL_DISTORTION_INFOi   s   %sDETECTOR_DIMENSIONSs   %sGONIO_VECTORSs   %sGONIO_VALUESs   %sGONIO_UNITSs   %sGONIO_NUM_VALUESg        t   mmg      ð?s   unknown axis unit %st   SATURATED_VALUEt   CCD(   i    i    i   (   g        g        g        (	   g      ð?g        g        g        g      ð?g        g        g        g      ð?(   t   _header_dictionaryR   R   t   mapt   floatR   t   colt$   axis_and_angle_as_r3_rotation_matrixR   t   tuplet   intt	   enumeratet   appendt   sqrt   RuntimeErrort   reverset   ranget   _detector_factoryt   complext   elems(   t   selft   detector_namet   detector_axest   Rt   detector_fastt   detector_slowt   beam_pixelst
   pixel_sizet
   image_sizet   detector_origint
   gonio_axest   gonio_valuest   gonio_unitst   gonio_num_axest	   rotationst   translationst   jt   unitt   axist   overloadt	   underload(    (    sZ   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/format/FormatSMVRigakuSaturnSN07400090.pyt	   _detector0   sd    	" 


	(   t   __name__t
   __module__t   __doc__t   staticmethodR   R;   (    (    (    sZ   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/format/FormatSMVRigakuSaturnSN07400090.pyR      s   t   __main__Ni   (   t
   __future__R    t   scitbxR   t"   dxtbx.format.FormatSMVRigakuSaturnR   R   R<   t   syst   argvt   argR   (    (    (    sZ   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/format/FormatSMVRigakuSaturnSN07400090.pyt   <module>   s   c