bucky package¶
Subpackages¶
- bucky.util package
- bucky.viz package
Submodules¶
bucky.arg_parser_model module¶
arg parser for bucky.model
This module handles all the CLI argument parsing for bucky.model and autodetects CuPy.
bucky.make_input_graph module¶
-
bucky.make_input_graph.
compute_population_density
(age_df, shape_df)¶ Computes normalized population density.
- Parameters
age_df (Pandas DataFrame) – age-stratified population data
shape_df (Geopandas GeoDataFrame) – GeoDataFrame with shape information indexed by FIPS
- Returns
popdens – DataFrame with population density by FIPS
- Return type
Pandas DataFrame
-
bucky.make_input_graph.
get_case_history
(historical_data, end_date, num_days=45)¶ Gets case and death history for the requested number of days for each FIPS.
If data is missing for a date, it is replaced with the data from the last valid date.
- Parameters
historical_data (Pandas DataFrame) – Dataframe with case, death data indexed by date, FIPS
end_date (date string) – Last date to get data for
num_days (int) – Number of days of history requested
- Returns
hist – Dictionary of case data, keyed by FIPS
- Return type
dict
-
bucky.make_input_graph.
get_lex
(last_date, window_size=7)¶ Reads county-level location exposure indices from PlaceIQ location data and applies a window.
- Parameters
last_date (last_date) – Fetches data for requested date
window_size (int (default: 7)) – Size of window, in days, to apply to data
- Returns
frac_df – TODO
- Return type
Pandas DataFrame
-
bucky.make_input_graph.
get_mobility_data
(popdens, end_date, age_data, add_territories=True)¶ Fetches mobility data.
- Parameters
popdens (Pandas DataFrame) – Population density indexed by FIPS
end_date (string) – Last date of historical data
age_data (Pandas DataFrame) – County-level age-stratified population data
add_territories (boolean) – Adds territory data if True
- Returns
mean_edge_weights (Pandas DataFrame) – TODO
move_dict (dict) – TODO
-
bucky.make_input_graph.
get_safegraph
(last_date, window_size=7)¶ Reads SafeGraph mobility data and applies a window.
- Parameters
last_date (last_date) – Fetches data for requested date
window_size (int (default: 7)) – Size of window, in days, to apply to data
- Returns
frac_df – TODO
- Return type
Pandas DataFrame
-
bucky.make_input_graph.
read_descartes_data
(end_date)¶ Reads Descartes mobility data [WS20].
- Parameters
end_date (string) – Last date to get Descartes data
- Returns
nat_frac_move (Pandas DataFrame) – TODO
dl_state (Pandas DataFrame) – TODO
dl_county (Pandas DataFrame) – TODO
Notes
Data provided by Descartes Labs (https://descarteslabs.com/mobility/) 1
- 1
Warren, Michael S. & Skillman, Samuel W. “Mobility Changes in Response to COVID-19”. arXiv:2003.14228 [cs.SI], Mar. 2020. arxiv.org/abs/2003.14228
-
bucky.make_input_graph.
read_lex_data
(date)¶ Reads county-level location exposure indices for a given date from PlaceIQ location data.
In order to improve performance, preprocessed data is saved. If the user requests data for a date that has already been preprocessed, it will read the data from disk instead of repeating the processing.
- Parameters
date (string) – Fetches data for requested date
- Returns
df_long – Preprocessed LEX data
- Return type
Pandas DataFrame
bucky.model module¶
-
class
bucky.model.
SEIR_covid
(seed=None, randomize_params_on_reset=True)¶ Bases:
object
-
static
RHS_func
(t, y, Nij, contact_mats, Aij, par, npi)¶
-
estimate_doubling_time
(days_back=7, doubling_time_window=7, mean_time_window=None, min_doubling_t=1.0)¶
-
estimate_doubling_time_WHO
(days_back=14, doubling_time_window=7, mean_time_window=None, min_doubling_t=1.0)¶
-
estimate_reporting
(cfr, days_back=14, case_lag=None, min_deaths=100.0)¶
-
get_state_indices
()¶
-
reset
(seed=None, params=None)¶
-
reset_A
(var)¶
-
run_once
(seed=None, outdir='raw_output/', output=True, output_queue=None)¶
-
static
-
exception
bucky.model.
SimulationException
¶ Bases:
Exception
-
bucky.model.
get_runid
(pid=0)¶
bucky.npi module¶
-
bucky.npi.
read_npi_file
(fname, start_date, end_t, adm2_map, disable_npi=False)¶ TODO Description.
- Parameters
fname (string) – Filename of NPI file
start_date (string) – Start date to use
end_t (int) – Number of days after start date
adm2_map (NumPy array) – Array of adm2 IDs
disable_npi (bool (default: False)) – Bool indicating whether NPIs should be disabled
- Returns
npi_params – TODO
- Return type
dict
bucky.numerical_libs module¶
Provides an interface to import numerical libraries using the GPU (if available).
-
bucky.numerical_libs.
use_cupy
(optimize=False)¶ Perform imports for libraries with APIs matching numpy, scipy.integrate.ivp, scipy.sparse.
These imports will use a monkey-patched version of these modules that has had all it’s numpy references replaced with CuPy.
if optimize is True, place the kernel optimization context in xp.optimize_kernels, otherwise make it a nullcontext (noop)
returns nothing but imports a version of ‘xp’, ‘ivp’, and ‘sparse’ to the global scope of this module
- Parameters
optimize (bool) – Enable kernel optimization in cupy >=v8.0.0. This will slow down initial function call (mostly reduction operations) but will offer better performance for repeated calls (e.g. in the RHS call of an integrator).
- Returns
exit_code – Non-zero value indicates error code, or zero on success.
- Return type
int
- Raises
NotImplementedError – If the user calls a monkeypatched function of the libs that isn’t fully implemented.
bucky.parameters module¶
-
bucky.parameters.
CI_to_std
(CI)¶
-
class
bucky.parameters.
buckyParams
(par_file=None, gpu=False)¶ Bases:
object
-
static
age_interp
(x_bins_new, x_bins, y)¶
-
static
calc_derived_params
(params)¶
-
generate_params
(var=0.2)¶
-
static
read_yml
(par_file)¶
-
reroll_params
(base_params, var)¶
-
static
rescale_doubling_rate
(D, params, xp, A=None)¶
-
static
-
bucky.parameters.
calc_Reff
(m, n, Tg, Te, r)¶
-
bucky.parameters.
calc_Te
(Tg, Ts, n, f)¶
-
bucky.parameters.
calc_Ti
(Te, Tg, n)¶
-
bucky.parameters.
calc_beta
(Te)¶
-
bucky.parameters.
calc_gamma
(Ti)¶
bucky.postprocess module¶
-
bucky.postprocess.
divide_by_pop
(dataframe, cols)¶ Given a dataframe and list of columns, divides the columns by the population column (‘N’).
- Parameters
dataframe (Pandas DataFrame) – Simulation data
cols (list of strings) – Column names to scale by population
- Returns
dataframe – Original dataframe with the requested columns scaled
- Return type
Pandas DataFrame