<commit_before>..  _Simulation_Investigation:

Simulation_Investigation class
==============================

When EoN performs a simulation with `return_full_data` set to True, it returns
a Simulation_Investigation object.  At it's core, this has the data about when
each node changed status and what its new status became.  This allows us to 
generate plots of the network at any given instance in time and to produce 
animations.

The basic display produced by a Simulation_Investigation object shows the 
network at a given snapshot in time on the left, and on the right it shows the
time series of S, I, and (if SIR) R.  It has the option to add additional 
curves as might have been calculated by an analytic model, or perhaps
another simulation.

In general, any of the dynamic simulations will produce a Simulation_Investigation
object if we pass it `return_full_data = True`.  

Quick Examples
^^^^^^^^^^^^^^

::

    import networkx as nx
    import EoN
    import matplotlib.pyplot as plt
    G = nx.grid_2d_graph(100,100) #each node is (u,v) where 0<=u,v<=99
    #we'll initially infect those near the middle 
    initial_infections = [(u,v) for (u,v) in G if 45<u<55 and 45<v<55]
    sim = EoN.fast_SIS(G, 1.0, 1.0, initial_infecteds = initial_infections, 
                   return_full_data=True, tmax = 10)
    pos = {node:node for node in G}
    sim.set_pos(pos)
    sim.display(6, node_size = 4) #display time 6
    plt.savefig('SIS_2dgrid.png')

This produces a snapshot at time 6:

.. image:: examples/SIS_2dgrid.png

::

    import networkx as nx
    import EoN
    import matplotlib.pyplot as plt
    G = nx.grid_2d_graph(100,100) #each node is (u,v) where 0<=u,v<=99
    #we'll initially infect those near the middle 
    initial_infections = [(u,v) for (u,v) in G if 45<u<55 and 45<v<55]
    sim = EoN.fast_SIR(G, 2.0, 1.0, initial_infecteds = initial_infections, 
                   return_full_data=True, tmax = 10)
    pos = {node:node for node in G}
    sim.set_pos(pos)
    ani=sim.animate(ts_plots=['I', 'SIR'], node_size = 4) 
    ani.save('SIR_2dgrid.mp4', fps=5, extra_args=['-vcodec', 'libx264'])

This produces an animation:

.. raw:: html 

   <video controls src="examples/SIR_2dgrid.mp4"></video> 

Quick List
^^^^^^^^^^

.. currentmodule:: EoN.Simulation_Investigation

.. autosummary::
   :toctree: functions
   
   display
   animate
   node_history
   node_status
   get_statuses
   summary
   t
   S
   I
   R
   add_timeseries
   update_ts_kwargs
   update_ts_label
   update_ts_colordict
   sim_update_kwargs
   sim_update_label
   sim_update_colordict
   set_pos
   
Short description
^^^^^^^^^^^^^^^^^
- Visualizations

  There are two main commands for visualization.  We can either produce a 
  snapshot at a given time, or produce an animation.  In either case we can
  optionally include plots of S, I, (and R) as functions of time.
  
  - **display**
  - **animate**
  
- Data about simulation

  Often we'll want to be able to check what happened to specific nodes in the
  network, or we'll want to know what the time history of the outbreak looked
  like
  
  - **node_history**
  - **node_status**
  - **get_statuses**
  - **summary**
  - **t**
  - **S**
  - **I**
  - **R**
  
- Details for plotting

  The remaining commands are to do with the specifics of how the plots appear
  
  - **update_ts_kwargs**
  - **update_ts_label**
  - **update_ts_colordict**
  - **sim_update_kwargs**
  - **sim_update_label**
  - **sim_update_colordict**
  - **set_pos**

<commit_msg>trying to get animation to appear in readthedocs<commit_after>..  _Simulation_Investigation:

Simulation_Investigation class
==============================

When EoN performs a simulation with `return_full_data` set to True, it returns
a Simulation_Investigation object.  At it's core, this has the data about when
each node changed status and what its new status became.  This allows us to 
generate plots of the network at any given instance in time and to produce 
animations.

The basic display produced by a Simulation_Investigation object shows the 
network at a given snapshot in time on the left, and on the right it shows the
time series of S, I, and (if SIR) R.  It has the option to add additional 
curves as might have been calculated by an analytic model, or perhaps
another simulation.

In general, any of the dynamic simulations will produce a Simulation_Investigation
object if we pass it `return_full_data = True`.  

Quick Examples
^^^^^^^^^^^^^^

::

    import networkx as nx
    import EoN
    import matplotlib.pyplot as plt
    G = nx.grid_2d_graph(100,100) #each node is (u,v) where 0<=u,v<=99
    #we'll initially infect those near the middle 
    initial_infections = [(u,v) for (u,v) in G if 45<u<55 and 45<v<55]
    sim = EoN.fast_SIS(G, 1.0, 1.0, initial_infecteds = initial_infections, 
                   return_full_data=True, tmax = 10)
    pos = {node:node for node in G}
    sim.set_pos(pos)
    sim.display(6, node_size = 4) #display time 6
    plt.savefig('SIS_2dgrid.png')

This produces a snapshot at time 6:

.. image:: examples/SIS_2dgrid.png

::

    import networkx as nx
    import EoN
    import matplotlib.pyplot as plt
    G = nx.grid_2d_graph(100,100) #each node is (u,v) where 0<=u,v<=99
    #we'll initially infect those near the middle 
    initial_infections = [(u,v) for (u,v) in G if 45<u<55 and 45<v<55]
    sim = EoN.fast_SIR(G, 2.0, 1.0, initial_infecteds = initial_infections, 
                   return_full_data=True, tmax = 10)
    pos = {node:node for node in G}
    sim.set_pos(pos)
    ani=sim.animate(ts_plots=['I', 'SIR'], node_size = 4) 
    ani.save('SIR_2dgrid.mp4', fps=5, extra_args=['-vcodec', 'libx264'])

This produces an animation:

.. raw:: html 

   <video controls src="_static/SIR_2dgrid.mp4"></video> 

Quick List
^^^^^^^^^^

.. currentmodule:: EoN.Simulation_Investigation

.. autosummary::
   :toctree: functions
   
   display
   animate
   node_history
   node_status
   get_statuses
   summary
   t
   S
   I
   R
   add_timeseries
   update_ts_kwargs
   update_ts_label
   update_ts_colordict
   sim_update_kwargs
   sim_update_label
   sim_update_colordict
   set_pos
   
Short description
^^^^^^^^^^^^^^^^^
- Visualizations

  There are two main commands for visualization.  We can either produce a 
  snapshot at a given time, or produce an animation.  In either case we can
  optionally include plots of S, I, (and R) as functions of time.
  
  - **display**
  - **animate**
  
- Data about simulation

  Often we'll want to be able to check what happened to specific nodes in the
  network, or we'll want to know what the time history of the outbreak looked
  like
  
  - **node_history**
  - **node_status**
  - **get_statuses**
  - **summary**
  - **t**
  - **S**
  - **I**
  - **R**
  
- Details for plotting

  The remaining commands are to do with the specifics of how the plots appear
  
  - **update_ts_kwargs**
  - **update_ts_label**
  - **update_ts_colordict**
  - **sim_update_kwargs**
  - **sim_update_label**
  - **sim_update_colordict**
  - **set_pos**


{'fraction_non_alphanumeric': 0.10728402032749859, 'fraction_numerical': 0.017786561264822136, 'mean_word_length': 3.357318573185732, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5158719', 'n_tokens_mistral': 2508, 'n_tokens_neox': 2342, 'n_words': 811}