diff --git a/CEP/PyBDSM/src/python/functions.py b/CEP/PyBDSM/src/python/functions.py index 16e7939d6586cc31c124891e733bf0aece02b0a6..61d6fa6417bf32f8e581ed17a77d479213f92d0d 100755 --- a/CEP/PyBDSM/src/python/functions.py +++ b/CEP/PyBDSM/src/python/functions.py @@ -1105,7 +1105,7 @@ def read_image_from_file(filename, img, indir, quiet=False): mylogger.userinfo(mylog, "Opened '"+image_file+"'") if img.use_io == 'rap': data = inputimage.getdata() - data, hdr = convert_pyrap_header(inputimage) + hdr = convert_pyrap_header(inputimage) if img.use_io == 'fits': data = fits[0].data hdr = fits[0].header diff --git a/CEP/PyBDSM/src/python/readimage.py b/CEP/PyBDSM/src/python/readimage.py index 82b5780c4f9aecbefebde74fcb2459d72eb45c30..fa7d58263a845fe3760bf657561646edc37eb32c 100644 --- a/CEP/PyBDSM/src/python/readimage.py +++ b/CEP/PyBDSM/src/python/readimage.py @@ -234,48 +234,48 @@ class Op_readimage(Op): if img.opts.beam is not None: beam = img.opts.beam else: - if img.use_io == 'rap': - iminfo = hdr['imageinfo'] - if iminfo.has_key('restoringbeam'): - beaminfo = iminfo['restoringbeam'] - if beaminfo.has_key('major') and beaminfo.has_key('minor') and beaminfo.has_key('major'): - bmaj = beaminfo['major']['value'] - bmin = beaminfo['minor']['value'] - bpa = beaminfo['positionangle']['value'] - # make sure all values are in degrees - if beaminfo['major']['unit'] == 'arcsec': - bmaj = bmaj / 3600.0 - if beaminfo['minor']['unit'] == 'arcsec': - bmin = bmin / 3600.0 - if beaminfo['major']['unit'] == 'rad': - bmaj = bmaj * 180.0 / N.pi - if beaminfo['minor']['unit'] == 'rad': - bmin = bmin * 180.0 / N.pi - beam = (bmaj, bmin, bpa) # all degrees - found = True - if img.use_io == 'fits': - try: - beam = (hdr['BMAJ'], hdr['BMIN'], hdr['BPA']) - found = True - except: - ### try see if AIPS as put the beam in HISTORY as usual - for h in hdr.get_history(): - # Check if h is a string or a FITS Card object (long headers are - # split into Cards as of PyFITS 3.0.4) - if not isinstance(h, str): - hstr = h.value - else: - hstr = h - if N.all(['BMAJ' in hstr, 'BMIN' in hstr, 'BPA' in hstr, 'CLEAN' in hstr]): +# if img.use_io == 'rap': +# iminfo = hdr['imageinfo'] +# if iminfo.has_key('restoringbeam'): +# beaminfo = iminfo['restoringbeam'] +# if beaminfo.has_key('major') and beaminfo.has_key('minor') and beaminfo.has_key('major'): +# bmaj = beaminfo['major']['value'] +# bmin = beaminfo['minor']['value'] +# bpa = beaminfo['positionangle']['value'] +# # make sure all values are in degrees +# if beaminfo['major']['unit'] == 'arcsec': +# bmaj = bmaj / 3600.0 +# if beaminfo['minor']['unit'] == 'arcsec': +# bmin = bmin / 3600.0 +# if beaminfo['major']['unit'] == 'rad': +# bmaj = bmaj * 180.0 / N.pi +# if beaminfo['minor']['unit'] == 'rad': +# bmin = bmin * 180.0 / N.pi +# beam = (bmaj, bmin, bpa) # all degrees +# found = True +# if img.use_io == 'fits': + try: + beam = (hdr['BMAJ'], hdr['BMIN'], hdr['BPA']) + found = True + except: + ### try see if AIPS as put the beam in HISTORY as usual + for h in hdr.get_history(): + # Check if h is a string or a FITS Card object (long headers are + # split into Cards as of PyFITS 3.0.4) + if not isinstance(h, str): + hstr = h.value + else: + hstr = h + if N.all(['BMAJ' in hstr, 'BMIN' in hstr, 'BPA' in hstr, 'CLEAN' in hstr]): + try: + dum, dum, dum, bmaj, dum, bmin, dum, bpa = hstr.split() + except ValueError: try: - dum, dum, dum, bmaj, dum, bmin, dum, bpa = hstr.split() + dum, dum, bmaj, dum, bmin, dum, bpa, dum, dum = hstr.split() except ValueError: - try: - dum, dum, bmaj, dum, bmin, dum, bpa, dum, dum = hstr.split() - except ValueError: - break - beam = (float(bmaj), float(bmin), float(bpa)) - found = True + break + beam = (float(bmaj), float(bmin), float(bpa)) + found = True if not found: raise RuntimeError("No beam information found in image header.") ### convert beam into pixels (at image center)