Skip to content

Commit

Permalink
Sky error fix (gwastro#4502)
Browse files Browse the repository at this point in the history
  • Loading branch information
jakeb245 authored Feb 10, 2024
1 parent ddaa94d commit e2c35ef
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions bin/pygrb/pycbc_pygrb_plot_injs_results
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def load_mass_data(input_file_handle, key, tag):
return data


def load_sky_error_data(input_file_handle, key, tag, trig_data):
def load_sky_error_data(input_file_handle, key, tag):
"""Extract data related to sky_error from raw injection and trigger data"""
if tag == 'missed':
# Missed injections are assigned null values
Expand All @@ -110,8 +110,8 @@ def load_sky_error_data(input_file_handle, key, tag, trig_data):
inj['ra'] = input_file_handle[tag+'/ra'][:]
inj['dec'] = input_file_handle[tag+'/dec'][:]
trig = {}
trig['ra'] = np.rad2deg(trig_data['network/longitude'][:])
trig['dec'] = np.rad2deg(trig_data['network/latitude'][:])
trig['ra'] = input_file_handle['network/ra'][:]
trig['dec'] = input_file_handle['network/dec'][:]
data = np.arccos(np.cos(inj['dec'] - trig['dec']) -
np.cos(inj['dec']) * np.cos(trig['dec']) *
(1 - np.cos(inj['ra'] - trig['ra'])))
Expand All @@ -128,7 +128,7 @@ easy_keys = ['distance', 'mass1', 'mass2', 'polarization',
'spin2_azimuthal', 'spin2_polar',
'dec', 'ra', 'phi_ref']
# Function to extract desired data from an injection file
def load_data(input_file_handle, keys, tag, trig_data):
def load_data(input_file_handle, keys, tag):
"""Create a dictionary containing the data specified by the
list of keys extracted from an injection file"""

Expand All @@ -148,7 +148,7 @@ def load_data(input_file_handle, keys, tag, trig_data):
data_dict[key] = load_incl_data(input_file_handle, key, tag)
elif key == 'sky_error':
data_dict[key] = load_sky_error_data(input_file_handle, key,
tag, trig_data)
tag)
except KeyError:
#raise NotImplemented(key+' not allowed: returning empty entry')
logging.info(key+' not allowed yet')
Expand Down Expand Up @@ -247,10 +247,10 @@ max_reweighted_snr = max(trig_data['network/reweighted_snr'][:])
# Post-process injections
# =======================
# Extract the necessary data from the missed injections for the plot
missed_inj = load_data(f, [x_qty, y_qty], 'missed', trig_data)
missed_inj = load_data(f, [x_qty, y_qty], 'missed')

# Extract the necessary data from the found injections for the plot
found_inj = load_data(f, [x_qty, y_qty], 'found', trig_data)
found_inj = load_data(f, [x_qty, y_qty], 'found')

# Injections found surviving vetoes
found_after_vetoes = found_inj if 'found_after_vetoes' not in f.keys() else f['found_after_vetoes']
Expand Down

0 comments on commit e2c35ef

Please sign in to comment.