ó
÷™xTc           @   sY   d  d l  m Z d  d l Z d  d l m Z m Z d  d l m Z d d d „  ƒ  YZ d S(   iÿÿÿÿ(   t   divisionN(   t
   Goniometert   KappaGoniometer(   t!   cbf_gonio_to_effective_axis_fixedt   goniometer_factoryc           B   s�   e  Z d  Z d „  Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z	 e d „  ƒ Z
 e d „  ƒ Z e d	 „  ƒ Z RS(
   s  A factory class for goniometer objects, which will encapsulate
  some standard goniometer designs to make it a little easier to get
  started with all of this - for cases when we are not using a CBF.
  When we have a CBF just use that factory method and everything will be
  peachy.c         C   s   d  S(   N(    (   t   self(    (    sD   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/model/goniometer.pyt   __init__   s    c         C   s+   t  t t t |  ƒ ƒ t t t | ƒ ƒ ƒ S(   N(   R   t   tuplet   mapt   float(   t   rotation_axist   fixed_rotation(    (    sD   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/model/goniometer.pyt   make_goniometer   s    c         C   s=   t  t |  ƒ t | ƒ t | ƒ t | ƒ t | ƒ t | ƒ ƒ S(   N(   R   R	   t   str(   t   alphat   omegat   kappat   phit	   directiont	   scan_axis(    (    sD   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/model/goniometer.pyt   make_kappa_goniometer"   s    					c       	   C   s   d }  d } t  j |  | ƒ S(   sU   Construct a single axis goniometer which is canonical in the
    CBF reference frame.i   i    (   i   i    i    (	   i   i    i    i    i   i    i    i    i   (   R   R   (   t   axist   fixed(    (    sD   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/model/goniometer.pyt   single_axis,   s    c       	   C   s   d }  d } t  j |  | ƒ S(   so   Construct a single axis goniometer which is canonical in the
    CBF reference frame, but reversed in rotation.iõÿÿÿi    i   (   iõÿÿÿi    i    (	   i   i    i    i    i   i    i    i    i   (   R   R   (   R   R   (    (    sD   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/model/goniometer.pyt   single_axis_reverse6   s    c      	   C   s+   t  |  ƒ d k s t ‚ d } t |  | ƒ S(   s‰   Return an goniometer instance for a known rotation axis, assuming
    that nothing is known about the fixed element of the rotation axis.i   i   i    (	   i   i    i    i    i   i    i    i    i   (   t   lent   AssertionErrorR   (   R   R   (    (    sD   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/model/goniometer.pyt
   known_axis@   s    c         C   s   t  j |  | | | | | ƒ S(   sU  Return a kappa goniometer where omega is the primary axis (i,e.
    aligned with X in the CBF coordinate frame) and has the kappa arm
    with angle alpha attached to it, aligned with -z, +y, +z or -y at
    omega = 0, that being the direction, which in turn has phi fixed to it
    which should initially be coincident with omega. We also need to know
    which axis is being used for the scan i.e. phi or omega. All angles
    should be given in degrees. This will work by first constructing the
    rotation axes and then composing them to the scan axis and fixed
    component of the rotation.(   R   R   (   R   R   R   R   R   R   (    (    sD   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/model/goniometer.pyR   K   s    c         C   s]   t  j ƒ  } | j |  t  j ƒ | j ƒ  } t | ƒ \ } } | j | ƒ ~ t j | | ƒ S(   s2   Initialize a goniometer model from an imgCIF file.(	   t   pycbft   cbf_handle_structt	   read_filet
   MSG_DIGESTt   construct_goniometerR   t   __swig_destroy__R   R   (   t   cif_filet
   cbf_handlet	   cbf_gonioR   R   (    (    sD   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/model/goniometer.pyt   imgCIFZ   s    c         C   s>   |  j  ƒ  } t | ƒ \ } } | j | ƒ ~ t j | | ƒ S(   sv   Initialize a goniometer model from an imgCIF file handle, where
    it is assumed that the file has already been read.(   R    R   R!   R   R   (   R#   R$   R   R   (    (    sD   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/model/goniometer.pyt   imgCIF_Hj   s
    (   t   __name__t
   __module__t   __doc__R   t   staticmethodR   R   R   R   R   R   R%   R&   (    (    (    sD   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/model/goniometer.pyR      s   	


(    (	   t
   __future__R    R   t   dxtbx_model_extR   R   t   goniometer_helpersR   R   (    (    (    sD   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/model/goniometer.pyt   <module>   s   