cosimoNigro / agnpy

Modelling jetted Active Galactic Nuclei radiative processes with python
https://agnpy.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
48 stars 33 forks source link

Error on synchrotron from interplated distribution #161

Open IlariaViale opened 4 months ago

IlariaViale commented 4 months ago

Hi all,

I was trying to compute the synchrotron emission from a distribution of electrons defined through the InterpolatedDistribution of agnpy. However, at the line sed_synch = synch.sed_flux(nu_grid) (where nu_grid = np.logspace(9, 27) * u.Hz) I obtain the following error (I am using a jupyter notebook):

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[25], line 5
      2 nu_grid = np.logspace(9, 27) * u.Hz
      4 # compute a synchrotron, and a self-absorbed synchrotron SED
----> 5 sed_synch = synch.sed_flux(nu_grid)
      6 sed_synch_ssa = synch_ssa.sed_flux(nu_grid)

File /sw_fermipy/mambaforge/envs/agnpy-tutorial/lib/python3.9/site-packages/agnpy/synchrotron/synchrotron.py:231, in Synchrotron.sed_flux(self, nu)
    220 def sed_flux(self, nu):
    221     r"""Evaluates the synchrotron flux SED for a Synchrotron object built
    222     from a Blob."""
    223     return self.evaluate_sed_flux(
    224         nu,
    225         self.blob.z,
    226         self.blob.d_L,
    227         self.blob.delta_D,
    228         self.blob.B,
    229         self.blob.R_b,
    230         self.blob.n_e,
--> 231         *self.blob.n_e.parameters,
    232         ssa=self.ssa,
    233         integrator=self.integrator,
    234         gamma=self.blob.gamma_e,
    235     )

AttributeError: 'InterpolatedDistribution' object has no attribute 'parameters'

I obtain the same also when trying to compute sed_synch_ssa = synch_ssa.sed_flux(nu_grid), sed_ssc = ssc.sed_flux(nu_grid), and sed_ssc_ssa = ssc_ssa.sed_flux(nu_grid).

cosimoNigro commented 1 month ago

Dear @IlariaViale,

I am very sorry for the late reply. To me it's working without those errors.

Is there any chance that you are using an older version that does not contain the fixes in https://github.com/cosimoNigro/agnpy/pull/145? Seems to me the parameters attribute was added there.

Or maybe we did the latest release (that I assumed you installed via conda) before fixing this! Using the dev version should fix this.