dingo.gw package
Subpackages
- dingo.gw.conversion package
- dingo.gw.data package
- dingo.gw.dataset package
- dingo.gw.domains package
- Submodules
- dingo.gw.domains.base module
- dingo.gw.domains.base_frequency_domain module
BaseFrequencyDomainBaseFrequencyDomain.add_phase()BaseFrequencyDomain.check_data_compatibility()BaseFrequencyDomain.delta_fBaseFrequencyDomain.f_minBaseFrequencyDomain.frequency_maskBaseFrequencyDomain.frequency_mask_lengthBaseFrequencyDomain.get_sample_frequencies_astype()BaseFrequencyDomain.noise_stdBaseFrequencyDomain.sample_frequenciesBaseFrequencyDomain.sample_frequencies_torchBaseFrequencyDomain.sample_frequencies_torch_cudaBaseFrequencyDomain.time_translate_data()
- dingo.gw.domains.build_domain module
- dingo.gw.domains.multibanded_frequency_domain module
MultibandedFrequencyDomainMultibandedFrequencyDomain.decimate()MultibandedFrequencyDomain.domain_dictMultibandedFrequencyDomain.durationMultibandedFrequencyDomain.f_maxMultibandedFrequencyDomain.f_minMultibandedFrequencyDomain.frequency_maskMultibandedFrequencyDomain.frequency_mask_lengthMultibandedFrequencyDomain.max_idxMultibandedFrequencyDomain.min_idxMultibandedFrequencyDomain.sample_frequenciesMultibandedFrequencyDomain.sampling_rateMultibandedFrequencyDomain.update()MultibandedFrequencyDomain.update_data()
decimate_uniform()
- dingo.gw.domains.time_domain module
- dingo.gw.domains.uniform_frequency_domain module
UniformFrequencyDomainUniformFrequencyDomain.delta_fUniformFrequencyDomain.domain_dictUniformFrequencyDomain.durationUniformFrequencyDomain.f_maxUniformFrequencyDomain.f_minUniformFrequencyDomain.frequency_maskUniformFrequencyDomain.frequency_mask_lengthUniformFrequencyDomain.get_sample_frequencies_astype()UniformFrequencyDomain.max_idxUniformFrequencyDomain.min_idxUniformFrequencyDomain.sample_frequenciesUniformFrequencyDomain.sampling_rateUniformFrequencyDomain.update()UniformFrequencyDomain.update_data()
- Module contents
- dingo.gw.importance_sampling package
- dingo.gw.inference package
- dingo.gw.noise package
- dingo.gw.training package
- dingo.gw.transforms package
- Submodules
- dingo.gw.transforms.detector_transforms module
- dingo.gw.transforms.general_transforms module
- dingo.gw.transforms.gnpe_transforms module
- dingo.gw.transforms.inference_transforms module
- dingo.gw.transforms.noise_transforms module
- dingo.gw.transforms.parameter_transforms module
- dingo.gw.transforms.utils module
- dingo.gw.transforms.waveform_transforms module
- Module contents
- dingo.gw.waveform_generator package
- Submodules
- dingo.gw.waveform_generator.frame_utils module
- dingo.gw.waveform_generator.waveform_generator module
NewInterfaceWaveformGeneratorNewInterfaceWaveformGenerator.domainNewInterfaceWaveformGenerator.generate_FD_modes_LO()NewInterfaceWaveformGenerator.generate_FD_waveform()NewInterfaceWaveformGenerator.generate_TD_modes_L0()NewInterfaceWaveformGenerator.generate_TD_modes_L0_conditioned_extra_time()NewInterfaceWaveformGenerator.generate_TD_waveform()NewInterfaceWaveformGenerator.generate_hplus_hcross_m()
SEOBNRv4PHM_maximum_starting_frequency()WaveformGeneratorWaveformGenerator.domainWaveformGenerator.full_domainWaveformGenerator.generate_FD_modes_LO()WaveformGenerator.generate_FD_waveform()WaveformGenerator.generate_TD_modes_L0()WaveformGenerator.generate_TD_waveform()WaveformGenerator.generate_hplus_hcross()WaveformGenerator.generate_hplus_hcross_m()WaveformGenerator.setup_mode_array()WaveformGenerator.spin_conversion_phase
generate_waveforms_parallel()generate_waveforms_task_func()sum_contributions_m()
- dingo.gw.waveform_generator.wfg_utils module
- Module contents
Submodules
dingo.gw.SVD module
- class dingo.gw.SVD.ApplySVD(svd_basis: SVDBasis, inverse: bool = False)
Bases:
objectTransform operator for applying an SVD compression / decompression.
- Parameters:
svd_basis (SVDBasis)
inverse (bool) – Whether to apply for the forward (compression) or inverse (decompression) transform. Default: False.
- class dingo.gw.SVD.SVDBasis(file_name=None, dictionary=None)
Bases:
DingoDatasetFor constructing, provide either file_name, or dictionary containing data and settings entries, or neither.
- Parameters:
file_name (str) – HDF5 file containing a dataset
dictionary (dict) – Contains settings and data entries. The data keys should be the same as save_keys
data_keys (list) – Variables that should be saved / loaded. This allows for class to store additional variables beyond those that are saved. Typically, this list would be provided by any subclass.
leave_on_disk_keys (Optional[list]) – Keys for which the values are not loaded into RAM when initializing the dataset. This reduces the memory footprint during training. Instead, the values are loaded from the HDF5 file during training.
- compress(data: ndarray)
Convert from data (e.g., frequency series) to compressed representation in terms of basis coefficients.
- Parameters:
data (np.ndarray)
- Return type:
array of basis coefficients
- compute_test_mismatches(data: ndarray, parameters: DataFrame | None = None, increment: int = 50, verbose: bool = False)
Test SVD basis by computing mismatches of compressed / decompressed data against original data. Results are saved as a DataFrame.
- Parameters:
data (np.ndarray) – Array of data sets to validate against.
parameters (pd.DataFrame) – Optional labels for the data sets. This is useful for checking performance on particular regions of the parameter space.
increment (int) – Specifies SVD truncations for computing mismatches. E.g., increment = 50 means that the SVD will be truncated at size [50, 100, 150, …, len(data)].
verbose (bool) – Whether to print summary statistics.
- dataset_type = 'svd_basis'
- decompress(coefficients: ndarray)
Convert from basis coefficients back to raw data representation.
- Parameters:
coefficients (np.ndarray) – Array of basis coefficients
- Return type:
array of decompressed data
- from_dictionary(dictionary: dict)
Load the SVD basis from a dictionary.
- Parameters:
dictionary (dict) – The dictionary should contain at least a ‘V’ key, and optionally an ‘s’ key.
- from_file(filename)
Load the SVD basis from a HDF5 file.
- Parameters:
filename (str)
- generate_basis(training_data: ndarray, n: int, method: str = 'scipy')
Generate the SVD basis from training data and store it.
The SVD decomposition takes
training_data = U @ diag(s) @ Vh
where U and Vh are unitary.
- Parameters:
training_data (np.ndarray) – Array of waveform data on the physical domain
n (int) – Number of basis elements to keep. n=0 keeps all basis elements.
method (str) – Select SVD method, ‘random’ or ‘scipy’
- print_validation_summary()
Print a summary of the validation mismatches.
dingo.gw.download_strain_data module
- dingo.gw.download_strain_data.download_event_data_in_FD(detectors, time_event, time_segment, time_buffer, window, num_segments_psd=128)
Download event data in frequency domain. This includes strain data for the event at GPS time t_event as well as the correcponding ASD.
- Parameters:
detectors (list) – list of detectors specified via strings
time_event (float) – GPS time of the event
time_segment (float) – length of the strain segment, in seconds
time_buffer (float) – specifies buffer time after time_event, in seconds
window (Union(np.ndarray, dict)) – Window used for Fourier transforming the event strain data. Either provided directly as np.ndarray, or as dict in which case the window is generated by window = dingo.gw.gwutils.get_window(**window).
num_segments_psd (int = 128) – number of segments used for PSD generation
- dingo.gw.download_strain_data.download_strain_data_in_FD(det, time_event, time_segment, time_buffer, window)
Download strain data for a GW event at GPS time time_event. The segment is time_segment seconds long, including time_buffer seconds after the event. The strain is Fourier transformed, the frequency domain strain is then time shifted by time_buffer, such that the event occurs at t=0.
- Parameters:
det (str) – detector
time_event (float) – GPS time of the event
time_segment (float) – length of the strain segment, in seconds
time_buffer (float) – specifies buffer time after time_event, in seconds
window (Union(np.ndarray, dict)) – Window used for Fourier transforming the event strain data. Either provided directly as np.ndarray, or as dict in which case the window is generated by window = dingo.gw.gwutils.get_window(**window).
- Returns:
event_strain – array with the frequency domain strain
- Return type:
np.array
- dingo.gw.download_strain_data.estimate_single_psd(time_start, time_segment, window, f_s=4096, num_segments: int = 128, det=None, channel=None)
Download strain data and generate a PSD based on these. Use num_segments of length time_segment, starting at GPS time time_start. If no channel is specified, GWOSC is used to download the data.
- Parameters:
time_start (float) – start GPS time for PSD estimation
time_segment (float) – time for a single segment for PSD information, in seconds
window (Union(np.ndarray, dict)) – Window used for PSD generation, needs to be the same as used for Fourier transform of event strain data. Either provided directly as np.ndarray, or as dict in which case the window is generated by window = dingo.gw.gwutils.get_window(**window).
num_segments (int = 256) – number of segments used for PSD generation
det (str) – If provided, will download data from GWOSC using TimeSeries.fetch_open_data(). Mutually exclusive with ‘channel’.
channel (str) – If provided, will download the data from the channel instead of gwosc using TimeSeries.get()
- Returns:
psd – array of psd
- Return type:
np.array
dingo.gw.gwutils module
- dingo.gw.gwutils.get_extrinsic_prior_dict(extrinsic_prior)
Build dict for extrinsic prior by starting with default_extrinsic_dict, and overwriting every element for which extrinsic_prior is not default. TODO: Move to dingo.gw.prior.py?
- dingo.gw.gwutils.get_mismatch(a, b, domain, asd_file=None)
Mistmatch is 1 - overlap, where overlap is defined by inner(a, b) / sqrt(inner(a, a) * inner(b, b)). See e.g. Eq. (44) in https://arxiv.org/pdf/1106.1021.pdf.
- Parameters:
a
b
domain
asd_file
- dingo.gw.gwutils.get_standardization_dict(extrinsic_prior_dict, wfd, selected_parameters, transform=None)
Calculates the mean and standard deviation of parameters. This is needed for standardizing neural-network input and output.
- Parameters:
extrinsic_prior_dict (dict)
wfd (WaveformDataset)
selected_parameters (list[str]) – List of parameters for which to estimate standardization factors.
transform (Transform) – Operator that will generate samples for parameters contained in selected_parameters that are not contained in the intrinsic or extrinsic prior. (E.g., H1_time, L1_time_proxy)
- dingo.gw.gwutils.get_window(window_kwargs)
Compute window from window_kwargs.
dingo.gw.injection module
- class dingo.gw.injection.GWSignal(wfg_kwargs: dict, wfg_domain: UniformFrequencyDomain | MultibandedFrequencyDomain, data_domain: UniformFrequencyDomain | MultibandedFrequencyDomain, ifo_list: list, t_ref: float)
Bases:
objectBase class for generating gravitational wave signals in interferometers. Generates waveform polarizations based on provided parameters, and then projects to detectors.
Includes option for whitening the signal based on a provided ASD.
- Parameters:
wfg_kwargs (dict) – Waveform generator parameters [approximant, f_ref, and (optionally) f_start].
wfg_domain (UniformFrequencyDomain | MultibandedFrequencyDomain) – Domain used for waveform generation. This can potentially deviate from the final domain, having a wider frequency range needed for waveform generation.
data_domain (UniformFrequencyDomain | MultibandedFrequencyDomain) – Domain object for final signal.
ifo_list (list) – Names of interferometers for projection.
t_ref (float) – Reference time that specifies ifo locations.
- property asd
Amplitude spectral density.
Either a single array, a dict (for individual interferometers), or an ASDDataset, from which random ASDs are drawn.
- property calibration_marginalization_kwargs
Dictionary with the following keys:
- calibration_envelope
Dictionary of the form {“H1”: filepath, “L1”: filepath, …} with locations of lookup tables for the calibration uncertainty curves.
- num_calibration_nodes
Number of nodes for the calibration model.
- num_calibration_curves
Number of calibration curves to use in marginalization.
- signal(theta)
Compute the GW signal for parameters theta.
Step 1: Generate polarizations Step 2: Project polarizations onto detectors; optionally (depending on self.whiten) whiten and scale.
- Parameters:
theta (dict) – Signal parameters. Includes intrinsic parameters to be passed to waveform generator, and extrinsic parameters for detector projection.
- Returns:
- keys:
waveform: GW strain signal for each detector. extrinsic_parameters: {} parameters: waveform parameters asd (if set): amplitude spectral density for each detector
- Return type:
dict
- signal_m(theta)
Compute the GW signal for parameters theta. Same as self.signal(theta) method, but it does not sum the contributions of the individual modes, and instead returns a dict {m: pol_m for m in [-l_max,…,0,…,l_max]} where each contribution pol_m transforms as exp(-1j * m * phase_shift) under phase shifts.
Step 1: Generate polarizations Step 2: Project polarizations onto detectors;
optionally (depending on self.whiten) whiten and scale.
- Parameters:
theta (dict) – Signal parameters. Includes intrinsic parameters to be passed to waveform generator, and extrinsic parameters for detector projection.
- Returns:
- keys:
- waveform:
GW strain signal for each detector, with individual contributions {m: pol_m for m in [-l_max,…,0,…,l_max]}
extrinsic_parameters: {} parameters: waveform parameters asd (if set): amplitude spectral density for each detector
- Return type:
dict
- property use_base_domain
- property whiten
Bool specifying whether to whiten (and scale) generated signals.
- class dingo.gw.injection.Injection(prior, **gwsignal_kwargs)
Bases:
GWSignalProduces injections of signals (with random or specified parameters) into stationary Gaussian noise. Output is not whitened.
- Parameters:
prior (PriorDict) – Prior used for sampling random parameters.
gwsignal_kwargs – Arguments to be passed to GWSignal base class.
- classmethod from_posterior_model_metadata(metadata)
Instantiate an Injection based on a posterior model. The prior, waveform settings, etc., will all be consistent with what the model was trained with.
- Parameters:
metadata (dict) – Dict which you can get via PosteriorModel.metadata
- injection(theta)
Generate an injection based on specified parameters.
This is a signal + noise consistent with the amplitude spectral density in self.asd. If self.asd is an ASDDataset, then it uses a random ASD from this dataset.
Data are not whitened.
- Parameters:
theta (dict) – Parameters used for injection.
- Returns:
- keys:
waveform: data (signal + noise) in each detector extrinsic_parameters: {} parameters: waveform parameters asd (if set): amplitude spectral density for each detector
- Return type:
dict
- random_injection()
Generate a random injection.
This is a signal + noise consistent with the amplitude spectral density in self.asd. If self.asd is an ASDDataset, then it uses a random ASD from this dataset.
Data are not whitened.
- Returns:
- keys:
waveform: data (signal + noise) in each detector extrinsic_parameters: {} parameters: waveform parameters asd (if set): amplitude spectral density for each detector
- Return type:
dict
dingo.gw.likelihood module
- class dingo.gw.likelihood.StationaryGaussianGWLikelihood(wfg_kwargs: dict, wfg_domain: Domain, data_domain: UniformFrequencyDomain | MultibandedFrequencyDomain, event_data: dict, t_ref: float | None = None, time_marginalization_kwargs: dict | None = None, phase_marginalization_kwargs: dict | None = None, calibration_marginalization_kwargs: dict | None = None, phase_grid=None, use_base_domain: bool = False, frequency_update: dict[str, float | dict[str, float | list[float]]] | None = None)
Bases:
GWSignal,LikelihoodImplements GW likelihood for stationary, Gaussian noise.
- Parameters:
wfg_kwargs (dict) – Waveform generator parameters (at least approximant and f_ref).
wfg_domain (dingo.gw.domains.Domain) – Domain used for waveform generation. This can potentially deviate from the final domain, having a wider frequency range needed for waveform generation.
data_domain (dingo.gw.domains.Domain) – Domain object for event data.
event_data (dict) – GW data. Contains strain data in event_data[“waveforms”] and asds in event_data[“asds”].
t_ref (float) – Reference time; true geocent time for GW is t_ref + theta[“geocent_time”].
time_marginalization_kwargs (dict) – Time marginalization parameters. If None, no time marginalization is used.
calibration_marginalization_kwargs (dict) – Calibration marginalization parameters. If None, no calibration marginalization is used.
phase_marginalization_kwargs (dict) – Phase marginalization parameters. If None, no phase marginalization is used.
use_base_domain (bool (default False)) – When the domain is a MultibandedFrequencyDomain, whether to use the associated base UniformFrequencyDomain for likelihood computations.
frequency_update (dict) –
Specifies settings for updating the frequency range example: {‘minimum_frequency’: {‘H1’: 30., ‘L1’: 20.},
maximum_frequency: 1024.}
- d_inner_h_complex(theta)
Calculate the complex inner product (d | h(theta)) between the stored data d and a simulated waveform with given parameters theta.
- Parameters:
theta (dict) – Parameters at which to evaluate h.
- Returns:
complex
- Return type:
Inner product
- d_inner_h_complex_multi(theta: DataFrame, num_processes: int = 1) ndarray
Calculate the complex inner product (d | h(theta)) between the stored data d and a simulated waveform with given parameters theta. Works with multiprocessing.
- Parameters:
theta (pd.DataFrame) – Parameters at which to evaluate h.
num_processes (int) – Number of parallel processes to use.
- Returns:
complex
- Return type:
Inner product
- initialize_time_marginalization(t_lower, t_upper, n_fft=1)
Initialize time marginalization. Time marginalization can be performed via FFT, which is super fast. However, this limits the time resolution to delta_t = 1/self.data_domain.f_max. In order to allow for a finer time resolution we compute the time marginalized likelihood n_fft via FFT on a grid of n_fft different time shifts [0, delta_t, 2*delta_t, …, (n_fft-1)*delta_t] and average over the time shifts. The effective time resolution is thus
delta_t_eff = delta_t / n_fft = 1 / (f_max * n_fft).
Note: Time marginalization in only implemented for uniform time priors.
- Parameters:
t_lower (float) – Lower time bound of the uniform time prior.
t_upper (float) – Upper time bound of the uniform time prior.
n_fft (int = 1) – Size of grid for FFT for time marginalization.
- log_likelihood(theta)
- log_likelihood_phase_grid(theta: dict, phases: ndarray | None = None) ndarray
- dingo.gw.likelihood.build_stationary_gaussian_likelihood(metadata, event_dataset=None, time_marginalization_kwargs=None)
Build a StationaryGaussianLikelihoodBBH object from the metadata.
- Parameters:
metadata (dict) – Metadata from stored dingo parameter samples file. Typially accessed via pd.read_pickle(/path/to/dingo-output.pkl).metadata.
event_dataset (str = None) – Path to event dataset for caching. If None, don’t cache.
time_marginalization_kwargs (dict = None) – Forwarded to the likelihood.
- Returns:
likelihood – likelihood object
- Return type:
- dingo.gw.likelihood.get_wfg(wfg_kwargs, data_domain, frequency_range=None)
Set up waveform generator from wfg_kwargs. The domain of the wfg is primarily determined by the data domain, but a new (larger) frequency range can be specified if this is necessary for the waveforms to be generated successfully (e.g., for EOB waveforms which require a sufficiently small f_min and sufficiently large f_max).
- Parameters:
wfg_kwargs (dict) – Waveform generator parameters.
data_domain (dingo.gw.domains.Domain) – Domain of event data, with bounds determined by likelihood integral.
frequency_range (dict = None) –
Frequency range for waveform generator. If None, that of data domain is used, which corresponds to the bounds of the likelihood integral. Possible keys:
- ’f_start’: float
Frequency at which to start the waveform generation. Overrides f_start in metadata[“model”][“dataset_settings”][“waveform_generator”].
- ’f_end’: float
Frequency at which to start the waveform generation.
- Returns:
wfg – Waveform generator object.
- Return type:
- dingo.gw.likelihood.inner_product(a, b, min_idx=0, delta_f=None, psd=None)
Compute the inner product between two complex arrays. There are two modes: either, the data a and b are not whitened, in which case delta_f and the psd must be provided. Alternatively, if delta_f and psd are not provided, the data a and b are assumed to be whitened already (i.e., whitened as d -> d * sqrt(4 delta_f / psd)).
Note: sum is only taken along axis 0 (which is assumed to be the frequency axis), while other axes are preserved. This is e.g. useful when evaluating kappa2 on a phase grid.
- Parameters:
a (np.ndaarray) – First array with frequency domain data.
b (np.ndaarray) – Second array with frequency domain data.
min_idx (int = 0) – Truncation of likelihood integral, index of lowest frequency bin to consider.
delta_f (float) – Frequency resolution of the data. If None, a and b are assumed to be whitened and the inner product is computed without further whitening.
psd (np.ndarray = None) – PSD of the data. If None, a and b are assumed to be whitened and the inner product is computed without further whitening.
- Returns:
inner_product
- Return type:
float
- dingo.gw.likelihood.inner_product_complex(a, b, min_idx=0, delta_f=None, psd=None)
Same as inner product, but without taking the real part. Retaining phase information is useful for the phase-marginalized likelihood. For further documentation see inner_product function.
- dingo.gw.likelihood.main()
dingo.gw.ls_cli module
- dingo.gw.ls_cli.determine_dataset_type(file_name)
- dingo.gw.ls_cli.ls()
dingo.gw.prior module
- class dingo.gw.prior.BBHExtrinsicPriorDict(dictionary=None, filename=None, aligned_spin=False, conversion_function=None)
Bases:
BBHPriorDictThis class is the same as BBHPriorDict except that it does not require mass parameters.
It also contains a method for estimating the standardization parameters.
- TODO:
Add support for zenith/azimuth
Defaults?
Initialises a Prior set for Binary Black holes
- Parameters:
dictionary (dict, optional) – See superclass
filename (str, optional) – See superclass
conversion_function (func) – Function to convert between sampled parameters and constraints. By default this generates many additional parameters, see BBHPriorDict.default_conversion_function
- default_conversion_function(sample)
Default parameter conversion function for BBH signals.
This generates: - the parameters passed to source.lal_binary_black_hole - all mass parameters
It does not generate: - component spins - source-frame parameters
- Parameters:
sample (dict) – Dictionary to convert
- Returns:
sample – Same as input
- Return type:
dict
- mean_std(keys=[], sample_size=50000, force_numerical=False)
Calculate the mean and standard deviation over the prior.
- Parameters:
keys (list(str)) – A list of desired parameter names
sample_size (int) – For nonanalytic priors, number of samples to use to estimate the result.
force_numerical (bool (False)) – Whether to force a numerical estimation of result, even when analytic results are available (useful for testing)
deviations. (Returns dictionaries for the means and standard)
TODO (Fix for constrained priors. Shouldn't be an issue for extrinsic parameters.)
- dingo.gw.prior.build_prior_with_defaults(prior_settings: Dict[str, str])
Generate BBHPriorDict based on dictionary of prior settings, allowing for default values.
- Parameters:
prior_settings (Dict) –
A dictionary containing prior definitions for intrinsic parameters Allowed values for each parameter are:
’default’ to use a default prior
- a string for a custom prior, e.g.,
”Uniform(minimum=10.0, maximum=80.0, name=None, latex_label=None, unit=None, boundary=None)”
a (Depending on the particular prior choices the dimensionality of)
vary. (parameter sample obtained from the returned GWPriorDict will)
- dingo.gw.prior.split_off_extrinsic_parameters(theta)
Split theta into intrinsic and extrinsic parameters.
- Parameters:
theta (dict) – BBH parameters. Includes intrinsic parameters to be passed to waveform generator, and extrinsic parameters for detector projection.
- Returns:
theta_intrinsic (dict) – BBH intrinsic parameters.
theta_extrinsic (dict) – BBH extrinsic parameters (includes calibration parameters).
dingo.gw.result module
- class dingo.gw.result.Result(**kwargs)
Bases:
ResultA dataset class to hold a collection of gravitational-wave parameter samples and perform various operations on them.
Compared to the base class, this class implements the domain, prior, and likelihood. It also includes a method for sampling the binary reference phase parameter based on the other parameters and the likelihood.
- Attributes:
- samplespd.Dataframe
Contains parameter samples, as well as (possibly) log_prob, log_likelihood, weights, log_prior, delta_log_prob_target.
- domainDomain
The domain of the data (e.g., UniformFrequencyDomain), needed for calculating likelihoods.
- priorPriorDict
The prior distribution, used for importance sampling.
- likelihoodLikelihood
The Likelihood object, needed for importance sampling.
- contextdict
Context data from which the samples were produced (e.g., strain data, ASDs).
- metadatadict
Metadata inherited from the Sampler object. This describes the neural networks and sampling settings used.
- event_metadatadict
Metadata for the event analyzed, including time, data conditioning, channel, and detector information.
- log_evidencefloat
Calculated log(evidence) after importance sampling.
- log_evidence_stdfloat (property)
Standard deviation of the log(evidence)
- effective_sample_size, n_efffloat (property)
Number of effective samples, (sum_i w_i)^2 / sum_i w_i^2
- sample_efficiencyfloat (property)
Number of effective samples / Number of samples
- synthetic_phase_kwargsdict
kwargs describing the synthetic phase sampling.
For constructing, provide either file_name, or dictionary containing data and settings entries, or neither.
- Parameters:
file_name (str) – HDF5 file containing a dataset
dictionary (dict) – Contains settings and data entries. The data keys should be the same as save_keys
data_keys (list) – Variables that should be saved / loaded. This allows for class to store additional variables beyond those that are saved. Typically, this list would be provided by any subclass.
leave_on_disk_keys (Optional[list]) – Keys for which the values are not loaded into RAM when initializing the dataset. This reduces the memory footprint during training. Instead, the values are loaded from the HDF5 file during training.
- property approximant
- property calibration_marginalization_kwargs
- property calibration_sampling_kwargs
- dataset_type = 'gw_result'
- property f_ref
- get_pesummary_samples(num_processes=1, resampling_method='clip+rejection')
Samples in a form suitable for PESummary.
These samples are adjusted to undo certain conventions used internally by Dingo:
Times are corrected by the reference time t_ref.
Samples are unweighted, using a fixed random seed for sampling importance
resampling. * The spin angles phi_jl and theta_jn are transformed to account for a difference in phase definition. * Some columns are dropped: delta_log_prob_target, log_prob
- Parameters:
num_processes (int) – Number of processes for spin conversion.
resampling_method (str) – Method for producing unweighted samples from weighted ones. ‘clip+rejection’: clip extreme weights then rejection sample (default). ‘sir’: sampling importance resampling (old behavior).
- get_samples_bilby_phase(num_processes=1)
Convert the spin angles phi_jl and theta_jn to account for a difference in phase definition compared to Bilby.
- Parameters:
num_processes (int) – Number of parallel processes.
- Returns:
Samples
- Return type:
pd.DataFrame
- property interferometers
- property maximum_frequency: dict[str, float] | float
- property minimum_frequency: dict[str, float] | float
- property pesummary_prior
The prior in a form suitable for PESummary.
By convention, Dingo stores all times relative to a reference time, typically the trigger time for an event. The prior returned here corrects for that offset to be consistent with other codes.
- property phase_marginalization_kwargs
- sample_calibration_parameters(calibration_sampling_kwargs: dict)
Sample calibration parameters from the calibration prior and add them to the samples DataFrame. Also updates self.prior with the calibration priors and adjusts self.samples[“log_prob”] accordingly.
This should be called before importance_sample() when importance sampling over calibration uncertainty. The calibration prior log_prob is added to self.samples[“log_prob”] so that it is properly accounted for in the importance sampling weights.
After calling this method, each sample will have calibration parameters (e.g., recalib_H1_amplitude_0, recalib_H1_phase_0, etc.) that will be used by the likelihood to apply calibration corrections.
- Parameters:
calibration_sampling_kwargs (dict) –
Calibration sampling parameters. Keys:
- calibration_envelopedict
Dictionary of the form {“H1”: filepath, “L1”: filepath, …} with locations of calibration envelope files (.txt).
- num_calibration_nodesint
Number of log-spaced frequency nodes for the calibration spline model.
- correction_typestr or dict or None, default “data”
Whether envelopes are over eta (“data”) or alpha (“template”). Can be a string (applied to all detectors), a dict mapping ifo names to correction types, or None (uses defaults from CALIBRATION_CORRECTION_TYPE_LOOKUP).
- sample_synthetic_phase(synthetic_phase_kwargs, inverse: bool = False)
Sample a synthetic phase for the waveform. This is a post-processing step applicable to samples theta in the full parameter space, except for the phase parameter (i.e., 14D samples). This step adds a phase parameter to the samples based on likelihood evaluations.
A synthetic phase is sampled as follows.
Compute and cache the modes for the waveform mu(theta, phase=0) for phase 0, organize them such that each contribution m transforms as exp(-i * m * phase).
Compute the likelihood on a phase grid, by computing mu(theta, phase) from the cached modes. In principle this likelihood is exact, however, it can deviate slightly from the likelihood computed without cached modes for various technical reasons (e.g., slightly different windowing of cached modes compared to full waveform when transforming TD waveform to FD). These small deviations can be fully accounted for by importance sampling. Note: when approximation_22_mode=True, the entire waveform is assumed to transform as exp(2i*phase), in which case the likelihood is only exact if the waveform is fully dominated by the (2, 2) mode.
Build a synthetic conditional phase distribution based on this grid. We use an interpolated prior distribution bilby.core.prior.Interped, such that we can sample and also evaluate the log_prob. We add a constant background with weight self.synthetic_phase_kwargs to the kde to make sure that we keep a mass-covering property. With this, the importance sampling will yield exact results even when the synthetic phase conditional is just an approximation.
Besides adding phase samples to self.samples[‘phase’], this method also modifies self.samples[‘log_prob’] by adding the log_prob of the synthetic phase conditional.
This method modifies self.samples in place.
- Parameters:
synthetic_phase_kwargs (dict) –
- This should consist of the kwargs
approximation_22_mode (optional) num_processes (optional) n_grid uniform_weight (optional)
inverse (bool, default False) – Whether to apply instead the inverse transformation. This is used prior to calculating the log_prob. In inverse mode, the posterior probability over phase is calculated for given samples. It is stored in self.samples[ ‘log_prob’].
- property synthetic_phase_kwargs
- property t_ref
- property time_marginalization_kwargs
- update_prior(prior_update)
Update the prior based on a new dict of priors. Use the existing prior for parameters not included in the new dict.
If class samples have not been importance sampled, then save new sample weights based on the new prior. If class samples have been importance sampled, then update the weights.
- Parameters:
prior_update (dict) – Priors to update. This should be of the form {key : prior_str}, where str is a string that can instantiate a prior via PriorDict(prior_update). The prior_update is provided in this form so that it can be properly saved with the Result and later instantiated.
- property use_base_domain: bool
dingo.gw.temporary_debug_utils module
- dingo.gw.temporary_debug_utils.save_training_injection(outname, pm, data, idx=0)
For debugging: extract a training injection. To be used inside train or test loop.