The Jorsater-van Moorsel method
This is a method for correcting for flux in images. For a cleaned cube, the flux is:
G = C + R
where C is the cleaned map and R is the residual map. However, they have different units (Jy/clean beam and Jy/dirty beam). We have to estimate the difference in area between the clean beam and the dirty beam to correct the units. This is done by scaling the residuals by some factor e (epsilon):
G_true = C + eR
In a dirty map (D), all the flux is in the "residuals" (since there is no clean component or clean beam).
G_true = eD
The solution to this equation for G (the true flux) is:
G = (C D) / (D - R)
We will have to do this channel by channel.
Determining Fluxes to use in the Jorsater van Moorsel correction
First, you have to apply your mask to the dirty map and the residual map. You DO NOT need to apply it to the C+R map. Use immask for this. You also shouldn't have to apply it to the clean component map because there will be no clean components outside the masked region.
For each region in each channel:
1) Determine the number of pixels in the region
2) Determine the number of pixels per beam (this is the same for the entire map): beam area = 1.133 FWHM_x FWHM_y, pix area = cellsize*cellsize
3) Determine the number of beams in the region using the conversion in step 2.
4) Determine the total flux in the region. Get the mean flux from imstat (<flux>) and multiply it by the number of beams in the region:
F = <flux> * nbeams
Note: in unix, "paste" will merge two files by putting each line of one next to each line of another