aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron LI <aly@aaronly.me>2017-11-24 23:43:33 +0800
committerAaron LI <aly@aaronly.me>2017-11-24 23:45:26 +0800
commit6f3fba36ef22de456af71844e9428e921daf6683 (patch)
treef1bb521ea604b76040f6e0a9b9e0017bd54c8453
parent93e91a746eee022d9ac50849c9450456e2aad7a8 (diff)
downloadatoolbox-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.
-rwxr-xr-xastro/oskar/wsclean.py20
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: