Skip to content

Commit

Permalink
Add Observation for one IACT "run"
Browse files Browse the repository at this point in the history
  • Loading branch information
cdeil committed Feb 17, 2016
1 parent 2e82428 commit d832e3e
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 32 deletions.
13 changes: 11 additions & 2 deletions examples/data_examples.py
Expand Up @@ -8,7 +8,7 @@


def test_data_manager():
filename = '/Users/deil/code/gammapy/gammapy/obs/tests/data/data-register.yaml'
filename = '/Users/deil/code/gammapy/gammapy/data/tests/data/data-register.yaml'
data_manager = DataManager.from_yaml(filename)
data_manager.info()

Expand All @@ -33,7 +33,16 @@ def test_data_store2():
ds.info()


def test_data_store_observation():
dir = gammapy_extra.dir / 'datasets/hess-crab4-hd-hap-prod2'
ds = DataStore.from_dir(dir)
ds.info()

obs = ds.load_obs(obs_id=23037)
obs.info()


if __name__ == '__main__':
# test_data_manager()
# test_data_store()
test_data_store2()
test_data_store_observation()
42 changes: 42 additions & 0 deletions gammapy/data/data_store.py
Expand Up @@ -12,6 +12,7 @@

__all__ = [
'DataStore',
'Observation',
]

log = logging.getLogger(__name__)
Expand Down Expand Up @@ -367,3 +368,44 @@ def _get_min_energy_threshold(observation_table, data_dir):
min_energy_threshold = min(min_energy_threshold, energy_threshold)

return min_energy_threshold


class Observation(object):
"""IACT observation dataset container.
TOOD: document
Examples
--------
Usually you'll use the `gammapy.data.DataStore` to load IACT `Observation` datasets like this:
>>> from gammapy.data import DataStore
>>> ds = DataStore.from_dir('$GAMMAPY_EXTRA/datasets/hess-crab4-hd-hap-prod2')
>>> obs = ds.load_obs(obs_id=23037)
>>> obs.info()
TODO: prints summary output...
"""
def __init__(self, events=None, gti=None, aeff=None, edisp=None, psf=None):
self.events = events
self.gti = gti
self.aeff = aeff
self.edisp = edisp
self.psf = psf

def peek(self):
"""Quick-look plots in a few panels."""

def info(self):
"""Print some summary info to stdout."""

def make_exposure_image(self, fov, energy_range):
"""Make exposure image ...
Do we want such methods here or as standalone functions that work with obs objects?
"""

def make_spectrum_observation(self, target_pos, on_radius):
"""Make `gammapy.spectrum.SpectrumObservation` for a given target pos and on radius.
Do we want such methods here or as standalone functions that work with obs objects?
"""
31 changes: 1 addition & 30 deletions gammapy/data/observation.py
@@ -1,6 +1,5 @@
# Licensed under a 3-clause BSD style license - see LICENSE.rst
from __future__ import absolute_import, division, print_function, unicode_literals
import logging
import numpy as np
from astropy.table import Table, Column, vstack
from astropy.units import Quantity
Expand All @@ -12,40 +11,11 @@
from ..catalog import select_sky_box, select_sky_circle

__all__ = [
# 'Observation',
'ObservationTable',
'ObservationGroups',
'ObservationGroupAxis',
]

log = logging.getLogger(__name__)


class Observation(object):
"""Observation.
An observation is a.k.a. run.
TODO: not clear if this class is useful.
Parameters
----------
TODO
"""

def __init__(self, GLON, GLAT, livetime=1800,
eff_area=1e12, background=0):
self.GLON = GLON
self.GLAT = GLAT
self.livetime = livetime

def wcs_header(self, system='FOV'):
"""Create a WCS FITS header for an per-run image.
The image is centered on the run position in one of these systems:
FOV, Galactic, Equatorial
"""
raise NotImplementedError


class ObservationTable(Table):
"""Observation table (a.k.a. run list).
Expand All @@ -54,6 +24,7 @@ class ObservationTable(Table):
convenience methods. The format of the observation table
is described in :ref:`dataformats_observation_lists`.
"""

# For now I've decided to not do the cleanup in `__init__`,
# but instead in `read`.
# See https://groups.google.com/d/msg/astropy-dev/0EaOw9peWSk/MSjH7q_7htoJ
Expand Down

0 comments on commit d832e3e

Please sign in to comment.