ó
7™xTc           @   s”   d  Z  d d l m Z d d l m Z d d l m Z d d l m Z d d l Z e j	 d ƒ d „  Z
 d	 „  Z d
 „  Z e d k r� e ƒ  n  d S(   s»   
Plot of Le Page 1982 deltas vs. Lebedev 2005 perturbations based on
random sampling of distorted unit cells compatible with the 81 2-fold
symmetry operations possible for reduced cells.
iÿÿÿÿ(   t   division(   t   sgtbx(   t   uctbx(   t   flexNi    c          C   s“   g  }  x† t  j d g d d g d ƒ D]d } t j | ƒ } | j ƒ  d k rT q' n  | j ƒ  | k rl q' n  | j ƒ  r~ q' n  |  j | ƒ q' W|  S(   Niÿÿÿÿi	   i   i   (   R   t   nested_loopR   t   rot_mxt   determinantt   inverset
   is_unit_mxt   append(   t   resultt   elementst   r(    (    sY   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/examples/le_page_1982_vs_lebedev_2005.pyt    enumerate_reduced_cell_two_folds   s    '   c   
   	   C   sF  x?|  D]7} t  j ƒ  } | j t  j | ƒ ƒ | j ƒ  d k sG t ‚ t  j d | ƒ j d d ƒ } xÖ t d ƒ D]È } x‡ t	 rt
 | j ƒ  j ƒ  ƒ } x: t d ƒ D], }	 | |	 c d t j ƒ  d d | 9<q¦ Wy t j | ƒ } Wn t k
 rü q{ XPq{ W| j | j d | d	 t	 ƒ ƒ | j | j d | ƒ ƒ qr Wq Wd  S(
   Ni   t   groupt   volumeiè  i   i   i   t   reduced_cellt   deg(   R   t   space_groupt
   expand_smxt   rt_mxt   order_zt   AssertionErrort   space_group_infot   any_compatible_crystal_symmetryt   xranget   Truet   listt	   unit_cellt
   parameterst   randomR   t
   ValueErrorR	   t   le_page_1982_deltat   lebedev_2005_perturbation(
   t	   two_foldst   fudge_factort   deltast   perturbationst   two_foldR   t   symt   i_trialt   uc_fudget   i(    (    sY   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/examples/le_page_1982_vs_lebedev_2005.pyt   sample   s(    		 *  c       
   C   sð   t  ƒ  }  t |  ƒ d k s! t ‚ t j ƒ  } t j ƒ  } x< d d d d d g D]% } t d |  d | d	 | d
 | ƒ qO Wt j d | ƒ } | j | ƒ } | j | ƒ } t d d ƒ } x- t	 | | ƒ D] \ } } | | I| IJqÇ Wd GHd  S(   NiQ   gü©ñÒMb`?g{®Gáz„?g{®Gáz”?gš™™™™™©?gš™™™™™¹?R"   R#   R$   R%   t   datat!   le_page_1982_vs_lebedev_2005_plott   wt   OK(
   R   t   lenR   R   t   doubleR+   t   sort_permutationt   selectt   opent   zip(   R"   R$   R%   R#   t   permt   ft   xt   y(    (    sY   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/examples/le_page_1982_vs_lebedev_2005.pyt   run,   s"    	t   __main__(   t   __doc__t
   __future__R    t   cctbxR   R   t   cctbx.array_familyR   R   t   seedR   R+   R:   t   __name__(    (    (    sY   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/examples/le_page_1982_vs_lebedev_2005.pyt   <module>   s   	
		