Skip to content

Commit

Permalink
Extend triggers information when possible (#393)
Browse files Browse the repository at this point in the history
Co-authored-by: Evan Goetz <evan.goetz@ligo.org>
  • Loading branch information
eagoetz and Evan Goetz authored Feb 5, 2024
1 parent 3f1db27 commit a18f5e8
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions gwsumm/triggers.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,24 @@ def get_triggers(channel, etg, segments, config=GWSummConfigParser(),
else:
trigs = read_cache(segcache, SegmentList([segment]), etg,
nproc=nproc, **read_kw)

# extend columns if possible to include bandwidth, central
# frequency, and duration
if trigs is not None:
if 'fstart' in columns and 'fend' in columns:
if 'bandwidth' not in columns:
trigs.add_column(trigs['fend'] - trigs['fstart'],
name='bandwidth')
if 'central_freq' not in columns:
trigs.add_column(
0.5*(trigs['fstart'] + trigs['fend']),
name='central_freq')
if ('tstart' in columns and
'tend' in columns and
'duration' not in columns):
trigs.add_column(trigs['tend'] - trigs['tstart'],
name='duration')

# record triggers
if trigs is not None:
# add metadata
Expand All @@ -260,6 +278,14 @@ def get_triggers(channel, etg, segments, config=GWSummConfigParser(),
raise KeyError
TableClass = get_etg_table(etg)
except KeyError: # build simple table
if 'fstart' in columns and 'fend' in columns:
for colval in ['bandwidth', 'central_freq']:
if colval not in columns:
columns.extend(colval)
if ('tstart' in columns and
'tend' in columns and
'duration' not in columns):
columns.extend('duration')
tab = EventTable(names=columns)
else: # map to LIGO_LW table with full column listing
tab = EventTable(lsctables.New(TableClass))
Expand Down

0 comments on commit a18f5e8

Please sign in to comment.