From 7e7614fbc9ad0f6cb3e65912134069082109fd6e Mon Sep 17 00:00:00 2001 From: tlatorre Date: Mon, 3 Dec 2018 10:04:24 -0600 Subject: add script to run multiple fits --- src/run-fit | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 src/run-fit (limited to 'src/run-fit') diff --git a/src/run-fit b/src/run-fit new file mode 100755 index 0000000..d987c37 --- /dev/null +++ b/src/run-fit @@ -0,0 +1,29 @@ +#!/usr/bin/env python +from __future__ import print_function, division +import subprocess +from os.path import splitext + +def run_fit(filename): + root, ext = splitext(filename) + output = root + '.txt' + cmd = ["./fit", filename, "-o", output] + subprocess.call(cmd) + +if __name__ == '__main__': + import argparse + from multiprocessing import Pool, cpu_count + + parser = argparse.ArgumentParser("fit multiple zdab files") + parser.add_argument("-j", "--jobs", type=int, default=None, + help="number of jobs") + parser.add_argument("filenames", nargs="+", + help="zdab files") + args = parser.parse_args() + + jobs = args.jobs + + if jobs is None: + jobs = cpu_count() + + p = Pool(jobs) + p.map(run_fit,args.filenames) -- cgit