diff --git a/CEP/PyBDSM/src/python/collapse.py b/CEP/PyBDSM/src/python/collapse.py index 8fdfe4a65b56d9b9606d95f44360507c7992f88a..62d78d6df2f188c386b999bd34940e9980430558 100644 --- a/CEP/PyBDSM/src/python/collapse.py +++ b/CEP/PyBDSM/src/python/collapse.py @@ -146,6 +146,7 @@ class Op_collapse(Op): if img.opts.blank_limit is not None or check_low: import scipy + import sys if check_low: threshold = 1e-5 else: @@ -153,7 +154,10 @@ class Op_collapse(Op): mylogger.userinfo(mylog, "Blanking pixels with values " "below %.1e Jy/beam" % (threshold,)) bad = (abs(image) < threshold) + original_stdout = sys.stdout # keep a reference to STDOUT + sys.stdout = func.NullDevice() # redirect the real STDOUT count = scipy.signal.convolve2d(bad, N.ones((3, 3)), mode='same') + sys.stdout = original_stdout # turn STDOUT back on mask_low = (count >= 5) if check_low: nlow = len(N.where(mask_low)[0]) diff --git a/CEP/PyBDSM/src/python/functions.py b/CEP/PyBDSM/src/python/functions.py index c1d633280c839965230dacebe2d79e915680aa08..d88f0c6622f38684b7e0f618aeaa708df7227f91 100755 --- a/CEP/PyBDSM/src/python/functions.py +++ b/CEP/PyBDSM/src/python/functions.py @@ -1209,8 +1209,10 @@ def read_image_from_file(filename, img, indir, quiet=False): # Check for incorrect spectral units. For example, "M/S" is not # recognized by PyWCS as velocity ("S" is actually Siemens, not - # seconds). - for i in range(naxis): + # seconds). Note that we check CUNIT3 and CUNIT4 even if the + # image has only 2 axes, as the header may still have these + # entries. + for i in range(4): key_val_raw = hdr.get('CUNIT' + str(i+1)) if key_val_raw != None: if 'M/S' in key_val_raw or 'm/S' in key_val_raw or 'M/s' in key_val_raw: