Commit c743ee3e authored by Gregory Ashton's avatar Gregory Ashton Committed by Colm Talbot
Browse files

Add a trigger-time method based on event names

parent 16448010
......@@ -428,14 +428,6 @@ class DataGenerationInput(Input):
)
self._sampling_frequency = sampling_frequency
@property
def trigger_time(self):
return self._trigger_time
@trigger_time.setter
def trigger_time(self, trigger_time):
self._trigger_time = trigger_time
def _set_interferometers_from_gaussian_noise(self):
""" Method to generate the interferometers data from Gaussian noise """
......
......@@ -10,6 +10,7 @@ from importlib import import_module
import numpy as np
import pandas as pd
from gwosc.datasets import event_gps
import bilby
......@@ -393,6 +394,18 @@ class Input(object):
@trigger_time.setter
def trigger_time(self, trigger_time):
# Convert trigger time
if trigger_time is None:
logger.debug("No trigger time given")
elif isinstance(trigger_time, str) and "GW" in trigger_time:
logger.info(
"Using gwosc to find trigger time for event {}".format(trigger_time)
)
trigger_time = event_gps(trigger_time)
else:
trigger_time = float(trigger_time)
self._trigger_time = trigger_time
if trigger_time is not None:
logger.info("Setting trigger time {}".format(trigger_time))
......
......@@ -185,7 +185,14 @@ def create_parser(top_level=True):
default=None,
)
data_gen_pars.add(
"--trigger-time", default=None, type=nonefloat, help="The trigger time"
"--trigger-time",
default=None,
type=nonestr,
help=(
"Either a GPS trigger time, or the event name (e.g. GW150914). "
"For event names, the gwosc package is used to identify the "
"trigger time"
),
)
data_gen_pars.add(
"--gaussian-noise",
......
accounting = ligo.dev.o3.cbc.pe.lalinference
trigger-time = 1126259462.4
trigger-time = GW150914
label = GW150914
outdir = outdir_GW150914
detectors = [H1, L1]
......
......@@ -93,6 +93,7 @@ setup(
"bilby>=0.6.8",
"scipy>=1.2.0",
"gwpy",
"gwosc",
"matplotlib",
"numpy",
"tqdm",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment