![]() ![]() formatted : bool Formatted version with column formats applied. Basically a generalisation of the "gadf" format, but currently there is no detailed documentation available. * "profile": Gammapy internal format to store energy dependent flux profiles. * "binned-time-series": table format support by Astropy's `~`. ![]() The following formats are supported: * "gadf-sed": format for sed flux points see :ref:`gadf:flux-points` for details * "lightcurve": Gammapy internal format to store energy dependent lightcurves. Parameters - filename : str Filename sed_type : Format specification. def write ( self, filename, sed_type = None, format = "gadf-sed", ** kwargs ): """Write flux points. You may download it with the command ``gammapy download datasets -tests -out $GAMMAPY_DATA`` """ The corresponding `sed_type` has to be defined in the meta data of the table:: > import numpy as np > from astropy import units as u > from astropy.table import Table > from gammapy.estimators import FluxPoints > from import PowerLawSpectralModel > table = Table() > pwl = PowerLawSpectralModel() > e_ref = np.geomspace(1, 100, 7) * u.TeV > table = e_ref > table = pwl(e_ref) > table = pwl.evaluate_error(e_ref) > ta = "dnde" > flux_points = om_table(table) > flux_ot(sed_type="flux") #doctest: +SKIP If you have flux points in a different data format, the format can be changed by renaming the table columns and adding meta data:: > from astropy import units as u > from astropy.table import Table > from gammapy.estimators import FluxPoints > from import make_path > filename = make_path('$GAMMAPY_DATA/tests/spectrum/flux_points/flux_points_ctb_37b.txt') > table = Table.read(filename ,format='ascii.csv', delimiter=' ', comment='#') > table.rename_column('Differential_Flux', 'dnde') > table.unit = 'cm-2 s-1 TeV-1' > table.rename_column('lower_error', 'dnde_errn') > table.unit = 'cm-2 s-1 TeV-1' > table.rename_column('upper_error', 'dnde_errp') > table.unit = 'cm-2 s-1 TeV-1' > table.rename_column('E', 'e_ref') > table.unit = 'TeV' > flux_points = om_table(table, sed_type="dnde") > flux_ot(sed_type="e2dnde") #doctest: +SKIP Note: In order to reproduce the example you need the tests datasets folder. The supported formats are described here: :ref:`gadf:flux-points` In summary, the following formats and minimum required columns are: * Format ``dnde``: columns ``e_ref`` and ``dnde`` * Format ``e2dnde``: columns ``e_ref``, ``e2dnde`` * Format ``flux``: columns ``e_min``, ``e_max``, ``flux`` * Format ``eflux``: columns ``e_min``, ``e_max``, ``eflux`` Parameters - table : `~` Table with flux point data Attributes - table : `~` Table with flux point data Examples - The `FluxPoints` object is most easily created by reading a file with flux points given in one of the formats documented above:: > from gammapy.estimators import FluxPoints > filename = '$GAMMAPY_DATA/hawc_crab/HAWC19_flux_points.fits' > flux_points = FluxPoints.read(filename) > flux_ot() #doctest: +SKIP An instance of `FluxPoints` can also be created by passing an instance of ``, which contains the required columns, such as `'e_ref'` and `'dnde'`. ![]() Class FluxPoints ( FluxMaps ): """Flux points container.
0 Comments
Leave a Reply. |