Commit 4e6d420c authored by Hiroaki Ohta's avatar Hiroaki Ohta
Browse files

inspiral_pipy.py: add functions related VT's estimation jobs

parent 7d9f6fc0
......@@ -393,6 +393,26 @@ def ref_psd_layer(dag, jobs, parent_nodes, segsdict, channel_dict, options):
return psd_nodes
def injection_template_match_layer(dag, jobs, parent_nodes, options, instruments):
inj_tmplt_match_nodes = {}
for inj in options.injections:
inj = inj.split(":")[-1]
sim_name = sim_tag_from_inj_file(inj)
inj_tmplt_match_nodes[sim_name] = {}
for nsplit in range(options.num_split_inj_files):
inj_tmplt_match_nodes[sim_name][nsplit] = dagparts.DAGNode(
jobs['injTmpltMatch'],
dag,
parent_nodes = parent_nodes,
input_files = {
"injection-file": "%s/%s_INJ_SPLIT_%04d.xml"%(jobs['injSplitter'].output_path, sim_name, nsplit),
"template-bank": options.template_bank
},
output_files = {"output": "%s/%s-INJECTION_TEMPLATE_MATCH_%s_%04d.xml.gz"%(jobs['injTmpltMatch'].output_path, instruments, sim_name, nsplit)}
)
return inj_tmplt_match_nodes
def median_psd_layer(dag, jobs, parent_nodes, options, boundary_seg, instruments):
gpsmod5 = str(int(boundary_seg[0]))[:5]
median_psd_path = subdir_path([jobs['medianPSD'].output_path, gpsmod5])
......@@ -985,6 +1005,32 @@ def calc_rank_pdf_layer(dag, jobs, marg_nodes, options, boundary_seg, instrument
return rankpdf_nodes, rankpdf_zerolag_nodes
def lnlrcdf_signal_layer(dag, jobs, parent_nodes, inj_tmplt_match_nodes, options, boundary_seg, instrument_set):
ngroup = min(options.ngroup, len(parent_nodes))
lnlrcdf_signal_nodes = {}
for inj in options.injections:
sim_name = sim_tag_from_inj_file(inj.split(":")[-1])
lnlrcdf_signal_nodes[sim_name] = []
for group in range(ngroup):
bin_keys = list(parent_nodes)[group::ngroup]
rankfiles = dict((bin_key, functools.partial(get_rank_file, "".join(sorted(instrument_set)), boundary_seg, bin_key)) for bin_key in bin_keys)
for nsplit in range(options.num_split_inj_files):
lnlrcdf_signal_nodes[sim_name].append(
dagparts.DAGNode(
jobs['lnlrcdfSignal'],
dag,
parent_nodes = [parent_nodes[bin_key] for bin_key in bin_keys] + [inj_tmplt_match_nodes[sim_name][nsplit]],
input_files = {
"injection_template_match_file": inj_tmplt_match_nodes[sim_name][nsplit].output_files["output"],
"likelihood-url": [rankfile('MARG_DIST_STATS', jobs['marginalize']) for rankfile in rankfiles.values()]
},
output_files = {"output-file": rankfiles[min(bin_keys)]('%s_%04d'%(sim_name, nsplit), jobs['lnlrcdfSignal'])},
)
)
return lnlrcdf_signal_nodes
def likelihood_layer(dag, jobs, marg_nodes, lloid_output, lloid_diststats, options, boundary_seg, instrument_set):
likelihood_nodes = {}
instruments = "".join(sorted(instrument_set))
......@@ -1297,6 +1343,49 @@ def compute_far_layer(dag, jobs, margnodes, injdbs, noninjdb, final_sqlite_nodes
return outnode
def make_mc_vtplot_layer(dag, jobs, parent_nodes, add_parent_node, options, instrument_set, output_dir, injdbs = None):
injs = [inj.split(":")[-1] for inj in options.injections]
for inj in injs + ["COMBINED"]:
sim_name = sim_tag_from_inj_file(inj)
if sim_name in parent_nodes:
parent = parent_nodes[sim_name]
if injdbs:
inj = [injdb for injdb in injdbs if sim_name in injdb][0]
elif inj == "COMBINED":
parent = sum(parent_nodes.values(), [])
if injdbs:
inj = injdbs
else:
inj = injs
else:
raise ValueError("internal error")
job = jobs['makeMcVtplot']
lnlrcdf_files = [node.output_files["output-file"] for node in parent]
lnlrcdf_caches = [CacheEntry.from_T050017("file://localhost%s" % os.path.abspath(lnlrcdf_file)) for lnlrcdf_file in lnlrcdf_files]
lnlrcdf_cache = dagparts.group_T050017_filename_from_T050017_files(lnlrcdf_caches, '.xml.gz', path = jobs['makeMcVtplot'].output_path)
input_files = {
"ranking-stat-pdf": "post_marginalized_likelihood.xml.gz",
"": inj
}
if injdbs:
job = jobs['makeMcVtplotCheck']
input_files["check-vt"] = ""
lnlrcdf_cache = dagparts.group_T050017_filename_from_T050017_files(lnlrcdf_caches, '.xml.gz', path = jobs['makeMcVtplotCheck'].output_path)
make_mc_vtplot_nodes = dagparts.DAGNode(
job,
dag,
parent_nodes = parent + [add_parent_node],
opts = {"instrument" : instrument_set},
input_files = input_files,
output_files = {"output-dir": output_dir},
input_cache_files = {"lnlrcdf-cache": lnlrcdf_files},
input_cache_file_name = os.path.basename(lnlrcdf_cache).replace('.xml.gz','.cache') if sim_name in parent_nodes else "COMBINED.cache"
)
def horizon_dist_layer(dag, jobs, psd_nodes, options, boundary_seg, output_dir, instruments):
"""calculate horizon distance
"""
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment