ó
‚™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 m Z d  d l	 m
 Z
 m Z m Z d
 d „ Z e e j _ d	 „  Z d
 S(   iÿÿÿÿ(   t   division(   t   miller(   t   crystal(   t   sgtbx(   t   uctbx(   t   flex(   t   cost   sint   pic         C   sR  |  j  ƒ  s t ‚ | j ƒ  s$ t ‚ |  j ƒ  j | j ƒ  ƒ sE t ‚ |  j ƒ  | j ƒ  k sc t ‚ | d k r{ t j } n  |  j	 ƒ  } | j	 ƒ  } | } | d IJx( |  j
 ƒ  D] } | d | j ƒ  IJq° W| Jg  d D] } d | ^ qÙ g  d D] } d
 | ^ qó } x7 t | |  j ƒ  j ƒ  ƒ D] \ }	 }
 | d |
 IJq&W| d IJd S(   s[    Export self and the miller array f_calc as ShelX would do with
  the instruction LIST 6
  s!   
loop
_symmetry_equiv_pos_as_xyz
s   '%s't   at   bt   cs   _cell_length_%st   alphat   betat   gammas   _cell_angle_%ss   %s	%fsˆ   
loop_
 _refln_index_h
 _refln_index_k
 _refln_index_l
 _refln_F_squared_meas
 _refln_F_squared_sigma
 _refln_F_calc
 _refln_phase_calc
N(   R	   R
   R   (   R   R   R   (   t   is_real_arrayt   AssertionErrort   is_complex_arrayt   indicest   all_eqt   anomalous_flagt   Nonet   syst   stdoutt   datat   space_groupt   as_xyzt   zipt	   unit_cellt
   parameters(   t   selft   f_calct   file_objectt   fot   fct   ft   opt   st   cell_labelst   lblt   param(    (    s=   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/shelx/fcf.pyt   miller_export_as_shelx_fcf
   s(    ! (	c      
   C   s,  t  t |  ƒ ƒ } t j ƒ  } i  } t j ƒ  } t j ƒ  } t j ƒ  } t j ƒ  } t j ƒ  } xœ| D]”}	 |	 j d ƒ rÇx|| D]=}	 |	 j ƒ  }	 |	 d k rß x| D]0 }	 |	 j ƒ  }	 |	 sÄ Pn  | j	 |	 d d !ƒ q¨ Wn× x t
 d ƒ D] }
 | j ƒ  qì Wx³ | D]« }	 |	 j ƒ  } | s#Pn  | \ } } } } } } } | j t | ƒ t | ƒ t | ƒ f ƒ | j t | ƒ ƒ | j t | ƒ ƒ | j t | ƒ ƒ | j t | ƒ ƒ qW|	 sƒ Pqƒ qƒ Wqg |	 j d ƒ rg |	 j ƒ  \ } } t | ƒ | | <qg qg Wt j g  d D] } | | ^ qƒ } t j d | d | ƒ } | t d 9} t j d | t j | ƒ d | t j | ƒ ƒ } t j d | d | ƒ j ƒ  } t j d | d | d | ƒ } | j ƒ  | j t j d |  d d d g ƒ ƒ t j d | d | ƒ } | j t j d |  d d g ƒ ƒ | | f S(   sS    Read the file of given name and return a pair of miller arrays
  (F_obs^2, F_cal) t   loop_t   _symmetry_equiv_pos_as_xyzi   iÿÿÿÿi   t   _cellt   _cell_length_at   _cell_length_bt   _cell_length_ct   _cell_angle_alphat   _cell_angle_betat   _cell_angle_gammaR   R   i´   t   realst   imagst   crystal_symmetryR   t
   miller_setR   t   sigmast   sourcet   labelst   F_squared_meast   F_squared_sigmat   F_calc(   R-   R.   R/   R0   R1   R2   (   t   itert   openR   R   R   t   miller_indext   doublet
   startswitht   stript
   expand_smxt   xranget   nextt   splitt   appendt   intt   floatR   R   R   t   symmetryR   t   complex_doubleR   R   R   t   sett   auto_anomaloust   arrayt#   set_observation_type_xray_intensityt   set_infot
   array_info(   t	   file_namet   fcfR   t   unit_cell_paramsR   t   f_obs_squarest   sigma_f_obs_squarest   f_calc_amplitudest   f_calc_phasest   lit   it   itemst   ht   kt   lR!   t   sig_foR"   t   phaseR'   t   valuet   pR   R5   R   R6   (    (    s=   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/shelx/fcf.pyt   list_6_as_miller_arrays1   s€       (  						
		N(   t
   __future__R    t   cctbxR   R   R   R   t   cctbx.array_familyR   t   cmathR   R   R   R   R)   RN   t   export_as_shelx_fcfRc   (    (    (    s=   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/iotbx/shelx/fcf.pyt   <module>   s   $