Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pycbc/inference/models/marginalized_gaussian_noise.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,19 +374,19 @@ class MarginalizedPolarization(DistMarg, BaseGaussianNoise):
marginalization over polarization angle. This is accomplished using
a fixed set of integration points distribution uniformation between
0 and 2pi. By default, 1000 integration points are used.
The 'polarization_samples' argument can be passed to set an alternate
The 'marginalize_vector_samples' argument can be passed to set an alternate
number of integration points.
"""
name = 'marginalized_polarization'

def __init__(self, variable_params, data, low_frequency_cutoff, psds=None,
high_frequency_cutoff=None, normalize=False,
polarization_samples=1000,
marginalize_vector_samples=1000,
**kwargs):

variable_params, kwargs = self.setup_marginalization(
variable_params,
polarization_samples=polarization_samples,
marginalize_vector_samples=marginalize_vector_samples,
**kwargs)

# set up the boiler-plate attributes
Expand Down
18 changes: 7 additions & 11 deletions pycbc/inference/models/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"""

import logging
import warnings
from distutils.util import strtobool

import numpy
Expand Down Expand Up @@ -63,6 +62,8 @@ def setup_marginalization(self,
marginalize_vector_params=None,
marginalize_vector_samples=1e3,
marginalize_sky_initial_samples=1e6,
marginalize_polarization=True,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See below

marginalize_polarization_samples=1e3,
**kwargs):
""" Setup the model for use with distance marginalization

Expand Down Expand Up @@ -96,7 +97,7 @@ def setup_marginalization(self,
-------
variable_params: list of strings
Set of variable params (missing distance-related parameter).
kwags: dict
kwargs: dict
The keyword arguments to the model initialization, may be modified
from the original set by this function.
"""
Expand Down Expand Up @@ -126,20 +127,15 @@ def pop_prior(param):
self.marginalize_sky_initial_samples = \
int(float(marginalize_sky_initial_samples))

if marginalize_polarization:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you want this section at all. The point was to just use the more general marginalize_vector setup. I think this change should just be removing options, not renaming them.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was added in as self.marginalize_vector_params must have 'polarization' as a key later. I'm happy to simply put this in as a no-if-statement thing if that is better?

pol_uniform = numpy.linspace(0, numpy.pi * 2.0, self.vsamples)
self.marginalize_vector_params['polarization'] = pol_uniform

for param in str_to_tuple(marginalize_vector_params, str):
logging.info('Marginalizing over %s, %s points from prior',
param, self.vsamples)
self.marginalized_vector_priors[param] = pop_prior(param)

# Remove in the future, backwards compatibility
if 'polarization_samples' in kwargs:
warnings.warn("use marginalize_vector_samples rather "
"than 'polarization_samples'", DeprecationWarning)
pol_uniform = numpy.linspace(0, numpy.pi * 2.0, self.vsamples)
self.marginalize_vector_params['polarization'] = pol_uniform
self.vsamples = int(kwargs['polarization_samples'])
kwargs.pop('polarization_samples')

self.reset_vector_params()

self.marginalize_phase = str_to_bool(marginalize_phase)
Expand Down
Loading