bvccheck.py

Knödlseder Jürgen, 01/06/2022 11:26 PM

Download (2.68 KB)

 
1
#! /usr/bin/env python
2
# ==========================================================================
3
# Check BVC file
4
#
5
# Copyright (C) 2021 Juergen Knoedlseder
6
#
7
# This program is free software: you can redistribute it and/or modify
8
# it under the terms of the GNU General Public License as published by
9
# the Free Software Foundation, either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# This program is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
#
20
# ==========================================================================
21
import gammalib
22

    
23

    
24
# ============== #
25
# Check BVC file #
26
# ============== #
27
def check_bvc(filename):
28
    """
29
    Check BVC file
30
    """
31
    # Open BVC file
32
    fits = gammalib.GFits(filename)
33

    
34
    # Get BVC table
35
    bvc = fits.table('COMPTEL_BVC')
36

    
37
    # Extract information
38
    for irow in range(bvc.nrows()):
39

    
40
        # Read information
41
        tjd    = bvc['TJD'][irow]
42
        tics   = bvc['TICS'][irow]
43
        ssb_x  = bvc['SSB_X'][irow]
44
        ssb_y  = bvc['SSB_Y'][irow]
45
        ssb_z  = bvc['SSB_Z'][irow]
46
        tdelta = bvc['TDELTA'][irow]
47
        #print(tjd,tics,ssb_x,ssb_y,ssb_z,tdelta)
48

    
49
        # Convert into sky direction
50
        time = gammalib.com_time(tjd,tics)            # Get time of row
51
        ssb  = gammalib.GVector(ssb_x, ssb_y, ssb_z)  # Setup vector pointing from SSB -> CGRO
52
        ssb /= ssb.norm()                             # Normalise vector to unity
53
        ssb  = -ssb                                   # Invert vector to point from CGRO -> SSB
54
        dir  = gammalib.GSkyDir()                     #
55
        dir.celvector(ssb)                            # Interpret vector in celestial coordinates
56
        sun  = gammalib.GSkyDir()
57
        sun.sun(time)                                 # Get coordinates of Sun
58
        
59
        # Show result
60
        print('%4.4d:%9.9d: (%13.2f,%13.2f,%13.2f) %10.7f  CGRO->SSB(%9.4f,%9.4f)  Sun(%9.4f,%9.4f)' %
61
              (tjd,tics,ssb_x,ssb_y,ssb_z,tdelta,dir.ra_deg(),dir.dec_deg(),sun.ra_deg(),sun.dec_deg()))
62

    
63
    # Return
64
    return
65

    
66

    
67
# ======================== #
68
# Main routine entry point #
69
# ======================== #
70
if __name__ == '__main__':
71

    
72
    # Set filename
73
    filename = '/project-data/comptel/data/phase01/vp0001_0/s10150_bvc.fits'
74

    
75
    # Check BVC file
76
    check_bvc(filename)
77

    
78
    # Create figure
79
    #fig = plt.figure(figsize=(12,8))
80

    
81
    # Show figure
82
    #plt.show()