ó
™xTc           @   s“   d  d l  m Z d  d l Z d e j f d „  ƒ  YZ e d k r� d  d l Z d  d l Z e ƒ  Z e j e j	 d ƒ e j
 e j	 d ƒ Z n  d S(   iÿÿÿÿ(   t   divisionNt   readerc           B   s    e  Z d  Z d „  Z d „  Z RS(   s.   A class to read the GAIN.CBF files used in XDSc         C   s   t  j j |  ƒ d  S(   N(   t   xds_cbfR   t   __init__(   t   self(    (    s@   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/xds/gain_cbf.pyR      s    c         C   s.  d d l  m } d d l } t j j |  ƒ } t | | d | j d ƒ ƒ } t | | d | j d ƒ ƒ } | j t	 | d ƒ g | d d | j
 ƒ} | j t	 | d ƒ g | d d | j
 ƒj ƒ  } | j | | ƒ }	 | j | | ƒ }
 | j | d | j ƒ} | |
 |	 f d | | | f <| S(   s    Get the gain array from the fileiÿÿÿÿ(   t   ceilNi    i   t   dtypeg     @�@(   t   mathR   t   numpyR   R   t   get_datat   intt   shapet   arrayt   ranget   int32t	   transposet   dividet   zerost   float64(   R   t   dimR   R   t   sampled_gaint   nyt   nxt   i1t   j1t   i2t   j2t   gain(    (    s@   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/xds/gain_cbf.pyR	      s    !!-3(   t   __name__t
   __module__t   __doc__R   R	   (    (    (    s@   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/xds/gain_cbf.pyR      s   	t   __main__i   i   (   t
   __future__R    R   R   R   t   sysR   t   handlet	   read_filet   argvR	   t   image(    (    (    s@   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/xds/gain_cbf.pyt   <module>	   s   	