forked from mfacorcoran/ogip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ogip_dictionary_arf.py
99 lines (86 loc) · 3.76 KB
/
ogip_dictionary_arf.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
def ogip_dictionary_arf():
"""
For a given OGIP file type, returns a dictionary giving the
extnames, the keywords and columns for that extension, and whether
the entry is required (1) or recommended (0), and the specific
values for the entry, if any.
All logic is possible, as the requirement is given as a string
that will be passed to eval() in a context where the object h will
contain a class instance that contains the header and the
functions
h.Exists('KEY')
h.hasVal('KEY','VAL')
etc.
@return:
"""
"""
this function returns the required and optional keywords and columns
as defined by OGIP 92-002 and 92-002a
"""
global status
global REPORT
"""
FOR the ARF file:
"""
"""
Define requirements for keywords for SPECRESP extension (note: EXTNAME is SPECRESP)
"""
reqkeys = {
"TELESCOP":{"level":1,"req":"h.Exists('TELESCOP')"},
"INSTRUME":{"level":1,"req":"h.Exists('INSTRUME')"},
"CHANTYPE":{"level":1,"req":"h.hasVal('CHANTYPE','PHA') or h.hasVal('CHANTYPE','PI')"},
"DETCHANS":{"level":1,"req":"h.Exists('DETCHANS')"},
"HDUCLASS":{"level":1,"req":"h.hasVal('HDUCLASS','OGIP')"},
"HDUCLAS1":{"level":1,"req":"h.hasVal('HDUCLAS1','RESPONSE')"},
"HDUCLAS2":{"level":1,"req":"h.hasVal('HDUCLAS2','SPECRESP')"},
"HDUVERS": {"level":1,"req":"h.Exists('HDUVERS')"},
"TLMIN*": {"level":1,"req":"h.Exists('TLMIN*')"},
"NUMGRP": {"level":1,"req":"h.Exists('NUMGRP')"},
"NUMELT": {"level":1,"req":"h.Exists('NUMELT')"},
"CCLS0001":{"level":1,"req":"h.hasVal('CCLS0001','CPF')"},
"CCNM0001":{"level":1,"req":"h.hasVal('CCNM0001','SPECRESP')"},
"CDTP0001":{"level":1,"req":"h.hasVal('CDTP0001','DATA')"},
"CVSD0001":{"level":1,"req":"h.Exists('CVSD0001')"},
"CVST0001":{"level":1,"req":"h.Exists('CVST0001')"},
"CDES0001":{"level":1,"req":"h.Exists('CDES0001')"},
#
# Optional
#
"FILTER": {"level":3,"req":"h.Exists('FILTER')"},
"PHAFILE": {"level":3,"req":"h.Exists('PHAFILE')"},
# minimum probability threshold in matrix (values < this are set to 0)
"LO_THRES":{"level":3,"req":"h.Exists('LO_THRES')"},
# required if channel numbering doesn"t start at 1
"HDUCLAS3":{"level":3,"req":"h.hasVal('HDUCLAS3','REDIST') or h.hasVal('HDUCLAS3','DETECTOR') or h.hasVal('HDUCLAS3','FULL')"},
"RMFVERSN":{"level":3,"req":"h.hasVal('RMFVERSN','1992A')"},
"HDUVERS": {"level":3,"req":"h.hasVal('HDUVERS','1.1.0')"},
"HDUVERS1":{"level":3,"req":"h.hasVal('HDUVERS1','1.1.0')"},
"HDUVERS2":{"level":3,"req":"h.hasVal('HDUVERS2','1.2.0')"},
}
"""
Define requirements for columns
"""
reqcols = {
# lower energy bound of bin (keV)
"ENERG_LO":{"level":1,"req":"h.hasCol('ENERG_LO')"},
# upper energy bound of bin (keV); generally ENERG_LO(J) = ENERG_HI(J-1)
"ENERG_HI":{"level":1,"req":"h.hasCol('ENERG_HI')"},
# the "effective area"
"SPECRESP":{"level":1,"req":"h.hasCol('SPECRESP')"}
}
specresp = {'KEYWORDS':reqkeys, 'COLUMNS':reqcols}
extns={'REQUIRED':['SPECRESP'],'OPTIONAL':[]}
# Alternate extension names for those required. Will generate an
# error but allow checking to continue.
alt_extns={'SPECRESP':['ARF']}
#
# create structure for the ARF file
#
ogip = {'EXTENSIONS':extns,
'ALT_EXTNS':alt_extns,
'SPECRESP':specresp,
'REFERENCE':'OGIP/92-002',
'REFURL':'https://heasarc.gsfc.nasa.gov/docs/heasarc/ofwg/ofwg_recomm.html',
'REFTITLE':'The Calibration Requirements for Spectral Analysis'
}
return ogip