ratt-ru / pfb-imaging

Preconditioned forward/backward clean algorithm
MIT License
6 stars 5 forks source link

image_convolver not seeing beam parameters in FITS file #35

Closed o-smirnov closed 3 years ago

o-smirnov commented 3 years ago

I'm trying to reconvolve a restored image to a lower resolution (15"). I hope I'm doing this correctly:

(cc) oms@young:~/projects/Shapley/selfcal-shap1/a3562$ image_convolver.py -image ../delaycal-old/A3562-delay-mask-MFS-image.fits -o a3562-15sec.image.fits -bm powerbeam.fits -pp 0.00416 0.00416 0

Input Options:
image  =  ../delaycal-old/A3562-delay-mask-MFS-image.fits
output_filename  =  a3562-15sec.image.fits
psf_pars  =  [0.00416, 0.00416, 0.0]
ncpu  =  96
circ_psf  =  False
beam_model  =  powerbeam.fits
pb_min  =  0.05

Using 96 threads

No psf parameters in fits file. Convolving model to resolution specified by psf-pars.
Using emaj = 4.16e-03, emin = 4.16e-03, PA = 0.00e+00 

Wrote clean psf to a3562-15sec.image.fits.clean_psf.fits 

Wrote convolved model to a3562-15sec.image.fits.convolved.fits 

All done here
(cc) oms@young:~/projects/Shapley/selfcal-shap1/a3562$ fitstool.py -H ../delaycal-old/A3562-delay-mask-MFS-image.fits | grep ^BM
BMAJ    =  0.00177446038226821                                                  
BMIN    =    0.001668472818617                                                  

I'm confused why it says there are no PSF parameters in the FITS file -- they're in there.

I guess it just takes a 15"x15" Gaussian and convolves with that in this case? But then the resulting resolution will be lower than 15", since the original image already had a characteristic resolution in it.

What I'd really like it to do is to work out a Gausaain kernel needed to down the resolution to 15" (based on the current PSF paremetrs), and apply that.

landmanbester commented 3 years ago

Did you pass in the psf_pars manually? Its looking for these keywords

nchan = freqs.size
psf_pars = {}
for i in range(1,nchan+1):
    key = 'BMAJ' + str(i)
    if key in hdr.keys():
        emaj = hdr[key]
        emin = hdr['BMIN' + str(i)]
        pa = hdr['BPA' + str(i)]
        psf_pars[i] = (emaj, emin, pa)

If they are in there it is probably a bug. Are these images from wsclean? If so how did you make the cube?

o-smirnov commented 3 years ago

Ah I see the bug. It's a single MFS image not a cube, so the beam keywords do not have numbers.

But the rest of the functionality is as I assume, correct? If it does find the beam size keywords, it will convolve by the required amount to inflate the PSF to 15"?

landmanbester commented 3 years ago

Yep, correct. Note you can only ever lower the resolution

o-smirnov commented 3 years ago

Well yes, it would be pretty magical otherwise...

landmanbester commented 3 years ago

@o-smirnov what about this one? It should be fixed but haven't tested it myself. Were you trying to convolve a single image to a resolution specified by psf_pars?

o-smirnov commented 3 years ago

Yep. And that seemed to work fine.