From 6f3fba36ef22de456af71844e9428e921daf6683 Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Fri, 24 Nov 2017 23:43:33 +0800 Subject: astro/wsclean.py: Use randonly generated temporary directory Therefore the conflict that running multiple WSClean's on the same MeasurementSet can be avoided. --- astro/oskar/wsclean.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'astro/oskar') diff --git a/astro/oskar/wsclean.py b/astro/oskar/wsclean.py index 511bb70..eeceb22 100755 --- a/astro/oskar/wsclean.py +++ b/astro/oskar/wsclean.py @@ -16,6 +16,7 @@ import re import argparse import subprocess import time +import tempfile def printlog(msg, logfile=None, **kwargs): @@ -28,11 +29,24 @@ def printlog(msg, logfile=None, **kwargs): def wsclean(args, dryrun=False, logfile=None): - # NOTE: Convert all arguments to strings - cmd = ["wsclean"] + [str(arg) for arg in args] + """ + Run the WSClean imager with the provided arguments. + + All the WSClean output is also captured and tee'd into a log file if + specified. However, the finer progress report of WSClean does not work + due to the buffered I/O ... + + A randomly generated temporary directory is specified, to avoid the + conflict when running multiple WSClean's on the same MeasurementSet. + """ + tmpdir = tempfile.TemporaryDirectory() + cmd = [ + "wsclean", "-tempdir", tmpdir.name, + ] + [str(arg) for arg in args] # NOTE: Convert all arguments to strings printlog("CMD: %s" % " ".join(cmd), logfile=logfile) if dryrun: print(">>> DRY RUN MODE <<<") + tmpdir.cleanup() return t1 = time.perf_counter() @@ -51,6 +65,7 @@ def wsclean(args, dryrun=False, logfile=None): logfile=logfile) printlog("-----------------------------------------------------------", logfile=logfile) + tmpdir.cleanup() def main(): @@ -133,7 +148,6 @@ def main(): "-log-time", "-pol", "XX", # OSKAR "Scalar" simulation only give "XX" component "-make-psf", # always make the PSF, even no cleaning performed - "-tempdir", "/tmp", ] if args.dirty: -- cgit v1.2.2