domeckert / pyproffit

Pyproffit is a Python code for the analysis of X-ray brightness profiles from clusters of galaxies
GNU General Public License v3.0
18 stars 4 forks source link

about psf convolution into profile directly #17

Closed poonh closed 2 years ago

poonh commented 2 years ago

In fitting.py, when you make a fit, it is possible to convolve in the psf in the model,

 if self.psfmat is not None:
            ym = np.dot(self.psfmat, ym)

Here ym is the profile from models.py. But actually the psf is only convolved in the counts. I tested with simulated data, and tried 1)the original method in which psf is convolved in the profile directly, and 2) convolve the psf in the counts first and derive the profile using psf convolved counts divided by (effective area*exposure). The two give noticeably different best-fit parameters. I modified the code so that the psf is only convolved in the counts in fitting.py.

domeckert commented 2 years ago

Thanks for your report. What you are saying here comes as a surprise, as I have tested the PSF convolution part of the code extensively and I did not find such a difference. The point to be made here is that the PSF convolution matrix is not diagonal and when convolving the counts or the surface brightness, it needs to be used differently. When using the counts the total number of photons should be preserved, which is achieved by using the transposed matrix. Conversely, the surface brightness is not necessarily preserved and the matrix itself should be used.

I have tested this part and just did it again, it appears that the two methods (once with the matrix and once with the transposed matrix) reproduce the expected profile (2D convolved) within 1%, see the plot below

image

poonh commented 2 years ago

Thank you so much, Dominique. I think the problem is I confuse the transposed matrix with the matrix itself. This part is actually a little bit difficult for me to understand and I need to study further. Thanks for giving me guidelines about what direction to go!

domeckert commented 2 years ago

Thanks for looking into this, it is always good to double check. I think the current implementation in the code is correct. There is an issue at large radii (as you can see above) which is due to the photons scattered outside of the radial range of interest, I was aware of the issue but I don't know yet how to fix it.

Closing this particular issue.

poonh commented 2 years ago

I know the mathematics by reading the code, though I still don't quite understand the physics. Now with your guidance, I just tested successfully with simulated data. I convolved in the transposed psf to the counts first, and then derived the profile. Then I compared with the profile with the psf matrix convolved in directly. The two are identical. Your help is precious. And I learnt more now.