Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create v0.4 #4

Merged
merged 40 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
ca1392b
Fixed the lalnoise implementation.
transientlunatic Aug 16, 2024
1e7dbd9
Updates to inference tests.
transientlunatic Aug 16, 2024
fe12e3d
Attempts to fix snr test.
transientlunatic Aug 16, 2024
58e6e14
Reverted various changes which break the GPR construction again.
transientlunatic Aug 16, 2024
5fb79d0
Update the github actions.
transientlunatic Aug 16, 2024
379bb88
Add install requirements to test runner.
transientlunatic Aug 16, 2024
918d53f
Modify the docs build.
transientlunatic Aug 16, 2024
9a07570
Fixed waveform alignment in likelihood.
transientlunatic Aug 16, 2024
7f20b36
Fix location of logabsdet.
transientlunatic Aug 19, 2024
97590b7
Updated tests to ensure compatibility between torch and numpy
transientlunatic Aug 19, 2024
239503a
Merge pull request #5 from transientlunatic/tests-add-likelihood-rang…
transientlunatic Aug 19, 2024
f729525
Updated the profiling tests.
transientlunatic Aug 20, 2024
6d46060
Updated the profiling tests.
transientlunatic Aug 20, 2024
967ac4e
Add cuda likelihood test.
transientlunatic Aug 20, 2024
56eaba0
Moved cuda likelihood.
transientlunatic Aug 20, 2024
ea80a54
Merge branch 'v0.4-preview' into update-profiling
transientlunatic Aug 20, 2024
5bf0cdc
Merge pull request #6 from transientlunatic/update-profiling
transientlunatic Aug 20, 2024
eefa5ef
Further inference improvements.
transientlunatic Aug 22, 2024
69110f4
Added a new test for the numpy uncertainty likelihood.
transientlunatic Aug 22, 2024
8023c1e
Actually add the tests.
transientlunatic Aug 22, 2024
1389ebd
Merge branch 'v0.4-preview' into tests-add-likelihood-range-tests
transientlunatic Aug 22, 2024
d17257d
Merge pull request #25 from transientlunatic/tests-add-likelihood-ran…
transientlunatic Aug 22, 2024
e0da2a4
Added first tests of the CUDA likelihood.
transientlunatic Aug 23, 2024
651012d
Merge branch 'tests-add-likelihood-range-tests' of github.com:transie…
transientlunatic Aug 23, 2024
58ac10d
Update the tests so the cuda-requiring ones are skipped in CI
transientlunatic Aug 23, 2024
1601ad4
Merge pull request #26 from transientlunatic/tests-add-likelihood-ran…
transientlunatic Aug 23, 2024
55b3237
Update handling of mass ratio
transientlunatic Aug 26, 2024
7faf90a
Merge branch 'master' into update-conversions
transientlunatic Aug 26, 2024
a7f2b60
Merge pull request #28 from transientlunatic/update-conversions
transientlunatic Aug 26, 2024
1efcd4c
Add MSUN_SI
transientlunatic Aug 26, 2024
6d75253
Merge branch 'update-conversions' of github.com:transientlunatic/hero…
transientlunatic Aug 26, 2024
208750c
Merge pull request #29 from transientlunatic/update-conversions
transientlunatic Aug 26, 2024
07889ea
Added some bug fixes.
transientlunatic Sep 3, 2024
e17b9a2
Merge pull request #30 from transientlunatic/bug-fixes
transientlunatic Sep 3, 2024
f7df371
Move to internal timeseries
transientlunatic Oct 1, 2024
62ce6c1
Merge branch 'v0.4-preview' of github.com:transientlunatic/heron into…
transientlunatic Oct 1, 2024
377ecbb
Minor fix for GPStime in injection
transientlunatic Oct 4, 2024
7112445
Changes to allow bilby to read frame files.
transientlunatic Dec 13, 2024
d73f8b9
Merge pull request #46 from transientlunatic/fix-injections
transientlunatic Jan 7, 2025
d540e12
Merge branch 'master' into v0.4-preview
transientlunatic Jan 7, 2025
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
37 changes: 37 additions & 0 deletions .github/workflows/documentation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Documentation
on:
push:
branches:
- master
- v*-preview

jobs:
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8

- name: Build HTML Docs
run: |
sudo apt install pandoc
pip install sphinx sphinx-multiversion
pip install kentigern
pip install -r requirements.txt
pip install -r requirements_dev.txt
pip install .
cd docs
make html

- name: SCP Deploy HTML Docs
uses: horochx/[email protected]
with:
local: docs/_build/html/*
remote: /home/danwilliams/code.daniel-williams.co.uk/heron/${{ github.ref_name }}
host: ${{ secrets.sshhost }}
user: ${{ secrets.sshuser }}
key: ${{ secrets.sshkey }}
44 changes: 13 additions & 31 deletions .github/workflows/review.yml
Original file line number Diff line number Diff line change
@@ -1,47 +1,29 @@
# This is a basic workflow to help you get started with Actions

name: CI

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
name: Tests
on:
push:
branches: [ review ]
branches:
- master
- v*-preview
pull_request:
branches: [ review ]
branches:
- master

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
test:
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- uses: actions/checkout@v2

- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Build HTML Docs

- name: Install dependencies
run: |
sudo apt install pandoc
pip install sphinx
pip install kentigern
pip install -r requirements.txt
pip install -r requirements_dev.txt
pip install .
cd docs
make html
pip install -r requirements_test.txt

- name: SCP Deploy HTML Docs
uses: horochx/[email protected]
with:
local: docs/_build/html/*
remote: /home/danwilliams/code.daniel-williams.co.uk/heron/review
host: ${{ secrets.sshhost }}
user: ${{ secrets.sshuser }}
key: ${{ secrets.sshkey }}
- name: Run Tests
run: |
python -m unittest discover tests/
11 changes: 7 additions & 4 deletions heron/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]}"
Expand All @@ -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],
Expand All @@ -113,7 +116,7 @@ def heron_inference(settings):
),
)
)
likelihood = MultiDetector(*likelihoods)
likelihood = MultiDetector(*likelihoods)

priors = heron.priors.PriorDict()
priors.from_dictionary(settings["priors"])
Expand Down
33 changes: 19 additions & 14 deletions heron/injection.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@


def make_injection(
waveform=IMRPhenomPv2,
injection_parameters={},
times=None,
detectors=None,
framefile=None,
psdfile=None,
waveform=IMRPhenomPv2,
injection_parameters={},
duration=32,
sample_rate=4096,
times=None,
detectors=None,
framefile=None,
):

parameters = {"ra": 0, "dec": 0, "psi": 0, "theta_jn": 0, "phase": 0}
Expand All @@ -34,7 +35,7 @@ def make_injection(
waveform = waveform()

if times is None:
times = np.linspace(-0.5, 0.1, int(0.6 * 4096))
times = np.linspace(parameters['gpstime']-duration+2, parameters['gpstime']+2, int(duration * sample_rate))
waveform = waveform.time_domain(
parameters,
times=times,
Expand All @@ -45,16 +46,19 @@ def make_injection(
logger.info(f"Making injection for {detector}")
psd_model = KNOWN_PSDS[psd_model]()
detector = KNOWN_IFOS[detector]()
if times is None:
times = waveform['plus'].times.value
data = psd_model.time_series(times)
print(data)

channel = f"{detector.abbreviation}:Injection"
injection = data + waveform.project(detector)
injection.channel = channel
injections[detector.abbreviation] = injection
likelihood = TimeDomainLikelihood(injection, psd=psd_model)
snr = likelihood.snr(waveform.project(detector))
# likelihood = TimeDomainLikelihood(injection, psd=psd_model)
# snr = likelihood.snr(waveform.project(detector))

logger.info(f"Optimal Filter SNR: {snr}")
#logger.info(f"Optimal Filter SNR: {snr}")

if framefile:
filename = f"{detector.abbreviation}_{framefile}.gwf"
Expand Down Expand Up @@ -115,21 +119,20 @@ def make_injection_zero_noise(
logger.info(f"Saving framefile to {filename}")
injection.write(filename, format="gwf")

return injections

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.keys()):
parameters[parameter] = value * UNITS[parameter]
return parameters


@click.command()
@click.option("--settings")
def injection(settings):

click.secho("Creating an injection with the heron injection engine")

settings = load_yaml(settings)

if "logging" in settings:
Expand All @@ -153,6 +156,8 @@ def injection(settings):
}
injections = make_injection(
waveform=IMRPhenomPv2,
duration=settings["duration"],
sample_rate=settings["sample rate"],
injection_parameters=parameters,
detectors=detector_dict,
framefile="injection",
Expand Down
Loading
Loading