Convenience functions¶
API¶
- 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.
- Parameters:
- ene
astropy.units.Quantityarray instance 1-D array of energies with associated phsyical units.
- ene
- Returns:
- energy_err_lo, energy_error_hi
astropy.units.Quantityarrays Arrays of low and high energy edges corresponding to each given energy of the input array.
- energy_err_lo, energy_error_hi
- 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.
- Parameters:
- energy
Quantityarray instance Observed photon energy array [physical type
energy]- flux
Quantityarray instance Observed flux array [physical type
fluxordifferential flux]- flux_error, flux_error_hi, flux_error_lo
Quantity - array instance
68% CL gaussian uncertainty of the flux [physical type
fluxordifferential flux]. Eitherflux_error(symmetrical uncertainty) orflux_error_hiandflux_error_lo(asymmetrical uncertainties) must be provided.- energy_width, energy_lo, energy_hi
Quantityarray - instance, optional
Width of the energy bins [physical type
energy]. Eitherenergy_width(bin width) orenergy_loandenergy_hi(Energies of the lower and upper bin edges) can be provided. If none are provided,generate_energy_edgeswill be used.- ulboolean or int array, optional
Boolean array indicating which of the flux values given in
fluxcorrespond to upper limits.- clfloat, optional
Confidence level of the flux upper limits given by
ul.
- energy
- Returns:
- data
astropy.table.QTable Data stored in an astropy Table.
- data
- 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.
- Parameters:
- xray_table
Table Data table (see Data format for details on the format) containing the X-ray spectrum.
- vhe_table
Table Data table (see Data format for details on the format) containing the HE/VHE gamma-ray spectrum.
- photon_energy_density
Quantityfloat, optional Energy density of the seed photon field for IC emission. Defaults to 0.261 eV/cm3, the energy density of the CMB.
- xray_table
- Returns:
- B
Quantityfloat Estimate of the magnetic flux density at the emitter.
- B