comod package
Submodules
comod.base module
- class comod.base.FunctionModel(states=None, parameters=None, rules=None, sum_state='N', nihil_state='!')[source]
Bases:
comod.base._Model
A compartment model with transition rules defined by callables
- class comod.base.Model(states=None, parameters=None, rules=None, sum_state='N', nihil_state='!')[source]
Bases:
comod.base._Model
A compartment model with transition rules defined by strings
- solve_time(initial, parameters, t, **kwargs)[source]
Solve the model numerically for parameters given as functions of time.
The solution is found using scipy.integrate.solve_ivp, which uses by default an Explicit Runge-Kutta method of order 5(4).
- Parameters
initial (list of float) – Initial population for each of the states.
parameters (list of callable) – Functions of time defining the parameters.
t (list of float) – Mesh of time values for which the solution is found.
kwargs – Additional arguments passed to solve_ivp.
- Returns
Values of each component (first coordinate) at the t mesh (second).
- Return type
numpy.ndarray
- comod.base.add_natural(model, birth_param='nu', death_param='mu', birth_state=None)[source]
Add some “natural” birth and death dynamics to a model
Births are described by an absolute rate, while deaths are relative to the population.
- Parameters
model (Model) – Base model which will be extended.
birth_param (str) – Name of the birth rate parameter.
death_param (str) – Name of the death rate parameter.
birth_state (str) – State were births take place. Defaults to the first state of model.
- Returns
A new model with the extended dynamics.
- Return type
comod.community module
- class comod.community.CommunityModel(base_model, communities, topology=None, exchange_term='m', equal_parameters=False, symmetric_matrix=False, labels=None)[source]
Bases:
comod.base.Model
comod.data module
- comod.data.fetch_JHU_daily(date_start, date_end, countries=None, columns=None, progress=True)[source]
Fetch a Dataframe with data from JHU CSSE COVID-19 Data.
The full repository name is COVID-19 Data Repository by the Center for Systems Science and Engineering (CSSE) at Johns Hopkins University.
Cf. https://github.com/CSSEGISandData/COVID-19 for license and terms of use.
- Parameters
date_start (str) – Start date in ISO format (e.g., 2021-01-31).
date_end (str) – End date in ISO format.
countries (None, str or list of str) – If provided, list of countries to keep.
columns (None or list of str) – If provided, lists of columns to use.
progress (bool) – Whether to diplay a progress bar.
- Returns
A dataframe with the information.
- Return type
pd.DataFrame
comod.models module
Module contents
comod - Compartment model Python package