Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small bug: not loading data with sherpa without declaring a systematics dictionary #164

Closed
cosimoNigro opened this issue Oct 8, 2024 · 0 comments · Fixed by #165
Closed

Comments

@cosimoNigro
Copy link
Owner

There is a small bug that prevents loading flux points with sherpa without using a dictionary for systematics.

The simple snippet

import astropy.units as u
import pkg_resources
from agnpy.fit import load_sherpa_flux_points

sed_path = pkg_resources.resource_filename("agnpy", "data/mwl_seds/Mrk421_2011.ecsv")

# define minimum and maximum energy to be used in the fit
E_min = (1e11 * u.Hz).to("eV", equivalencies=u.spectral())
E_max = 100 * u.TeV

sed = load_sherpa_flux_points(sed_path, E_min, E_max)

gives

---------------------------------------------------------------------------
UnboundLocalError                         Traceback (most recent call last)
Cell In[5], line 7
      4 E_min = (1e11 * u.Hz).to("eV", equivalencies=u.spectral())
      5 E_max = 100 * u.TeV
----> 7 sed = load_sherpa_flux_points(sed_path, E_min, E_max)

File ~/work/agnpy/master/agnpy/agnpy/fit/data.py:59, in load_sherpa_flux_points(sed_path, E_min, E_max, systematics_dict)
     57     y = np.append(y, e2dnde)
     58     y_err_stat = np.append(y_err_stat, (e2dnde_errn + e2dnde_errp) / 2)
---> 59     y_err_syst = np.append(y_err_syst, e2dnde_err_syst)
     61 sed = Data1D("sed", x, y, staterror=y_err_stat, syserror=np.asarray(y_err_syst))
     63 # set the minimum energy to be used for the fit

UnboundLocalError: local variable 'e2dnde_err_syst' referenced before assignment

I am fixing it right now...

@cosimoNigro cosimoNigro changed the title Small bug with declaration of systematics dictionary in Small bug with loading data with sherpa wihout declaration of systematics dictionary Oct 8, 2024
@cosimoNigro cosimoNigro changed the title Small bug with loading data with sherpa wihout declaration of systematics dictionary Small bug: not loading data with sherpa without declaring a systematics dictionary Oct 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant