Skip to content

Commit

Permalink
PyGRB bugfixes/corrections (#4443)
Browse files Browse the repository at this point in the history
* Fix array indexing

* Move polarization calculations to avoid NameError

* naming correction

* Correct naming correction

* Fix coh_ifosnr sky location variables

* Fix inj results plots (maybe not completely)

* Make skygrid plot work (units questionable)

* Fix double numpy import

* Clarify units

* Codeclimate

* Use proper degree naming convention

* Revert sky error change

* Miniscule change to retrigger test
  • Loading branch information
jakeb245 authored Oct 19, 2023
1 parent e8f0b82 commit f1e16ea
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 16 deletions.
6 changes: 3 additions & 3 deletions bin/pycbc_multi_inspiral
Original file line number Diff line number Diff line change
Expand Up @@ -473,10 +473,10 @@ with ctx:
# If we have triggers above coinc threshold and more than 2
# ifos, then calculate the coherent statistics
if len(coinc_idx) != 0 and nifo > 2:
# Plus and cross polarization
fp = {ifo: ap[ifo][position_index][0] for ifo in args.instruments}
fc = {ifo: ap[ifo][position_index][1] for ifo in args.instruments}
if args.projection=='left+right':
#Plus and cross polarization
fp = {ifo: ap[ifo][position_index][0] for ifo in args.instruments}
fc = {ifo: ap[ifo][position_index][1] for ifo in args.instruments}
# Left polarized coherent SNR
project_l = coh.get_projection_matrix(
fp, fc, sigma, projection='left')
Expand Down
4 changes: 2 additions & 2 deletions bin/pygrb/pycbc_pygrb_grb_info_table
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ data[0].append(utc_time)
headers.append('Coordinated Universal Time')

data[0].append(str(opts.ra))
headers.append('R.A.')
headers.append('R.A. (deg)')

data[0].append(str(opts.dec))
headers.append('Dec')
headers.append('Dec (deg)')

data[0].append(str(opts.sky_error))
headers.append('Sky Error')
Expand Down
8 changes: 4 additions & 4 deletions bin/pygrb/pycbc_pygrb_plot_coh_ifosnr
Original file line number Diff line number Diff line change
Expand Up @@ -97,16 +97,16 @@ def load_data(input_file, vetoes, ifos, opts, injections=False):
sigma_tot = numpy.zeros(num_trigs)

# Get parameters necessary for antenna responses
longitude = numpy.degrees(trigs['network/longitude'])
latitude = numpy.degrees(trigs['network/latitude'])
ra = trigs['network/ra'][:]
dec = trigs['network/dec'][:]
time = trigs['network/end_time_gc'][:]

# Get antenna response based parameters
for ifo in ifos:
antenna = Detector(ifo)
ifo_f_resp = \
ppu.get_antenna_responses(antenna, longitude,
latitude, time)
ppu.get_antenna_responses(antenna, ra,
dec, time)

# Get the average for f_resp_mean and calculate sigma_tot
data['f_resp_mean'][ifo] = ifo_f_resp.mean()
Expand Down
2 changes: 1 addition & 1 deletion bin/pygrb/pycbc_pygrb_plot_injs_results
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@


"""
Plot found/missed injection properties for the triggered search (PyGRB).'
Plot found/missed injection properties for the triggered search (PyGRB).
"""

import h5py, logging, os.path, argparse, sys
Expand Down
7 changes: 4 additions & 3 deletions bin/pygrb/pycbc_pygrb_plot_skygrid
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ trig_data = load_data(trig_file, vetoes)
# Generate sky grid plot
#

xlabel = "Longitude (Degrees)"
ylabel = "Latitude (Degrees)"
xlabel = "RA (deg)"
ylabel = "Dec (deg)"

if opts.verbose:
sys.stdout.write("\nPlotting...\n")
Expand All @@ -103,7 +103,8 @@ fig = plt.figure()
ax = fig.gca()
ax.set_xlabel(xlabel)#, fontsize=16)
ax.set_ylabel(ylabel)#, fontsize=16)
ax.plot(trig_data['network/longitude'][:], trig_data['network/latitude'][:],
# Trigger RA/Dec data is stored in radians, so convert to degrees
ax.plot(numpy.rad2deg(trig_data['network/ra']), numpy.rad2deg(trig_data['network/dec']),
'ko', markerfacecolor='blue')
# Wrap up
save_fig_with_metadata(fig, outfile, cmd=' '.join(sys.argv),
Expand Down
4 changes: 2 additions & 2 deletions bin/pygrb/pycbc_pygrb_pp_workflow
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,8 @@ ini_file = _workflow.FileList([_workflow.File(wflow.ifos, '',
layout.single_layout(base, ini_file)

# Create versioning information
wf.make_versioning_page(
_workflow,
_workflow.make_versioning_page(
wflow,
wflow.cp,
rdir['workflow/version'],
)
Expand Down
2 changes: 1 addition & 1 deletion pycbc/conversions.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ def remnant_mass_from_mass1_mass2_spherical_spin_eos(
# If a maximum NS mass is not provided, accept all values and
# let the EOS handle this (in ns.initialize_eos)
if ns_bh_mass_boundary is None:
mask = numpy.ones(ensurearray(mass2).size[0], dtype=bool)
mask = numpy.ones(ensurearray(mass2)[0].size, dtype=bool)
# Otherwise perform the calculation only for small enough NS masses...
else:
mask = mass2 <= ns_bh_mass_boundary
Expand Down
2 changes: 2 additions & 0 deletions pycbc/workflow/matched_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,8 @@ def setup_matchedfltr_dax_generated_multi(workflow, science_segs, datafind_outs,

if match_fltr_exe == 'pycbc_multi_inspiral':
exe_class = select_matchedfilter_class(match_fltr_exe)
# Right ascension + declination provided in degrees,
# so convert to radians
cp.set('inspiral', 'ra',
str(radians(float(cp.get('workflow', 'ra')))))
cp.set('inspiral', 'dec',
Expand Down

0 comments on commit f1e16ea

Please sign in to comment.