ó
nt9Yc           @   sË   d  d l  j Z d  d l Z d  d l m Z d   Z d   Z d d  Z
 d   Z d   Z d   Z d	   Z d
 d d  Z d e d
 d d  Z d d d  Z d d d  Z d d  Z d d  Z d S(   i˙˙˙˙N(   t   odeintc          C   s#   d }  d d } d } |  | | f S(   Ng      $@g       @g      @g      <@(    (   t   sigmat   bt   r(    (    s(   /home/sws07om/pythond/IIEVCA/lorenz63.pyt   standard_param_values   s    
c   	      C   sO   |  \ } } } | \ } } } | | | | | | | | | | | | g S(   N(    (	   t   wt   tt   pt   xt   yt   zR   R   R   (    (    s(   /home/sws07om/pythond/IIEVCA/lorenz63.pyt   f   s    c         C   sR   | d  k r t   } n  t j d | |  } t t |  | d | f } | | f S(   Ni    t   args(   t   NoneR   t   npt   arangeR    R   (   t   w0t   t1t   dtR   R   R   (    (    s(   /home/sws07om/pythond/IIEVCA/lorenz63.pyt   integrate_system   s
    c         C   s   |  d |  d |  d f S(   Ni    i   i   (    (   R   (    (    s(   /home/sws07om/pythond/IIEVCA/lorenz63.pyt   unpack_state   s    c          C   sI   d }  d } d } d } d } t  |  | | g | |  \ } } | | f S(   Ngq=
×Łp@gq=
×Łp@g33333ł5@g     @o@g{ŽGáz?(   R   (   t   x0t   y0t   z0R   R   R   R   (    (    s(   /home/sws07om/pythond/IIEVCA/lorenz63.pyt   generate_background_attractor"   s    !c         C   s]   d d d g d d d g d d d g g } d | d t  |   GHt j j |  | |  } | S(   NgŠ?i    s4   Usando %d condiciones iniciales alrededor del punto s$   (x0, y0, z0) = (%5.2f, %5.2f, %5.2f)(   R   R   t   randomt   multivariate_normal(   t	   w0_centret   Nt   covR   (    (    s(   /home/sws07om/pythond/IIEVCA/lorenz63.pyt$   generate_ensemble_initial_conditions2   s    *c         C   sŕ   |  j  d } t j t | |  d | f  } xU t |  D]G } t |  | d  d   f | |  \ | d  d   d  d   | f <} q< Wt j | d d  d   d  d   f  } d | d	 GHd | d
 GHd | d GH| | f S(   Ni    i   i˙˙˙˙s   std(x) = %5.2fs   std(y) = %5.2fi   s   std(z) = %5.2fi   (   i    i    (   i   i   (   i   i   (   t   shapeR   t   zerost   intt   rangeR   R   (   R   R   R   R   t   w_pertt   nnR   t   C(    (    s(   /home/sws07om/pythond/IIEVCA/lorenz63.pyt   integrate_ensemble?   s    "E(t   xzc         C   s˙   t    \ } } |  d k rJ | d  d   d f } | d  d   d f } nv |  d k r | d  d   d f } | d  d   d f } n; |  d k rŔ | d  d   d f } | d  d   d f } n  | d  k rĺ t j | | d d n | j | | d d d  S(	   NR'   i    i   t   xyi   t   yzt   colort   grey(   R   R   t   pltt   plot(   t   projt   axesR   R   t   u1t   u2(    (    s(   /home/sws07om/pythond/IIEVCA/lorenz63.pyt   plot_background_attractorL   s    t   blackc      	   C   sŞ  | d k r; |  d  d   d f } |  d  d   d f } nv | d k rv |  d  d   d f } |  d  d   d f } n; | d k rą |  d  d   d f } |  d  d   d f } n  | d  k r3t j | | d | | rŚt j | d | d d d	 d
 d d | t j | d | d d d d
 d d | qŚns | j | | d | | rŚ| j | d | d d d	 d
 d d | | j | d | d d d d
 d d | n  d  S(   NR'   i    i   R(   i   R)   R*   t   markert   ^t	   linestylet   nonei˙˙˙˙t   o(   R   R,   R-   (   R   t   colourt   extremesR.   R/   R0   R1   (    (    s(   /home/sws07om/pythond/IIEVCA/lorenz63.pyt
   plot_orbit^   s,    ####c         C   s   t  } | d  k r? t j d d d t d t \ } } t } n  | d j | |  d  d   d f d | | r | d j d  n  | d j | |  d  d   d f d | | rÇ | d j d  n  | d	 j | |  d  d   d	 f d | | r| d	 j d
  | d	 j d  n  | S(   Ni   i   t   sharext   shareyi    R*   R   R	   i   R   R
   (   t   FalseR   R,   t   subplotst   TrueR-   t
   set_ylabelt
   set_xlabel(   R   R   R9   t   axarrt   write_labelsR   (    (    s(   /home/sws07om/pythond/IIEVCA/lorenz63.pyt   plot_componentsx   s    $	***c         C   s   d d l  m } | d  k r1 t j d d  } n  |  d  d   d f } |  d  d   d f } |  d  d   d f } | j | | | d | d  S(	   Ni˙˙˙˙(   t   Axes3Dt
   projectiont   3di    i   i   R*   (   t   mpl_toolkits.mplot3dRF   R   R,   t   gcaR-   (   R   R9   R/   RF   R0   R1   t   u3(    (    s(   /home/sws07om/pythond/IIEVCA/lorenz63.pyt   plot_attractor   s    güŠńŇMbP?c         C   sI   t  j t  j | | | k | | | k    } |  | d  d   f j   S(   N(   R   t   wheret   logical_andt   flatten(   R   R   t   t_0t   tolt   ix(    (    s(   /home/sws07om/pythond/IIEVCA/lorenz63.pyt   find_system_state   s    /c         C   sş  t  j d d d t d d \ } } t j d d d	  } | d
 j |  d d
 d  d   f d | d t | d  k	 r | d
 j | d
 d d d d n  | d
 j d  t j d d d  } | d j |  d d d  d   f d | d t | d  k	 r| d j | d d d d d n  | d j d  t j d
 d d  } | d j |  d d d  d   f d | d t | d  k	 rĽ| d j | d d d d d n  | d j d  d  S(   Ni   i   R=   t   figsizei
   i   iě˙˙˙i   i)   i    i˙˙˙˙t   binst   normedR*   R3   t	   linewidthi   R   iâ˙˙˙i   i=   R	   i2   i3   R
   (   i
   i   (	   R,   R?   R@   R   t   linspacet   histR   t   axvlineRB   (   t   w_fctt   w_anaR   RC   RU   (    (    s(   /home/sws07om/pythond/IIEVCA/lorenz63.pyt	   plot_pdfs   s     $0$0$0$(   t   matplotlib.pyplott   pyplotR,   t   numpyR   t   scipy.integrateR    R   R   R   R   R   R   R   R&   R2   R>   R;   RE   RL   RS   R]   (    (    (    s(   /home/sws07om/pythond/IIEVCA/lorenz63.pyt   <module>   s   						