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

different best fit parameters found using chi statistics #15

Open poonh opened 2 years ago

poonh commented 2 years ago

I fit my data with single beta model, using chi statistics, and I find the best fitting rc varies greatly on the binsize(the maximum I used is 30 arcsecs). Sometimes even negative values for rc are found. When I test with simulated data, I find the smaller the binsize, the more accurate the fitting parameters are. I find the problem lies in models.py. In the program,

def BetaModel(x, beta, rc, norm, bkg)

The input x is the mid point of each bin. If the binsize is small enough, the change in each bin is very close to linear, and it is ok to use the mid point as the average. But as the binsize gets large, the change inside each bin is less linear. That's why the best-fit parameters found differ a lot with different binsize. I changed the input x to the Profile object, and retrieve the relevant parameters in the BetaModel function so that "out" is calculated in exactly the same way as it is in SBProfile. It takes a lot longer, around 1 hour for XMM Newton data with a 900*900 pixel image.

domeckert commented 2 years ago

Thanks, I am aware of this point, it is clear that we are currently making the assumption that the model is constant within each bin, which may not be true when the bin size is large.

The correct way of proceeding would be to integrate the model within the bin, which is what we are doing in practice. This would be a little faster than what you suggest, but still much slower than what we are currently doing. One possible solution would be to have the model integration as an option and keep the point evaluation as default, as in the vast majority of cases it is good enough. In the meantime, for your own problem I suggest you to use narrower bins and fit the data with C-stat, which will work even in the low-count regime.