Skip to content
Snippets Groups Projects

Resolve "Add calibration to online runs"

Merged Gregory Ashton requested to merge 102-add-calibration-to-online-runs into master
+ 54
0
@@ -115,6 +115,55 @@ def read_from_json(json_file):
return candidate
def calibration_lookup(trigger_time, detector):
""" Lookup function for the relevant calibration file
Assumes that it is running on CIT where the calibration files are stored
under /hom/cbc/pe/O3/calibrationenvelopes
Parameters
----------
trigger_time: float
The trigger time of interest
detector: str [H1, L1, V1]
Detector string
Returns
-------
filepath: str
The path to the relevant calibration envelope file. If no calibration
file can be determined, None is returned.
"""
base = "/home/cbc/pe/O3/calibrationenvelopes"
CALENVS_LOOKUP = dict(
H1=os.path.join(base, "LIGO_Hanford/H_CalEnvs.txt"),
L1=os.path.join(base, "LIGO_Livingston/L_CalEnvs.txt"),
V1=os.path.join(base, "Virgo/V_CalEnvs.txt"),
)
calenv = CALENVS_LOOKUP[detector]
times = []
files = []
with open(calenv, "r") as f:
for line in f:
time, filename = line.rstrip("\n").split(" ")
times.append(float(time))
files.append(filename)
if trigger_time < times[0]:
raise logger.warning(
"Requested trigger time prior to earliest calibration file"
)
return None
for i in range(len(times)):
if trigger_time > times[i]:
directory = os.path.dirname(calenv)
calib_file = "{}/{}".format(directory, files[i])
return os.path.abspath(calib_file)
def create_config_file(candidate, gracedb, outdir, roq=True):
""" Creates ini file from defaults and candidate contents
@@ -156,6 +205,8 @@ def create_config_file(candidate, gracedb, outdir, roq=True):
prior = determine_prior_file_from_parameters(chirp_mass)
calib_dict = {det: calibration_lookup(trigger_time, det) for det in ifos}
config_dict = dict(
label=gracedb,
outdir=outdir,
@@ -181,6 +232,9 @@ def create_config_file(candidate, gracedb, outdir, roq=True):
phase_marginalization=True,
n_parallel=4,
create_summary=True,
calibration_model="CubicSpline",
spline_calibration_envelope_dict=calib_dict,
spline_calibration_nodes=5,
)
if roq and config_dict["duration"] > 4:
Loading