oslocyclotronlab / ompy

A python implementation of the Oslo method
https://ompy.readthedocs.io
GNU General Public License v3.0
6 stars 7 forks source link

Erroneous error message in `Extractor.decompose: AssertionError: Ex and Eg must have the same bin width #181

Closed tellefs closed 3 years ago

tellefs commented 3 years ago

I currently get the error

---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
<ipython-input-21-aa77797cdd86> in <module>
     12 trapezoid_cut.act_on(std)
     13 
---> 14 product = extractor.decompose(mat, std, product=True)[2]
     15 fig, ax = plt.subplots(2,1)
     16 om.normalize_rows(mat.values)

~/ompy/ompy/extractor.py in decompose(self, matrix, std, x0, product)
    243         dEx = matrix.Ex[1] - matrix.Ex[0]
    244         dEg = matrix.Eg[1] - matrix.Eg[0]
--> 245         assert dEx == dEg, \
    246             "Ex and Eg must have the same bin width. Currently they have"\
    247             f"dEx: {dEx:.1f} and dEg: {dEg:.1f}. You have to rebin.\n"\

AssertionError: Ex and Eg must have the same bin width. Currently they havedEx: 200.0 and dEg: 200.0. You have to rebin.
The `ensemble` class has a `rebin` method.

when trying to create the FG matrix from the extracted NLD and gSF.

I havent looked deep into it yet, but the error seems weird, given that they actually have the same bin-width, which is also printed.

fzeiser commented 3 years ago

I guess it's a float point error. Probably it should not be an assert equal statement, but something like numpy.isclose