Skip to content
Snippets Groups Projects
Commit 61736b1c authored by Duncan Meacher's avatar Duncan Meacher
Browse files

Added multi injection channel functionality

parent 39104039
No related branches found
No related tags found
No related merge requests found
......@@ -260,12 +260,14 @@ def parse_command_line():
dq_channel_dict = datasource.channel_dict_from_channel_list(options.dq_channel_name)
framexmit_dict = datasource.framexmit_ports['CIT'] # set the default
framexmit_dict.update(datasource.framexmit_dict_from_framexmit_list(options.framexmit_addr))
inj_channel_dict = datasource.channel_dict_from_channel_list(options.inj_channel_name)
inj_channel_dict = datasource.channel_dict_from_channel_list_with_node_range(options.inj_channel_name)
inj_dq_channel_dict = datasource.channel_dict_from_channel_list(options.inj_dq_channel_name)
inj_framexmit_dict = datasource.framexmit_dict_from_framexmit_list(options.inj_framexmit_addr)
if inj_channel_dict and not ( set(inj_channel_dict.keys()) == set(channel_dict.keys()) ):
raise ValueError("Either no injection jobs must be given or the injection and non-injection channels must be specified for the same set of detectors")
if inj_channel_dict:
for nodes in inj_channel_dict.keys():
if not ( set(inj_channel_dict[nodes].keys()) == set(channel_dict.keys()) ):
raise ValueError("Either no injection jobs must be given or the injection and non-injection channels must be specified for the same set of detectors")
options.state_vector_on_off_dict = inspiral.state_vector_on_off_dict_from_bit_lists(options.state_vector_on_bits, options.state_vector_off_bits)
......@@ -389,7 +391,7 @@ for num_insp_nodes, (svd_banks, likefile, zerolikefile) in enumerate(zip(bank_gr
inspInjNode = inspiral_pipe.generic_node(gstlalInspiralInjJob, dag, [],
opts = {"psd-fft-length":options.psd_fft_length,
"ht-gate-threshold":options.ht_gate_threshold,
"channel-name":datasource.pipeline_channel_list_from_channel_dict(inj_channel_dict),
"channel-name":datasource.pipeline_channel_list_from_channel_dict_with_node_range(inj_channel_dict, node = jobTags[-1]),
"dq-channel-name":datasource.pipeline_channel_list_from_channel_dict(inj_dq_channel_dict, opt = "dq-channel-name"),
"state-vector-on-bits":options.inj_state_vector_on_bits,
"state-vector-off-bits":options.inj_state_vector_off_bits,
......
......@@ -85,6 +85,30 @@ def channel_dict_from_channel_list(channel_list):
"""
return dict(instrument_channel.split("=") for instrument_channel in channel_list)
def channel_dict_from_channel_list_with_node_range(channel_list):
"""!
Given a list of channels with a range of mass bins, produce a dictionary
keyed by ifo of channel names:
The list here typically comes from an option parser with options that
specify the "append" action.
Examples:
>>> channel_dict_from_channle_list_with_node_range(["0000:0002:H1=LSC_STRAIN_1,L1=LSC_STRAIN_2", "0002:0004:H1=LSC_STRAIN_3,L1=LSC_STRAIN_4", "0004:0006:H1=LSC_STRAIN_5,L1=LSC_STRAIN_6"])
{'0000' : {'H1': 'LSC_STRAIN_1', 'L1': 'LSC-STRAIN_2'},
'0001' : {'H1': 'LSC_STRAIN_1', 'L1': 'LSC-STRAIN_2'},
'0002' : {'H1': 'LSC_STRAIN_3', 'L1': 'LSC-STRAIN_4'},
'0003' : {'H1': 'LSC_STRAIN_3', 'L1': 'LSC-STRAIN_4'},
'0004' : {'H1': 'LSC_STRAIN_5', 'L1': 'LSC-STRAIN_6'},
'0005' : {'H1': 'LSC_STRAIN_5', 'L1': 'LSC-STRAIN_6'} }
"""
outdict = {}
for instrument_channel_full in channel_list:
instrument_channel_split = instrument_channel_full.split(':')
for ii in range(int(instrument_channel_split[0]),int(instrument_channel_split[1])):
outdict[str(ii).zfill(4)] = dict((instrument_channel.split("=")) for instrument_channel in instrument_channel_split[2].split(','))
return outdict
def pipeline_channel_list_from_channel_dict(channel_dict, ifos = None, opt = "channel-name"):
"""!
......@@ -120,6 +144,40 @@ def pipeline_channel_list_from_channel_dict(channel_dict, ifos = None, opt = "ch
return outstr
def pipeline_channel_list_from_channel_dict_with_node_range(channel_dict, node = 0, ifos = None, opt = "channel-name"):
"""!
Creates a string of channel names options from a dictionary keyed by ifos.
FIXME: This function exists to work around pipeline.py's inability to
give the same option more than once by producing a string to pass as an argument
that encodes the other instances of the option.
- override --channel-name with a different option by setting opt.
- restrict the ifo keys to a subset of the channel_dict by.
setting ifos
Examples:
>--->>> pipeline_channel_list_from_channel_dict({'0000': {'H2': 'SOMETHING-ELSE', 'H1': 'LSC-STRAIN'}}, node=0)
>---'H2=SOMETHING-ELSE --channel-name=H1=LSC-STRAIN '
>--->>> pipeline_channel_list_from_channel_dict({'0000': {'H2': 'SOMETHING-ELSE', 'H1': 'LSC-STRAIN'}}, node=0, ifos=["H1"])
>---'H1=LSC-STRAIN '
>--->>> pipeline_channel_list_from_channel_dict('0000': {{'H2': 'SOMETHING-ELSE', 'H1': 'LSC-STRAIN'}}, node=0, opt="test-string")
>---'H2=SOMETHING-ELSE --test-string=H1=LSC-STRAIN '
"""
outstr = ""
node = str(node).zfill(4)
if ifos is None:
ifos = channel_dict[node].keys()
for i, ifo in enumerate(ifos):
if i == 0:
outstr += "%s=%s " % (ifo, channel_dict[node][ifo])
else:
outstr += "--%s=%s=%s " % (opt, ifo, channel_dict[node][ifo])
return outstr
## #### Default dictionary of state vector on/off bits by ifo
# Used as the default argument to state_vector_on_off_dict_from_bit_lists()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment