casting.py

Knödlseder Jürgen, 07/08/2012 10:33 PM

Download (1.86 KB)

 
1
#! /usr/bin/env python
2
# ==========================================================================
3
# This script creates an observation container with 3 different observations
4
# and loops over all observations in that container to show the observation
5
# types. Ideally, we would like to see the correct derived class type in each
6
# iteration.
7
#
8
# Copyright (C) 2012 Juergen Knoedlseder
9
#
10
# This program is free software: you can redistribute it and/or modify
11
# it under the terms of the GNU General Public License as published by
12
# the Free Software Foundation, either version 3 of the License, or
13
# (at your option) any later version.
14
#
15
# This program is distributed in the hope that it will be useful,
16
# but WITHOUT ANY WARRANTY; without even the implied warranty of
17
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
# GNU General Public License for more details.
19
#
20
# You should have received a copy of the GNU General Public License
21
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
22
#
23
# ==========================================================================
24
from gammalib import *
25

    
26

    
27
# ================ #
28
# Observation loop #
29
# ================ #
30
def loop():
31
        """
32
        """
33
        # Initialise observation container
34
        obs = GObservations()
35

    
36
        # Add observations
37
        lat = GLATObservation()
38
        cta = GCTAObservation()
39
        mwl = GMWLObservation()
40
        obs.append(lat)
41
        obs.append(cta)
42
        obs.append(mwl)
43
        
44
        # Loop over observations
45
        for one in obs:
46
                #print one
47
                print type(one)
48
        
49
        # Return
50
        return
51

    
52

    
53
# ======================== #
54
# Main routine entry point #
55
# ======================== #
56
if __name__ == '__main__':
57
        """
58
        This script creates an observation container with 3 different
59
        observations and loops over all observations in that container
60
        to show the observation types. Ideally, we would like to see
61
        the correct derived class type in each iteration.
62
        """
63
        # Execute loop
64
        loop()