physDBD package
Subpackages
Submodules
physDBD.data_desc module
- class physDBD.data_desc.DataDesc(no_seeds: int, time_start: float, time_end: float, time_interval: float, species: List[str])
Bases:
object
- __init__(no_seeds: int, time_start: float, time_end: float, time_interval: float, species: List[str])
Data description
- Args:
no_seeds (int): no. seeds time_start (float): time start (real time) time_end (float): time end (real time) time_interval (float): time interval (real time) species (List[str]): list of species
- no_seeds: int
- no_times: int
- species: List[str]
- time_end: float
- time_interval: float
- time_start: float
- times: numpy.array
physDBD.diff_tvr module
- class physDBD.diff_tvr.DiffTVR(n: int, dx: float)
Bases:
object
- __init__(n: int, dx: float)
Differentiate with TVR.
- Args:
n (int): Number of points in data. dx (float): Spacing of data.
- get_deriv_tvr(data: numpy.array, deriv_guess: numpy.array, alpha: float, no_opt_steps: int, return_progress: bool = False, return_interval: int = 1) Tuple[numpy.array, numpy.array]
Get derivative via TVR over optimization steps
- Args:
data (np.array): Data of size N deriv_guess (np.array): Guess for derivative of size N-1 alpha (float): Regularization parameter no_opt_steps (int): No. opt steps to run return_progress (bool, optional): True to return derivative progress during optimization. Defaults to False. return_interval (int, optional): Interval at which to store derivative if returning. Defaults to 1.
- Returns:
Tuple[np.array,np.array]: First is the final derivative of size N-1, second is the stored derivatives if return_progress=True of size no_opt_steps+1 x N-1, else [].
- get_deriv_tvr_update(data: numpy.array, deriv_curr: numpy.array, alpha: float) numpy.array
Get the TVR update
- Args:
data (np.array): Data of size N deriv_curr (np.array): Current deriv of size N-1 alpha (float): Regularization parameter
- Returns:
np.array: Update vector of size N-1
- make_en_mat(deriv_curr: numpy.array) numpy.array
Diffusion matrix
- Args:
deriv_curr (np.array): Current derivative of length N-1
- Returns:
np.array: N-2 x N-2
- make_gn_vec(deriv_curr: numpy.array, data: numpy.array, alpha: float, ln_mat: numpy.array) numpy.array
Negative right hand side of linear problem
- Args:
deriv_curr (np.array): Current derivative of size N-1 data (np.array): Data of size N alpha (float): Regularization parameter ln_mat (np.array): Diffusivity term from make_ln_mat
- Returns:
np.array: Vector of length N-1
- make_hn_mat(alpha: float, ln_mat: numpy.array) numpy.array
Matrix in linear problem
- Args:
alpha (float): Regularization parameter ln_mat (np.array): Diffusivity term from make_ln_mat
- Returns:
np.array: N-1 x N-1
- make_ln_mat(en_mat: numpy.array) numpy.array
Diffusivity term
- Args:
en_mat (np.array): Result from make_en_mat
- Returns:
np.array: N-1 x N-1
physDBD.helpers module
- physDBD.helpers.array_safe_eq(a, b) bool
Check if a and b are equal, even if they are numpy arrays. Needed for checking equality with @dataclass(eq=False) decorator
- physDBD.helpers.convert_np_to_pd(arr_with_times: numpy.array, nv: int, nh: int) pandas.core.frame.DataFrame
Convert a numpy array of wt, b, sig2, muh, varh_diag to a pandas dataframe with named columns
- Args:
- arr_with_times (np.array): Array of size TxN where T is the number of timepoints and
N is the size of (wt,b,sig2,muh,varh_diag) = (nv*nh, nv, 1, nh, nh) = nv*nh + nv + 1 + 2*nh
nv (int): No. visible species nh (int): No. hidden species
- Returns:
pd.DataFrame: Pandas data frame
- physDBD.helpers.dc_eq(dc1, dc2) bool
checks if two dataclasses which hold numpy arrays are equal. Needed for checking equality with @dataclass(eq=False) decorator
- physDBD.helpers.normalize(vec: numpy.array) numpy.array
Normalize 1D np arr
- Args:
vec (np.array): 1D vec to normalize
- Returns:
np.array: normalized
physDBD.import_helper module
- class physDBD.import_helper.ImportHelper
Bases:
object
- static create_fnames(data_dir: str, no_seeds: int) List[str]
Create fnames for different seeds with zero padding 4
- Args:
data_dir (str): Data directory no_seeds (int): No seeds
- Returns:
List[str]: List of filenames
- static import_gillespie_ssa_at_time(fnames: List[str], time: float, species: List[str]) numpy.array
Import seeds from different files at a single time
- Args:
fnames (List[str]): The different files corresponding to the seeds time (float): Time (real time) species (List[str]): Species
- Raises:
ValueError: If species not found
- Returns:
np.array: Array of size (no_seeds, no_species)
- static import_gillespie_ssa_from_data_desc(data_desc: physDBD.data_desc.DataDesc, data_dir: str) numpy.array
Import Gillespie SSA data
- Args:
data_desc (DataDesc): Data description data_dir (str): Data directory
- Returns:
np.array: Numpy array of size (no_times, no_seeds, no_species)
- static import_gillespie_ssa_from_data_desc_at_time(data_desc: physDBD.data_desc.DataDesc, data_dir: str, time: float) numpy.array
Import Gillespie SSA data at a single timepoint
- Args:
data_desc (DataDesc): Data description data_dir (str): Data directory time (float): Time (real time)
- Returns:
np.array: Numpy array of size (no_seeds, no_species)
- static import_gillespie_ssa_whole_file(fnames: List[str], times: List[float], species: List[str]) numpy.array
Import Gillespie SSA whole file and extract multiple times for different seeds
- Args:
fnames (List[str]): List of files corresponding to different seeds times (List[float]): List of times (real time) to extract species (List[str]): Species
- Raises:
ValueError: If species not found
- Returns:
np.array: array of size (no_times, no_seeds, no_species)