Skip to content
Snippets Groups Projects
Commit d55efcee authored by David Rafferty's avatar David Rafferty
Browse files

Task #3403: Fix to 2D images with incorrect spectral units.

parent 8604834f
No related branches found
No related tags found
No related merge requests found
...@@ -146,6 +146,7 @@ class Op_collapse(Op): ...@@ -146,6 +146,7 @@ class Op_collapse(Op):
if img.opts.blank_limit is not None or check_low: if img.opts.blank_limit is not None or check_low:
import scipy import scipy
import sys
if check_low: if check_low:
threshold = 1e-5 threshold = 1e-5
else: else:
...@@ -153,7 +154,10 @@ class Op_collapse(Op): ...@@ -153,7 +154,10 @@ class Op_collapse(Op):
mylogger.userinfo(mylog, "Blanking pixels with values " mylogger.userinfo(mylog, "Blanking pixels with values "
"below %.1e Jy/beam" % (threshold,)) "below %.1e Jy/beam" % (threshold,))
bad = (abs(image) < 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') count = scipy.signal.convolve2d(bad, N.ones((3, 3)), mode='same')
sys.stdout = original_stdout # turn STDOUT back on
mask_low = (count >= 5) mask_low = (count >= 5)
if check_low: if check_low:
nlow = len(N.where(mask_low)[0]) nlow = len(N.where(mask_low)[0])
......
...@@ -1209,8 +1209,10 @@ def read_image_from_file(filename, img, indir, quiet=False): ...@@ -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 # Check for incorrect spectral units. For example, "M/S" is not
# recognized by PyWCS as velocity ("S" is actually Siemens, not # recognized by PyWCS as velocity ("S" is actually Siemens, not
# seconds). # seconds). Note that we check CUNIT3 and CUNIT4 even if the
for i in range(naxis): # 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)) key_val_raw = hdr.get('CUNIT' + str(i+1))
if key_val_raw != None: 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: if 'M/S' in key_val_raw or 'm/S' in key_val_raw or 'M/s' in key_val_raw:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment