ó
>™xTc           @   sä   d  d l  m 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
 d  d l Z d  d l m Z d  d l m Z e
 j d	 ƒ e j d	 ƒ d
 „  Z e d k rà e j ƒ  Z e ƒ  d e j ƒ  e GHn  d S(   iÿÿÿÿ(   t   division(   t   real_space_target_and_gradients(   t   sgtbx(   t   flex(   t   random_structureN(   t   real_space_refinement_simple(   t   approx_equali    c          C   s‰  d d% d „ }  t  j d t j d ƒ d d d	 d
 d d g d d d ƒ } |  d | ƒ \ } } } | j ƒ  } | j d d ƒ t j | j d | ƒ ƒ } d G| GH|  d | ƒ \ } } } xš | j	 ƒ  d g d D]� }	 t
 j d | d | d | d | d d d d d |	 d d  d d  ƒ 	}
 |
 j } |
 j } t j | j d |
 j ƒ ƒ } d! G| GHqÑ Wt | d d" ƒ snt ‚ | d# k  s€t ‚ d$ GHd  S(&   Ng      ø?g      ð?i   c         S   sM   |  j  d | ƒ j ƒ  } | j d | ƒ } | j ƒ  | j ƒ  } | | | f S(   Nt   d_mint   resolution_factor(   t   structure_factorst   f_calct   fft_mapt   apply_sigma_scalingt   real_map_unpadded(   t   xray_structureR   R   t   fcR   t   result(    (    s^   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/maptbx/tst_real_space_target_and_gradients.pyt   compute_map   s
    
t   space_group_infot   P212121t   elementst   Nt   Ct   Ot   St   Pi
   t   volume_per_atomi2   R   t   mean_distancegš™™™™™é?t   others   Start:i   t   miller_arrayt   crystal_griddingt
   map_targett   max_iterationsiô  t   min_iterationsi   t   stept   geometry_restraints_managert   target_typet   diff_maps   Final:gü©ñÒMbP?g-Cëâ6?t   OKg      Ð?(   R   R   R   R   t   deep_copy_scattererst   shake_sites_in_placeR   t   meant	   distancesR   R   t   minimizationt   Nonet   map_currentR   t   AssertionError(   R   t   xrsR   t   tmpt   xrs_sht   start_errorR-   R   R   R"   t	   minimizedt   final_error(    (    s^   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/maptbx/tst_real_space_target_and_gradients.pyt   run   s<    							t   __main__s   Time: %8.3f(   t
   __future__R    t   cctbx.maptbxR   t   cctbxR   t   cctbx.array_familyR   t   cctbx.developmentR   t   randomt   timeR   t   libtbx.test_utilsR   t   seedt   set_random_seedR5   t   __name__t   t0(    (    (    s^   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/maptbx/tst_real_space_target_and_gradients.pyt   <module>   s   	0