ó
ÿ™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   Format(   t
   FormatHDF5t   FormatHDF5Dectrisc           B   s°   e  Z d  Z e d „  ƒ Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z d d	 „ Z d d
 „ Z d d „ Z d d „ Z d d „ Z d d „ Z d d „ Z RS(   sè    This is a placeholder implementation only.  Open example dataset
      provided by Dectris Ltd, Jan 2013.  Read the first image only.
      Later replace this with a sweep-oriented implementation that
      reads the whole dataset.c         C   sD   t  Sy t j |  d ƒ j d ƒ } Wn t k
 r9 } t  SX| d k S(   Nt   rbi   s   ‰HDF

(   t   FalseR   t	   open_filet   readt   IOError(   t
   image_filet   tagt   e(    (    sL   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/format/FormatHDF5Dectris.pyt
   understand
   s    c         C   s)   |  j  | ƒ s t ‚ t j |  | ƒ d  S(   N(   R   t   AssertionErrorR   t   __init__(   t   selfR	   (    (    sL   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/format/FormatHDF5Dectris.pyR      s    c         C   s3   d d l  m } | |  j ƒ |  _ |  j j ƒ  d  S(   Niÿÿÿÿ(   t
   EIGERImage(   t   iotbx.detectors.eigerR   t   _image_filet   detectorbaset
   readHeader(   R   R   (    (    sL   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/format/FormatHDF5Dectris.pyt   _start   s    c         C   s   |  j  j ƒ  S(   N(   t   _goniometer_factoryt   single_axis(   R   (    (    sL   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/format/FormatHDF5Dectris.pyt   _goniometer   s    c         C   s‹   |  j  j d d d |  j j d |  j j |  j j f d d d d d	 |  j j |  j j f d
 |  j j |  j j f d d |  j j	 f d g  ƒ 	S(   s$   Return a model for a simple detectort   sensort   PADt   distancet   beam_centret   fast_directions   +xt   slow_directions   -yt
   pixel_sizet
   image_sizet   trusted_rangeiÿÿÿÿt   mask(
   t   _detector_factoryt   simpleR   R   t   beamxt   beamyR   t   size1t   size2t
   saturation(   R   (    (    sL   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/format/FormatHDF5Dectris.pyt	   _detector#   s    			c         C   s   |  j  j |  j j ƒ S(   s#   Return a simple model for the beam.(   t   _beam_factoryR$   R   t
   wavelength(   R   (    (    sL   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/format/FormatHDF5Dectris.pyt   _beam4   s    c         C   sH   |  j  j d d d d d |  j j |  j j |  j j f d i d d 6ƒ S(   sR   Replace this with true values later
       when HDF5 sweep support is implemented.t   image_rangei   t   exposure_timet   oscillationt   epochsg        (   i   i   (   t   _scan_factoryt	   make_scanR   t	   osc_startt   deltaphi(   R   (    (    sL   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/format/FormatHDF5Dectris.pyt   _scan9   s    	c         C   s   |  j  j ƒ  S(   N(   R   t   image_count(   R   (    (    sL   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/format/FormatHDF5Dectris.pyt   get_num_imagesF   s    c         C   s   t  j |  ƒ S(   N(   R   t   get_goniometer(   R   t   index(    (    sL   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/format/FormatHDF5Dectris.pyR9   I   s    c         C   s   t  j |  ƒ S(   N(   R   t   get_detector(   R   R:   (    (    sL   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/format/FormatHDF5Dectris.pyR;   L   s    c         C   s   t  j |  ƒ S(   N(   R   t   get_beam(   R   R:   (    (    sL   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/format/FormatHDF5Dectris.pyR<   O   s    c         C   s   t  j |  ƒ S(   N(   R   t   get_scan(   R   R:   (    (    sL   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/format/FormatHDF5Dectris.pyR=   R   s    c         C   s   t  j |  ƒ S(   N(   R   t   get_raw_data(   R   R:   (    (    sL   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/format/FormatHDF5Dectris.pyR>   U   s    c         C   s   | |  j  _ |  j  S(   N(   R   t
   img_number(   R   R:   (    (    sL   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/format/FormatHDF5Dectris.pyt   get_detectorbaseX   s    c         C   s   |  j  j | ƒ S(   N(   R   t   get_data_link(   R   R:   (    (    sL   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/format/FormatHDF5Dectris.pyt   get_image_file\   s    N(   t   __name__t
   __module__t   __doc__t   staticmethodR   R   R   R   R*   R-   R6   R8   t   NoneR9   R;   R<   R=   R>   R@   RB   (    (    (    sL   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/format/FormatHDF5Dectris.pyR      s    
							t   __main__Ni   (   t
   __future__R    t   dxtbx.format.FormatR   t   dxtbx.format.FormatHDF5R   R   RC   t   syst   argvt   argR   (    (    (    sL   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/format/FormatHDF5Dectris.pyt   <module>   s   Z