mhardcastle / radioflux

Measuring radio flux density with ds9
GNU General Public License v3.0
11 stars 4 forks source link

radioflux seems to fail on WSClean images due to header issues (CROTA3) #4

Closed rvweeren closed 8 years ago

rvweeren commented 8 years ago

/usr/local/lib/python2.7/dist-packages/radioflux/radioflux.py -i -b spix_background.reg -f spix_sourceall.reg Cband_spix_taper1.2arcsec.image.tt0.conv.pbcor.fits Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/radioflux/radioflux.py", line 286, in flux_for_files(args.files,args.fgr,args.bgr,args.indiv,args.bgsub,verbose=args.verbose) File "/usr/local/lib/python2.7/dist-packages/radioflux/radioflux.py", line 247, in flux_for_files rm=radiomap(fitsfile,verbose=verbose) File "/usr/local/lib/python2.7/dist-packages/radioflux/radioflux.py", line 171, in init self.prhd.remove('CROTA%i' %i) File "/usr/local/lib/python2.7/dist-packages/astropy/io/fits/header.py", line 1542, in remove del self[self.index(keyword)] File "/usr/local/lib/python2.7/dist-packages/astropy/io/fits/header.py", line 1435, in index raise ValueError('The keyword %r is not in the header.' % keyword) ValueError: The keyword 'CROTA3' is not in the header.

rvweeren commented 8 years ago

Commenting

self.prhd.remove('CROTA%i' %i)

gets me further, but then it fails with

/usr/local/lib/python2.7/dist-packages/radioflux/radioflux.py -i -b spix_background.reg -f spix_sourceall.reg Cband_spix_taper1.2arcsec.image.tt0.conv.pbcor.fits WARNING: AstropyDeprecationWarning: The ascard function is deprecated and may be removed in a future version. Use the .cards attribute instead. [astropy.utils.decorators] WARNING: AstropyDeprecationWarning: The CardList class has been deprecated; all its former functionality has been subsumed by the Header class, so CardList objects should not be directly created. See the PyFITS 3.1.0 CHANGELOG for more details. [astropy.io.fits.card] WARNING: AstropyDeprecationWarning: The ascard function is deprecated and may be removed in a future version. Use the .cards attribute instead. [astropy.utils.decorators] Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/radioflux/radioflux.py", line 286, in flux_for_files(args.files,args.fgr,args.bgr,args.indiv,args.bgsub,verbose=args.verbose) File "/usr/local/lib/python2.7/dist-packages/radioflux/radioflux.py", line 249, in flux_for_files bg_ir=pyregion.open(bgr).as_imagecoord(rm.headers[0]) File "build/bdist.linux-x86_64/egg/pyregion/init.py", line 57, in as_imagecoord

File "build/bdist.linux-x86_64/egg/pyregion/ds9_region_parser.py", line 184, in sky_to_image File "build/bdist.linux-x86_64/egg/pyregion/wcs_helper.py", line 230, in _get_radesys

mhardcastle commented 8 years ago

Works for me with latest radioflux and LOFAR wsclean images, but I'm guessing yours is not LOFAR since it mentions Cband! Would you mind sending me a copy of the map (or a sub-region that displays the problem) and I'll try to sort it. Then I can put the image in my test suite to ensure it doesn't break in future.

(The removal of the headers is the horrible hack I have to do to get pyregion to work with reg files in WCS, since it can't cope with anything other than 2D images if WCS is used. Sometimes I think it might be easier to fix pyregion than to continue to work round it...)

rvweeren commented 8 years ago

Send you the fits image.

rvweeren commented 8 years ago

Just picked up another header issue, now for images made with new casapy tclean.

(caused by the CTYPE 4 = VOPT)

CTYPE4 = 'VOPT '
CRVAL4 = -0.000000000000E+00
CDELT4 = -1.197176371033E+08
CRPIX4 = 1.000000000000E+00
CUNIT4 = 'm/s '
PV2_1 = 0.000000000000E+00
PV2_2 = 0.000000000000E+00
RESTFRQ = 1.498588047601E+09 /Rest Frequency (Hz)
SPECSYS = 'LSRK ' /Spectral reference frame
ALTRVAL = 1.498588047601E+09 /Alternate frequency reference value
ALTRPIX = 1.000000000000E+00 /Alternate frequency reference pixel

ofar:/data5/rvweeren/MACSJ0717_JVLA/spixregions> ls ../Lband4configs/im_all_comb_1.image.tt0.pbcor.fits.gzTraceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/radioflux/radioflux.py", line 286, in flux_for_files(args.files,args.fgr,args.bgr,args.indiv,args.bgsub,verbose=args.verbose) File "/usr/local/lib/python2.7/dist-packages/radioflux/radioflux.py", line 247, in flux_for_files rm=radiomap(fitsfile,verbose=verbose) File "/usr/local/lib/python2.7/dist-packages/radioflux/radioflux.py", line 129, in init raise RadioError('Unknown CTYPE %i = %s' % (i,ctype)) main.RadioError: Unknown CTYPE 4 = VOPT

rvweeren commented 8 years ago

Just picked up another header issue, now for images made with the new casapy tclean.

(caused by the CTYPE 4 = VOPT)

CTYPE4 = 'VOPT '
CRVAL4 = -0.000000000000E+00
CDELT4 = -1.197176371033E+08
CRPIX4 = 1.000000000000E+00
CUNIT4 = 'm/s '
PV2_1 = 0.000000000000E+00
PV2_2 = 0.000000000000E+00
RESTFRQ = 1.498588047601E+09 /Rest Frequency (Hz)
SPECSYS = 'LSRK ' /Spectral reference frame
ALTRVAL = 1.498588047601E+09 /Alternate frequency reference value
ALTRPIX = 1.000000000000E+00 /Alternate frequency reference pixel

ofar:/data5/rvweeren/MACSJ0717_JVLA/spixregions> ls ../Lband4configs/im_all_comb_1.image.tt0.pbcor.fits.gzTraceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/radioflux/radioflux.py", line 286, in flux_for_files(args.files,args.fgr,args.bgr,args.indiv,args.bgsub,verbose=args.verbose) File "/usr/local/lib/python2.7/dist-packages/radioflux/radioflux.py", line 247, in flux_for_files rm=radiomap(fitsfile,verbose=verbose) File "/usr/local/lib/python2.7/dist-packages/radioflux/radioflux.py", line 129, in init raise RadioError('Unknown CTYPE %i = %s' % (i,ctype)) main.RadioError: Unknown CTYPE 4 = VOPT

mhardcastle commented 8 years ago

Try the latest version, should fix both these issues. (Though yet another hack was needed to deal with the PC... headers in the wsclean image.)

rvweeren commented 8 years ago

Yes, it works now. Thanks for the very quick response.