From 1d30baa73e8507021e6b515dac3499c2f1d816c4 Mon Sep 17 00:00:00 2001 From: Jürgen Knödlseder Date: Fri, 3 Feb 2017 12:39:56 +0100 Subject: [PATCH] Support handling of difference unit in show_lightcurve.py script --- examples/show_lightcurve.py | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/examples/show_lightcurve.py b/examples/show_lightcurve.py index ea0788d..501707f 100755 --- a/examples/show_lightcurve.py +++ b/examples/show_lightcurve.py @@ -47,12 +47,28 @@ def plot_lightcurve(filename, plotfile): # Read spectrum file fits = gammalib.GFits(filename) table = fits.table(1) + + # Extract standard columns c_mjd = table['MJD'] c_emjd = table['e_MJD'] - c_flux = table['EnergyFlux'] - c_eflux = table['e_EnergyFlux'] c_ts = table['TS'] - c_upper = table['EFluxUpperLimit'] + + # Extract columns dependent on flux type + if table.contains('EnergyFlux'): + c_flux = table['EnergyFlux'] + c_eflux = table['e_EnergyFlux'] + c_upper = table['EFluxUpperLimit'] + ylabel = r'E $\times$ dN/dE (erg cm$^{-2}$ s$^{-1}$)' + elif table.contains('PhotonFlux'): + c_flux = table['PhotonFlux'] + c_eflux = table['e_PhotonFlux'] + c_upper = table['FluxUpperLimit'] + ylabel = r'N(E) (ph cm$^{-2}$ s$^{-1}$)' + else: + c_flux = table['Prefactor'] + c_eflux = table['e_Prefactor'] + c_upper = table['DiffUpperLimit'] + ylabel = r'dN/dE (cm$^{-2}$ s$^{-1}$ MeV$^{-1}$)' # Initialise arrays to be filled mjd = [] @@ -97,7 +113,7 @@ def plot_lightcurve(filename, plotfile): plt.errorbar(ul_mjd, ul_flux, xerr=[ul_e_mjd, ul_e_mjd], yerr=ul_e_flux, uplims=True, fmt='ro') plt.xlabel('MJD (days)') - plt.ylabel(r'E $\times$ dN/dE (erg cm$^{-2}$ s$^{-1}$)') + plt.ylabel(ylabel) # Show figure if len(plotfile) > 0: -- libgit2 0.21.4