ó
õxTc           @   sL   d  d l  m Z d e f d     YZ e d k rH e   Z e j   n  d S(   i’’’’(   t   divisiont   Testc           B   s>   e  Z d    Z d   Z d   Z d   Z d   Z d   Z RS(   c         C   sü   d d  l  } d d  l } y | j j d  } Wn" t k
 rR } d GHt d  n X| j j | d d d  } d d  l } | j	 |  } | j
   |  _ t |  j  d k s³ t  d	 |  _ |  j d j   |  _ |  j d j |  j d j    |  _ d  S(
   Ni’’’’t   dials_regressions%   FAIL: dials_regression not configuredi    t   image_examplest   XDSs	   XPARM.XDSi   gÓ
b®ł(Š?(   t   ost   libtbx.load_envt   envt	   dist_patht   KeyErrort   exitt   patht   joint   dxtbxt   loadt   get_detectort   detectort   lent   AssertionErrort   attlent   get_distancet   distancet   get_ray_intersectiont
   get_normalt   origin(   t   selfR   t   libtbxR   t   et   filenameR   t   models(    (    sW   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/tests/model/tst_parallax_correction.pyt   __init__   s"    		c            sU   d d l  m     f d   } x* t d  D] } |   } |  j |  q, Wd GHd  S(   Ni’’’’(   t   uniformc              s     d d    d d  f S(   Niü’’ič  (    (    (   R   (    sW   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/tests/model/tst_parallax_correction.pyt   <lambda>   s    i'  t   OK(   t   randomR   t   ranget
   tst_single(   R   t   random_coordt   it   xy(    (   R   sW   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/tests/model/tst_parallax_correction.pyt   run   s    	c         C   s£   d d l  m } | j |  } | j |  j |   } | j |  j |   } | j |  j |   } t | |  d k  s t  t | |  d k  s t  d  S(   Ni’’’’(   t   matrixgHÆ¼ņ×z>gü©ńŅMbP?(   t   scitbxR)   t   colt   correct_goldt   correctt   correct_invt   absR   (   R   R'   R)   t   xy_corr_goldt   xy_corrt   xy_corr_inv(    (    sW   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/tests/model/tst_parallax_correction.pyR$   )   s    c         C   sü   d d l  m } | j |  j d j |   } |  j | | j   } |  j d j   } | j | d | d | d f  } | j | d | d | d f  } | j |  | j   } | j |  | j   }	 | j | d | | d |	 f  }
 |
 S(	   Ni’’’’(   R)   i    i   i   i   i   i   (	   R*   R)   R+   R   t   get_lab_coordR   t   lengtht   get_d_matrixt   dot(   R   R'   R)   t   s1t   labt   dt   d0t   d1t   mm0t   mm1t   mmcal(    (    sW   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/tests/model/tst_parallax_correction.pyR,   7   s    $$%c         C   s,   d d l  m } | |  j |  j |  j |  S(   Ni’’’’(   t   parallax_correction(   t   dxtbx.modelR?   R   R   R   (   R   R'   R?   (    (    sW   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/tests/model/tst_parallax_correction.pyR-   C   s    c         C   s,   d d l  m } | |  j |  j |  j |  S(   Ni’’’’(   t   parallax_correction_inv(   R@   RA   R   R   R   (   R   R'   RA   (    (    sW   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/tests/model/tst_parallax_correction.pyR.   G   s    (   t   __name__t
   __module__R   R(   R$   R,   R-   R.   (    (    (    sW   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/tests/model/tst_parallax_correction.pyR      s   					t   __main__N(   t
   __future__R    t   objectR   RB   t   testR(   (    (    (    sW   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/tests/model/tst_parallax_correction.pyt   <module>   s   I	