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

Background subtraction test failed #7

Closed botteon closed 3 years ago

botteon commented 3 years ago

Hi,

I've cloned the latest version of pyproffit, the test_script.py fails with "Background subtraction test failed". The fail is due to the fact that the condition at https://github.com/domeckert/pyproffit/blob/2425151f1d672492543dddbd82cf6d9af73b577d/validation/test_script.py#L124 is not satisfied for one element of the array:

In [22]: np.abs(np.log(dop[:,:6]/test_sb))>1e-3                                                                                                             
Out[22]: 
array([[False, False, False, False, False, False],
       [False, False, False, False, False, False],
       [False, False, False, False, False, False],
       [False, False, False, False, False, False],
       [False, False, False, False, False, False],
       [False, False, False, False, False, False],
       [False, False, False, False, False, False],
       [False, False, False, False, False, False],
       [False, False, False, False, False, False],
       [False, False, False, False, False, False],
       [False, False, False, False, False, False],
       [False, False, False, False, False, False],
       [False, False, False, False, False, False],
       [False, False, False, False, False, False],
       [False, False, False, False, False, False],
       [False, False, False, False, False, False],
       [False, False, False, False, False, False],
       [False, False, False, False, False, False],
       [False, False, False, False, False, False],
       [False, False, False, False, False, False],
       [False, False, False, False, False, False],
       [False, False, False, False, False, False],
       [False, False, False, False, False, False],
       [False, False, False, False, False, False],
       [False, False, False, False, False, False],
       [False, False, False, False, False, False],
       [False, False, False, False, False, False],
       [False, False, False, False, False, False],
       [False, False, False, False, False, False],
       [False, False, False, False, False, False],
       [False, False, False, False, False, False],
       [False, False, False, False, False, False],
       [False, False, False, False, False, False],
       [False, False,  True, False, False, False],
       [False, False, False, False, False, False]])
monamolham commented 3 years ago

Yea It happened with me too, I commented this if condition and the rest of the test worked fine

domeckert commented 3 years ago

Thanks for pointing out this issue, I'll look into it

monamolham commented 3 years ago

Hi, I found that It gives error if I tried to plot subtracted bkg, giving the next error messages..

prof.Plot(model=mod, axes=[4., 5., 1e-5, 1e-3])

File "/home/mona/.local/lib/python3.6/site-packages/pyproffit/profextract.py", line 801, in Plot ymin = np.min(chi[reg]) - 1. File "<__array_function__ internals>", line 6, in amin File "/home/mona/.local/lib/python3.6/site-packages/numpy/core/fromnumeric.py", line 2831, in amin keepdims=keepdims, initial=initial, where=where) File "/home/mona/.local/lib/python3.6/site-packages/numpy/core/fromnumeric.py", line 87, in _wrapreduction return ufunc.reduce(obj, axis, dtype, out, **passkwargs) ValueError: zero-size array to reduction operation minimum which has no identity

domeckert commented 3 years ago

Hi @monamolham

Looking into the code, I think this means that there is no data in the range of interest (here, 4-5 arcmin). Here are the corresponding lines of code:

if axes is None: ax2.axis([xmin, xmax, ylim[0], ylim[1]]) else: xmin = axes[0] xmax = axes[1] reg = np.where(np.logical_and(rads>=xmin, rads<=xmax)) ymin = np.min(chi[reg]) - 1.

If "reg" has a size of zero (i.e. there are no active radii between xmin and xmax) it will not be possible to determine the boundary of the plot, obviously. Just try to extend the range along the x axis and that should solve your problem, i.e. this is not a bug.

monamolham commented 3 years ago

Hi, sorry yes it is working fine now when I changed range...Thanks :)

domeckert commented 3 years ago

Thanks for the update. Closing