Skip to content

Commit

Permalink
Modify the sanity checks of the PSD to be compatible with numpy 2.x
Browse files Browse the repository at this point in the history
and add sanity check on the PSD of the XML file.
Modify gracedb.py to be up to date with numpy2.x
  • Loading branch information
jacquot committed Oct 22, 2024
1 parent 7ecfd8d commit f5d34e1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 12 additions & 1 deletion examples/live/check_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def check_single_results(args):
continue

# check that PSD is sane
psd = group['psd'][:] / pycbc.DYN_RANGE_FAC ** 2
psd = group['psd'][:].astype(np.float64) / pycbc.DYN_RANGE_FAC ** 2
psd_df = group['psd'].attrs['delta_f']
psd_f = np.arange(len(psd)) * psd_df
psd_epoch = group['psd'].attrs['epoch']
Expand Down Expand Up @@ -142,6 +142,17 @@ def check_found_events(args):
si_table = lsctables.SnglInspiralTable.get_table(xmldoc)
ci_table = lsctables.CoincInspiralTable.get_table(xmldoc)

#check the PSD of the XML file
event, = LigoLWEventSource(ctrigfp, psd_file=ctrigfp, coinc_def=None).values()
for entry in event.singles:
psd = entry.psd.data.data
if (psd < 1e-48).any() \
or (psd > 1e-40).any() \
or not np.isfinite(psd).all() :
log.error('Invalid PSD in %s', ctrigfp)
found_fail = True


trig_props['tc'][x] = si_table[0].end
trig_props['mass1'][x] = si_table[0].mass1
trig_props['mass2'][x] = si_table[0].mass2
Expand Down
2 changes: 1 addition & 1 deletion pycbc/io/gracedb.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ def __init__(self, coinc_ifos, ifos, coinc_results, **kwargs):
fseries = lal.CreateREAL8FrequencySeries(
"psd", psd.epoch, kwargs['low_frequency_cutoff'], psd.delta_f,
lal.StrainUnit**2 / lal.HertzUnit, len(psd) - kmin)
fseries.data.data = psd.numpy()[kmin:] / pycbc.DYN_RANGE_FAC ** 2.0
fseries.data.data = psd.numpy()[kmin:].astype(numpy.float64) / pycbc.DYN_RANGE_FAC ** 2.0
psds_lal[ifo] = fseries
make_psd_xmldoc(psds_lal, outdoc)

Expand Down

0 comments on commit f5d34e1

Please sign in to comment.