ó
ý™xTc           @   s{   d  d l  m Z d  d l m Z d e f d „  ƒ  YZ e d k rw d  d l Z x& e j d D] Z e j	 e ƒ GHq\ Wn  d S(   iÿÿÿÿ(   t   division(   t   Formatt   FormatMarIPc           B   sS   e  Z d  Z e d „  ƒ Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 RS(   s   An image reading class for MarIP-format images
  Positive identification:  first 140 bytes contain the string "mar research"
  c         C   sG   y t  j |  d ƒ j d ƒ } Wn t k
 r3 t SX| j d ƒ d k S(   Nt   rbiŒ   s   mar researchi    (   R   t	   open_filet   readt   IOErrort   Falset   find(   t
   image_filet   tag(    (    sF   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/format/FormatMarIP.pyt
   understand   s
    c         C   s)   |  j  | ƒ s t ‚ t j |  | ƒ d S(   s3   Initialise the image structure from the given file.N(   R   t   AssertionErrorR   t   __init__(   t   selfR	   (    (    sF   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/format/FormatMarIP.pyR      s    c         C   s3   d d l  m } | |  j ƒ |  _ |  j j ƒ  d S(   sÂ   Open the image file, read the image header, copy the key / value
    pairs into an internal dictionary self._header_dictionary along with
    the length of the header in bytes self._header_size.iÿÿÿÿ(   t
   MARIPImageN(   t   iotbx.detectors.marIPR   t   _image_filet   detectorbaset
   readHeader(   R   R   (    (    sF   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/format/FormatMarIP.pyt   _start   s    c         C   s   |  j  j ƒ  S(   N(   t   _goniometer_factoryt   single_axis(   R   (    (    sF   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/format/FormatMarIP.pyt   _goniometer#   s    c         C   sÇ   |  j  j d d k s t ‚ |  j j d d d |  j  j d d |  j  j d |  j  j d	 f d
 d d d d |  j  j d |  j  j d f d |  j  j d |  j  j d f d d |  j  j d f d g  ƒ 	S(   sq   Return a model for a simple detector, which at the moment insists
    that the offsets and rotations are all 0.0.t   TWOTHETAg        t   sensort   IMAGE_PLATEt   distancet   DISTANCEt   beam_centret   BEAM_CENTER_Xt   BEAM_CENTER_Yt   fast_directions   +xt   slow_directions   -yt
   pixel_sizet
   PIXEL_SIZEt
   image_sizet   SIZE1t   SIZE2t   trusted_rangei    t   CCD_IMAGE_SATURATIONt   mask(   R   t
   parametersR   t   _detector_factoryt   simple(   R   (    (    sF   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/format/FormatMarIP.pyt	   _detector'   s    c         C   s   |  j  j |  j j d ƒ S(   s#   Return a simple model for the beam.t
   WAVELENGTH(   t   _beam_factoryR,   R   R*   (   R   (    (    sF   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/format/FormatMarIP.pyt   _beam;   s    c         C   sT   |  j  j d |  j d d d |  j j j ƒ  d |  j j d d |  j j d d	 d
 ƒ S(   s+   Return the scan information for this image.t   filenamet   formatt   MARIPt   exposure_timest	   osc_startt	   OSC_STARTt	   osc_widtht	   OSC_RANGEt   epochN(   t   _scan_factoryt   singleR   R   t   adaptort   exposure_timeR*   t   None(   R   (    (    sF   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/format/FormatMarIP.pyt   _scan@   s    	(   t   __name__t
   __module__t   __doc__t   staticmethodR   R   R   R   R-   R0   R?   (    (    (    sF   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/format/FormatMarIP.pyR      s   					t   __main__Ni   (
   t
   __future__R    t   dxtbx.format.FormatR   R   R@   t   syst   argvt   argR   (    (    (    sF   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/format/FormatMarIP.pyt   <module>   s   D