Skip to content

Commit bdfb15c

Browse files
authored
Improved pygrb missed/quiet injection tables job handler (#4877)
* Imporved pygrb missed/quiet injection tables job handler * Removing resolve_url_to_file from make_pygrb_injs_tables
1 parent 82d6263 commit bdfb15c

File tree

1 file changed

+27
-33
lines changed

1 file changed

+27
-33
lines changed

Diff for: pycbc/workflow/grb_utils.py

+27-33
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737

3838
from pycbc import makedir
3939
from pycbc.workflow.core import \
40-
File, FileList, configparser_value_to_file, resolve_url_to_file, \
40+
File, FileList, resolve_url_to_file,\
4141
Executable, Node
4242
from pycbc.workflow.jobsetup import select_generic_executable
4343
from pycbc.workflow.pegasus_workflow import SubWorkflow
@@ -598,10 +598,11 @@ def make_pygrb_info_table(workflow, exec_name, out_dir, in_files=None,
598598
return node, node.output_files
599599

600600

601-
def make_pygrb_injs_tables(workflow, out_dir, # exclude=None, require=None,
602-
inj_set=None, tags=None):
603-
"""Adds a PyGRB job to make quiet-found and missed-found injection tables.
601+
def make_pygrb_injs_tables(workflow, out_dir, bank_file, off_file, seg_files,
602+
inj_file=None, on_file=None, tags=None):
604603
"""
604+
Adds a job to make quiet-found and missed-found injection tables,
605+
or loudest trigger(s) table."""
605606

606607
tags = [] if tags is None else tags
607608

@@ -610,30 +611,23 @@ def make_pygrb_injs_tables(workflow, out_dir, # exclude=None, require=None,
610611
# Initialize job node
611612
grb_name = workflow.cp.get('workflow', 'trigger-name')
612613
extra_tags = ['GRB'+grb_name]
613-
# TODO: why is inj_set repeated twice in output files?
614-
if inj_set is not None:
615-
extra_tags.append(inj_set)
616614
node = PlotExecutable(workflow.cp, exec_name,
617615
ifos=workflow.ifos, out_dir=out_dir,
618616
tags=tags+extra_tags).create_node()
617+
# Pass the bank-file
618+
node.add_input_opt('--bank-file', bank_file)
619+
# Offsource input file (or equivalently trigger file for injections)
620+
offsource_file = off_file
621+
node.add_input_opt('--offsource-file', offsource_file)
619622
# Pass the veto and segment files and options
620623
if workflow.cp.has_option('workflow', 'veto-files'):
621624
veto_files = build_veto_filelist(workflow)
622625
node.add_input_list_opt('--veto-files', veto_files)
623-
trig_time = workflow.cp.get('workflow', 'trigger-time')
624-
node.add_opt('--trigger-time', trig_time)
625-
# Other shared tuning values
626-
for opt in ['chisq-index', 'chisq-nhigh', 'null-snr-threshold',
627-
'veto-category', 'snr-threshold', 'newsnr-threshold',
628-
'sngl-snr-threshold', 'null-grad-thresh', 'null-grad-val']:
629-
if workflow.cp.has_option('workflow', opt):
630-
node.add_opt('--'+opt, workflow.cp.get('workflow', opt))
626+
node.add_input_list_opt('--seg-files', seg_files)
631627
# Handle input/output for injections
632-
if inj_set:
628+
if inj_file is not None:
633629
# Found-missed injection file (passed as File instance)
634-
fm_file = configparser_value_to_file(workflow.cp,
635-
'injections-'+inj_set,
636-
'found-missed-file')
630+
fm_file = inj_file
637631
node.add_input_opt('--found-missed-file', fm_file)
638632
# Missed-found and quiet-found injections html output files
639633
for mf_or_qf in ['missed-found', 'quiet-found']:
@@ -647,20 +641,20 @@ def make_pygrb_injs_tables(workflow, out_dir, # exclude=None, require=None,
647641
tags=extra_tags+['QUIET_FOUND'])
648642
# Handle input/output for onsource/offsource
649643
else:
650-
# Onsource input file (passed as File instance)
651-
onsource_file = configparser_value_to_file(workflow.cp,
652-
'workflow', 'onsource-file')
653-
node.add_input_opt('--onsource-file', onsource_file)
654-
# Loudest offsource triggers and onsource trigger html and h5
655-
# output files
656-
for src_type in ['onsource-trig', 'offsource-trigs']:
657-
src_type_tags = [src_type.upper().replace('-', '_')]
658-
node.new_output_file_opt(workflow.analysis_time, '.html',
659-
'--loudest-'+src_type+'-output-file',
660-
tags=extra_tags+src_type_tags)
661-
node.new_output_file_opt(workflow.analysis_time, '.h5',
662-
'--loudest-'+src_type+'-h5-output-file',
663-
tags=extra_tags+src_type_tags)
644+
src_type = 'offsource-trigs'
645+
if on_file is not None:
646+
src_type = 'onsource-trig'
647+
# Onsource input file (passed as File instance)
648+
onsource_file = on_file
649+
node.add_input_opt('--onsource-file', onsource_file)
650+
# Loudest offsource/onsource triggers html and h5 output files
651+
src_type_tags = [src_type.upper().replace('-', '_')]
652+
node.new_output_file_opt(workflow.analysis_time, '.html',
653+
'--loudest-'+src_type+'-output-file',
654+
tags=extra_tags+src_type_tags)
655+
node.new_output_file_opt(workflow.analysis_time, '.h5',
656+
'--loudest-'+src_type+'-h5-output-file',
657+
tags=extra_tags+src_type_tags)
664658

665659
# Add job node to the workflow
666660
workflow += node

0 commit comments

Comments
 (0)