ó
ó™xTc           @   s£   d  d l  m Z d  d l Z d  d l Z d  d l m Z d  d l m Z d „  Z d d d „  ƒ  YZ	 d „  Z
 e d	 k rŸ e	 e
 e j d
 ƒ ƒ Z e j ƒ  n  d S(   iÿÿÿÿ(   t   divisionN(   t   matrix(   t   detector_helpers_typesc         C   sa   d |  k r d Sd |  k r  d Sd |  k r0 d Sd |  k r@ d Sd	 |  k rP d
 St  d |  ‚ d S(   sO   Translate from a xia2 name from the detector library to an XDS detector
  name.t   pilatust   PILATUSt   rayonixt   CCDCHESSt   adsct   ADSCt   saturnt   SATURNt   raxist   RAXISs   detector %s unknownN(   t   RuntimeError(   t	   xia2_name(    (    sB   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/example/to_xds.pyt   xds_detector_name   s    t   to_xdsc           B   s>   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   c         C   sv   | j  ƒ  |  _ t | j ƒ  ƒ t | j ƒ  ƒ f |  _ | j ƒ  |  _ | j ƒ  |  _	 | j
 ƒ  |  _ | j ƒ  |  _ d  S(   N(   t   get_templatet	   _templatet   mint   indicest   maxt
   _start_endt   get_goniometert   _goniometert   get_detectort	   _detectort   get_beamt   _beamt   get_scant   _scan(   t   selft   sweep(    (    sB   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/example/to_xds.pyt   __init__&   s    'c         C   s   |  j  S(   N(   R   (   R   (    (    sB   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/example/to_xds.pyR   0   s    c         C   s   |  j  S(   N(   R   (   R   (    (    sB   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/example/to_xds.pyR   3   s    c         C   s   |  j  S(   N(   R   (   R   (    (    sB   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/example/to_xds.pyR   6   s    c         C   s   |  j  S(   N(   R   (   R   (    (    sB   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/example/to_xds.pyR   9   s    c         C   su  |  j  ƒ  j ƒ  } t t |  j  ƒ  j ƒ  ƒ \ } } |  j  ƒ  j ƒ  \ } } t d | ƒ } t d | ƒ } t j d ƒ j d d t	 ƒ} t
 t j | | | | | ƒ ƒ }	 |  j  ƒ  j ƒ  }
 d |	 |
 d d |
 d f GH|	 d	 k rî d
 GHn  d | |  j  ƒ  j ƒ  j GHd | |  j  ƒ  j ƒ  j GHd | | | | f GH| |  j  ƒ  j ƒ  } | |  j  ƒ  j ƒ  } | j | ƒ } | |  j  ƒ  j ƒ  } | |  j ƒ  j ƒ  t j t j |  j ƒ  j ƒ  ƒ j ƒ  ƒ } | | j | ƒ | } | j | ƒ } | j | ƒ } d | j | ƒ GHd | | | | f GHd | |  j ƒ  j ƒ  j GHd |  j ƒ  j ƒ  d GHd |  j ƒ  j ƒ  d GHd |  j ƒ  j ƒ  GHd | j GHd |  j ƒ  j ƒ  GHd |  j ƒ  j ƒ  GHd |  j j  d d ƒ GHd GHxK |  j  ƒ  j! ƒ  D]7 \ } } } } d | d | d | d | d f GHqóW|  j ƒ  j" ƒ  } | d d k rcd | d f } n  d | GHd GHd  S(   Niè  g      ð?g        g     €f@t   degs4   DETECTOR=%s MINIMUM_VALID_PIXEL_VALUE=%d OVERLOAD=%di    i   R   s   SENSOR_THICKNESS= 0.32s,   DIRECTION_OF_DETECTOR_X-AXIS= %.3f %.3f %.3fs,   DIRECTION_OF_DETECTOR_Y-AXIS= %.3f %.3f %.3fs   NX=%d NY=%d QX=%.4f QY=%.4fs   DETECTOR_DISTANCE= %.3fs   ORGX= %.1f ORGY= %.1fs   ROTATION_AXIS= %.3f %.3f %.3fs   STARTING_ANGLE= %.3fs   OSCILLATION_RANGE= %.3fs   X-RAY_WAVELENGTH= %.5fs'   INCIDENT_BEAM_DIRECTION= %.3f %.3f %.3fs   FRACTION_OF_POLARIZATION= %.3fs)   POLARIZATION_PLANE_NORMAL= %.3f %.3f %.3fs    NAME_TEMPLATE_OF_DATA_FRAMES= %st   #t   ?s   TRUSTED_REGION= 0.0 1.41s    UNTRUSTED_RECTANGLE= %d %d %d %ds   DATA_RANGE= %d %ds7   JOB=XYCORR INIT COLSPOT IDXREF DEFPIX INTEGRATE CORRECT(   g      ð?g        g        (#   R   t   get_typet   mapt   intt   get_image_sizet   get_pixel_sizeR   t   colt$   axis_and_angle_as_r3_rotation_matrixt   TrueR   R   t   gett   get_trusted_ranget   get_fast_axist   elemst   get_slow_axist   crosst
   get_originR   t   get_directiont   matht   sqrtt   dotR   t   get_rotation_axisR   t   get_oscillationt   get_wavelengtht   get_polarization_fractiont   get_polarization_normalR   t   replacet   get_maskt   get_image_range(   R   t   sensort   fastt   slowt   ft   st   dft   dst   Rt   detectort   trustedt   Ft   St   Nt   origint   beamt   centret   xt   yt   f0t   f1t   s0t   s1t	   start_end(    (    sB   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/example/to_xds.pyt   XDS<   sn    !+
%&	(   t   __name__t
   __module__R!   R   R   R   R   RW   (    (    (    sB   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/example/to_xds.pyR   %   s   	
				c         C   s?   d d l  m } | j |  ƒ } t | ƒ d k s7 t ‚ | d S(   Niÿÿÿÿ(   t   ImageSetFactoryi   i    (   t   dxtbx.imagesetRZ   t   newt   lent   AssertionError(   t   list_of_imagesRZ   t   sweeps(    (    sB   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/example/to_xds.pyt   factory…   s    t   __main__i   (    (   t
   __future__R    t   sysR5   t   scitbxR   t"   dxtbx.model.detector_helpers_typesR   R   R   Ra   RX   t   argvt   xsxRW   (    (    (    sB   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/example/to_xds.pyt   <module>   s   	`	