diff --git a/examples/live/check_results.py b/examples/live/check_results.py index 79fd67b9c8f..42b932ae88e 100755 --- a/examples/live/check_results.py +++ b/examples/live/check_results.py @@ -11,7 +11,7 @@ from ligo.lw.utils import load_filename as load_xml_doc from ligo.lw import lsctables from pycbc import conversions as conv - +from ligo.skymap.io import LigoLWEventSource def close(a, b, c): return abs(a - b) <= c @@ -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'] @@ -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 diff --git a/pycbc/io/gracedb.py b/pycbc/io/gracedb.py index 0692eec3c60..52dc240a358 100644 --- a/pycbc/io/gracedb.py +++ b/pycbc/io/gracedb.py @@ -222,7 +222,10 @@ 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)