Skip to content

Commit

Permalink
Update datasets PIG
Browse files Browse the repository at this point in the history
  • Loading branch information
adonath committed Jul 2, 2019
1 parent b613e44 commit 52518e5
Showing 1 changed file with 26 additions and 20 deletions.
46 changes: 26 additions & 20 deletions docs/development/pigs/pig-008.rst
Expand Up @@ -82,16 +82,13 @@ The `MapDataset` implements at least the following methods:
dataset.npred()
dataset.likelihood_per_bin()
dataset.likelihood(mask)
dataset.likelihood()
The `.setup()` method creates cutouts of the exposure map for the individual
model components, assigns the correspoding IRFs to the model component and
bundles all into `SourceIRFModel` or `ModelEvaluator()` classes. The list of model
evaluators is cached on the `MapDataset` and used later to efficiently compute
the predicted number of counts.

The `mask` argument to the `.likelihood` method allows to set a global fitting
mask, when mutiple `MapDataset` are fitted jointly.
bundles all into `MapEvaluator()` object. The list of model evaluators is
cached on the `MapDataset` and used later to efficiently compute the predicted
number of counts.


`MapDatasetOnOff`
Expand All @@ -112,7 +109,7 @@ For on-off based analyses a `MapDatasetOnOff` class could be introduced.
psf = Map.read("stacked/psf.fits")
dataset_onoff = MapDatasetOnOff(
counts_on=counts_on,
counts=counts,
counts_off=counts_off,
alpha=alpha,
edisp=edisp,
Expand Down Expand Up @@ -155,37 +152,43 @@ For spectral analysis we propose to introduce a `SpectrumDataset`:
dataset.npred()
dataset.likelihoop_per_bin()
dataset.likelihood(mask)
dataset.likelihood()
The `SpectrumDatasets` with a parametric background model will be introduced first.
The `SpectrumDataset` with a parametric background model will be introduced first.


`SpectrumDatasetOnOff`
----------------------

For ON / OFF based spectral analysis we propose to introduce a `SpectrumDatasetOnOff`:
For ON / OFF based spectral analysis we propose to refactor the existing `SpectrumObservation`
into a`SpectrumDatasetsOnOff` class:

.. code ::
from gammapy.spectrum import SpectrumDatasetOnOff
model = SpectralModel()
model = PowerLaw()
edisp = EnergyDispersion.read()
counts = Spectrum.read()
counts = CountsSpectrum.read()
counts_off = CountsSpectrum.read()
dataset = SpectrumDataset(
aeff = EffectiveAreaTable.read()
dataset = SpectrumDatasetOnOff(
counts=counts,
counts_off=counts_off,
model=model,
background_model=background_model,
edisp=edisp,
livetime="1 h".
aeff=aeff,
)
dataset.npred()
dataset.likelihoop_per_bin()
dataset.likelihood()
The existing `SpectrumObservation` will be refactored into the `SpectrumDatasetsOnOff` class.
.


`FluxPointsDataset`
Expand Down Expand Up @@ -215,7 +218,7 @@ The `FluxPointsDataset` should define at least the following methods:
dataset = FluxPointsDataset()
dataset.likelihood_per_bin()
dataset.likelihood(mask)
dataset.likelihood()
# predicted flux form the spectral model
dataset.flux_pred()
Expand Down Expand Up @@ -256,7 +259,7 @@ is supposed to work:
# check whether all contained datasets are of the same type
datasets.is_all_same_type
datasets.likelihood(mask)
datasets.likelihood()
fit = Fit(datasets)
Expand All @@ -266,7 +269,6 @@ is supposed to work:
fit.optimize()
The linking of parameters of the spectral model is natively achieved, as the same
instance of the spectral model is passed to two different datasets, while the
background model is created for every dataset separately.
Expand Down Expand Up @@ -344,6 +346,9 @@ dataset. Here is an example:
background-model: "obs-123/background.fits"
model: "model.yaml" # optionally
The `SpectrumDatasetOnOff` in addition implemnets serialisation to the standard
OGIP format described on the gadf_pha_ page:


Addtionally one could introduce a single FITS file serializiaton for quickly writing /
reading datasets to disk:
Expand Down Expand Up @@ -503,4 +508,5 @@ Decision


.. _gammapy: https://github.com/gammapy/gammapy
.. _gammapy-web: https://github.com/gammapy/gammapy-webpage
.. _gammapy-web: https://github.com/gammapy/gammapy-webpage
.. _gadf_pha: https://gamma-astro-data-formats.readthedocs.io/en/latest/spectra/ogip/index.html

0 comments on commit 52518e5

Please sign in to comment.