sid.update_states

Module Contents

Functions

update_states(states: pandas.DataFrame, newly_infected_contacts: pandas.Series, newly_infected_events: pandas.Series, params: pandas.DataFrame, virus_strains: Dict[str, Any], to_be_processed_tests: Optional[pandas.Series], newly_vaccinated: pandas.Series, seed: itertools.count, derived_state_variables)

Update the states with new infections and advance it by one period.

_update_countdowns(states)

Update countdowns.

_update_info_on_newly_infected(states, newly_infected_contacts, newly_infected_events, virus_strains)

Update information with newly infected individuals.

_kill_people_over_icu_limit(states, params, seed)

Kill people over the ICU limit.

_update_info_on_new_tests(states: pandas.DataFrame, to_be_processed_tests: pandas.Series) → pandas.DataFrame

_update_info_on_new_vaccinations(states: pandas.DataFrame, newly_vaccinated: pandas.Series) → pandas.DataFrame

Activate the counter for immunity by vaccinations.

update_derived_state_variables(states, derived_state_variables)

_update_immunity_level(states: pandas.DataFrame, params: pandas.DataFrame) → pandas.DataFrame

Update immunity levels from infection and vaccination.

compute_waning_immunity(params: pandas.DataFrame, days_since_event: pandas.Series, event: str) → pandas.Series

Compute waning immunity level.

_get_waning_immunity_coefficients(params: pandas.DataFrame, event: str) → Dict[str, float]

Transform high-level arguments for waning immunity to low-level coefficients.

update_states(states: pandas.DataFrame, newly_infected_contacts: pandas.Series, newly_infected_events: pandas.Series, params: pandas.DataFrame, virus_strains: Dict[str, Any], to_be_processed_tests: Optional[pandas.Series], newly_vaccinated: pandas.Series, seed: itertools.count, derived_state_variables)[source]

Update the states with new infections and advance it by one period.

States are changed in place to save copying!

Parameters
  • states (pandas.DataFrame) – See The states DataFrame.

  • newly_infected_contacts (pandas.Series) – Boolean series indicating individuals infected by contacts. There can be an overlap with infections by events.

  • newly_infected_events (pandas.Series) – Boolean series indicating individuals infected by events. There can be an overlap with infections by contacts.

  • params (pandas.DataFrame) – See params.

  • virus_strains (Dict[str, Any]) – A dictionary with the keys "names", "contagiousness_factor" and "immunity_resistance_factor" holding the different contagiousness factors and immunity resistance factors of multiple viruses.

  • to_be_processed_tests (pandas.Series) – Tests which are going to be processed.

  • newly_vaccinated (Optional[pandas.Series]) – A series which indicates newly vaccinated people.

  • seed (itertools.count) – Seed counter to control randomness.

  • derived_state_variables (Dict[str, str]) – A dictionary that maps names of state variables to pandas evaluation strings that generate derived state variables, i.e. state variables that can be calculated from the existing state variables.

Returns: states (pandas.DataFrame): Updated states with reduced countdown lengths,

newly started countdowns, and killed people over the ICU limit.

_update_countdowns(states)[source]

Update countdowns.

_update_info_on_newly_infected(states, newly_infected_contacts, newly_infected_events, virus_strains)[source]

Update information with newly infected individuals.

_kill_people_over_icu_limit(states, params, seed)[source]

Kill people over the ICU limit.

_update_info_on_new_tests(states: pandas.DataFrame, to_be_processed_tests: pandas.Series) pandas.DataFrame[source]
_update_info_on_new_vaccinations(states: pandas.DataFrame, newly_vaccinated: pandas.Series) pandas.DataFrame[source]

Activate the counter for immunity by vaccinations.

update_derived_state_variables(states, derived_state_variables)[source]
_update_immunity_level(states: pandas.DataFrame, params: pandas.DataFrame) pandas.DataFrame[source]

Update immunity levels from infection and vaccination.

compute_waning_immunity(params: pandas.DataFrame, days_since_event: pandas.Series, event: str) pandas.Series[source]

Compute waning immunity level.

The immunity level is a simple piece-wise function parametrized over the maximum level of achievable immunity, the number of days it takes to achieve this maximum and the linear slope determining how fast the immunity level decreases after reaching the maximum. Before the maximum is achieved the function is modeled as a third-degree polynomial and afterwards as a linear function. The coefficients are adjusted to the parameters and set in _get_waning_immunity_coefficients.

Parameters
  • params (pandas.DataFrame) – See params.

  • days_since_event (pandas.Series) – Series containing days since event occurred for each individual in the state.

  • event (str) – Reason for immunity. Must be in {“infection”, “vaccination”}.

Returns

Adjusted immunity level.

Return type

immunity (pandas.Series)

_get_waning_immunity_coefficients(params: pandas.DataFrame, event: str) Dict[str, float][source]

Transform high-level arguments for waning immunity to low-level coefficients.

Coefficients are calibrated to parameters in params.

Parameters
  • params (pandas.DataFrame) – See params.

  • event (str) – Reason for immunity. Must be in {“infection”, “vaccination”}.

Returns

The coefficients.

Return type

coef (Dict[str, float])