From 34a82af51f6f2adb66c91a51751eaec8fc7db49d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 25 Jul 2024 10:58:56 +0000 Subject: [PATCH 1/7] Bump torch from 1.4.0 to 2.2.0 Bumps [torch](https://github.com/pytorch/pytorch) from 1.4.0 to 2.2.0. - [Release notes](https://github.com/pytorch/pytorch/releases) - [Changelog](https://github.com/pytorch/pytorch/blob/main/RELEASE.md) - [Commits](https://github.com/pytorch/pytorch/compare/v1.4.0...v2.2.0) --- updated-dependencies: - dependency-name: torch dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 204f015..cb725eb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -10,5 +10,5 @@ george nestle elk-waveform gpytorch==1.0.1 -torch==1.4.0 +torch==2.2.0 torchvision==0.5.0 From fca68b73aad912c53287ed10e95392676637255b Mon Sep 17 00:00:00 2001 From: pyup-bot Date: Tue, 20 Aug 2024 14:12:41 +0100 Subject: [PATCH 2/7] Update torch from 2.2.0 to 2.4.0 --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index cb725eb..d7acace 100644 --- a/requirements.txt +++ b/requirements.txt @@ -10,5 +10,5 @@ george nestle elk-waveform gpytorch==1.0.1 -torch==2.2.0 +torch==2.4.0 torchvision==0.5.0 From 1fab73dca034061795a15c2a7a2235bdae1a24c9 Mon Sep 17 00:00:00 2001 From: pyup-bot Date: Tue, 20 Aug 2024 14:12:47 +0100 Subject: [PATCH 3/7] Pin numpydoc to latest version 1.8.0 --- requirements_dev.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements_dev.txt b/requirements_dev.txt index 1ace67f..19b5387 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -9,6 +9,6 @@ george nestle sphinx -numpydoc +numpydoc==1.8.0 git+https://github.com/transientlunatic/sphinx-daniel-theme.git nbsphinx From c45dfd48069abe087a1b4ab4c3008f98e381275b Mon Sep 17 00:00:00 2001 From: pyup-bot Date: Tue, 20 Aug 2024 14:12:48 +0100 Subject: [PATCH 4/7] Pin nbsphinx to latest version 0.9.5 --- requirements_dev.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements_dev.txt b/requirements_dev.txt index 1ace67f..6a0614e 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -11,4 +11,4 @@ nestle sphinx numpydoc git+https://github.com/transientlunatic/sphinx-daniel-theme.git -nbsphinx +nbsphinx==0.9.5 From 55b32379df0dd94da9e8fdd6b7ba13b36692906c Mon Sep 17 00:00:00 2001 From: Daniel Williams Date: Mon, 26 Aug 2024 12:52:29 +0100 Subject: [PATCH 5/7] Update handling of mass ratio --- heron/likelihood.py | 2 +- heron/models/__init__.py | 22 ++++++++++++++-------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/heron/likelihood.py b/heron/likelihood.py index 2b304d8..3c8fd05 100644 --- a/heron/likelihood.py +++ b/heron/likelihood.py @@ -108,7 +108,7 @@ def __call__(self, parameters): self.logger.info(parameters) keys = set(parameters.keys()) - extrinsic = {"phase", "psi", "ra", "dec", "theta_jn"} + extrinsic = {"phase", "psi", "ra", "dec", "theta_jn", "gpstime", "geocent_time"} conversions = {"mass_ratio", "total_mass", "luminosity_distance"} bad_keys = keys - set(self.waveform._args.keys()) - extrinsic - conversions if len(bad_keys) > 0: diff --git a/heron/models/__init__.py b/heron/models/__init__.py index f3ba0fd..c311280 100644 --- a/heron/models/__init__.py +++ b/heron/models/__init__.py @@ -26,16 +26,22 @@ def _convert_luminosity_distance(self, args): return args def _convert_mass_ratio_total_mass(self, args): - - args["m1"] = (args["total_mass"] / (1 + args["mass_ratio"])).to_value( - u.kilogram - ) - args["m2"] = (args["total_mass"] / (1 + 1 / args["mass_ratio"])).to_value( - u.kilogram - ) + args["m1"] = (args["total_mass"] / (1 + args["mass_ratio"])) + args["m2"] = (args["total_mass"] / (1 + (1 / args["mass_ratio"]))) + # Do these have units? + # If not then we can skip some relatively expensive operations and apply a heuristic. + if isinstance(args["m1"], u.Quantity): + args["m1"] = args["m1"].to_value(u.kilogram) + args["m2"] = args["m2"].to_value(u.kilogram) + if (not isinstance(args["m1"], u.Quantity)) and (args["m1"] < 1000): + # This appears to be in solar masses + args["m1"] *= MSUN_SI + if (not isinstance(args["m2"], u.Quantity)) and (args["m2"] < 1000): + # This appears to be in solar masses + args["m2"] *= MSUN_SI + args.pop("total_mass") args.pop("mass_ratio") - return args From 1efcd4c29ec7bcef1bd751a5cb42bb780e93fdce Mon Sep 17 00:00:00 2001 From: Daniel Williams Date: Mon, 26 Aug 2024 13:59:44 +0100 Subject: [PATCH 6/7] Add MSUN_SI --- heron/models/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/heron/models/__init__.py b/heron/models/__init__.py index c311280..171c0f6 100644 --- a/heron/models/__init__.py +++ b/heron/models/__init__.py @@ -1,5 +1,6 @@ import torch -from lal import antenna +import numpy as np +from lal import antenna, MSUN_SI from astropy import units as u From 07889ea54c4c0499a9d6b4bb7dcc68b2dbeb696d Mon Sep 17 00:00:00 2001 From: Daniel Williams Date: Tue, 3 Sep 2024 10:56:46 +0100 Subject: [PATCH 7/7] Added some bug fixes. --- heron/inference.py | 11 +++++++---- heron/injection.py | 2 +- heron/likelihood.py | 7 +++++-- heron/models/lalsimulation.py | 1 - heron/priors.py | 1 + heron/types.py | 3 +++ requirements.txt | 6 +++--- 7 files changed, 20 insertions(+), 11 deletions(-) diff --git a/heron/inference.py b/heron/inference.py index f68d95d..f680c16 100644 --- a/heron/inference.py +++ b/heron/inference.py @@ -6,7 +6,7 @@ import click -from gwpy.timeseries import TimeSeries +from .types import TimeSeries import astropy.units as u from nessai.flowsampler import FlowSampler @@ -84,6 +84,7 @@ def heron_inference(settings): if "data files" in settings.get("data", {}): # Load frame files from disk for ifo in settings["interferometers"]: + print(f"Loading {ifo} data") logger.info( f"Loading {ifo} data from " f"{settings['data']['data files'][ifo]}/{settings['data']['channels'][ifo]}" @@ -93,14 +94,16 @@ def heron_inference(settings): channel=settings["data"]["channels"][ifo], format="gwf", ) - elif "injection" in other_settings: - pass + #elif "injection" in other_settings: + # pass # Make Likelihood if len(settings["interferometers"]) > 1: likelihoods = [] + print("Creating likelihoods") waveform_model = KNOWN_WAVEFORMS[settings["waveform"]["model"]]() for ifo in settings["interferometers"]: + print(f"\t {ifo}") likelihoods.append( KNOWN_LIKELIHOODS[settings.get("likelihood").get("function")]( data[ifo], @@ -113,7 +116,7 @@ def heron_inference(settings): ), ) ) - likelihood = MultiDetector(*likelihoods) + likelihood = MultiDetector(*likelihoods) priors = heron.priors.PriorDict() priors.from_dictionary(settings["priors"]) diff --git a/heron/injection.py b/heron/injection.py index c6f2e6d..a0e357f 100644 --- a/heron/injection.py +++ b/heron/injection.py @@ -115,7 +115,7 @@ def injection_parameters_add_units(parameters): UNITS = {"luminosity_distance": u.megaparsec, "m1": u.solMass, "m2": u.solMass} for parameter, value in parameters.items(): - if not isinstance(value, u.Quantity): + if not isinstance(value, u.Quantity) and parameter in UNITS: parameters[parameter] = value * UNITS[parameter] return parameters diff --git a/heron/likelihood.py b/heron/likelihood.py index 3c8fd05..968d504 100644 --- a/heron/likelihood.py +++ b/heron/likelihood.py @@ -60,7 +60,6 @@ def __init__( self.timeseries = data self.data = np.array(data.data) self.times = data.times - self.C = self.psd.covariance_matrix(times=self.times) self.inverse_C = np.linalg.inv(self.C) @@ -96,7 +95,11 @@ def snr(self, waveform): return np.sqrt(np.abs(h_h)) def log_likelihood(self, waveform, norm=True): - a, b = self.timeseries.determine_overlap(self, waveform) + w = self.timeseries.determine_overlap(self, waveform) + if w is not None: + (a,b) = w + else: + return -np.inf residual = np.array(self.data.data[a[0]:a[1]]) - np.array(waveform.data[b[0]:b[1]]) weighted_residual = ( (residual) @ self.solve(self.C[a[0]:a[1],b[0]:b[1]], residual) * (self.dt * self.dt / 4) / 4 diff --git a/heron/models/lalsimulation.py b/heron/models/lalsimulation.py index 559b90d..df963ec 100644 --- a/heron/models/lalsimulation.py +++ b/heron/models/lalsimulation.py @@ -91,7 +91,6 @@ def _convert_units(self, args): args[name] = argument.to_value(units[mappings[name]]) elif name in mappings.keys() and argument: # This is commented out as it causes problems if e.g. lalnative values are passed - print(f"Performing a mapping on {name}, {argument}") args[name] = (argument * default_units[mappings[name]]).to_value( units[mappings[name]] ) diff --git a/heron/priors.py b/heron/priors.py index bca4049..d5b6265 100644 --- a/heron/priors.py +++ b/heron/priors.py @@ -13,6 +13,7 @@ "Uniform": bilby.prior.Uniform, "PowerLaw": bilby.prior.PowerLaw, "Sine": bilby.prior.Sine, + "Cosine": bilby.prior.Cosine, "UniformSourceFrame": bilby.gw.prior.UniformSourceFrame, "UniformInComponentsMassRatio": bilby.gw.prior.UniformInComponentsMassRatio, } diff --git a/heron/types.py b/heron/types.py index 42765d4..0a36cba 100644 --- a/heron/types.py +++ b/heron/types.py @@ -50,6 +50,9 @@ def is_in(time, timeseries): overlap = timeseries_a.times[0], timeseries_a.times[-1] else: overlap = None + #print("No overlap found") + #print(timeseries_a.times[0], timeseries_a.times[-1]) + #print(timeseries_b.times[0], timeseries_b.times[-1]) return None start_a = np.argmin(np.abs(timeseries_a.times - overlap[0])) diff --git a/requirements.txt b/requirements.txt index 4ba302f..1f1671b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -16,6 +16,6 @@ click asimov pesummary nessai -gpytorch==1.0.1 -torch==2.4.0 -torchvision==0.5.0 +gpytorch +torch +torchvision