Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • john-veitch/bilby
  • duncanmmacleod/bilby
  • colm.talbot/bilby
  • lscsoft/bilby
  • matthew-pitkin/bilby
  • salvatore-vitale/tupak
  • charlie.hoy/bilby
  • bfarr/bilby
  • virginia.demilio/bilby
  • vivien/bilby
  • eric-howell/bilby
  • sebastian-khan/bilby
  • rhys.green/bilby
  • moritz.huebner/bilby
  • joseph.mills/bilby
  • scott.coughlin/bilby
  • matthew.carney/bilby
  • hyungwon.lee/bilby
  • monica.rizzo/bilby
  • christopher-berry/bilby
  • lindsay.demarchi/bilby
  • kaushik.rao/bilby
  • charles.kimball/bilby
  • andrew.matas/bilby
  • juan.calderonbustillo/bilby
  • patrick-meyers/bilby
  • hannah.middleton/bilby
  • eve.chase/bilby
  • grant.meadors/bilby
  • khun.phukon/bilby
  • sumeet.kulkarni/bilby
  • daniel.reardon/bilby
  • cjhaster/bilby
  • sylvia.biscoveanu/bilby
  • james-clark/bilby
  • meg.millhouse/bilby
  • joshua.willis/bilby
  • nikhil.sarin/bilby
  • paul.easter/bilby
  • youngmin/bilby
  • daniel-williams/bilby
  • shanika.galaudage/bilby
  • bruce.edelman/bilby
  • avi.vajpeyi/bilby
  • isobel.romero-shaw/bilby
  • andrew.kim/bilby
  • dominika.zieba/bilby
  • jonathan.davies/bilby
  • marc.arene/bilby
  • srishti.tiwari/bilby-tidal-heating-eccentric
  • aditya.vijaykumar/bilby
  • michael.williams/bilby
  • cecilio.garcia-quiros/bilby
  • rory-smith/bilby
  • maite.mateu-lucena/bilby
  • wushichao/bilby
  • kaylee.desoto/bilby
  • brandon.piotrzkowski/bilby
  • rossella.gamba/bilby
  • hunter.gabbard/bilby
  • deep.chatterjee/bilby
  • tathagata.ghosh/bilby
  • arunava.mukherjee/bilby
  • philip.relton/bilby
  • reed.essick/bilby
  • pawan.gupta/bilby
  • francisco.hernandez/bilby
  • rhiannon.udall/bilby
  • leo.tsukada/bilby
  • will-farr/bilby
  • vijay.varma/bilby
  • jeremy.baier/bilby
  • joshua.brandt/bilby
  • ethan.payne/bilby
  • ka-lok.lo/bilby
  • antoni.ramos-buades/bilby
  • oliviastephany.wilk/bilby
  • jack.heinzel/bilby
  • samson.leong/bilby-psi4
  • viviana.caceres/bilby
  • nadia.qutob/bilby
  • michael-coughlin/bilby
  • hemantakumar.phurailatpam/bilby
  • boris.goncharov/bilby
  • sama.al-shammari/bilby
  • siqi.zhong/bilby
  • jocelyn-read/bilby
  • marc.penuliar/bilby
  • stephanie.letourneau/bilby
  • alexandresebastien.goettel/bilby
  • alec.gunny/bilby
  • serguei.ossokine/bilby
  • pratyusava.baral/bilby
  • sophie.hourihane/bilby
  • eunsub/bilby
  • james.hart/bilby
  • pratyusava.baral/bilby-tg
  • zhaozc/bilby
  • pratyusava.baral/bilby_SoG
  • tomasz.baka/bilby
  • nicogerardo.bers/bilby
  • soumen.roy/bilby
  • isaac.mcmahon/healpix-redundancy
  • asamakai.baker/bilby-frequency-dependent-antenna-pattern-functions
  • anna.puecher/bilby
  • pratyusava.baral/bilby-x-g
  • thibeau.wouters/bilby
  • christian.adamcewicz/bilby
  • raffi.enficiaud/bilby
109 results
Show changes
Commits on Source (35)
Showing
with 152 additions and 66 deletions
......@@ -75,6 +75,10 @@ basic-3.10:
<<: *test-python
image: python:3.10
basic-3.11:
<<: *test-python
image: python:3.11
.test-samplers-import: &test-samplers-import
stage: initial
script:
......@@ -90,6 +94,10 @@ import-samplers-3.10:
<<: *test-samplers-import
image: containers.ligo.org/lscsoft/bilby/v2-bilby-python310
import-samplers-3.11:
<<: *test-samplers-import
image: containers.ligo.org/lscsoft/bilby/v2-bilby-python311
.precommits: &precommits
stage: initial
script:
......@@ -98,17 +106,9 @@ import-samplers-3.10:
- pip install --upgrade pip
- pip --cache-dir=$CACHE_DIR install --upgrade bilby
- pip --cache-dir=$CACHE_DIR install .
- pip --cache-dir=$CACHE_DIR install pre-commit
# Run precommits (flake8, spellcheck, isort, no merge conflicts, etc)
- pre-commit run --all-files --verbose --show-diff-on-failure
precommits-py3.9:
<<: *precommits
image: containers.ligo.org/lscsoft/bilby/v2-bilby-python39
variables:
CACHE_DIR: ".pip39"
PYVERSION: "python39"
precommits-py3.10:
<<: *precommits
image: containers.ligo.org/lscsoft/bilby/v2-bilby-python310
......@@ -137,7 +137,7 @@ install:
python-3.9:
<<: *unit-test
needs: ["basic-3.9", "precommits-py3.9"]
needs: ["basic-3.9"]
image: containers.ligo.org/lscsoft/bilby/v2-bilby-python39
python-3.10:
......@@ -157,6 +157,11 @@ python-3.10:
- htmlcov/
expire_in: 30 days
python-3.11:
<<: *unit-test
needs: ["basic-3.11"]
image: containers.ligo.org/lscsoft/bilby/v2-bilby-python311
.test-sampler: &test-sampler
stage: test
script:
......@@ -166,7 +171,7 @@ python-3.10:
python-3.9-samplers:
<<: *test-sampler
needs: ["basic-3.9", "precommits-py3.9"]
needs: ["basic-3.9"]
image: containers.ligo.org/lscsoft/bilby/v2-bilby-python39
python-3.10-samplers:
......@@ -174,6 +179,11 @@ python-3.10-samplers:
needs: ["basic-3.10", "precommits-py3.10"]
image: containers.ligo.org/lscsoft/bilby/v2-bilby-python310
python-3.11-samplers:
<<: *test-sampler
needs: ["basic-3.11"]
image: containers.ligo.org/lscsoft/bilby/v2-bilby-python311
integration-tests-python-3.10:
stage: test
image: containers.ligo.org/lscsoft/bilby/v2-bilby-python310
......@@ -198,21 +208,24 @@ integration-tests-python-3.10:
plotting-python-3.9:
<<: *plotting
image: containers.ligo.org/lscsoft/bilby/v2-bilby-python39
needs: ["basic-3.9", "precommits-py3.9"]
needs: ["basic-3.9"]
plotting-python-3.10:
<<: *plotting
image: containers.ligo.org/lscsoft/bilby/v2-bilby-python310
needs: ["basic-3.10", "precommits-py3.10"]
plotting-python-3.11:
<<: *plotting
image: containers.ligo.org/lscsoft/bilby/v2-bilby-python311
needs: ["basic-3.11"]
# ------------------- Docs stage -------------------------------------------
docs:
stage: docs
image: containers.ligo.org/lscsoft/bilby/v2-bilby-python310
before_script:
- conda install -c conda-forge pandoc ipython jupyter nbconvert
- python -m pip install ipykernel
- python -m ipykernel install
script:
# Make the documentation
......@@ -258,7 +271,8 @@ pages:
script:
- cd containers
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker build --tag v3-bilby-$PYVERSION - < v3-dockerfile-test-suite-$PYVERSION
- cp v3-dockerfile-test-suite-$PYVERSION Dockerfile
- docker build --tag v3-bilby-$PYVERSION .
- docker image tag v3-bilby-$PYVERSION containers.ligo.org/lscsoft/bilby/v2-bilby-$PYVERSION:latest
- docker image push containers.ligo.org/lscsoft/bilby/v2-bilby-$PYVERSION:latest
......@@ -272,6 +286,11 @@ build-python310-container:
variables:
PYVERSION: "python310"
build-python311-container:
<<: *build-container
variables:
PYVERSION: "python311"
pypi-release:
stage: deploy
image: containers.ligo.org/lscsoft/bilby/v2-bilby-python310
......@@ -279,7 +298,6 @@ pypi-release:
TWINE_USERNAME: $PYPI_USERNAME
TWINE_PASSWORD: $PYPI_PASSWORD
before_script:
- python -m pip install twine setuptools_scm build
- python -m build --sdist --wheel --outdir dist/ .
script:
- twine upload dist/*
......
......@@ -57,6 +57,7 @@ Michael Puerrer
Michael Williams
Monica Rizzo
Moritz Huebner
Nico Gerardo Bers
Nicola De Lillo
Nikhil Sarin
Nirban Bose
......@@ -72,6 +73,7 @@ Roberto Cotesta
Rory Smith
S. H. Oh
Sacha Husa
Samson Leong
Scott Coughlin
Serguei Ossokine
Shanika Galaudage
......@@ -79,6 +81,7 @@ Sharan Banagiri
Shichao Wu
Simon Stevenson
Soichiro Morisaki
Soumen Roy
Stephen R Green
Sumeet Kulkarni
Sylvia Biscoveanu
......@@ -94,3 +97,4 @@ Marc Penuliar
Andrew Fowlie
Martin White
Peter Tsun-Ho Pang
Alexandre Sebastien Goettel
# All notable changes will be documented in this file
## [2.2.3] 2024-02-24
Version 2.2.3 release of Bilby
This is a bugfix release
There are also a number of testing/infrastructure updates.
### Changes
- Fix a bug when the specified maximum frequency is too low for the multibanding likelihood (!1279)
- Allow the `DirichletElement` prior to be pickled (!1312)
- Add the ability to change the pool size when resuming a `dynesty` job (!1315)
- Fix how the random seed is passed to `dynesty` (!1319)
## [2.2.2] 2023-11-29
Version 2.2.2 release of Bilby
This is a bugfix release reverting a change from 2.2.1
### Changes
- Revert !1284 (!1306)
## [2.2.1] 2023-1111
Version 2.2.1 release of Bilby
This release is a bugfix release.
### Changes
- Ensure inteferometer metadata is not empty (!1281)
- Make interrupted pools exit more quickly (!1284)
- Fix conditional sampling with DeltaFunction conditions (!1289)
- The triangular prior raised an error with numpy (!1294)
- Make sure strain data resampling works (!1295)
- Dynesty logging (!1296)
- A bug with saving lists that contain None (!1301)
- Preparatory fix an upcoming change in dynesty (!1302)
## [2.2.0] 2023-07-24
Version 2.2.0 release of Bilby
......
import torch
from nflows.distributions.normal import StandardNormal
from nflows.flows.base import Flow
from nflows.nn import nets as nets
from nflows.transforms import (
from glasflow.nflows.distributions.normal import StandardNormal
from glasflow.nflows.flows.base import Flow
from glasflow.nflows.nn import nets as nets
from glasflow.nflows.transforms import (
CompositeTransform,
MaskedAffineAutoregressiveTransform,
RandomPermutation,
)
from nflows.transforms.coupling import (
from glasflow.nflows.transforms.coupling import (
AdditiveCouplingTransform,
AffineCouplingTransform,
)
from nflows.transforms.normalization import BatchNorm
from glasflow.nflows.transforms.normalization import BatchNorm
from torch.nn import functional as F
# Turn off parallelism
......
......@@ -754,10 +754,10 @@ class NormalizingFlowProposal(DensityEstimateProposal):
@staticmethod
def check_dependencies(warn=True):
if importlib.util.find_spec("nflows") is None:
if importlib.util.find_spec("glasflow") is None:
if warn:
logger.warning(
"Unable to utilise NormalizingFlowProposal as nflows is not installed"
"Unable to utilise NormalizingFlowProposal as glasflow is not installed"
)
return False
else:
......
......@@ -28,6 +28,7 @@ class DeltaFunction(Prior):
minimum=peak, maximum=peak, check_range_nonzero=False)
self.peak = peak
self._is_fixed = True
self.least_recently_sampled = peak
def rescale(self, val):
"""Rescale everything to the peak with the correct shape.
......@@ -1608,7 +1609,7 @@ class Triangular(Prior):
"""
return (
+ (val > self.mode)
(val > self.mode)
+ (val > self.minimum)
* (val <= self.maximum)
/ (self.scale)
......
......@@ -168,14 +168,14 @@ class Prior(object):
def cdf(self, val):
""" Generic method to calculate CDF, can be overwritten in subclass """
from scipy.integrate import cumtrapz
from scipy.integrate import cumulative_trapezoid
if np.any(np.isinf([self.minimum, self.maximum])):
raise ValueError(
"Unable to use the generic CDF calculation for priors with"
"infinite support")
x = np.linspace(self.minimum, self.maximum, 1000)
pdf = self.prob(x)
cdf = cumtrapz(pdf, x, initial=0)
cdf = cumulative_trapezoid(pdf, x, initial=0)
interp = interp1d(x, cdf, assume_sorted=True, bounds_error=False,
fill_value=(0, 1))
return interp(val)
......
......@@ -372,6 +372,7 @@ class DirichletElement(ConditionalBeta):
label + str(ii) for ii in range(order)
]
self.__class__.__name__ = 'DirichletElement'
self.__class__.__qualname__ = 'DirichletElement'
def dirichlet_condition(self, reference_parms, **kwargs):
remaining = 1 - sum(
......
......@@ -510,14 +510,14 @@ class PriorDict(dict):
sample: dict
Dictionary of the samples of which we want to have the probability of
kwargs:
The keyword arguments are passed directly to `np.product`
The keyword arguments are passed directly to `np.prod`
Returns
=======
float: Joint probability of all individual sample probabilities
"""
prob = np.product([self[key].prob(sample[key]) for key in sample], **kwargs)
prob = np.prod([self[key].prob(sample[key]) for key in sample], **kwargs)
return self.check_prob(sample, prob)
......@@ -711,16 +711,22 @@ class ConditionalPriorDict(PriorDict):
def sample_subset(self, keys=iter([]), size=None):
self.convert_floats_to_delta_functions()
subset_dict = ConditionalPriorDict({key: self[key] for key in keys})
add_delta_keys = [
key
for key in self.keys()
if key not in keys and isinstance(self[key], DeltaFunction)
]
use_keys = add_delta_keys + list(keys)
subset_dict = ConditionalPriorDict({key: self[key] for key in use_keys})
if not subset_dict._resolved:
raise IllegalConditionsException(
"The current set of priors contains unresolvable conditions."
)
samples = dict()
for key in subset_dict.sorted_keys:
if isinstance(self[key], Constraint):
if key not in keys or isinstance(self[key], Constraint):
continue
elif isinstance(self[key], Prior):
if isinstance(self[key], Prior):
try:
samples[key] = subset_dict[key].sample(
size=size, **subset_dict.get_required_variables(key)
......@@ -764,7 +770,7 @@ class ConditionalPriorDict(PriorDict):
sample: dict
Dictionary of the samples of which we want to have the probability of
kwargs:
The keyword arguments are passed directly to `np.product`
The keyword arguments are passed directly to `np.prod`
Returns
=======
......@@ -776,7 +782,7 @@ class ConditionalPriorDict(PriorDict):
self[key].prob(sample[key], **self.get_required_variables(key))
for key in sample
]
prob = np.product(res, **kwargs)
prob = np.prod(res, **kwargs)
return self.check_prob(sample, prob)
def ln_prob(self, sample, axis=None):
......
......@@ -162,11 +162,11 @@ class Interped(Prior):
self._initialize_attributes()
def _initialize_attributes(self):
from scipy.integrate import cumtrapz
from scipy.integrate import cumulative_trapezoid
if np.trapz(self._yy, self.xx) != 1:
logger.debug('Supplied PDF for {} is not normalised, normalising.'.format(self.name))
self._yy /= np.trapz(self._yy, self.xx)
self.YY = cumtrapz(self._yy, self.xx, initial=0)
self.YY = cumulative_trapezoid(self._yy, self.xx, initial=0)
# Need last element of cumulative distribution to be exactly one.
self.YY[-1] = 1
self.probability_density = interp1d(x=self.xx, y=self._yy, bounds_error=False, fill_value=0)
......
......@@ -123,6 +123,9 @@ class Dynesty(NestedSampler):
The proposal methods to use during MCMC. This can be some combination
of :code:`"diff", "volumetric"`. See the dynesty guide in the Bilby docs
for more details. default=:code:`["diff"]`.
rstate: numpy.random.Generator (None)
Instance of a numpy random generator for generating random numbers.
Also see :code:`seed` in 'Other Parameters'.
Other Parameters
================
......@@ -143,8 +146,13 @@ class Dynesty(NestedSampler):
has no impact on the sampling.
dlogz: float, (0.1)
Stopping criteria
seed: int (None)
Use to seed the random number generator if :code:`rstate` is not
specified.
"""
sampling_seed_key = "seed"
@property
def _dynesty_init_kwargs(self):
params = inspect.signature(self.sampler_init).parameters
......@@ -176,6 +184,7 @@ class Dynesty(NestedSampler):
def default_kwargs(self):
kwargs = self._dynesty_init_kwargs
kwargs.update(self._dynesty_sampler_kwargs)
kwargs["seed"] = None
return kwargs
def __init__(
......@@ -265,6 +274,14 @@ class Dynesty(NestedSampler):
for equiv in self.npool_equiv_kwargs:
if equiv in kwargs:
kwargs["queue_size"] = kwargs.pop(equiv)
if "seed" in kwargs:
seed = kwargs.get("seed")
if "rstate" not in kwargs:
kwargs["rstate"] = np.random.default_rng(seed)
else:
logger.warning(
"Kwargs contain both 'rstate' and 'seed', ignoring 'seed'."
)
def _verify_kwargs_against_default_kwargs(self):
if not self.kwargs["walks"]:
......@@ -446,7 +463,7 @@ class Dynesty(NestedSampler):
if sample == "rwalk":
logger.info(
"Using the bilby-implemented rwalk sample method with ACT estimated walks. "
f"Using the bilby-implemented {sample} sample method with ACT estimated walks. "
f"An average of {2 * self.nact} steps will be accepted up to chain length "
f"{self.maxmcmc}."
)
......@@ -460,7 +477,7 @@ class Dynesty(NestedSampler):
dynesty.nestedsamplers._SAMPLING["rwalk"] = AcceptanceTrackingRWalk()
elif sample == "acceptance-walk":
logger.info(
"Using the bilby-implemented rwalk sampling with an average of "
f"Using the bilby-implemented {sample} sampling with an average of "
f"{self.naccept} accepted steps per MCMC and maximum length {self.maxmcmc}"
)
from .dynesty_utils import FixedRWalk
......@@ -468,7 +485,7 @@ class Dynesty(NestedSampler):
dynesty.nestedsamplers._SAMPLING["acceptance-walk"] = FixedRWalk()
elif sample == "act-walk":
logger.info(
"Using the bilby-implemented rwalk sampling tracking the "
f"Using the bilby-implemented {sample} sampling tracking the "
f"autocorrelation function and thinning by "
f"{self.nact} with maximum length {self.nact * self.maxmcmc}"
)
......@@ -604,6 +621,7 @@ class Dynesty(NestedSampler):
sampling_time_s=self.sampling_time.seconds,
ncores=self.kwargs.get("queue_size", 1),
)
self.kwargs["rstate"] = None
def _update_sampling_time(self):
end_time = datetime.datetime.now()
......@@ -717,6 +735,7 @@ class Dynesty(NestedSampler):
self.sampler.nqueue = -1
self.start_time = self.sampler.kwargs.pop("start_time")
self.sampling_time = self.sampler.kwargs.pop("sampling_time")
self.sampler.queue_size = self.kwargs["queue_size"]
self.sampler.pool = self.pool
if self.pool is not None:
self.sampler.M = self.pool.map
......
......@@ -68,7 +68,7 @@ class LivePointSampler(UnitCubeSampler):
self.kwargs["live"] = self.live_u
i = self.rstate.integers(self.nlive)
u = self.live_u[i, :]
return u, np.identity(self.npdim)
return u, np.identity(self.ncdim)
class MultiEllipsoidLivePointSampler(MultiEllipsoidSampler):
......
......@@ -283,7 +283,7 @@ def encode_for_hdf5(key, item):
output = item
elif np.issubdtype(item_array.dtype, np.number):
output = np.array(item)
elif issubclass(item_array.dtype.type, str) or item[0] is None:
elif issubclass(item_array.dtype.type, str) or None in item:
output = list()
for value in item:
if isinstance(value, str):
......
......@@ -90,7 +90,7 @@ class Interferometer(object):
self.strain_data = InterferometerStrainData(
minimum_frequency=minimum_frequency,
maximum_frequency=maximum_frequency)
self.meta_data = dict()
self.meta_data = dict(name=name)
def __eq__(self, other):
if self.name == other.name and \
......@@ -607,7 +607,7 @@ class Interferometer(object):
Returns
=======
float: The matched filter signal to noise ratio squared
complex: The matched filter signal to noise ratio
"""
return gwutils.matched_filter_snr(
......
......@@ -55,7 +55,7 @@ class TabularEOS(object):
"""
def __init__(self, eos, sampling_flag=False, warning_flag=False):
from scipy.integrate import cumtrapz
from scipy.integrate import cumulative_trapezoid
self.sampling_flag = sampling_flag
self.warning_flag = warning_flag
......@@ -83,7 +83,7 @@ class TabularEOS(object):
self.warning_flag = True
else:
integrand = self.pressure / (self.energy_density + self.pressure)
self.pseudo_enthalpy = cumtrapz(integrand, np.log(self.pressure), initial=0) + integrand[0]
self.pseudo_enthalpy = cumulative_trapezoid(integrand, np.log(self.pressure), initial=0) + integrand[0]
self.interp_energy_density_from_pressure = CubicSpline(np.log10(self.pressure),
np.log10(self.energy_density),
......
......@@ -517,7 +517,7 @@ class MBGravitationalWaveTransient(GravitationalWaveTransient):
for ifo in self.interferometers:
logger.info("Pre-computing linear coefficients for {}".format(ifo.name))
fddata = np.zeros(N // 2 + 1, dtype=complex)
fddata[:len(ifo.frequency_domain_strain)][ifo.frequency_mask] += \
fddata[:len(ifo.frequency_domain_strain)][ifo.frequency_mask[:len(fddata)]] += \
ifo.frequency_domain_strain[ifo.frequency_mask] / ifo.power_spectral_density_array[ifo.frequency_mask]
for b in range(self.number_of_bands):
Ks, Ke = self.Ks_Ke[b]
......@@ -606,7 +606,7 @@ class MBGravitationalWaveTransient(GravitationalWaveTransient):
for ifo in self.interferometers:
logger.info("Pre-computing quadratic coefficients for {}".format(ifo.name))
full_inv_psds = np.zeros(N // 2 + 1)
full_inv_psds[:len(ifo.power_spectral_density_array)][ifo.frequency_mask] = (
full_inv_psds[:len(ifo.power_spectral_density_array)][ifo.frequency_mask[:len(full_inv_psds)]] = (
1 / ifo.power_spectral_density_array[ifo.frequency_mask]
)
for b in range(self.number_of_bands):
......
......@@ -142,10 +142,6 @@ class RelativeBinningGravitationalWaveTransient(GravitationalWaveTransient):
self.fiducial_polarizations = None
self.per_detector_fiducial_waveforms = dict()
self.per_detector_fiducial_waveform_points = dict()
self.bin_freqs = dict()
self.bin_inds = dict()
self.bin_widths = dict()
self.bin_centers = dict()
self.set_fiducial_waveforms(self.fiducial_parameters)
logger.info("Initial fiducial waveforms set up")
self.setup_bins()
......@@ -219,6 +215,8 @@ class RelativeBinningGravitationalWaveTransient(GravitationalWaveTransient):
bin_inds.append(bin_index)
bin_freqs.append(bin_freq)
self.bin_inds = np.array(bin_inds, dtype=int)
self.bin_sizes = np.diff(bin_inds)
self.bin_sizes[-1] += 1
self.bin_freqs = np.array(bin_freqs)
self.number_of_bins = len(self.bin_inds) - 1
logger.debug(
......@@ -319,6 +317,10 @@ class RelativeBinningGravitationalWaveTransient(GravitationalWaveTransient):
for edge in self.bin_freqs:
index = np.where(masked_frequency_array == edge)[0][0]
masked_bin_inds.append(index)
# For the last bin, make sure to include
# the last point in the frequency array
masked_bin_inds[-1] += 1
masked_strain = interferometer.frequency_domain_strain[mask]
masked_h0 = self.per_detector_fiducial_waveforms[interferometer.name][mask]
masked_psd = interferometer.power_spectral_density_array[mask]
......@@ -370,16 +372,15 @@ class RelativeBinningGravitationalWaveTransient(GravitationalWaveTransient):
waveform_polarizations=signal_polarizations,
interferometer=interferometer,
)
f = interferometer.frequency_array
duplicated_r0, duplicated_r1, duplicated_fm = np.zeros((3, f.shape[0]), dtype=complex)
for i in range(self.number_of_bins):
idxs = slice(self.bin_inds[i], self.bin_inds[i + 1])
duplicated_fm[idxs] = self.bin_centers[i]
duplicated_r0[idxs] = r0[i]
duplicated_r1[idxs] = r1[i]
idxs = slice(self.bin_inds[0], self.bin_inds[-1] + 1)
duplicated_r0 = np.repeat(r0, self.bin_sizes)
duplicated_r1 = np.repeat(r1, self.bin_sizes)
duplicated_fm = np.repeat(self.bin_centers, self.bin_sizes)
full_waveform_ratio = duplicated_r0 + duplicated_r1 * (f - duplicated_fm)
f = interferometer.frequency_array
full_waveform_ratio = np.zeros(f.shape[0], dtype=complex)
full_waveform_ratio[idxs] = duplicated_r0 + duplicated_r1 * (f[idxs] - duplicated_fm)
return fiducial_waveform * full_waveform_ratio
def calculate_snrs(self, waveform_polarizations, interferometer, return_array=True):
......
......@@ -1385,10 +1385,10 @@ class HealPixMapPriorDist(BaseJointPriorDist):
"""
Method that builds the inverse cdf of the P(pixel) distribution for rescaling
"""
from scipy.integrate import cumtrapz
from scipy.integrate import cumulative_trapezoid
yy = self._all_interped(self.pix_xx)
yy /= np.trapz(yy, self.pix_xx)
YY = cumtrapz(yy, self.pix_xx, initial=0)
YY = cumulative_trapezoid(yy, self.pix_xx, initial=0)
YY[-1] = 1
self.inverse_cdf = interp1d(x=YY, y=self.pix_xx, bounds_error=True)
......
......@@ -205,7 +205,7 @@ def gwsignal_binary_black_hole(frequency_array, mass_1, mass_2, luminosity_dista
]
if EDOM:
failed_parameters = dict(mass_1=mass_1, mass_2=mass_2,
spin_1=(spin_1x, spin_2y, spin_1z),
spin_1=(spin_1x, spin_1y, spin_1z),
spin_2=(spin_2x, spin_2y, spin_2z),
luminosity_distance=luminosity_distance,
iota=iota, phase=phase,
......@@ -614,7 +614,7 @@ def _base_lal_cbc_fd_waveform(
EDOM = (e.args[0] == 'Internal function call failed: Input domain error')
if EDOM:
failed_parameters = dict(mass_1=mass_1, mass_2=mass_2,
spin_1=(spin_1x, spin_2y, spin_1z),
spin_1=(spin_1x, spin_1y, spin_1z),
spin_2=(spin_2x, spin_2y, spin_2z),
luminosity_distance=luminosity_distance,
iota=iota, phase=phase,
......@@ -1124,7 +1124,7 @@ def _base_waveform_frequency_sequence(
EDOM = (e.args[0] == 'Internal function call failed: Input domain error')
if EDOM:
failed_parameters = dict(mass_1=mass_1, mass_2=mass_2,
spin_1=(spin_1x, spin_2y, spin_1z),
spin_1=(spin_1x, spin_1y, spin_1z),
spin_2=(spin_2x, spin_2y, spin_2z),
luminosity_distance=luminosity_distance,
iota=iota, phase=phase)
......
......@@ -398,7 +398,7 @@ def read_frame_file(file_name, start_time, end_time, resample=None, channel=None
strain = TimeSeries.read(source=file_name, channel=channel, start=start_time, end=end_time, **kwargs)
loaded = True
logger.info('Successfully loaded {}.'.format(channel))
except RuntimeError:
except (RuntimeError, ValueError):
logger.warning('Channel {} not found. Trying preset channel names'.format(channel))
if loaded is False:
......@@ -418,12 +418,12 @@ def read_frame_file(file_name, start_time, end_time, resample=None, channel=None
**kwargs)
loaded = True
logger.info('Successfully read strain data for channel {}.'.format(channel))
except RuntimeError:
except (RuntimeError, ValueError):
pass
if loaded:
if resample and (strain.sample_rate.value != resample):
strain.resample(resample)
strain = strain.resample(resample)
return strain
else:
logger.warning('No data loaded.')
......