diff options
author | Aaron LI <aly@aaronly.me> | 2017-11-24 23:43:33 +0800 |
---|---|---|
committer | Aaron LI <aly@aaronly.me> | 2017-11-24 23:45:26 +0800 |
commit | 6f3fba36ef22de456af71844e9428e921daf6683 (patch) | |
tree | f1bb521ea604b76040f6e0a9b9e0017bd54c8453 /astro | |
parent | 93e91a746eee022d9ac50849c9450456e2aad7a8 (diff) | |
download | atoolbox-6f3fba36ef22de456af71844e9428e921daf6683.tar.bz2 |
astro/wsclean.py: Use randonly generated temporary directory
Therefore the conflict that running multiple WSClean's on the same
MeasurementSet can be avoided.
Diffstat (limited to 'astro')
-rwxr-xr-x | astro/oskar/wsclean.py | 20 |
1 files changed, 17 insertions, 3 deletions
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: |