27The KNOwn Pulsar pipelinE - lalpulsar_knope
29DAG generation code for running the known pulsar search pipeline
32from __future__
import print_function, division
34from lalpulsar
import knope_utils
as knope
36from configparser
import ConfigParser
40description =
"""Setup a Condor DAG file to run the known pulsar search pipeline based on information given in config.ini.
41The user must specify the configuration file for the script to run.
44parser = argparse.ArgumentParser(description=description)
47 "inifile", help=
"The configuation (.ini) file"
53 help=
"Automatically submit the Condor DAG",
60 help=
"Set the directory to run the pipeline in (overwrites any value in the config.ini file)",
68 help=
"A pulsar name to search for rather than all pulsars given in a parameter file directory (this can be specified multiple times to search for more than one pulsar).",
71opts = parser.parse_args()
80 cp.readfp(open(inifile))
82 print(
"Error... problem parsing '%s' configuration file" % inifile, file=sys.stderr)
85if opts.runpath
is not None:
86 cp.set(
"analysis",
"run_dir", opts.runpath)
90 automated = cp.getboolean(
"analysis",
"autonomous")
95submitdag = opts.condor_submit
98 submitdag = cp.getboolean(
"analysis",
"submit_dag")
103dag = knope.knopeDAG(cp, inifile, pulsarlist=opts.pulsarlist)
104if dag.error_code != 0:
105 if dag.error_code
in knope.KNOPE_ERROR.keys():
106 print(knope.KNOPE_ERROR[dag.error_code], file=sys.stderr)
108 print(
"Error... unrecognised error code!", file=sys.stderr)
111 if not automated
or dag.error_code != knope.KNOPE_ERROR_NO_SEGMENTS:
112 sys.exit(dag.error_code)
115if not automated
or dag.error_code != knope.KNOPE_ERROR_NO_SEGMENTS:
116 dag.write_sub_files()
119 print(
"Successfully created DAG file: '%s'" % dag.get_dag_file())
122 from subprocess
import Popen
124 x = Popen([
"condor_submit_dag", dag.get_dag_file()])
126 if x.returncode == 0:
127 print(
"Submitted DAG file")
129 print(
"Unable to submit DAG file")
131 print(
"Run 'condor_submit_dag %s' to submit DAG file" % dag.get_dag_file())
134 if cp.has_option(
"analysis",
"pickle_file"):
136 pfile = cp.get(
"analysis",
"pickle_file")
137 fp = open(pfile,
"wb")
141 print(
"Warning... could not output analysis class to pickle file")
143 print(
"No new science segments found in current time frame")