ó
ª™xTc           @   sZ  d  d l  m Z d  d l m Z d  d l m Z d  d l m Z d  d l Z d  d l m	 Z	 d  d l
 m Z d  d l m Z d  d l Z d  d	 l m Z d  d l Z d  d l Z d  d l Z d
 e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d S(   iÿÿÿÿ(   t   division(   t   miller(   t   crystal(   t   table_utilsN(   t   reindex(   t   flex(   t   Sorry(   t   robust_statisticst
   reindexingc           B   s;   e  Z d  Z d d d d d d „ Z d „  Z d d „ Z RS(   s    Reindexing matrices gš™™™™™©?g      @c         C   s  | |  _  | |  _ | |  _ | |  _ |  j d  k rB t j |  _ n  | |  _ | j ƒ  j	 | ƒ |  _
 | j ƒ  j	 | ƒ j ƒ  |  _ | j ƒ  j	 | ƒ j ƒ  |  _ t j d |  j j ƒ  d |  j j ƒ  ƒ |  _ t j d |  j j ƒ  d |  j j ƒ  ƒ |  _ t j d |  j d |  j d |  j  d |  j d |  j d |  j j ƒ  d	 |  j ƒ |  _ |  j j |  _ |  j j |  _ |  j j |  j ƒ j ƒ  |  _ |  j j |  j ƒ j ƒ  |  _ |  j j  ƒ  |  _! |  j j" ƒ  |  _# g  |  _$ g  |  _% t& |  j# ƒ d
 k r	|  j' ƒ  |  j( ƒ  n |  j d IJd  S(   Nt	   unit_cellt   space_groupt   xs1t   xs2t   relative_length_tolerancet   absolute_angle_tolerancet	   max_deltat   anomalous_flagt   outi    s6   No simple reindexing relation found between unit cells()   R   R   t   lattice_symmetry_max_deltaR   t   Nonet   syst   stdoutt	   file_namet	   deep_copyt   set_observation_typet	   set_b_orit   average_bijvoet_matest   set_at   set_bR   t   symmetryR	   R
   t   set_a_xst   set_b_xsR   t   reindexing_operatorsR   t   cosetst   cb_op_to_n_1t   set_a_to_nigglit   cb_op_to_n_2t   set_b_to_nigglit   change_basist
   map_to_asut	   set_a_nigt	   set_b_nigt   cb_ops_in_niggli_settingt   ops_in_niggli_settingt   combined_cb_opst   nice_cb_opst	   cc_valuest   matchest   lent   analyset   select_and_transform(   t   selfR   R   R   R   R   R   R   (    (    sI   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/pair_analyses.pyt   __init__   sD    														
c         C   sÐ   g  } xÃ t  |  j |  j ƒ D]¬ \ } } |  j j | ƒ j ƒ  } |  j j | d t ƒ\ } } | j	 | d t ƒ} |  j
 j | j ƒ  ƒ |  j j d t | j ƒ  j ƒ  ƒ t |  j j ƒ  j ƒ  ƒ ƒ q Wd  S(   Nt   assert_is_similar_symmetryg      Y@(   t   zipR+   R-   R)   R&   R'   R(   t   common_setst   Falset   correlationR.   t   appendt   coefficientR/   t   floatt   indicest   size(   R3   t
   table_datat   cb_opt
   comb_cb_opt   tmp_set_b_nigt   tmp_set_a_nigt   tmp_cc(    (    sI   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/pair_analyses.pyR1   H   s    		"g      è?c         C   s9  d } d } g  } x˜ t  t |  j ƒ ƒ D]� } | j |  j | j ƒ  d |  j | d |  j | d g ƒ |  j | | k r( | |  j | k  r© |  j | } | } q© q( q( Wd } d
 | | d <t j | g | d d  d t
 d t d d d d ƒ|  _ |  j J|  j d IJ|  j d IJ|  j J|  j |  j IJ|  j Jt |  j | j ƒ  ƒ d k rf|  j d IJny |  j d |  j | j ƒ  IJ|  j d IJ|  j d  k	 rß|  j GH|  j d IJ|  j d |  j |  j | j ƒ  f IJn  |  j d IJ|  j j |  j ƒ j |  j | ƒ j |  j j ƒ  ƒ j ƒ  j |  j ƒ } | S(   Ng      ð¿i    s   %4.3fs   %4.1fs      t   Operatort   Correlations   matches (%)t   choices    <--- i   t   commentst
   has_headert   separate_rowst   prefixs   | t   postfixs    |s   Reference analysess6      The following reindexing operators have been found:s   h,k,lsU   The data doesn't need to be reindexed! Indexing is consistent between these datasets.s?   If the data is reindexed with operator (%s), the correlation ofs4   the intensities to the reference data is maximized. s#   This can be done for instance with:sN     phenix.reflection_file_converter %s --change_of_basis="%s" <output_options> sO   -------------------------------------------------------------------------------(   RE   RF   s   matches (%)RG   (   t   rangeR0   R-   R:   t   as_hklR.   R/   R   t   formatR   t   TrueR8   t   tableR   t   strR   R   R&   R%   R+   t   inverseR'   R   (   R3   t   matches_cut_offt   max_cct   locationR?   t   iit   legendt   transform_b(    (    sI   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/pair_analyses.pyR2   W   sR    
*N(   t   __name__t
   __module__t   __doc__R   R4   R1   R2   (    (    (    sI   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/pair_analyses.pyR      s   /	t   delta_generatorc           B   s   e  Z d  d „ Z RS(   g      ð?c         C   s6  | j  ƒ  |  _ | j  ƒ  |  _ d | |  _ |  j j ƒ  s@ t ‚ |  j j ƒ  sU t ‚ |  j j ƒ  rt |  j j ƒ  n  |  j j ƒ  r“ |  j j ƒ  n  |  j j |  j ƒ \ |  _ |  _ |  j j	 d |  j j
 ƒ  |  j d |  j j ƒ  |  j ƒ j |  j ƒ |  _ |  j j	 d |  j j
 ƒ  |  j j
 ƒ  d t j |  j j ƒ  |  j j ƒ  |  j j ƒ  |  j j ƒ  ƒ ƒ j |  j ƒ |  _ |  j j	 d t j |  j j
 ƒ  |  j j
 ƒ  ƒ d t j |  j j ƒ  |  j j ƒ  |  j j ƒ  |  j j ƒ  ƒ ƒ j |  j ƒ |  _ |  j j ƒ  s|  j j ƒ  n  |  j j ƒ  s7|  j j ƒ  n  |  j j	 d |  j j
 ƒ  |  j j
 ƒ  d t j |  j j ƒ  |  j j ƒ  |  j j ƒ  |  j j ƒ  ƒ ƒ j |  j ƒ |  _ |  j j	 d t j |  j j
 ƒ  |  j j
 ƒ  ƒ d t j |  j j ƒ  |  j j ƒ  |  j j ƒ  |  j j ƒ  ƒ ƒ j |  j ƒ |  _ d  S(   Ng      ð?t   datat   sigmas(   R   t   natt   dert   nsr_biast   is_real_arrayt   AssertionErrort   is_xray_intensity_arrayt	   f_sq_as_fR7   t   customized_copyR^   R_   R   R   t   sqrtt   delta_ft   abst   abs_delta_ft	   f_as_f_sqt   delta_it   abs_delta_i(   R3   R`   Ra   Rb   (    (    sI   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/pair_analyses.pyR4   Ž   sL    !#%##%#(   RZ   R[   R4   (    (    (    sI   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/pair_analyses.pyR]   �   s   t   outlier_rejectionc           B   s_   e  Z d  d i e d 6e d 6e d 6d d „ Z d „  Z d „  Z d „  Z d	 „  Z	 d
 „  Z
 RS(   i   i    t   solvet   rmst   rms_and_sigmac         C   sŸ  | |  _  | |  _ |  j  d  k r0 t j |  _  n  | |  _ | |  _ | j ƒ  |  _ | j ƒ  |  _	 |  j j
 |  j	 ƒ \ |  _ |  _	 |  j j ƒ  s– t ‚ |  j j ƒ  s« t ‚ |  j j ƒ  rÏ |  j j ƒ  |  _ n  |  j	 j ƒ  ró |  j	 j ƒ  |  _	 n  t |  j |  j	 ƒ } | j |  _ |  j j d t ƒ |  j j d t d d ƒ |  _ |  j j d t d d ƒ |  _ t j |  j j ƒ  j ƒ  t ƒ |  _ |  j ƒ  |  j ƒ  d  S(   Nt   auto_binningt   use_binningt   return_failg   ¢”mB(   R   t   methodR   R   R   t   cut_level_rmst   cut_level_sigmaR   R`   Ra   R7   Rc   Rd   Re   Rf   R]   Rk   Ri   t   setup_binner_d_star_sq_stepRP   t$   mean_of_intensity_divided_by_epsilont   mean_df2t(   mean_of_squared_sigma_divided_by_epsilont	   mean_sdf2R   t   boolR=   R>   t   resultt   detect_outlierst   remove_outliers(   R3   R`   Ra   Rw   Rx   Rv   R   t	   delta_gen(    (    sI   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/pair_analyses.pyR4   Å   s6    				!$
c         C   sÁ   d } |  j  d r  | d 7} n  |  j  d r: | d 7} n  |  j  d rT | d 7} n  | d k so t d ƒ ‚ n  |  j  d r‰ |  j ƒ  n  |  j  d r£ |  j ƒ  n  |  j  d r½ |  j ƒ  n  d  S(   Ni    Rp   i   Rq   Rr   s/   Outlier removal protocol not specified properly(   Rv   R   t   detect_outliers_solvet   detect_outliers_rmst   detect_outliers_sigma(   R3   t
   count_true(    (    sI   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/pair_analyses.pyR€   ö   s    c         C   s  t  j |  j j ƒ t  j |  j j ƒ } x± |  j j ƒ  j ƒ  D]š } |  j j ƒ  j | ƒ j	 ƒ  } | | |  j j
 ƒ  |  j j
 ƒ  } t  j | ƒ |  j } |  j j ƒ  | k } | j | ƒ } |  j j | | ƒ |  _ q> W|  j J|  j d |  j j t ƒ IJ|  j d IJ|  j Jd S(   s  
    TT says:
    I toss everything > 3 sigma in the scaling,
    where sigma comes from the rms of everything being scaled:

    sigma**2 = <delta**2>- <experimental-sigmas**2>

    Then if a particular
    delta**2 > 3 sigma**2 + experimental-sigmas**2
    then I toss it.
    s     %8i potential outliers detecteds'    They will be removed from the data setN(   R   t   doubleR{   R^   R}   Ri   t   binnert	   range_allt	   selectiont
   iselectionR_   Rh   Rw   t   selectR   t   set_selectedR   t   countRP   (   R3   t   terwilliger_sigma_arrayt
   bin_numberRŠ   t   tmp_sigma_arrayt   potential_outliers(    (    sI   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/pair_analyses.pyRƒ     s    
c         C   sÐ   x‘ |  j  j ƒ  j ƒ  D]z } |  j  j ƒ  j | ƒ j ƒ  } |  j  j ƒ  |  j t j |  j	 j | ƒ k } | j
 | ƒ } |  j j | | ƒ |  _ q W|  j J|  j d |  j j t ƒ IJ|  j d IJ|  j Jd  S(   Ns     %8i potential outliers detecteds'    They will be removed from the data set(   Ri   Rˆ   R‰   RŠ   R‹   R^   Rw   t   mathRh   R{   RŒ   R   R�   R   RŽ   RP   (   R3   R�   RŠ   R’   (    (    sI   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/pair_analyses.pyR„   0  s    
c         C   sb  |  j  j ƒ  |  j  j ƒ  |  j k  } | j ƒ  } |  j j ƒ  |  j j ƒ  |  j k  } | j ƒ  } x‘ |  j j ƒ  j ƒ  D]z } |  j j ƒ  j	 | ƒ j ƒ  } |  j j ƒ  |  j
 t j |  j j | ƒ k } | j | ƒ } |  j j | | ƒ |  _ qx W|  j j | t ƒ |  _ |  j j | t ƒ |  _ |  j J|  j d |  j j t ƒ IJ|  j d IJ|  j Jd  S(   Ns     %8i potential outliers detecteds'    They will be removed from the data set(   R`   R^   R_   Rx   R‹   Ra   Ri   Rˆ   R‰   RŠ   Rw   R“   Rh   R{   RŒ   R   R�   RP   R   RŽ   (   R3   t   potential_outlier_natt
   nat_selectt   potential_outlier_dert
   der_selectR�   RŠ   R’   (    (    sI   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/pair_analyses.pyR…   @  s&    
c         C   sy   |  j  j |  j ƒ } t j |  j  j ƒ  | j ƒ  ƒ } |  j  j | j d ƒ ƒ |  _  |  j  j |  j ƒ \ |  _  |  _ d  S(   Ni    (	   R`   RŒ   R   R   t   match_indicesR=   t   single_selectionR7   Ra   (   R3   R’   R/   (    (    sI   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/pair_analyses.pyR�   ^  s
    N(   RZ   R[   R8   RP   R   R4   R€   Rƒ   R„   R…   R�   (    (    (    sI   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/pair_analyses.pyRo   Ä   s   +		#		t   f_double_prime_ratioc           B   sA   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d d „ Z RS(   c   	      C   s‚  | j  ƒ  s t ‚ | j  ƒ  s$ t ‚ | j ƒ  } | j ƒ  } | j ƒ  sN t ‚ | j ƒ  ri | j ƒ  } n  | j ƒ  s{ t ‚ | j ƒ  r– | j ƒ  } n  | j ƒ  \ } } | j ƒ  | j ƒ  |  _ | j	 ƒ  | j	 ƒ  | j	 ƒ  | j	 ƒ  |  _
 | j ƒ  \ } } | j ƒ  | j ƒ  |  _ | j	 ƒ  | j	 ƒ  | j	 ƒ  | j	 ƒ  |  _ t j d g ƒ |  _ t j j d |  ƒ |  j d |  _ d  S(   Ng      ð?t   target_evaluatori    (   R   Rd   R   Rc   t   is_xray_amplitude_arrayRl   t   hemispheres_acentricsR^   t   diff1R_   t   v1t   diff2t   v2R   R‡   t   xt   scitbxt   lbfgst   runt   ratio(	   R3   t   lambda1t   lambda2t   tmp_l1t   tmp_l2t   l1pt   l1nt   l2pt   l2n(    (    sI   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/pair_analyses.pyR4   j  s*    c         C   s"   |  j  ƒ  } |  j ƒ  } | | f S(   N(   t   compute_functionalt   compute_gradient(   R3   t   ft   g(    (    sI   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/pair_analyses.pyt    compute_functional_and_gradients‹  s    c         C   sh   |  j  |  j |  j d } | | } |  j |  j |  j d |  j d } | | } t j | ƒ } | S(   Ni    (   Rž   R    R¢   RŸ   R¡   R   t   sum(   R3   t   topt   bottomR   (    (    sI   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/pair_analyses.pyR¯   ‘  s    
&
c         C   s¡   |  j  |  j |  j d |  j d } |  j |  j |  j d } d |  j d | | |  j | | } d |  j | | } t j | | ƒ } t j | g ƒ S(   Ni    g       À(   RŸ   R¡   R¢   Rž   R    R   R´   R‡   (   R3   t
   tmp_bottomt   tmp_topt   part1t   part2R   (    (    sI   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/pair_analyses.pyR°   ™  s    &(c         C   si   d } |  j  ƒ  } |  j d c | 7<|  j  ƒ  } |  j d c | 8<| | } | | } t j | g ƒ S(   NgH¯¼šò×z>i    (   R¯   R¢   R   R‡   (   R3   t   ht   currentt   newR   (    (    sI   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/pair_analyses.pyt   compute_gradient_fd¡  s    
c         C   s9   | d  k r t j } n  | J| d |  j d IJ| Jd  S(   Ns)   Estimated ratio of fdp(w1)/fwp(w2): %3.2fi    (   R   R   R   R¢   (   R3   R   (    (    sI   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/pair_analyses.pyt   show«  s
    N(	   RZ   R[   R4   R³   R¯   R°   R¾   R   R¿   (    (    (    sI   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/pair_analyses.pyRš   i  s   	!				
t"   delta_f_prime_f_double_prime_ratioc           B   s   e  Z d  d „ Z RS(   g      ð?c         C   sü  | j  ƒ  |  _ | j  ƒ  |  _ |  j j ƒ  rB |  j j ƒ  |  _ n  |  j j ƒ  rf |  j j ƒ  |  _ n  |  j j |  j ƒ \ |  _ |  _ |  j j d t ƒ |  j j |  j ƒ |  j j	 ƒ  |  _
 |  j j	 ƒ  |  _ |  j
 j d t ƒ |  j j d t ƒ |  j j ƒ  \ |  _ |  _ |  j j |  j
 ƒ |  j j |  j
 ƒ t j ƒ  } d } xu|  j j ƒ  j ƒ  D]^} |  j
 j ƒ  j | ƒ j ƒ  } |  j
 j | ƒ j ƒ  } |  j j | ƒ j ƒ  }	 |  j
 j | ƒ j ƒ  }
 |  j j | ƒ j ƒ  } |  j j ƒ  j | ƒ j ƒ  } |  j j | ƒ j ƒ  } |  j j | ƒ j ƒ  } |  j j | ƒ j ƒ  } |  j j | ƒ j ƒ  } d  } d  } d  } d  } | j ƒ  d k rÅt j | |	 | |	 ƒ } t j |
 |
 | | ƒ } n  | j ƒ  d k rt j | | | | ƒ } t j | | | | ƒ } n  | j ƒ  d k r`| j ƒ  d k r¾t j | | ƒ | k r»t j | | ƒ | k r¸t j | ƒ } t j | ƒ } d | | } | G| GH| j | ƒ | d 7} q¸q»q¾q`q`Wd  |  _ | |  _  |  j  d k røt! j" | ƒ |  _ n  d  S(   NRs   i    g       @g      ð?(#   R   R©   Rª   Re   Rf   R7   Ry   RP   t   use_binner_ofR   t   tmp_l1_no_anot   tmp_l2_no_anoR�   t   plus2t   minus2t   use_binning_ofR   R‡   Rˆ   R‰   RŠ   R‹   RŒ   R^   R_   R   R>   t   meanR“   Rh   R:   R¦   t   numberR   t   trimean(   R3   R§   R¨   t   levelt	   estimatesRŽ   t   binRŠ   t   tmp1t   tmp2t   stmp1t   stmp2t   tmp3t   tmp4t   stmp3t   stmp4t   tmpisot   tmpsisot   tmpanot   tmpsanot   delta_iso_sqt   delta_ano_sqt   tmp(    (    sI   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/pair_analyses.pyR4   µ  sj    !			(   RZ   R[   R4   (    (    (    sI   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/pair_analyses.pyRÀ   ´  s   t   singh_ramasheshan_fa_estimatec           B   s5   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z RS(   c         C   su  | j  ƒ  |  _ | j  ƒ  |  _ |  j j ƒ  rB |  j j ƒ  |  _ n  |  j j ƒ  rf |  j j ƒ  |  _ n  |  j j |  j ƒ \ |  _ |  _ |  j j ƒ  \ |  _ |  _ |  j j ƒ  \ |  _	 |  _
 |  j j ƒ  |  j j ƒ  |  _ |  j	 j ƒ  |  j
 j ƒ  |  _ |  j j ƒ  |  j j ƒ  |  j j ƒ  |  j j ƒ  |  _ t j |  j ƒ |  _ |  j	 j ƒ  |  j	 j ƒ  |  j
 j ƒ  |  j
 j ƒ  |  _ t j |  j ƒ |  _ |  j j ƒ  |  j j ƒ  |  _ |  j	 j ƒ  |  j
 j ƒ  |  _ | | |  _ | | |  _ d  |  _ d  |  _ d  |  _ d  |  _ d  |  _ d  |  _ d  |  _ d  |  _ |  j  ƒ  |  j j! d |  j d |  j ƒ j" |  j ƒ |  _ d  S(   NR^   R_   (#   R   t   w1t   w2Rœ   Rl   R7   R�   t   p1t   n1t   p2t   n2R^   Rž   R    R_   t   s1R   Rh   t   s2t   sum1t   sum2t   k1_sqt   k2_sqR   t   determinantt   fat   sigfat   selectort	   iselectort   at   bt   ct   compute_fa_valuesRg   R   (   R3   RÝ   RÞ   t   k1t   k2(    (    sI   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/pair_analyses.pyR4     sB    !  								
	c         C   sO   |  j  t j |  j d ƒ |  j t j |  j d ƒ } | d } | |  _ d  S(   Ng�íµ ÷Æ°>g       @(   Rä   R   Rj   R    Rã   Rž   Rë   (   R3   RÛ   (    (    sI   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/pair_analyses.pyt   set_sigma_ratio9  s    
c         C   sÆ   |  j  |  j  |  j  d |  j |  j d |  j d |  _ |  j  |  j |  j |  j d |  j |  j |  _ d |  j |  j |  j |  j d |  j  |  j |  j |  j |  j |  j |  _ d  S(   Ni   g      Ð?g      ð?g       @g      À?(	   Rè   Rç   Rî   Rå   Ræ   Rï   R    Rž   Rð   (   R3   (    (    sI   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/pair_analyses.pyt   compute_coefs?  s    ;c         C   sM   |  j  |  j  d |  j |  j |  _ |  j d k |  _ |  j j ƒ  |  _ d  S(   Ng      @i    (   Rï   Rî   Rð   Ré   Rì   R‹   Rí   (   R3   (    (    sI   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/pair_analyses.pyt   compute_determinantJ  s    %c         C   s1  |  j  ƒ  |  j ƒ  |  j j ƒ  } |  j j | d ƒ |  _ |  j t j |  j ƒ } | d |  j	 } |  j t j |  j ƒ } | d |  j	 } | | k } | } | j | j ƒ  d ƒ } | j | j ƒ  d ƒ } | | } | d k  j ƒ  } | j | d ƒ } | | |  _
 |  j ƒ  |  j |  j
 |  _ d  S(   Ni    i   (   Rõ   Rö   Rì   R‹   Ré   R�   Rï   R   Rh   Rî   Rê   Rô   Rë   (   R3   t   reset_selectort   choice1t   choice2t   select1t   select2(    (    sI   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/pair_analyses.pyRñ   O  s$    



(   RZ   R[   R4   Rô   Rõ   Rö   Rñ   (    (    (    sI   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/pair_analyses.pyRÜ     s
   	7			t   mum_dadc           B   s   e  Z d  d „ Z RS(   g      ð?c         C   sì  | j  ƒ  |  _ | j  ƒ  |  _ |  j j ƒ  sB |  j j ƒ  |  _ n  |  j j ƒ  sf |  j j ƒ  |  _ n  |  j j |  j ƒ \ |  _ |  _ |  j j ƒ  \ } } | j ƒ  | j ƒ  |  _ | j ƒ  | j ƒ  |  _	 | j
 ƒ  | j
 ƒ  | j
 ƒ  | j
 ƒ  |  _ |  j j ƒ  \ } } | j ƒ  | j ƒ  |  _ | j ƒ  | j ƒ  |  _ | j
 ƒ  | j
 ƒ  | j
 ƒ  | j
 ƒ  |  _ t j |  j	 | |  j d ƒ |  _ t j |  j | | |  j d ƒ |  _ | j d |  j d |  j ƒ j |  j ƒ |  _ d  S(   Ng       @R^   R_   (   R   RÝ   RÞ   Rœ   Rf   R7   R�   R^   t   mean1Rž   R_   RŸ   t   mean2R    R¡   R   Rj   t   new_diffRh   t   new_sigma_meanRg   R   t   dad(   R3   R§   R¨   Rò   R«   R¬   R­   R®   (    (    sI   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/pair_analyses.pyR4   k  s,    !$(		(   RZ   R[   R4   (    (    (    sI   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/pair_analyses.pyRü   j  s   (   t
   __future__R    t   cctbxR   R   t   libtbxR   t   cctbx.sgtbx.cosetst   cctbx.crystalR   t   cctbx.array_familyR   t   libtbx.utilsR   t   mmtbx.scalingt   mmtbxt   scitbx.python_utilsR   R   R“   t   scitbx.lbfgsR£   t   objectR   R]   Ro   Rš   RÀ   RÜ   Rü   (    (    (    sI   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/mmtbx/scaling/pair_analyses.pyt   <module>   s$   }7¥KMi