ó
S™xTc           @   s¦   d  d l  m Z d  d l m Z d  d l Z d  d l m Z d  d l m	 Z	 e
 e
 d „ Z d e f d „  ƒ  YZ d	 e f d
 „  ƒ  YZ e j j d ƒ Z d „  Z d S(   iÿÿÿÿ(   t   division(   t   SorryN(   t   object_oriented_patterns(   t   sqrtc   	      C   s¿   d d l  m } |  j ƒ  } | j d |  j ƒ  d | j t ƒ ƒ } |  j d | ƒ } | j ƒ  j d |  j	 ƒ  ƒ } | j
 ƒ  } | r” | j ƒ  } n  | r» | j ƒ  j d |  j	 ƒ  ƒ } n  | S(   Niÿÿÿÿ(   t   crystalt	   unit_cellt   space_groupt   crystal_symmetry(   t   cctbxR   R   t   symmetryR   t(   build_derived_reflection_intensity_groupt   Falset   customized_copyt   complete_setR   t   sys_absent_flagst   generate_bijvoet_matest   expand_to_p1(	   t   arrayR   R   R   t   sgt	   base_symmt
   base_arrayR   t   absence_array(    (    sB   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/miller/display.pyt   generate_systematic_absences   s    	t   scenec           B   sV   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 RS(	   só   
  Data for visualizing a Miller array graphically, either as a 3D view or
  a 2D zone of reciprocal space.  Currently used in phenix.data_viewer, but
  easily extensible to any other graphics platform (e.g. a PNG embedded in
  a web page).
  c   
      C   sM  | |  _  | |  _ d d l m } d d l m } d d l m } |  j ƒ  |  j } | j	 ƒ  } | |  _	 d  |  _ d  |  _ | j rý d d d g j |  j j ƒ |  _ | j d | j ƒ  d	 |  j d
 | j ƒ |  _ |  j j t ƒ d k rý t d ƒ ‚ qý n  | j ƒ  } | j ƒ  |  _ | j ƒ  |  _ | j |  j d d d f ƒ | j d |  j d d f ƒ | j d d |  j d f ƒ g |  _ |  j ƒ  |  j d  k	 rÖ|  j j ƒ  j |  j ƒ |  _ |  j j |  j ƒ |  _ n | j ƒ  |  _ | j |  j ƒ d |  _ | j  |  j! j" ƒ  t# ƒ |  _$ | j  |  j! j" ƒ  t# ƒ |  _% | j& rP|  j' ƒ  n  | j( rp| j) rp|  j* ƒ  n  | j  |  j j" ƒ  t ƒ |  _+ |  j j" ƒ  }	 |  j, j" ƒ  |	 k s¸t- ‚ |  j j" ƒ  |	 k sÓt- ‚ |  j! j" ƒ  |	 k sît- ‚ |  j$ j" ƒ  |	 k s	t- ‚ |  j% j" ƒ  |	 k s$t- ‚ |  j j" ƒ  |	 k s?t- ‚ |  j. ƒ  d  S(   Niÿÿÿÿ(   t   miller(   R   (   t   flext   ht   kt   lt   indicest
   slice_axist   slice_indexi    s   No data selected!i   i   g      Y@(/   t   miller_arrayt   settingsR   R   R   t   cctbx.array_familyR   t   process_input_arrayt
   work_arrayR   t   Nonet   slice_selectiont
   axis_indext
   slice_modet   indexR   t   simple_sliceR   R   t   countt   Truet
   ValueErrort
   index_spant   d_mint	   abs_ranget	   hkl_ranget   reciprocal_space_vectort   axest   generate_view_datat   selectt   datat   pointst   boolt   radiit   sizeR   t   missing_flagsR   t   show_missingt   generate_missing_reflectionst   show_systematic_absencest   show_only_missingR   t   visible_pointst   colorst   AssertionErrort   clear_labels(
   t   selfR    R!   R   R   R   R   t   ucR.   t   n_points(    (    sB   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/miller/display.pyt   __init__&   s\    		
					!		%
	c         C   sý  d d l  m } |  j j ƒ  } |  j } | j ƒ  } t j ƒ  |  _ | j	 ƒ  rz | j
 | d k  | j | j ƒ  d ƒ ƒ n  | j ƒ  rž | j rž | j ƒ  } n  | j d  k	 rÅ | j d | j ƒ } n  | j ƒ  |  _ | j rì | j ƒ  } n  |  j j r| j ƒ  j | ƒ |  _ n  | j ra| j ƒ  } | j ƒ  j d | ƒ } |  j j ƒ  j d | ƒ |  _ n  | j ƒ  } t |  _ t | | j ƒ rét |  _ | j | j ƒ  d ƒ } | j
 | t k | j | j ƒ  d ƒ ƒ | } | j ƒ  |  _ nt | | j ƒ r| j ƒ  |  _ nd t | | j  ƒ r4| j! | ƒ |  _ n= t" | j ƒ  d ƒ ra| j ƒ  j# ƒ  |  _ n t$ d	 | ƒ ‚ | j% rð| j& ƒ  d  k r›t' d
 ƒ ‚ n  | j& ƒ  } | j( | d k ƒ } | j d | j ƒ  | j& ƒ  ƒ } | j ƒ  |  _ n  | |  _) d  S(   Niÿÿÿÿ(   R   i    g        R/   R   g      ð?t	   as_doubles   Unexpected data type: %rs   sigmas not defined.R6   (*   t   scitbx.array_familyR   R    t	   deep_copyR!   R6   t   oopt   nullt   missing_sett   is_xray_intensity_arrayt   set_selectedt   doubleR:   t   is_unique_set_under_symmetryt
   map_to_asuR/   R%   t   resolution_filtert   filtered_arrayt   expand_anomalousR   R<   R   t   lone_setR   R   R   R   t   r_free_modet
   isinstanceR8   R,   t   complex_doublet   abst   hasattrRH   t   RuntimeErrort   show_data_over_sigmat   sigmasR   R5   R$   (   RD   R   R   R!   R6   t   original_symmetryt   data_as_floatR^   (    (    sB   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/miller/display.pyR#   X   sZ    	+					(	"c      	   C   sñ  d d l  m } d d l m } |  j } |  j } t | | j ƒ rn | j d ƒ rn | j | j	 ƒ  d ƒ } n  | j
 r› t | | j ƒ r› | j | ƒ } n | j ƒ  } | j rÔ t | | j ƒ rÔ | j | ƒ } n | j ƒ  } | j r.| j |  j ƒ } | j s.| j |  j ƒ } | j |  j ƒ } q.n  | j d k ry| j d	 | d
 | j | j	 ƒ  t ƒ d t d | j ƒ } n{ | j d k rÄ| j d	 | d
 | j | j	 ƒ  t ƒ d t d | j ƒ } n0 | j rÖd } n d } | j | j	 ƒ  | ƒ } | j r| j r| j |  j ƒ } n  |  j j ƒ  }	 |	 j ƒ  d d !}
 t |	 j d ƒ ƒ } d | } d | } | j | ƒ } | | } | j rš| j | ƒ } n  | | } | | k  } | j  | | j | j	 ƒ  | ƒ ƒ | |  _! | |  _" | |  _# d  S(   Niÿÿÿÿ(   R   (   t   graphics_utilsi    i   t   rainbowt   heatmapt   redbluet
   propertiest	   selectiont	   color_allt   gradient_typet	   grayscalet	   shade_allt   invertg      ð?g        i   gš™™™™™É?i(   (   Rb   Rc   Rd   (   g      ð?g      ð?g      ð?(   g        g        g        (   i   i   i   ($   RI   R   t   scitbxRa   R!   R6   RX   RP   t   all_eqR:   t   sqrt_scale_colorsR   RJ   t   sqrt_scale_radiiR(   R5   R&   t   keep_constant_scalet   color_schemet   color_by_propertyR8   R,   R   t   grayscale_by_propertyt   black_backgroundt   vec3_doubleR$   R   t
   parameterst   minR2   t   maxRO   R9   t
   max_radiusRA   (   RD   R   Ra   R!   R6   t   data_for_colorst   data_for_radiiRA   t
   base_colorRE   t   abct   min_distt
   min_radiusRy   t	   max_valuet   scaleR9   t	   too_small(    (    sB   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/miller/display.pyR4   ‹   sd    		!						


	
"		c   
      C   sT  d d l  m } d d l m } |  j } |  j } | j ƒ  } | j r³ | j ƒ  |  _	 | j ƒ  |  _
 | j ƒ  |  _ | j ƒ  |  _ | j ƒ  |  _ | j ƒ  |  _ | j ƒ  |  _ n  | j r| j d |  j j ƒ  d |  j d | j ƒ } |  j j | ƒ j ƒ  } n |  j j ƒ  } | j ƒ  } | d k rP| j | ƒ d }	 |  j
 j |	 ƒ | j d	 k r||  j	 j | j | d ƒ ƒ nJ | j d k rª|  j	 j | j | d ƒ ƒ n |  j	 j | j | d ƒ ƒ |  j j | j | |  j d ƒ ƒ |  j j | j | t ƒ ƒ |  j j | ƒ |  j j | j | d ƒ ƒ |  j j | j | t ƒ ƒ n  d  S(   Niÿÿÿÿ(   R   (   R   R   R   R   i    g      Y@Rc   g        g      ð?Rb   Rd   i   g      ð¿(   g        g      ð?g        (   s   rainbows   redblue(   g      ð?i    i    (   g      ð?g      ð?g      ð?(    R   R   R"   R   R!   R$   R   R?   Ru   RA   R7   RP   R9   R8   R;   t   miller_indexR   R6   R   R(   R*   RM   R'   R   R5   R:   R2   t   extendRq   Ry   R,   R   (
   RD   R   R   R!   R   RE   R&   t   missingt	   n_missingt   points_missing(    (    sB   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/miller/display.pyR=   Ã   sD    						#c         C   sV  d d l  m } d d l  m } d d l m } |  j } |  j } t d |  j d | j d | j	 ƒ } | j
 r« | j d | j ƒ  d	 |  j d
 | j ƒ } | j | ƒ } n  | j ƒ  } | j t ƒ d k rÔ d GHn~| j ƒ  }	 x1 | j ƒ  D]# }
 | j ƒ  |
 } |	 j | ƒ qí W|	 j ƒ  d k rR|  j j ƒ  } | j |	 ƒ d } |  j j | ƒ |	 j ƒ  } |  j j | j |	 j ƒ  |  j ƒ ƒ |  j j |	 ƒ |  j j | j  |	 j ƒ  t! ƒ ƒ |  j" j | j  |	 j ƒ  t ƒ ƒ |  j j | j | d ƒ ƒ | j# d k r-|  j$ j | j% |	 j ƒ  d ƒ ƒ qR|  j$ j | j% |	 j ƒ  d ƒ ƒ n  d  S(   Niÿÿÿÿ(   R   (   R   (   R   R   R   R   R   R   R   i    s   No systematic absences found!id   g      ð¿Rd   g      ð?g        g      à?(   g      ð?g      ð?g        (   g      ð?g      à?g      ð?(&   R   R   R   R"   R   R!   RT   R   R   RU   R(   R*   R   R'   R   R5   R6   R+   R,   Rƒ   t
   iselectiont   appendR:   R$   R   R2   R7   R„   R9   RP   Ry   R;   R8   R   R   Rq   RA   Ru   (   RD   R   R   R   R!   R   R   R&   t   absence_flagst   new_indicest   i_seqt   hklRE   R7   t   n_sys_absent(    (    sB   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/miller/display.pyR   é   sF    							%""%c         C   s   t  g  ƒ |  _ d  S(   N(   t   sett   label_points(   RD   (    (    sB   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/miller/display.pyRC     s    c         C   s   |  j  | } |  j j | ƒ S(   N(   R   R   t   d(   RD   R   R�   (    (    sB   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/miller/display.pyt   get_resolution_at_point  s    c         C   s\   |  j  | } |  j j | ƒ } |  j | s9 |  j | rB d  } n |  j | } | | | f S(   N(   R   R   R‘   R;   R   R%   R6   (   RD   R   R�   R/   t   value(    (    sB   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/miller/display.pyt   get_reflection_info  s    	(   t   __name__t
   __module__t   __doc__RG   R#   R4   R=   R   RC   R’   R”   (    (    (    sB   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/miller/display.pyR      s   	2	3	8	&	.		t	   render_2dc           B   se   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d
 d „ Z d	 „  Z RS(   c         C   s    | |  _  | |  _ |  j ƒ  d  S(   N(   R   R!   t   setup_colors(   RD   R   R!   (    (    sB   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/miller/display.pyRG   (  s    		c         C   s   t  ƒ  ‚ d  S(   N(   t   NotImplementedError(   RD   (    (    sB   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/miller/display.pyt   GetSize-  s    c         C   sd   |  j  ƒ  \ } } t | | ƒ d d } t | d | d ƒ } t | d | d ƒ } | | | f S(   Ni   i   (   R›   Rw   Rx   (   RD   t   wR   t   rt   center_xt   center_y(    (    sB   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/miller/display.pyt   get_center_and_radius0  s
    c         C   sÁ   |  j  j rf d |  _ d |  _ |  j  j d k r< d |  _ q½ |  j  j d	 k rZ d
 |  _ q½ d |  _ nW d |  _ d |  _ |  j  j d k r– d |  _ n' |  j  j d k r´ d |  _ n	 d |  _ d  S(   Ng        g      ð?Rc   Rb   Rd   (   g        g        g        (   g      ð?g      ð?g      ð?(   g        g      ð?g        (   s   rainbows   redblue(   g      ð?g        g        (   g      ð?g      ð?g      ð?(   g      ð?g      ð?g      ð?(   g        g        g        (   g        g      ð?g        (   s   rainbows   redblue(   g      ð?g        g        (   g        g        g        (   R!   Rt   t   _backgroundt   _foregroundRq   t   _missing(   RD   (    (    sB   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/miller/display.pyR™   7  s    				c         C   s   d S(   Ng      Y@(    (   RD   (    (    sB   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/miller/display.pyt   get_scale_factorK  s    c         C   s  g  |  _  g  |  _ |  j j s$ t ‚ |  j j d k rK d \ } } d } n9 |  j j d k rr d \ } } d } n d \ } } d } |  j ƒ  \ } } } |  j j | | d } |  j j | | d }	 |  j j	 rn|  j j | | |  j j | | f }
 |  j j | | |  j j | | f } t
 |
 d d |
 d d ƒ } t
 | d d | d d ƒ } | d | } | d | } |
 d | |
 d | f }
 | d | | d | f } |  j | | | | |
 d | |
 d ƒ |  j | | | | | d | | d ƒ |  j | | d | |
 d d	 | |
 d d
 ƒ |  j | | d | | d d	 | | d ƒ n  |  j j | t | |	 ƒ } | |  j j 9} d |  j j |  j ƒ  } xVt |  j j ƒ D]B\ } } | | | | } } | | | | } | | | | } |  j j | | t | |	 ƒ } |  j j rC| } n t d | ƒ } | |  j j 9} |  j  j | | f ƒ |  j j | ƒ |  j j | r±|  j | | | | ƒ qÈ|  j j | rç|  j | | | | |  j j | ƒ qÈ|  j | | | | |  j j | ƒ qÈWd  S(   NR   i   i   R   R   i    g      Y@i
   i   i   g      à?(   i   i   (   R   R   (   i    i   (   R   R   (   i    i   (   R   R   (   t
   _points_2dt	   _radii_2dR!   R(   RB   R   R    R   R3   t	   show_axesR   t	   draw_linet	   draw_textRy   Rx   R�   R/   R¤   t	   enumerateR7   R9   t   uniform_sizeR‰   R;   t   draw_open_circleR   RA   t   draw_filled_circle(   RD   t   canvast   i_xt   i_yR3   Rž   RŸ   R�   t   x_maxt   y_maxt   x_endt   y_endt   x_lent   y_lent   x_scalet   y_scaleRy   t   r_scaleR   R�   t   x_t   y_t   xt   yt   r_point(    (    sB   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/miller/display.pyt   renderN  sd    				((  !	&c         C   s   t  ƒ  ‚ d  S(   N(   Rš   (   RD   R®   t   x1t   y1t   x2t   y2(    (    sB   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/miller/display.pyR¨   †  s    c         C   s   t  ƒ  ‚ d  S(   N(   Rš   (   RD   R®   t   textR¼   R½   (    (    sB   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/miller/display.pyR©   ‰  s    c         C   s   t  ƒ  ‚ d  S(   N(   Rš   (   RD   R®   R¼   R½   t   radiust   color(    (    sB   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/miller/display.pyR¬   Œ  s    c         C   s   t  ƒ  ‚ d  S(   N(   Rš   (   RD   R®   R¼   R½   RÅ   RÆ   (    (    sB   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/miller/display.pyR­   �  s    N(   R•   R–   RG   R›   R    R™   R¤   R¿   R¨   R©   R%   R¬   R­   (    (    (    sB   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/miller/display.pyR˜   '  s   						8		s9  
  data = None
    .type = path
    .optional = False
  labels = None
    .type = str
  symmetry_file = None
    .type = str
  black_background = True
    .type = bool
  show_axes = True
    .type = bool
  show_data_over_sigma = False
    .type = bool
  sqrt_scale_radii = True
    .type = bool
  sqrt_scale_colors = False
    .type = bool
  expand_to_p1 = False
    .type = bool
  expand_anomalous = False
    .type = bool
  spheres = True
    .type = bool
  show_missing = False
    .type = bool
  show_only_missing = False
    .type = bool
  show_systematic_absences = False
    .type = bool
  sphere_detail = 20
    .type = int
  pad_radii = False
    .type = bool
  slice_mode = False
    .type = bool
  keep_constant_scale = True
    .type = bool
  slice_axis = *h k l
    .type = choice
  slice_index = 0
    .type = int
  color_scheme = *rainbow heatmap redblue grayscale mono
    .type = choice
  show_labels = True
    .type = bool
  uniform_size = False
    .type = bool
  d_min = None
    .type = float
  scale = 1
    .type = int
  map_to_asu = False
    .type = bool
c           C   s   t  j ƒ  j ƒ  S(   N(   t   master_philt   fetcht   extract(    (    (    sB   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/miller/display.pyR!   Ê  s    (   t
   __future__R    t   libtbx.utilsR   t   libtbx.philt   libtbxR   RK   t   mathR   R   R   t   objectR   R˜   t   philt   parseRÇ   R!   (    (    (    sB   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/miller/display.pyt   <module>   s   ÿ 	k	6	