CV19 module¶
-
class
cv19.
Graph
¶ Bases:
object
class Graph This class is used to create and manipulated graphs It makes a heavy use of the node class A graph is made of nodes and edges. This class allows to store a value for each node and different “weights” for each edge. Also, edges are directed.
Exampe of usage: g = Graph()
- for i, inode in enumerate([‘A’,’B’,’C’,’D’]):
- print(i) g.add_node(inode, 0)
nms = [‘x’, ‘y’] g.add_edge(‘A’, ‘B’, nms, [1, 100]) g.add_edge(‘A’, ‘C’, nms, [2, 200]) g.add_edge(‘B’, ‘D’, nms, [3, 300]) g.add_edge(‘D’, ‘B’, nms, [4, 400]) g.add_edge(‘D’, ‘C’, nms, [5, 500]) g.add_edge(‘C’, ‘C’, nms, [6, 600])
# A node can be connected to itself. g.add_edge(‘B’, ‘B’, nms, [333, 333])
g.show()
- vert_dict: dict
- a dict containing the vertices
- num_vertices : int
- the number of nodes (or vertices) in a graph
add_node(node, value) get_node() get_node_value() set_node() get_node_ids() get_nodes_to() get_nodes_from()
-
add_edge
(frm, to, names=[], values=0)¶ warning: does not verify if edge already exists
-
add_node
(nnode, value)¶ method: add_node
Adds a node to a graph. The node must have a value.
-
get_edge
(frm, to, field)¶
-
get_node
(n)¶ method: get_node
n: strnode: a node object
-
get_node_ids
()¶
-
get_node_value
(n)¶ method: get_node_value
n: strvalue: float
-
get_nodes_from
(nnode)¶
-
get_nodes_to
(nnode)¶
-
node_activation
(nnode, key)¶
-
node_upgrade
(nnode, key)¶
-
set_node
(n, value)¶ method: set_node
- n: str
- The ID or name of the node
- value: float
- The value to be assigned to the node
updates the Graph
-
show_connections
()¶
-
show_weights
()¶
-
class
cv19.
InfectionCurve
¶ Bases:
object
-
compute
(p)¶ InfectionCurve(self, p): computes the Infection Curve based on a probabilistic model implemented in a simulation
- Args:
- config object from ParseConfig
Raises:
- Returns:
- Time series for the curves of: - Infected - Confirmed - Recovered - Confirmed at home - Confirmed at hospital - Confirmed at ICU - Dead
-
model_SEIR
()¶
-
model_SIR
(p)¶
-
plt_IC
()¶ plots the infection curve
- Args:
- ic: time series fplot: filename for the plot
Raises:
- Returns:
- Nothing, just save the plot.
-
plt_IC_n
()¶ plots the infection curve
- Args:
- ic: time series fplot: filename for the plot
Raises:
- Returns:
- Nothing, just save the plot.
-
-
class
cv19.
node
(nnode, value)¶ Bases:
object
class node This class is used to create and manipulated nodes.
-
add_neighbor
(neighbor, names, values)¶
-
be_neighbor
(neighbor, names, values)¶
-
get_connections
()¶
-
get_id
()¶
-
get_weight
(neighbor)¶
-
-
class
cv19.
parser
(defaults=None, dict_type=<class 'collections.OrderedDict'>, allow_no_value=False, *, delimiters=('=', ':'), comment_prefixes=('#', ';'), inline_comment_prefixes=None, strict=True, empty_lines_in_values=True, default_section='DEFAULT', interpolation=<object object>, converters=<object object>)¶ Bases:
configparser.ConfigParser
parser class manipulation of parser from ini files
-
check_file
(sys_args)¶ chek_file(args): Parse paramenters for the simulation from a .ini file
- Args:
- filename (str): the file name of the map to be read
Raises:
- Returns:
- readmap: a healpix map, class ?
-
load_filenames
()¶ load_filenames(self): make filenames based on info in config file
- Args:
- None
Raises:
- Returns:
- list of filenames
-
load_parameters
()¶ load_parameters(self): load parameters from config file
- Args:
- None
Raises:
- Returns:
- list of parameters as a named tuple
-
read_config_file
()¶ chek_file(args): Parse paramenters for the simulation from a .ini file
- Args:
- filename (str): the file name of the map to be read
Raises:
- Returns:
- readmap: a healpix map, class ?
-
-
class
cv19.
table_draw
¶ Bases:
object
-
add_clean_column
(columnname, column)¶
-
load
(filename)¶
-
random_gen
(xinfname, xsupname, yname)¶ - method: random_gen
- Generates a random sample from a given probability density The probability density must be in the table, in the table_draw class.
-
save_clean_CDF
(filename)¶
-
tabular
(x, y)¶
-
test_random_gen
(nran, fplot)¶
-