Data format

The observed spectra to be used as constraints for the particle distribution have to be provided to the get_sampler and run_sampler functions in the form of an astropy.table.Table object. More information on creating, reading and manipulating Table can be found in the astropy documentation.

The table needs at least these columns, with the appropriate associated units (with the physical type indicated in brackets below):

  • energy: Observed photon energy [energy]

  • flux: Observed fluxes [flux or differential flux]

  • flux_error: 68% CL gaussian uncertainty of the flux [flux or differential flux]. It can also be provided as flux_error_lo and flux_error_hi (see below).

Optional columns:

  • energy_width: Width of the energy bin [energy], or

  • energy_error: Half-width of the energy bin [energy], or

  • energy_error_lo and energy_error_hi: Distance from bin center to lower and upper bin edges [energy], or

  • energy_lo and energy_hi: Energy edges of the corresponding energy bin [energy]

  • flux_error_lo and flux_error_hi: 68% CL gaussian lower and upper uncertainties of the flux.

  • ul: Flag to indicate that a flux measurement is an upper limit. The flux error values for this measurement will be disregarded.

  • flux_ul: Upper limit to the flux. If not present, the flux column will be taken as an upper limit for those measurements with the ul flag.

The keywords metadata field of the table can be used to provide the confidence level of the upper limits with the keyword cl, which defaults to 90%. The astropy.io.ascii reader can recover all the needed information from ASCII tables in the Ecsv, Ipac, and Daophot formats, and everything except the cl keyword from tables in the SExtractor format. A data table to be used with naima can then be read with the astropy.io.ascii reader:

>>> from astropy.io import ascii
>>> data_table = ascii.read("RXJ1713_HESS_2007.dat")

The table column names, types, and units, will be read automatically from the file.

Multiple data tables

Multiple data tables can be provided to get_sampler and run_sampler as a list. Each of them has to fulfill the requirements above, but they don’t have to be in the same format, as naima will concatenate them as appropriate. If some of the tables are in differential flux and some others in energy flux, they will all be converted to the format of the first table in the list. However, this can be controlled with the data_sed argument of get_sampler, which will control whether all data tables are converted to an SED (data_sed=True) or to differential fluxes (data_sed=False).

Data table examples

Ipac

Below you can see an example of a file in Ipac format that includes all the necessary fields. This format is focused on being human readable. Everything starting with a slash and a space is a comment, and keywords are given after a slash without a space.

\ VHE gamma-ray spectrum of RX J1713.7-3946
\
\ Originally published in 2007 from 2003, 2004, and 2005 observations. The
\ spectrum here is as published in the 2011 erratum
\ Main paper: Aharonian et al. 2007, A&A 464, 235
\ Erratum: Aharonian et al. 2011, A&A 531, 1
\ Confidence level of upper limits is 2 sigma
\
\cl=0.95
|energy|energy_edge_lo|energy_edge_hi|           flux|     flux_error|  ul|
|double|        double|        double|         double|         double|long|
|   TeV|           TeV|           TeV|1 / (cm2 s TeV)|1 / (cm2 s TeV)|    |
   0.33            0.3           0.37        2.29e-10         3.2e-11    0 
    0.4           0.37           0.44        1.25e-10         1.6e-11    0 
   0.49           0.44           0.54        9.46e-11           9e-12    0 
   0.59           0.54           0.65        6.06e-11         5.2e-12    0 
   0.71           0.65           0.79        4.37e-11         3.1e-12    0 
   0.86           0.79           0.95        2.15e-11         1.8e-12    0 
   1.04           0.95           1.15        1.82e-11         1.1e-12    0 
   1.26           1.15           1.39        1.17e-11           7e-13    0 
   1.53           1.39           1.69        8.87e-12           5e-13    0 
   1.85           1.69           2.04        5.63e-12         3.3e-13    0 
   2.24           2.04           2.47        3.78e-12         2.3e-13    0 
   2.71           2.47           2.99        2.49e-12         1.6e-13    0 
   3.28           2.99           3.63        1.64e-12         1.1e-13    0 
   3.98           3.63           4.39        1.04e-12           8e-14    0 
   4.81           4.39           5.31        7.48e-13         5.7e-14    0 
   5.82           5.31           6.43        4.34e-13           4e-14    0 
   7.05           6.43           7.79        2.32e-13           3e-14    0 
   8.53           7.79           9.43        1.25e-13           2e-14    0 
  10.33           9.43          11.41        1.07e-13         1.4e-14    0 
  12.51          11.41          13.81        5.61e-14         9.7e-15    0 
  15.14          13.81          16.72        2.17e-14         6.9e-15    0 
  18.32          16.72          20.24        1.84e-14         4.6e-15    0 
  22.18          20.24           24.5        9.24e-15        3.16e-15    0 
  26.85           24.5          29.66         7.4e-15        2.06e-15    0 
   32.5          29.66          35.91        6.46e-15         1.5e-15    0 
  47.19          35.91          63.71        9.63e-16        3.93e-16    0 
  81.26          63.71         113.02        1.98e-16        1.29e-16    0 
 169.79         113.02         293.82        1.35e-16             0.0    1 

Ecsv

The same table shown in Ecsv format.

# %ECSV 0.9
# ---
# datatype:
# - {name: energy, unit: TeV, datatype: float64}
# - {name: energy_edge_lo, unit: TeV, datatype: float64}
# - {name: energy_edge_hi, unit: TeV, datatype: float64}
# - {name: flux, unit: 1 / (cm2 s TeV), datatype: float64}
# - {name: flux_error, unit: 1 / (cm2 s TeV), datatype: float64}
# - {name: ul, unit: '', datatype: int64}
# meta: !!omap
# - comments: [VHE gamma-ray spectrum of RX J1713.7-3946, 'Originally published in 2007
#       from 2003, 2004, and 2005 observations. The', spectrum here is as published
#       in the 2011 erratum, 'Main paper: Aharonian et al. 2007, A&A 464, 235', 'Erratum:
#       Aharonian et al. 2011, A&A 531, 1', Confidence level of upper limits is 2 sigma]
# - keywords: !!omap
#   - cl: {value: 0.95}
energy energy_edge_lo energy_edge_hi flux flux_error ul
0.33 0.3 0.37 2.29e-10 3.2e-11 0
0.4 0.37 0.44 1.25e-10 1.6e-11 0
0.49 0.44 0.54 9.46e-11 9e-12 0
0.59 0.54 0.65 6.06e-11 5.2e-12 0
0.71 0.65 0.79 4.37e-11 3.1e-12 0
0.86 0.79 0.95 2.15e-11 1.8e-12 0
1.04 0.95 1.15 1.82e-11 1.1e-12 0
1.26 1.15 1.39 1.17e-11 7e-13 0
1.53 1.39 1.69 8.87e-12 5e-13 0
1.85 1.69 2.04 5.63e-12 3.3e-13 0
2.24 2.04 2.47 3.78e-12 2.3e-13 0
2.71 2.47 2.99 2.49e-12 1.6e-13 0
3.28 2.99 3.63 1.64e-12 1.1e-13 0
3.98 3.63 4.39 1.04e-12 8e-14 0
4.81 4.39 5.31 7.48e-13 5.7e-14 0
5.82 5.31 6.43 4.34e-13 4e-14 0
7.05 6.43 7.79 2.32e-13 3e-14 0
8.53 7.79 9.43 1.25e-13 2e-14 0
10.33 9.43 11.41 1.07e-13 1.4e-14 0
12.51 11.41 13.81 5.61e-14 9.7e-15 0
15.14 13.81 16.72 2.17e-14 6.9e-15 0
18.32 16.72 20.24 1.84e-14 4.6e-15 0
22.18 20.24 24.5 9.24e-15 3.16e-15 0
26.85 24.5 29.66 7.4e-15 2.06e-15 0
32.5 29.66 35.91 6.46e-15 1.5e-15 0
47.19 35.91 63.71 9.63e-16 3.93e-16 0
81.26 63.71 113.02 1.98e-16 1.29e-16 0
169.79 113.02 293.82 1.35e-16 0.0 1

SExtractor

And the same table shown in the SExtractor format

# VHE gamma-ray spectrum of RX J1713.7-3946
#
# Originally published in 2007 from 2003, 2004, and 2005 observations. The
# spectrum here is as published in the 2011 erratum
# Main paper: Aharonian et al. 2007, A&A 464, 235
# Erratum: Aharonian et al. 2011, A&A 531, 1
# Confidence level of upper limits is 2 sigma
#
# 1 energy [TeV]
# 2 energy_edge_lo [TeV]
# 3 energy_edge_hi [TeV]
# 4 flux [cm-2 s-1 TeV-1]
# 5 flux_errori [cm-2 s-1 TeV-1]
# 6 ul
0.33    0.3     0.37    2.29e-10  3.2e-11   0
0.4     0.37    0.44    1.25e-10  1.6e-11   0
0.49    0.44    0.54    9.46e-11  9e-12     0
0.59    0.54    0.65    6.06e-11  5.2e-12   0
0.71    0.65    0.79    4.37e-11  3.1e-12   0
0.86    0.79    0.95    2.15e-11  1.8e-12   0
1.04    0.95    1.15    1.82e-11  1.1e-12   0
1.26    1.15    1.39    1.17e-11  7e-13     0
1.53    1.39    1.69    8.87e-12  5e-13     0
1.85    1.69    2.04    5.63e-12  3.3e-13   0
2.24    2.04    2.47    3.78e-12  2.3e-13   0
2.71    2.47    2.99    2.49e-12  1.6e-13   0
3.28    2.99    3.63    1.64e-12  1.1e-13   0
3.98    3.63    4.39    1.04e-12  8e-14     0
4.81    4.39    5.31    7.48e-13  5.7e-14   0
5.82    5.31    6.43    4.34e-13  4e-14     0
7.05    6.43    7.79    2.32e-13  3e-14     0
8.53    7.79    9.43    1.25e-13  2e-14     0
10.33   9.43    11.41   1.07e-13  1.4e-14   0
12.51   11.41   13.81   5.61e-14  9.7e-15   0
15.14   13.81   16.72   2.17e-14  6.9e-15   0
18.32   16.72   20.24   1.84e-14  4.6e-15   0
22.18   20.24   24.5    9.24e-15  3.16e-15  0
26.85   24.5    29.66   7.4e-15   2.06e-15  0
32.5    29.66   35.91   6.46e-15  1.5e-15   0
47.19   35.91   63.71   9.63e-16  3.93e-16  0
81.26   63.71   113.02  1.98e-16  1.29e-16  0
169.79  113.02  293.82  1.35e-16  0.0       1

If the table is in SExtractor format, the confidence level of the upper limits can be added after reading the table as a keyword:

>>> data_table.meta["keywords"] = {"cl": {"value": 0.95}}