fermiPy / fermipy

Fermi-LAT Python Analysis Framework
http://fermipy.readthedocs.org/
BSD 3-Clause "New" or "Revised" License
51 stars 53 forks source link

Different SED error-bars from plots generated by write_roi and its FITS file: Fermipy v1.0.1 #426

Closed PankajK-APDF closed 1 year ago

PankajK-APDF commented 3 years ago

With the Fermipy v1.0.1 version, I am getting huge error bars in a few bins e.g. 2-3 GeV, 3-4, 10-20 GeV, 20 - 30 GeV, and GeV (in general, energy-range: 2 -- 30 GeV) on the SED data points when plotting the FITS and NPY file that were saved using module "gta.write_roi" compared to the SED plots produced using the same module with "make_plots=True" keyword. Please see the attached plots (black: gta.write_roi generated with "make_plots=True"; Orange: Plotted using Matplotlib from the FITS file produced by "gta.write_roi").

LAT_sed_check 4fgl_j0854 8+2006_sed

I checked this for all the SED that I generated for my ICRC2021 proceeding (https://pos.sissa.it/395/644/) and the issue appears for the bins in the energy range: 2 -- 30 GeV

This is what I am doing within python for plotting the SED

`sed_tab = table.Table.read('4fgl_j0854.8+2006_sed.fits') tsMask = sed_tab['ts'] < 4.0 ## used by fermipy internally sedMask = NP.invert(tsMask)

sedDat = sed_tab['e2dnde'][sedMask] sed_eRef = sed_tab['e_ref'][sedMask] sedDatErr = sed_tab['e2dnde_err'][sedMask]

plt.errorbar(sed_eRef, sedDat, yerr=sedDatErr, xerr=[e_erLo[sedMask], e_erHi[sedMask]], fmt='o')`

henrikef commented 1 year ago

@PankajK-APDF Sorry for not getting back to you on this earlier. Is this still an issue for fermipy 1.2, fermitools 2.2 with the newer versions of astropy?

omodei commented 1 year ago

You are using the symmetric error instead of asymmetric errors. In the SED dictionary, you are using "e2dnde_err" while "gta.write_roi" (which call plot_flux_points](https://github.com/fermiPy/fermipy/blob/fbd4c95ffadbff31cbb9cc862ff84a78dc734ef5/fermipy/plotting.py#L745) uses 'e2dnde_err_lo' and 'e2dnde_err_hi'.