Skip to content

Commit

Permalink
custom minifollowup to a eccentricity search
Browse files Browse the repository at this point in the history
  • Loading branch information
yi-fan-wang committed Sep 17, 2024
1 parent 650abf9 commit 51c9c14
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 2 deletions.
8 changes: 8 additions & 0 deletions bin/minifollowups/pycbc_page_coincinfo
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,14 @@ for ifo in files.keys():
headers.append("s<sub>1z</sub>")
headers.append("s<sub>2z</sub>")
headers.append("Duration")
# display eccentricity and relative anomaly if they exist
try:
data[-1].append('%5.2f' % bank['eccentricity'][tid])
data[-1].append('%5.2f' % bank['rel_anomaly'][tid])
headers.append("eccentricity")
headers.append("rel_anomaly")
except:
pass

html += str(pycbc.results.static_table(
data,
Expand Down
8 changes: 8 additions & 0 deletions bin/minifollowups/pycbc_page_snglinfo
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,14 @@ headers.append("M<sub>c</sub>")
headers.append("s<sub>1z</sub>")
headers.append("s<sub>2z</sub>")
headers.append("Duration")
# display eccentricity and relative anomaly if they exist
try:
data[0].append('%5.2f' % sngl_file.eccentricity[0])
data[0].append('%5.2f' % sngl_file.rel_anomaly[0])
headers.append("eccentricity")
headers.append("rel_anomaly")
except AttributeError:
pass

if args.significance_file and not args.n_loudest:
with hdf.HFile(args.significance_file, 'r') as sig_f:
Expand Down
6 changes: 6 additions & 0 deletions bin/minifollowups/pycbc_sngl_minifollowup
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,12 @@ for rank, num_event in enumerate(order):
curr_params['f_lower'] = trigs.f_lower[num_event]
curr_params[args.instrument + '_end_time'] = time
curr_params['mean_time'] = time
# optional eccentric parameters, only present when using SEOBNRv4/5E
try:
curr_params['eccentricity'] = trigs.eccentricity[num_event]
curr_params['rel_anomaly'] = trigs.rel_anomaly[num_event]
except AttributeError:
pass
# don't require precessing template info if not present
try:
curr_params['spin1x'] = trigs.spin1x[num_event]
Expand Down
9 changes: 8 additions & 1 deletion bin/plotting/pycbc_plot_waveform
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ parser.add_argument("--u-val", type=float, default=0,
"h(t) = h_+ * u_val + h_x. Only needed in the case of "
"waveforms where h_+ and h_x are not related by a "
"simple phase shift.")
# Optional arguments for eccentricity
parser.add_argument("--eccentricity", type=float, default=0,
help="Eccentricity of the orbit. ")
parser.add_argument("--rel-anomaly", type=float, default=0,
help="Relativistic anomaly. ")
# Other optional arguments
parser.add_argument("--taper-template", choices=["start","end","startend"],
help="For time-domain approximants, taper the start and/or"
Expand Down Expand Up @@ -105,7 +110,9 @@ tmp_params = io.WaveformArray.from_kwargs(
spin2y=opt.spin2y,
spin2z=opt.spin2z,
inclination=opt.inclination,
coa_phase=opt.coa_phase)
coa_phase=opt.coa_phase,
eccentricity=opt.eccentricity,
rel_anomaly=opt.rel_anomaly)

# Deal with parameter-dependent approximant string
approximant = waveform.bank.parse_approximant_arg(opt.approximant,
Expand Down
9 changes: 8 additions & 1 deletion bin/pycbc_single_template
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,11 @@ parser.add_argument("--u-val", type=float, default=None,
help="The ratio between hplus and hcross to use in the "
"template, according to h(t) = hplus * u_val + hcross. "
"If not given only hplus is used.")
# Optional arguments for eccentric templates
parser.add_argument("--eccentricity", type=float, default=0,
help="The orbital eccentricity. Default = 0")
parser.add_argument("--rel-anomaly", type=float, default=0,
help="The relativistic anomaly. Default = 0")
parser.add_argument("--window", type=float,
help="Time to save on each side of the given trigger time")
parser.add_argument("--order", type=int,
Expand Down Expand Up @@ -228,7 +233,9 @@ if not opt.use_params_of_closest_injection:
spin1z=opt.spin1z,
spin2x=opt.spin2x,
spin2y=opt.spin2y,
spin2z=opt.spin2z)
spin2z=opt.spin2z,
eccentricity=opt.eccentricity,
rel_anomaly=opt.rel_anomaly)

with ctx:
fft.from_cli(opt)
Expand Down
10 changes: 10 additions & 0 deletions pycbc/io/hdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,16 @@ def inclination(self):
self.checkbank('inclination')
return self.bank['inclination'][:][self.template_id]

@property
def eccentricity(self):
self.checkbank('eccentricity')
return self.bank['eccentricity'][:][self.template_id]

@property
def rel_anomaly(self):
self.checkbank('rel_anomaly')
return self.bank['rel_anomaly'][:][self.template_id]

@property
def f_lower(self):
self.checkbank('f_lower')
Expand Down
7 changes: 7 additions & 0 deletions pycbc/workflow/minifollowups.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,10 @@ def make_single_template_files(workflow, segs, ifo, data_read_name,
except:
node.add_opt('--u-val',
"%.6f" % params['u_vals_%s' % ifo])
# If this is a eccentricity search
if 'eccentricity' in params:
node.add_opt('--eccentricity', "%.6f" % params['eccentricity'])
node.add_opt('--rel-anomaly', "%.6f" % params['rel_anomaly'])

if params[ifo + '_end_time'] > 0 and not use_mean_time:
trig_time = params[ifo + '_end_time']
Expand Down Expand Up @@ -687,6 +691,9 @@ def make_plot_waveform_plot(workflow, params, out_dir, ifos, exclude=None,
node.add_opt('--spin2y',"%.6f" % params['spin2y'])
node.add_opt('--inclination',"%.6f" % params['inclination'])
node.add_opt('--u-val', "%.6f" % params['u_vals'])
if 'eccentricity' in params:
node.add_opt('--eccentricity', "%.6f" % params['eccentricity'])
node.add_opt('--rel-anomaly', "%.6f" % params['rel_anomaly'])
node.new_output_file_opt(workflow.analysis_time, '.png',
'--output-file')
workflow += node
Expand Down

0 comments on commit 51c9c14

Please sign in to comment.