cogwheel.gw_prior.extrinsic.UniformPhasePrior¶
- class cogwheel.gw_prior.extrinsic.UniformPhasePrior(*, tgps, ref_det_name, f_avg, par_dic_0=None, **kwargs)¶
Bases:
ReferenceDetectorMixin,UniformPriorMixin,UnitJacobianMixin,PriorUniform prior for the orbital phase.
The sampled variable phi_ref_hat differs from the standard coalescence phase phi_ref by an additive function of psi, iota, ra, dec, time, such that it describes the well-measured phase of the waveform at a reference detector. Note: for waveforms with higher modes the posterior will have a discontinuity when
angle(geometric_factor_refdet) = pi. However the folded posterior does not have this discontinuity.Methods
Antenna coefficients (F+, Fx) at the reference detector.
Sample the prior using rejection sampling.
Return the complex geometric factor
Return a list of parameter names that map to given "fast" standard parameters.
Return dictionary with keyword arguments to __init__.
Name of the module that defines the instance's class.
Return parameters accepted by the class constructor.
phi_ref to phi_ref_hat
Add columns in-place for self.sampled_params to samples.
Natural log Jacobian determinant of the inverse transform.
Natural logarithm of the prior probability density.
Return log prior and standard parameters.
Return a new instance of the class, possibly updating init_kwargs.
Log prior density in standard coordinates.
Time delay from Earth center to the reference detector.
Write class instance to json file.
phi_ref_hat to phi_ref.
Add columns in-place for self.standard_params to samples.
Return a function that unfolds its parameters and applies func to each unfolding.
Attributes
conditioned_onfolded_paramsfolded_reflected_paramsfolded_shifted_paramsMaximum log prior density, useful for rejection sampling.
periodic_paramsrange_dic3d location of the reference detector on Earth [meters].
reflective_paramssampled_paramsstandard_paramssubclass_registry- fplus_fcross_refdet(ra, dec, psi)¶
Antenna coefficients (F+, Fx) at the reference detector.
- generate_random_samples(n_samples, seed=None, return_lnz=False)¶
Sample the prior using rejection sampling.
This is more efficient for more uniform priors.
- Parameters:
- n_samplesint
How many samples to generate.
- seed
Passed to
numpy.default_rng, for reproducibility.
- Returns:
- samplespd.DataFrame
Columns are
.sampled_params + .standard_params, and rows are samples distributed according to the prior.- lnz, dlnzfloat, float
Log of the integral of the prior over the bounds, and estimate of the 1-sigma uncertainty. Only returned if return_lnz is set to
True. Useful for estimating the normalization constant of the prior. Note: This differs from the lnz that nested samplers (e.g. PyMultiNest or Nautilus) would compute, in that it has the phase-space volume differential applied. I.e. if lnprior == 0, lnz == log(prod(self.cubesize)) while nested samplers would return lnz == 0.
- geometric_factor_refdet(ra, dec, psi, iota)¶
Return the complex geometric factor
\[R = \frac{1+\cos^2 \iota}{2} F_{+} - i \cos \iota \ F_{\times}\]that relates a waveform with generic orientation to an overhead face-on one for quadrupolar waveforms. Note that the amplitude
|R|is between 0 and 1.
- classmethod get_fast_sampled_params(fast_standard_params)¶
Return a list of parameter names that map to given “fast” standard parameters.
Useful for sampling fast-slow parameters. Updating fast sampling parameters is guaranteed to only change fast standard parameters.
- get_init_dict(**kwargs)¶
Return dictionary with keyword arguments to __init__.
Only works if the class stores its init parameters as attributes with the same names. Otherwise, the subclass should override this method.
- Parameters:
- **kwargs
Allows to manually override some keys. The remaining ones will be read from the instance’s attributes. All keywords must be in the __init__ signature. It’s mostly here to facilitate overriding by subclasses.
- get_module_name()¶
Name of the module that defines the instance’s class.
- classmethod init_parameters(include_optional=True)¶
Return parameters accepted by the class constructor.
The parameters are sorted by parameter kind (i.e. positional arguments first, keyword arguments last). The self parameter is excluded.
- Parameters:
- include_optionalbool
Whether to include parameters with defaults in the returned list.
- Returns:
- list of
inspect.Parameterobjects
- list of
- inverse_transform(phi_ref, iota, ra, dec, psi, t_geocenter)¶
phi_ref to phi_ref_hat
- inverse_transform_samples(samples: DataFrame)¶
Add columns in-place for self.sampled_params to samples.
- Parameters:
- samplespandas.Dataframe
Must include columns for .standard_params and .conditioned_on.
- Raises:
- ValueError
If samples.index is not a simple range.
- ln_jacobian_determinant(*par_vals, **par_dic)¶
Natural log Jacobian determinant of the inverse transform.
Take
.standard_params + .conditioned_onparameters and return a float representinglog|∂{sampled_params} / ∂{standard_params}|
- lnprior(*par_vals, **par_dic)¶
Natural logarithm of the prior probability density.
- Parameters:
- *par_vals, **par_dic
.sampled_params + .conditioned_onparameters
- Returns:
- float
Natural logarithm of the prior probability density in the space of sampled parameters.
- lnprior_and_transform(*par_vals, **par_dic)¶
Return log prior and standard parameters.
The reason for this function is that for CombinedPrior it is already necessary to evaluate self.transform() in order to evaluate self.lnprior(). CombinedPrior overwrites this function so the user can get both lnprior and transform without evaluating transform twice.
- Returns:
- float
Log prior, output of .lnprior.
- dict
Standard parameters, output of .transform.
- property max_lnprior¶
Maximum log prior density, useful for rejection sampling.
- property ref_det_location¶
3d location of the reference detector on Earth [meters].
- reinstantiate(**new_init_kwargs)¶
Return a new instance of the class, possibly updating init_kwargs.
Values not passed will be taken from the current instance.
- standard_lnprior(**parameters)¶
Log prior density in standard coordinates.
- Parameters:
- **parameters
Values for
.standard_paramsand.conditioned_onparameters.
- time_delay_refdet(ra, dec)¶
Time delay from Earth center to the reference detector.
- to_json(dirname, basename=None, *, dir_permissions=493, file_permissions=420, overwrite=False)¶
Write class instance to json file.
It can then be loaded with read_json.
- transform(phi_ref_hat, iota, ra, dec, psi, t_geocenter)¶
phi_ref_hat to phi_ref.
- transform_samples(samples: DataFrame)¶
Add columns in-place for self.standard_params to samples.
- Parameters:
- samplespandas.Dataframe
Must include columns for .sampled_params and .conditioned_on.
- Raises:
- ValueError
If samples.index is not a simple range.
- unfold_apply(func, otypes=(<class 'float'>, ))¶
Return a function that unfolds its parameters and applies func to each unfolding.
The returned function returns a list of length 2**n_folds.
- Parameters:
- funccallable
A python function or method.
- otypesstr or list of dtypes
Output type, passed to
np.vectorize. You can passNoneto decide automatically, but then an extra function call will be made.
- Returns:
- callable
Unfolding function.