ó
ûxTc           @   s   d  d l  m Z d  d l 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  GHqx Wn  d S(	   i˙˙˙˙(   t   divisionN(   t   FormatCBFFull(   t   determine_pilatus_maskt   FormatCBFFullPilatusc           B   s8   e  Z d  Z e d    Z d   Z d   Z d   Z RS(   sK   An image reading class for full CBF format images from Pilatus
  detectors.c         C   sI   t  j |   } x3 | j d  D]" } d | k r d | k r t Sq Wt S(   sV   Check to see if this looks like an CBF format image, i.e. we can
    make sense of it.s   
s   _array_data.header_conventiont   PILATUS(   R   t   get_cbf_headert   splitt   Truet   False(   t
   image_filet   headert   record(    (    sO   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/format/FormatCBFFullPilatus.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	   (    (    sO   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/format/FormatCBFFullPilatus.pyR   #   s    c         C   s9   t  j |   t j   |  _ |  j j |  j t j  d S(   sK   Open the image file as a cbf file handle, and keep this somewhere
    safe.N(   R   t   _startt   pycbft   cbf_handle_structt   _cbf_handlet   read_widefilet   _image_filet
   MSG_DIGEST(   R   (    (    sO   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/format/FormatCBFFullPilatus.pyR   ,   s    c         C   sj   |  j  j |  j d  } | d j d  x: t |  D], \ } } } } | d j | | | |  q6 W| S(   s<   Return a working detector instance, with added mask regions.t   PADi    i˙˙˙˙i@B (   i˙˙˙˙i@B (   t   _detector_factoryt   imgCIF_HR   t   set_trusted_rangeR   t   add_mask(   R   t   detectort   f0t   s0t   f1t   s1(    (    sO   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/format/FormatCBFFullPilatus.pyt	   _detector7   s    	(   t   __name__t
   __module__t   __doc__t   staticmethodR   R   R   R!   (    (    (    sO   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/format/FormatCBFFullPilatus.pyR      s
   			t   __main__i   (   t
   __future__R    R   t   dxtbx.format.FormatCBFFullR   t!   dxtbx.format.FormatPilatusHelpersR   R   R"   t   syst   argvt   argR   (    (    (    sO   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/format/FormatCBFFullPilatus.pyt   <module>
   s   3