ó
±éRc           @   s   d  d l  Z  d  d l Z d  d l Z d  d l m Z m Z d  d l m Z d  d l m	 Z	 d  d l m
 Z
 d e f d „  ƒ  YZ e ƒ  Z d e f d	 „  ƒ  YZ d
 e f d „  ƒ  YZ d f  d „  ƒ  YZ e j d ƒ d e e f d „  ƒ  Yƒ Z e j d ƒ d e e f d „  ƒ  Yƒ Z d e f d „  ƒ  YZ e j d ƒ d e e f d „  ƒ  Yƒ Z e j d ƒ d e e f d „  ƒ  Yƒ Z d f  d „  ƒ  YZ e j d ƒ d e e f d  „  ƒ  Yƒ Z e j d! ƒ d" e e f d# „  ƒ  Yƒ Z d$ f  d% „  ƒ  YZ e j d& ƒ d' e e f d( „  ƒ  Yƒ Z e j d) ƒ d* e e f d+ „  ƒ  Yƒ Z d, e f d- „  ƒ  YZ d. e f d/ „  ƒ  YZ d0 e f d1 „  ƒ  YZ d2 e f d3 „  ƒ  YZ  d S(4   iÿÿÿÿN(   t   iterablet   is_string_like(   t
   subprocess(   t   verbose(   t   rcParamst   MovieWriterRegistryc           B   s5   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z RS(   c         C   s   t  ƒ  |  _ d  S(   N(   t   dictt   avail(   t   self(    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyt   __init__'   s    c            s   ‡  ‡ f d †  } | S(   Nc            s    |  j  ƒ  r |  ˆ j ˆ  <n  |  S(   N(   t   isAvailableR   (   t   writerClass(   t   nameR   (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyt   wrapper0   s    (    (   R   R   R   (    (   R   R   sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyt   register/   s    c         C   s   |  j  j ƒ  S(   s&    Get a list of available MovieWriters.(   R   t   keys(   R   (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyt   list6   s    c         C   s   | |  j  k S(   N(   R   (   R   R   (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyt   is_available:   s    c         C   s#   |  j  s t d ƒ ‚ n  |  j  | S(   Ns   No MovieWriters available!(   R   t   RuntimeError(   R   R   (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyt   __getitem__=   s    	(   t   __name__t
   __module__R	   R   R   R   R   (    (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyR   &   s
   				t   MovieWriterc           B   s¤   e  Z d  Z d d d d d d „ Z e d „  ƒ Z d „  Z e j	 d „  ƒ Z
 d „  Z d „  Z d „  Z d	 „  Z d
 „  Z d „  Z e d „  ƒ Z e d „  ƒ Z RS(   s§  
    Base class for writing movies. Fundamentally, what a MovieWriter does
    is provide is a way to grab frames by calling grab_frame(). setup()
    is called to start the process and finish() is called afterwards.
    This class is set up to provide for writing movie frame data to a pipe.
    saving() is provided as a context manager to facilitate this process as::

      with moviewriter.saving('myfile.mp4'):
          # Iterate over frames
          moviewriter.grab_frame()

    The use of the context manager ensures that setup and cleanup are
    performed as necessary.

    frame_format: string
        The format used in writing frame data, defaults to 'rgba'
    i   c         C   s²   | |  _  d |  _ | d k r. t d |  _ n	 | |  _ | d k rS t d |  _ n	 | |  _ | d k r� t t |  j ƒ |  _ n	 | |  _ | d k r¥ t	 ƒ  |  _
 n	 | |  _
 d S(   s‘  
        Construct a new MovieWriter object.

        fps: int
            Framerate for movie.
        codec: string or None, optional
            The codec to use. If None (the default) the setting in the
            rcParam `animation.codec` is used.
        bitrate: int or None, optional
            The bitrate for the saved movie file, which is one way to control
            the output file size and quality. The default value is None,
            which uses the value stored in the rcParam `animation.bitrate`.
            A value of -1 implies that the bitrate should be determined
            automatically by the underlying utility.
        extra_args: list of strings or None
            A list of extra string arguments to be passed to the underlying
            movie utiltiy. The default is None, which passes the additional
            argurments in the 'animation.extra_args' rcParam.
        metadata: dict of string:string or None
            A dictionary of keys and values for metadata to include in the
            output file. Some keys that may be of use include:
            title, artist, genre, subject, copyright, srcform, comment.
        t   rgbas   animation.codecs   animation.bitrateN(   t   fpst   frame_formatt   NoneR   t   codect   bitrateR   t   args_keyt
   extra_argsR   t   metadata(   R   R   R   R   R   R   (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyR	   W   s    					c         C   s-   |  j  j ƒ  \ } } | |  j | |  j f S(   s2   A tuple (width,height) in pixels of a movie frame.(   t   figt   get_size_inchest   dpi(   R   t   width_inchest   height_inches(    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyt
   frame_size‡   s    c         G   s)   | |  _  | |  _ | |  _ |  j ƒ  d S(   sˆ  
        Perform setup for writing the movie file.

        fig: `matplotlib.Figure` instance
            The figure object that contains the information for frames
        outfile: string
            The filename of the resulting movie file
        dpi: int
            The DPI (or resolution) for the file.  This controls the size
            in pixels of the resulting movie file.
        N(   t   outfileR    R"   t   _run(   R   R    R&   R"   t   args(    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyt   setup�   s    			c         g   s    |  j  | Œ  d V|  j ƒ  d S(   s�   
        Context manager to facilitate writing the movie file.

        ``*args`` are any parameters that should be passed to `setup`.
        N(   R)   t   finish(   R   R(   (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyt   saving¡   s    c      
   C   s{   |  j  ƒ  } t j d ƒ r' t j } n	 t j } t j d d j | ƒ ƒ t j	 | d t
 d | d | d t j ƒ|  _ d  S(   Nt   debugs$   MovieWriter.run: running command: %st    t   shellt   stdoutt   stderrt   stdin(   t   _argsR   t   get   sysR/   R   t   PIPEt   reportt   joint   Popent   Falset   _proc(   R   t   commandt   output(    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyR'   ­   s    		c         C   s   |  j  ƒ  d S(   s,   Finish any processing for writing the movie.N(   t   cleanup(   R   (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyR*   ¼   s    c         K   s�   t  j d d d ƒy/ |  j j |  j ƒ  d |  j d |  j | �WnF t k
 rŠ |  j j	 ƒ  \ } } t  j d | | f d d ƒ‚  n Xd S(	   sÍ   
        Grab the image information from the figure and save as a movie frame.
        All keyword arguments in savefig_kwargs are passed on to the 'savefig'
        command that saves the figure.
        s'   MovieWriter.grab_frame: Grabbing frame.t   levelR,   t   formatR"   s(   MovieWriter -- Error running proc:
%s
%st   helpfulN(
   R   R6   R    t   savefigt   _frame_sinkR   R"   R   R:   t   communicate(   R   t   savefig_kwargst   outt   err(    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyt
   grab_frameÀ   s    	c         C   s
   |  j  j S(   s4   Returns the place to which frames should be written.(   R:   R1   (   R   (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyRB   Ô   s    c         C   s
   t  d ƒ S(   s9   Assemble list of utility-specific command-line arguments.s)   args needs to be implemented by subclass.(   t   NotImplementedError(   R   (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyR2   Ø   s    c         C   sG   |  j  j ƒ  \ } } t j d | d d ƒt j d | d d ƒd S(   s>   Clean-up and collect the process used to write the movie file.s!   MovieWriter -- Command stdout:
%sR>   R,   s!   MovieWriter -- Command stderr:
%sN(   R:   RC   R   R6   (   R   RE   RF   (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyR=   Ü   s
    		c         C   s   t  |  j S(   sã   
        Returns the binary path to the commandline tool used by a specific
        subclass. This is a class method so that the tool can be looked for
        before making a particular MovieWriter subclass available.
        (   R   t   exec_key(   t   cls(    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyt   bin_pathä   s    c         C   sL   y3 t  j |  j ƒ  d t d t  j d t  j ƒt SWn t k
 rG t SXd S(   sw   
        Check to see if a MovieWriter subclass is actually available by
        running the commandline tool.
        R.   R/   R0   N(   R   R8   RK   R9   R5   t   Truet   OSError(   RJ   (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyR
   í   s    	
N(   R   R   t   __doc__R   R	   t   propertyR%   R)   t
   contextlibt   contextmanagerR+   R'   R*   RG   RB   R2   R=   t   classmethodRK   R
   (    (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyR   E   s   /								t   FileMovieWriterc           B   sk   e  Z d  Z d „  Z d e d „ Z e d „  ƒ Z e j d „  ƒ Z d „  Z	 d „  Z
 d „  Z d	 „  Z RS(
   s6   `MovieWriter` subclass that handles writing to a file.c         O   s$   t  j |  | | Ž t d |  _ d  S(   Ns   animation.frame_format(   R   R	   R   R   (   R   R(   t   kwargs(    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyR	   ÿ   s    t   _tmpc         C   sO   | |  _  | |  _ | |  _ | |  _ | |  _ d |  _ t ƒ  |  _ d |  _ d S(   s½  
        Perform setup for writing the movie file.

        fig: `matplotlib.Figure` instance
            The figure object that contains the information for frames
        outfile: string
            The filename of the resulting movie file
        dpi: int
            The DPI (or resolution) for the file.  This controls the size
            in pixels of the resulting movie file.
        frame_prefix: string, optional
            The filename prefix to use for the temporary files. Defaults
            to '_tmp'
        clear_temp: bool
            Specifies whether the temporary files should be deleted after
            the movie is written. (Useful for debugging.) Defaults to True.
        i    s
   %s%%07d.%sN(	   R    R&   R"   t
   clear_tempt   temp_prefixt   _frame_counterR   t   _temp_namest   fname_format_str(   R   R    R&   R"   t   frame_prefixRV   (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyR)     s    						c         C   s   |  j  S(   sƒ   
        Format (png, jpeg, etc.) to use for saving the frames, which can be
        decided by the individual subclasses.
        (   t   _frame_format(   R   (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyR     s    c         C   s/   | |  j  k r | |  _ n |  j  d |  _ d  S(   Ni    (   t   supported_formatsR\   (   R   R   (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyR   &  s    c         C   s   |  j  |  j |  j f S(   N(   RZ   RW   R   (   R   (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyt   _base_temp_name-  s    c         C   s_   |  j  ƒ  |  j } |  j j | ƒ t j d |  j | f d d ƒ|  j d 7_ t | d ƒ S(   Ns7   FileMovieWriter.frame_sink: saving frame %d to fname=%sR>   R,   i   t   wb(   R^   RX   RY   t   appendR   R6   t   open(   R   t   fname(    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyRB   2  s    c         C   sJ   |  j  ƒ  t j |  ƒ |  j j rF t d t |  j j ƒ d ƒ ‚ n  d  S(   Ns#   Error creating movie, return code: s!    Try running with --verbose-debug(   R'   R   R*   R:   t
   returncodeR   t   str(   R   (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyR*   C  s
    
c         C   sj   t  j |  ƒ |  j rf d d  l } t j d t |  j ƒ d d ƒx! |  j D] } | j | ƒ qL Wn  d  S(   Niÿÿÿÿs)   MovieWriter: clearing temporary fnames=%sR>   R,   (	   R   R=   RV   t   osR   R6   Rd   RY   t   remove(   R   Re   Rb   (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyR=   P  s    	(   R   R   RN   R	   RL   R)   RO   R   t   setterR^   RB   R*   R=   (    (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyRS   ý   s   				t
   FFMpegBasec           B   s#   e  Z d  Z d Z e d „  ƒ Z RS(   s   animation.ffmpeg_paths   animation.ffmpeg_argsc         C   s¥   d |  j  g } |  j d k r; | j d d |  j g ƒ n  |  j rW | j |  j ƒ n  x: |  j j ƒ  D]) \ } } | j d d | | f g ƒ qg W| d |  j g S(   Ns   -vcodeci    s   -bs   %dks	   -metadatas   %s=%ss   -y(   R   R   t   extendR   R   t   itemsR&   (   R   R(   t   kt   v(    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyt   output_argsd  s    	!(   R   R   RI   R   RO   Rm   (    (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyRh   `  s   t   ffmpegt   FFMpegWriterc           B   s   e  Z d  „  Z RS(   c         C   s}   |  j  ƒ  d d d d d d |  j d |  j d t |  j ƒ g } t j d ƒ sb | d	 d
 g 7} n  | d d g |  j 7} | S(   Ns   -ft   rawvideos   -vcodecs   -ss   %dx%ds   -pix_fmts   -rR,   s	   -loglevelt   quiets   -is   pipe:(   RK   R%   R   Rd   R   R   R3   Rm   (   R   R(   (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyR2   v  s    (   R   R   R2   (    (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyRo   t  s   t   ffmpeg_filet   FFMpegFileWriterc        	   B   s2   e  Z d  d d d d d d d d g	 Z d	 „  Z RS(
   t   pngt   jpegt   ppmt   tifft   sgit   bmpt   pbmt   rawR   c         C   s>   |  j  ƒ  d t |  j ƒ d t |  j ƒ d |  j ƒ  g |  j S(   Ns   -vframess   -rs   -i(   RK   Rd   RX   R   R^   Rm   (   R   (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyR2   ‰  s    (   R   R   R]   R2   (    (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyRs   „  s   t
   AVConvBasec           B   s   e  Z d  Z d Z RS(   s   animation.avconv_paths   animation.avconv_args(   R   R   RI   R   (    (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyR|   “  s   t   avconvt   AVConvWriterc           B   s   e  Z RS(    (   R   R   (    (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyR~   ™  s   t   avconv_filet   AVConvFileWriterc           B   s   e  Z RS(    (   R   R   (    (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyR€   Ÿ  s   t   MencoderBasec           B   sG   e  Z d  Z d Z d d d d d d d g Z d	 „  Z e d
 „  ƒ Z RS(   s   animation.mencoder_paths   animation.mencoder_argsR   t   artistt   genret   subjectt	   copyrightt   srcformt   commentc         C   s*   d |  j  k r& |  j  d |  j  d <n  d  S(   Nt   titleR   (   R   (   R   (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyt   _remap_metadata±  s    c            s³   ˆ  j  ƒ  d ˆ  j d d d d ˆ  j g } ˆ  j d k rR | j d ˆ  j ƒ n  ˆ  j rn | j ˆ  j ƒ n  ˆ  j r¯ | j d d	 j ‡  f d
 †  ˆ  j j	 ƒ  Dƒ ƒ g ƒ n  | S(   Ns   -os   -ovct   lavcs	   -lavcoptss	   vcodec=%si    s   vbitrate=%ds   -infot   :c         3   s4   |  ]* \ } } | ˆ  j  k r d  | | f Vq d S(   s   %s=%sN(   t   allowed_metadata(   t   .0Rk   Rl   (   R   (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pys	   <genexpr>¿  s   	(
   R‰   R&   R   R   R`   R   Ri   R   R7   Rj   (   R   R(   (    (   R   sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyRm   µ  s    
		(   R   R   RI   R   RŒ   R‰   RO   Rm   (    (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyR�   ¦  s   	t   mencodert   MencoderWriterc           B   s   e  Z d  „  Z RS(   c      	   C   s>   |  j  ƒ  d d d d d |  j d |  j |  j f g |  j S(   Nt   -s   -demuxerRp   s	   -rawvideos
   w=%i:h=%i:s   fps=%i:format=%s(   RK   R%   R   R   Rm   (   R   (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyR2   È  s    
	(   R   R   R2   (    (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyR�   Æ  s   t   mencoder_filet   MencoderFileWriterc           B   s#   e  Z d  d d d g Z d „  Z RS(   Rt   Ru   t   tgaRx   c         C   sL   |  j  ƒ  d |  j |  j f d t |  j ƒ d d |  j |  j f g |  j S(   Ns   mf://%s*.%ss   -framess   -mfs   type=%s:fps=%d(   RK   RW   R   Rd   RX   R   Rm   (   R   (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyR2   Ö  s
    		(   R   R   R]   R2   (    (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyR’   Ò  s   t   ImageMagickBasec           B   s2   e  Z d  Z d Z e d „  ƒ Z e d „  ƒ Z RS(   s   animation.convert_paths   animation.convert_argsc         C   s   d |  j  S(   Ng      Y@(   R   (   R   (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyt   delayå  s    c         C   s
   |  j  g S(   N(   R&   (   R   (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyRm   é  s    (   R   R   RI   R   RO   R•   Rm   (    (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyR”   á  s   t   imagemagickt   ImageMagickWriterc           B   s   e  Z d  „  Z RS(   c         C   sF   |  j  ƒ  d d |  j d d d t |  j ƒ d d d |  j g
 |  j S(	   Ns   -sizes   %ix%is   -deptht   8s   -delays   -loopt   0s   %s:-(   RK   R%   Rd   R•   R   Rm   (   R   (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyR2   ð  s
    	(   R   R   R2   (    (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyR—   î  s   t   imagemagick_filet   ImageMagickFileWriterc        	   B   s2   e  Z d  d d d d d d d d g	 Z d	 „  Z RS(
   Rt   Ru   Rv   Rw   Rx   Ry   Rz   R{   R   c         C   s<   |  j  ƒ  d t |  j ƒ d d d |  j |  j f g |  j S(   Ns   -delays   -loopR™   s   %s*.%s(   RK   Rd   R•   RW   R   Rm   (   R   (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyR2   ý  s    (   R   R   R]   R2   (    (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyR›   ø  s   t	   Animationc        
   B   sÈ   e  Z d  Z d e d „ Z d „  Z d „  Z d d d d d d d d d d „	 Z d „  Z	 d „  Z
 d „  Z d „  Z d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   s2  
    This class wraps the creation of an animation using matplotlib. It is
    only a base class which should be subclassed to provide needed behavior.

    *fig* is the figure object that is used to get draw, resize, and any
    other needed events.

    *event_source* is a class that can run a callback when desired events
    are generated, as well as be stopped and started. Examples include timers
    (see :class:`TimedAnimation`) and file system notifications.

    *blit* is a boolean that controls whether blitting is used to optimize
    drawing.
    c         C   s“   | |  _  | o | j j |  _ |  j ƒ  |  _ | |  _ |  j ƒ  | j j d |  j	 ƒ |  _
 |  j  j j d |  j ƒ |  _ |  j r� |  j ƒ  n  d  S(   Nt
   draw_eventt   close_event(   t   _figt   canvast   supports_blitt   _blitt   new_frame_seqt	   frame_seqt   event_sourcet
   _init_drawt   mpl_connectt   _startt   _first_draw_idt   _stopt	   _close_idt   _setup_blit(   R   R    R¥   t   blit(    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyR	     s    		
	c         G   sC   |  j  j |  j ƒ |  j  j ƒ  |  j j j |  j ƒ d |  _ d S(   s‹   
        Starts interactive animation. Adds the draw frame command to the GUI
        handler, calls show to start the event loop.
        N(	   R¥   t   add_callbackt   _stept   startRŸ   R    t   mpl_disconnectR©   R   (   R   R(   (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyR¨   .  s    c         G   sX   |  j  r" |  j j j |  j ƒ n  |  j j j |  j ƒ |  j j |  j ƒ d  |  _ d  S(   N(
   R¢   RŸ   R    R±   t
   _resize_idR«   R¥   t   remove_callbackR¯   R   (   R   R(   (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyRª   ;  s
    	c      
      sä  |
 d k r i  }
 n  d |
 k r~ | d k p? t | t t f ƒ s~ d j t | t ƒ r] | n	 | j j ƒ GH|
 j d ƒ q~ n  ˆ  j	 d k	 r¬ ˆ  j
 j j ˆ  j	 ƒ t } n t } | d k rÝ t ˆ  d ƒ rÝ d ˆ  j } n  | d k rö t d } n  | d k rt d } n  | d k r(t d	 } n  | d k rAt d
 } n  ˆ  g } |	 d k	 rv| j ‡  f d †  |	 Dƒ ƒ n  t | ƒ r
| t j k r¶t | | | | d | d | ƒ} q
d d l } | j d | ƒ y t j ƒ  d } Wq
t k
 rt d ƒ ‚ q
Xn  t j d t | ƒ d d ƒ| j ˆ  j
 | | ƒ �x xp t j  g  | D] } | j! ƒ  ^ qPŒ  D]F } x0 t" | | ƒ D] \ } } | j# | d t ƒqW| j$ |
 �  qiWWd QX| ràˆ  j
 j j% d ˆ  j& ƒ ˆ  _	 n  d S(   sÙ  
        Saves a movie file by drawing every frame.

        *filename* is the output filename, e.g., :file:`mymovie.mp4`

        *writer* is either an instance of :class:`MovieWriter` or a string
        key that identifies a class to use, such as 'ffmpeg' or 'mencoder'.
        If nothing is passed, the value of the rcparam `animation.writer` is
        used.

        *fps* is the frames per second in the movie. Defaults to None,
        which will use the animation's specified interval to set the frames
        per second.

        *dpi* controls the dots per inch for the movie frames. This combined
        with the figure's size in inches controls the size of the movie.

        *codec* is the video codec to be used. Not all codecs are supported
        by a given :class:`MovieWriter`. If none is given, this defaults to the
        value specified by the rcparam `animation.codec`.

        *bitrate* specifies the amount of bits used per second in the
        compressed movie, in kilobits per second. A higher number means a
        higher quality movie, but at the cost of increased file size. If no
        value is given, this defaults to the value given by the rcparam
        `animation.bitrate`.

        *extra_args* is a list of extra string arguments to be passed to the
        underlying movie utiltiy. The default is None, which passes the
        additional argurments in the 'animation.extra_args' rcParam.

        *metadata* is a dictionary of keys and values for metadata to include
        in the output file. Some keys that may be of use include:
        title, artist, genre, subject, copyright, srcform, comment.

        *extra_anim* is a list of additional `Animation` objects that should
        be included in the saved movie file. These need to be from the same
        `matplotlib.Figure` instance. Also, animation frames will just be
        simply combined, so there should be a 1:1 correspondence between
        the frames from the different animations.

        *savefig_kwargs* is a dictionary containing keyword arguments to be
        passed on to the 'savefig' command which is called repeatedly to save
        the individual frames. This can be used to set tight bounding boxes,
        for example.
        t   bbox_inchesRr   R‘   s¬   Warning: discarding the 'bbox_inches' argument in 'savefig_kwargs' as it is only currently supported with the writers 'ffmpeg_file' and 'mencoder_file' (writer used: '{}').t	   _intervalg     @�@s   animation.writers   savefig.dpis   animation.codecs   animation.bitratec         3   s'   |  ] } | j  ˆ  j  k r | Vq d  S(   N(   RŸ   (   R�   t   anim(   R   (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pys	   <genexpr>ª  s   R   R   iÿÿÿÿNs   MovieWriter %s unavailablei    sf   Cannot save animation: no writers are available. Please install mencoder or ffmpeg to save animations.s   Animation.save using %sR>   R@   R­   R�   (   Rr   R‘   ('   R   t
   isinstanceRs   R’   R?   Rd   t	   __class__R   t   popR©   RŸ   R    R±   RL   R9   t   hasattrRµ   R   Ri   R   t   writersR   t   warningst   warnR   t
   IndexErrort
   ValueErrorR   R6   t   typeR+   t	   itertoolst   izipt   new_saved_frame_seqt   zipt   _draw_next_frameRG   R§   R¨   (   R   t   filenamet   writerR   R"   R   R   R   R   t
   extra_animRD   t   reconnect_first_drawt   all_animR¼   t   at   dataR¶   t   d(    (   R   sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyt   saveC  sd    1			#c         G   sC   y* t  |  j ƒ } |  j | |  j ƒ t SWn t k
 r> t SXd S(   s‰   
        Handler for getting events. By default, gets the next frame in the
        sequence and hands the data off to be drawn.
        N(   t   nextR¤   RÅ   R¢   RL   t   StopIterationR9   (   R   R(   t	   framedata(    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyR¯   Õ  s    c         C   s   t  |  j ƒ S(   s,   Creates a new sequence of frame information.(   t   itert
   _framedata(   R   (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyR£   ä  s    c         C   s
   |  j  ƒ  S(   s9   Creates a new sequence of saved/cached frame information.(   R£   (   R   (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyRÃ   é  s    c         C   s1   |  j  | | ƒ |  j | ƒ |  j | | ƒ d  S(   N(   t	   _pre_drawt   _draw_framet
   _post_draw(   R   RÑ   R­   (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyRÅ   î  s    c         C   s   d  S(   N(    (   R   (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyR¦   õ  s    c         C   s#   | r |  j  |  j |  j ƒ n  d  S(   N(   t   _blit_cleart   _drawn_artistst   _blit_cache(   R   RÑ   R­   (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyRÔ   ú  s    c         C   s   t  d ƒ ‚ d  S(   NsD   Needs to be implemented by subclasses to actually make an animation.(   RH   (   R   RÑ   (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyRÕ      s    c         C   s<   | r( |  j  r( |  j |  j  |  j ƒ n |  j j j ƒ  d  S(   N(   RØ   t
   _blit_drawRÙ   RŸ   R    t	   draw_idle(   R   RÑ   R­   (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyRÖ     s    c         C   sœ   g  } xb | D]Z } | j  | k rG | j j j | j  j ƒ | | j  <n  | j  j | ƒ | j | j  ƒ q Wx* t | ƒ D] } | j j j | j ƒ qx Wd  S(   N(	   t   axest   figureR    t   copy_from_bboxt   bboxt   draw_artistR`   t   setR­   (   R   t   artistst   bg_cachet
   updated_axRË   t   ax(    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyRÚ     s    %c         C   sB   t  d „  | Dƒ ƒ } x% | D] } | j j j | | ƒ q Wd  S(   Nc         s   s   |  ] } | j  Vq d  S(   N(   RÜ   (   R�   RË   (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pys	   <genexpr>$  s    (   Rá   RÝ   R    t   restore_region(   R   Râ   Rã   RÜ   RË   (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyR×      s    c         C   sJ   t  ƒ  |  _ g  |  _ |  j j j d |  j ƒ |  _ |  j d  |  j
 ƒ d  S(   Nt   resize_event(   R   RÙ   RØ   RŸ   R    R§   t   _handle_resizeR²   RÖ   R   R¢   (   R   (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyR¬   (  s
    	c         G   s\   |  j  j j |  j ƒ |  j j ƒ  |  j j ƒ  |  j ƒ  |  j  j j	 d |  j
 ƒ |  _ d  S(   NR�   (   RŸ   R    R±   R²   R¥   t   stopRÙ   t   clearR¦   R§   t   _end_redraw(   R   R(   (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyRè   1  s    
c         C   sX   |  j  d  |  j ƒ |  j j ƒ  |  j j j |  j ƒ |  j j j	 d |  j
 ƒ |  _ d  S(   NRç   (   RÖ   R   R¢   R¥   R°   RŸ   R    R±   R²   R§   Rè   (   R   t   evt(    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyRë   =  s
    N(   R   R   RN   R   R9   R	   R¨   Rª   RÎ   R¯   R£   RÃ   RÅ   R¦   RÔ   RÕ   RÖ   RÚ   R×   R¬   Rè   Rë   (    (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyRœ     s(   		�								
					t   TimedAnimationc           B   s>   e  Z d  Z d d e d d „ Z d „  Z d „  Z d „  Z RS(   sI  
    :class:`Animation` subclass that supports time-based animation, drawing
    a new frame every *interval* milliseconds.

    *repeat* controls whether the animation should repeat when the sequence
    of frames is completed.

    *repeat_delay* optionally adds a delay in milliseconds before repeating
    the animation.
    iÈ   c         O   se   | |  _  | |  _ | |  _ | d  k rE | j j ƒ  } |  j  | _ n  t j |  | d | | | Žd  S(   NR¥   (	   Rµ   t   _repeat_delayt   repeatR   R    t	   new_timert   intervalRœ   R	   (   R   R    Rñ   t   repeat_delayRï   R¥   R(   RT   (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyR	   R  s    			c         G   sŽ   t  j |  | Œ } | r† |  j r† |  j ƒ  |  _ |  j rs |  j j |  j ƒ |  j j |  j	 ƒ |  j |  j _
 t St  j |  | Œ Sn | Sd S(   s-   
        Handler for getting events.
        N(   Rœ   R¯   Rï   R£   R¤   Rî   R¥   R³   R®   t   _loop_delayRñ   RL   (   R   R(   t   still_going(    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyR¯   b  s    
	c         G   s$   |  j  j |  j ƒ t j |  ƒ d  S(   N(   R¥   R³   Ró   Rœ   Rª   (   R   R(   (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyRª   y  s    c         G   sF   |  j  j |  j ƒ |  j |  j  _ |  j  j |  j ƒ t j |  ƒ d  S(   N(   R¥   R³   Ró   Rµ   Rñ   R®   R¯   Rœ   (   R   R(   (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyRó   €  s    N(	   R   R   RN   R   RL   R	   R¯   Rª   Ró   (    (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyRí   G  s   
			t   ArtistAnimationc           B   s2   e  Z d  Z d „  Z d „  Z d „  Z d „  Z RS(   s   
    Before calling this function, all plotting should have taken place
    and the relevant artists saved.

    frame_info is a list, with each list entry a collection of artists that
    represent what needs to be enabled on each frame. These will be disabled
    for other frames.
    c         O   s,   g  |  _  | |  _ t j |  | | | Ž d  S(   N(   RØ   RÓ   Rí   R	   (   R   R    Râ   R(   RT   (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyR	   ‘  s    		c         C   s‚   g  } xT |  j  ƒ  D]F } x= | D]5 } | j t ƒ | j | k r  | j | j ƒ q  q  Wq Wx | D] } | j j j ƒ  qd Wd  S(   N(   R£   t   set_visibleR9   RÜ   R`   RÝ   R    t   draw(   R   RÜ   t   fR‚   Rå   (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyR¦   š  s    c         C   sD   | r |  j  |  j |  j ƒ n! x |  j D] } | j t ƒ q) Wd S(   s5   
        Clears artists from the last frame.
        N(   R×   RØ   RÙ   Rö   R9   (   R   RÑ   R­   R‚   (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyRÔ   ¨  s    c         C   s+   | |  _  x | D] } | j t ƒ q Wd  S(   N(   RØ   Rö   RL   (   R   Râ   R‚   (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyRÕ   ´  s    	(   R   R   RN   R	   R¦   RÔ   RÕ   (    (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyRõ   ˆ  s
   				t   FuncAnimationc           B   sG   e  Z d  Z d d d d d „ Z d „  Z d „  Z d „  Z d „  Z RS(   sõ  
    Makes an animation by repeatedly calling a function *func*, passing in
    (optional) arguments in *fargs*.

    *frames* can be a generator, an iterable, or a number of frames.

    *init_func* is a function used to draw a clear frame. If not given, the
    results of drawing from the first item in the frames sequence will be
    used. This function will be called once before the first frame.

    If blit=True, *func* and *init_func* should return an iterable of
    drawables to clear.
    c            sø   | r | |  _  n	 d |  _  | |  _ | |  _ ˆ  d  k rH t j |  _ nc t ˆ  ƒ r` ˆ  |  _ nK t ˆ  ƒ r� ‡  f d †  |  _ t	 ˆ  ƒ |  _ n ‡  f d †  |  _ ˆ  |  _ |  j d  k rÆ d |  _ n  | |  _
 g  |  _ t j |  | | � g  |  _ d  S(   Nc              s
   t  ˆ  ƒ S(   N(   RÒ   (    (   t   frames(    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyt   <lambda>ã  s    c              s   t  t ˆ  ƒ ƒ S(   N(   RÒ   t   range(    (   Rú   (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyRû   æ  s    id   (    (   R2   t   _funct
   save_countR   RÁ   t   countt	   _iter_gent   callableR    t   lent
   _init_funct	   _save_seqRí   R	   (   R   R    t   funcRú   t	   init_funct   fargsRþ   RT   (    (   Rú   sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyR	   Ì  s(    						c         C   s
   |  j  ƒ  S(   N(   R   (   R   (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyR£   ø  s    c         C   s3   |  j  r t |  j  ƒ St j |  j ƒ  |  j ƒ Sd  S(   N(   R  RÒ   RÁ   t   isliceR£   Rþ   (   R   (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyRÃ   ü  s    	c         C   s>   |  j  d  k r+ |  j t |  j ƒ  ƒ ƒ n |  j  ƒ  |  _ d  S(   N(   R  R   RÕ   RÏ   R£   RØ   (   R   (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyR¦     s    c         C   s@   |  j  j | ƒ |  j  |  j |  _  |  j | |  j Œ |  _ d  S(   N(   R  R`   Rþ   Rý   R2   RØ   (   R   RÑ   (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyRÕ     s    N(	   R   R   RN   R   R	   R£   RÃ   R¦   RÕ   (    (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyRù   ¾  s   	+				
(!   R4   RÁ   RP   t   matplotlib.cbookR    R   t   matplotlib.compatR   t
   matplotlibR   R   t   objectR   R»   R   RS   Rh   R   Ro   Rs   R|   R~   R€   R�   R�   R’   R”   R—   R›   Rœ   Rí   Rõ   Rù   (    (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/animation.pyt   <module>   sF   	¸c 	
ÿ EA6