Convenience functions


naima.generate_energy_edges(ene, groups=None)[source]

Generate energy bin edges from given energy array.

Generate an array of energy edges from given energy array to be used as abcissa error bar limits when no energy uncertainty or energy band is provided.

eneastropy.units.Quantity array instance

1-D array of energies with associated phsyical units.

energy_err_lo, energy_error_hiastropy.units.Quantity arrays

Arrays of low and high energy edges corresponding to each given energy of the input array.

naima.build_data_table(energy, flux, flux_error=None, flux_error_lo=None, flux_error_hi=None, energy_width=None, energy_lo=None, energy_hi=None, ul=None, cl=None)[source]

Read data into data dict.

energyQuantity array instance

Observed photon energy array [physical type energy]

fluxQuantity array instance

Observed flux array [physical type flux or differential flux]

flux_error, flux_error_hi, flux_error_loQuantity
array instance

68% CL gaussian uncertainty of the flux [physical type flux or differential flux]. Either flux_error (symmetrical uncertainty) or flux_error_hi and flux_error_lo (asymmetrical uncertainties) must be provided.

energy_width, energy_lo, energy_hiQuantity array
instance, optional

Width of the energy bins [physical type energy]. Either energy_width (bin width) or energy_lo and energy_hi (Energies of the lower and upper bin edges) can be provided. If none are provided, generate_energy_edges will be used.

ulboolean or int array, optional

Boolean array indicating which of the flux values given in flux correspond to upper limits.

clfloat, optional

Confidence level of the flux upper limits given by ul.


Data stored in an astropy Table.

naima.sed_conversion(energy, model_unit, sed)[source]

Manage conversion between differential spectrum and SED

naima.estimate_B(xray_table, vhe_table, photon_energy_density=<Quantity 0.261 eV / cm3>)[source]

Estimate magnetic field from synchrotron to Inverse Compton luminosity ratio

Estimate the magnetic field from the ratio of X-ray to gamma-ray emission according to:

\[\frac{L_\mathrm{xray}}{L_\gamma} = \frac{u_\mathrm{B}}{u_\mathrm{ph}} = \frac{B^2}{ 8 \pi u_\mathrm{ph}}\]

where \(L_\mathrm{xray}\) is the X-ray luminosity, \(L_\gamma\) is the gamma-ray luminosity, and \(u_\mathrm{ph}\) is the seed photon field energy density.

Note that this assumes that the ratio of observed fluxes is equal to the ratio of bolometric synchrotron and IC luminosities, and that IC proceeds in the Thomson regims. This assumption is safe as long as the X-ray and gamma-ray emission contain the bulk of the bolometric emission (i.e., the peak in the SED is in the X-ray and gamma-ray observed bands). Even if the assumption does not hold, this is a good starting point for the magnetic field when doing simultaneous X-ray and gamma-ray spectral fits.


Data table (see Data format for details on the format) containing the X-ray spectrum.


Data table (see Data format for details on the format) containing the HE/VHE gamma-ray spectrum.

photon_energy_densityQuantity float, optional

Energy density of the seed photon field for IC emission. Defaults to 0.261 eV/cm3, the energy density of the CMB.

BQuantity float

Estimate of the magnetic flux density at the emitter.