diffbank.bank.Bank#
- class diffbank.bank.Bank(amp, Psi, fs, Sn, m_star, eta, sample_base, density_fun_base=<function Bank.<lambda>>, name='test')[source]#
Bases:
objectClass representing a template bank.
- calc_bank_effectualness(key, n, show_progress=True)[source]#
Computes effectualness of bank at points sampled from the metric density. See
diffbank.utils.get_bank_effectualness().- Raises
RuntimeError – if the bank does not contain templates
- computed_vars: Set[str] = {'_dim', '_eff_pad_high', '_eff_pad_low', 'effectualness_points', 'effectualnesses', 'eta_est', 'eta_est_err', 'n_templates', 'ratio_max', 'templates'}[source]#
The names of attributes that are computed in the course of working with a bank. For example, this includes
"templates".
- density_fun(theta)[source]#
Computes the determinant of the metric over the intrinsic of the binary, maximized over the time and phase at coalescence. See
diffbank.metric.get_density().- Return type
ndarray
- est_ratio_max(key, n_iter=1000, n_init=200, show_progress=True)[source]#
Estimate maximum of the ratio of target to base density using empirical supremum rejection sampling. See
diffbank.utils.est_ratio_max().- Return type
Tuple[ndarray,ndarray]
- fill_bank(key, method='random', n_eff=1000, show_progress=True)[source]#
Fills the bank with the required number of templates using the random or stochastic sampling methods from Coogan et al 2022. Updates the
templatesandn_templatesattributes. Seediffbank.utils.gen_bank_random()anddiffbank.utils.gen_bank_stochastic().- Raises
RuntimeError – if
ratio_maxis not set
- g_fun(theta)[source]#
Computes the metric for the intrinsic binary parameters of the binary, maximized over the time and phase at coalescence. See
diffbank.metric.get_density().- Return type
ndarray
- gam_fun(theta)[source]#
Computes the metric for the time of coalescence and intrinsic parameters of the binary. See
diffbank.metric.get_gam().- Return type
ndarray
- gen_template_rejection(key)[source]#
Generates a single template using rejection sampling. See
diffbank.utils.gen_template_rejection().- Raises
RuntimeError – if
ratio_maxis not set- Return type
ndarray
- gen_templates_rejection(key, n_templates)[source]#
Generates multiple templates using rejection sampling. See
diffbank.utils.gen_template_rejection().- Raises
RuntimeError – if
ratio_maxis not set- Return type
ndarray
- get_top_matches_templates(theta2s, amp2=None, Psi2=None, n_top=1, show_progress=True)[source]#
Finds best-matching templates for a set of points for a waveform model distinct from the bank’s. See
diffbank.utils.get_top_matches_templates().- Raises
RuntimeError – if the bank does not contain templates
- Return type
Tuple[ndarray,ndarray]
- classmethod load(path, amp, Psi, Sn, sample_base, ignore_key_errors=False)[source]#
Loads template bank’s non-function attributes from a
npzfile. The other required attributes must be provided as arguments to this function.- Parameters
path (
str) – path tonpzfile generated withBank.saveamp (
Callable[[ndarray,ndarray],ndarray]) – function returning the amplitude of the Fourier-domain waveform as a function of frequency and parametersPsi (
Callable[[ndarray,ndarray],ndarray]) – function returning the phase of the Fourier-domain waveform as a function of frequency and parametersSn (
Callable[[ndarray],ndarray]) – power spectral density of the detector noisesample_base (
Callable[[PRNGKeyArray,int],ndarray]) –jit-able base sampler for rejection sampling from the metric density. Takes a key and number of samples as arguments.ignore_key_errors (
bool) – ifTrue, will try to load the bank even if there are extra or missing keys in thenpzfile.
- Raises
ValueError – if the bank being loaded is missing or contains extra keys, and
ignore_key_errorsisFalse. This should only happen when trying to load old banks afterdiffbankgoes through major updates.- Returns
A new
Bank
- match_fun(theta1, theta2, amp2=None, Psi2=None)[source]#
Gets the match between a point from the bank’s waveform model and a different point, potentially with a distinct waveform model. See
diffbank.utils.get_match().- Parameters
theta1 (
ndarray) – the point from the same waveform model as the banktheta2 (
ndarray) – the other pointamp2 (
Optional[Callable[[ndarray,ndarray],ndarray]]) – amplitude function for thetheta2. If not provided, it is assumedtheta2has the same waveform model as the bank.Psi2 (
Optional[Callable[[ndarray,ndarray],ndarray]]) – phase function for thetheta2. If not provided, it is assumedtheta2has the same waveform model as the bank.
- Return type
ndarray- Returns
The match between the waveforms for the two points.