forked from mfacorcoran/ogip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ogip_dictionary_timing.py
296 lines (256 loc) · 11.4 KB
/
ogip_dictionary_timing.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
def ogip_dictionary_timing():
"""
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 not, 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.
"""
"""
FOR RATE TABLE:
"""
"""
Define requirements for Keywords for RATE table
"""
reqkeys = {
"TELESCOP":{"level":1,"req":"h.Exists('TELESCOP')"},
"INSTRUME":{"level":1,"req":"h.Exists('INSTRUME')"},
"DATE-OBS":{"level":1,"req":"h.Exists('DATE-OBS')"},
"DATE-END":{"level":1,"req":"h.Exists('DATE-END')"},
# can be given as single keyword or integer + fraction; either ok
"TSTART": {"level":1,"req":"h.Exists('TSTART') or ( h.Exists('TSTARTI') and h.Exists('TSTARTF') )"},
# can be given as single keyword or integer + fraction; either ok
"TSTOP": {"level":1,"req":"h.Exists('TSTOP') or ( h.Exists('TSTOPI') and h.Exists('TSTOPF') )"},
"TIMESYS": {"level":1,"req":"h.Exists('TIMESYS')"},
"TIMEUNIT":{"level":1,"req":"h.Exists('TIMEUNIT')"},
"TIMEREF": {"level":1,"req":"h.Exists('TIMEREF')"},
# OGIP is the allowed keyword value
"HDUCLASS":{"level":1,"req":"h.hasVal('HDUCLASS','OGIP')"},
# LIGHTCURVE is the allowed keyword value
"HDUCLAS1":{"level":1,"req":"h.hasVal('HDUCLAS1','LIGHTCURVE')"},
#
# Optional
#
"DETNAM": {"level":3,"req":"h.Exists('DETNAM')"},
"FILTER": {"level":3,"req":"h.Exists('FILTER')"},
"RA*": {"level":3,"req":"h.Exists('RA*')"},
"DEC*": {"level":3,"req":"h.Exists('DEC*')"},
"CLOCKCOR": {"level":3,"req":"h.Exists('CLOCKCOR')"},
"NUMBAND": {"level":3,"req":"h.Exists('NUMBAND')"},
# time-obs can be included in date-obs
"TIME-OBS": {"level":3,"req":"h.Exists('TIME-OBS')"},
# time-end can be included in date-end
"TIME-END": {"level":3,"req":"h.Exists('TIME-END')"},
"TIMVERSN": {"level":3,"req":"h.Exists('TIMVERSN')"},
"OBJECT": {"level":3,"req":"h.Exists('OBJECT')"},
"AUTHOR": {"level":3,"req":"h.Exists('AUTHOR')"},
"TASSIGN": {"level":3,"req":"h.Exists('TASSIGN')"},
"TIERRELA": {"level":3,"req":"h.Exists('TIERRELA')"},
"TIERABSO": {"level":3,"req":"h.Exists('TIERABSO')"},
"ONTIME": {"level":3,"req":"h.Exists('ONTIME')"},
"BACKAPP": {"level":3,"req":"h.Exists('BACKAPP')"},
"VIGNAPP": {"level":3,"req":"h.Exists('VIGNAPP')"},
"DEADAPP": {"level":3,"req":"h.Exists('DEADAPP')"},
"EMIN*": {"level":3,"req":"h.Exists('EMIN*')"},
"EMAX*": {"level":3,"req":"h.Exists('EMAX*')"},
"BACKV*": {"level":3,"req":"h.Exists('BACKV*')"},
"BACKE*": {"level":3,"req":"h.Exists('BACKE*')"},
"DEADC*": {"level":3,"req":"h.Exists('DEADC*')"},
"GEOAREA": {"level":3,"req":"h.Exists('GEOAREA')"},
"VIGNET": {"level":3,"req":"h.Exists('VIGNET')"},
"NPIXSOU": {"level":3,"req":"h.Exists('NPIXSOU')"},
"NPIXBACK": {"level":3,"req":"h.Exists('NPIXBACK')"},
# can be given as single keyword or integer + fraction; either ok
"TIMEZERO":{"level":3,"req":"h.Exists('TIMEZERO') or ( h.Exists('TIMEZERI') and h.Exists('TIMEZERF') )"}
}
"""
Define requirements for columns
"""
reqcols = {
"TIME": {"level":1,"req":"h.hasCol('TIME')"},
"RATE|COUNTS":{"level":1,"req":"h.hasCol('RATE') or h.hasCol('COUNTS')"},
"BACKV": {"level":3,"req":"h.hasCol('BACKV')"},
"BACKE": {"level":3,"req":"h.hasCol('BACKE')"},
"DEADC": {"level":3,"req":"h.hasCol('DEADC')"}
}
rate = {'KEYWORDS':reqkeys, 'COLUMNS':reqcols}
"""
FOR EVENTS TABLE:
"""
"""
Define requirements for keywords for EVENTS table
"""
reqkeys = {
"TELESCOP":{"level":1,"req":"h.Exists('TELESCOP')"},
"INSTRUME":{"level":1,"req":"h.Exists('INSTRUME')"},
"DATE-OBS":{"level":1,"req":"h.Exists('DATE-OBS')"},
"DATE-END":{"level":1,"req":"h.Exists('DATE-END')"},
# can be given as single keyword or integer + fraction; either ok
"TSTART": {"level":1,"req":"h.Exists('TSTART') or ( h.Exists('TSTARTI') and h.Exists('TSTARTF') )"},
# can be given as single keyword or integer + fraction; either ok
"TSTOP": {"level":1,"req":"h.Exists('TSTOP') or ( h.Exists('TSTOPI') and h.Exists('TSTOPF') )"},
"TIMESYS": {"level":1,"req":"h.Exists('TIMESYS')"},
"TIMEUNIT":{"level":1,"req":"h.Exists('TIMEUNIT')"},
"HDUCLASS":{"level":1,"req":"h.hasVal('HDUCLASS','OGIP')"},
"HDUCLAS1":{"level":1,"req":"h.hasVal('HDUCLAS1','EVENTS')"},
#
# Optional
#
"ONTIME": {"level":3,"req":"h.Exists('ONTIME')"},
"DETNAM": {"level":3,"req":"h.Exists('DETNAM')"},
"FILTER": {"level":3,"req":"h.Exists('FILTER')"},
"RA*": {"level":3,"req":"h.Exists('RA*')"},
"DEC*": {"level":3,"req":"h.Exists('DEC*')"},
"CLOCKCOR":{"level":3,"req":"h.Exists('CLOCKCOR')"},
"NUMBAND": {"level":3,"req":"h.Exists('NUMBAND')"},
# time-obs can be included in date-obs
"TIME-OBS":{"level":3,"req":"h.Exists('TIME-OBS')"},
# time-end can be included in date-end
"TIME-END":{"level":3,"req":"h.Exists('TIME-END')"},
"TIMVERSN":{"level":3,"req":"h.Exists('TIMVERSN')"},
"OBJECT": {"level":3,"req":"h.Exists('OBJECT')"},
"AUTHOR": {"level":3,"req":"h.Exists('AUTHOR')"},
"TASSIGN": {"level":3,"req":"h.Exists('TASSIGN')"},
"TIERRELA":{"level":3,"req":"h.Exists('TIERRELA')"},
"TIERABSO":{"level":3,"req":"h.Exists('TIERABSO')"},
"BACKAPP": {"level":3,"req":"h.Exists('BACKAPP')"},
"VIGNAPP": {"level":3,"req":"h.Exists('VIGNAPP')"},
"DEADAPP": {"level":3,"req":"h.Exists('DEADAPP')"},
# can be given as single keyword or integer + fraction; either ok
"TIMEZERO":{"level":3,"req":"h.Exists('TIMEZERO') or ( h.Exists('TIMEZERI') and h.Exists('TIMEZERF') )"},
}
"""
Define requirements for columns
"""
reqcols = {
"TIME":{"level":1,"req":"h.hasCol('TIME')"},
#
# Optional
#
"X": {"level":3,"req":"h.hasCol('X')"},
"Y": {"level":3,"req":"h.hasCol('Y')"},
"PHA": {"level":3,"req":"h.hasCol('PHA')"},
"PI": {"level":3,"req":"h.hasCol('PI')"},
"DETX":{"level":3,"req":"h.hasCol('DETX')"},
"DETY":{"level":3,"req":"h.hasCol('DETY')"}
}
events = {'KEYWORDS':reqkeys, 'COLUMNS':reqcols}
"""
FOR GTI TABLE:
"""
"""
Define requirements for keywords for GTI table
"""
reqkeys = {
"TELESCOP":{"level":1,"req":"h.Exists('TELESCOP')"},
"INSTRUME":{"level":1,"req":"h.Exists('INSTRUME')"},
#
# Optional
#
"DETNAM": {"level":3,"req":"h.Exists('DETNAM')"},
"FILTER": {"level":3,"req":"h.Exists('FILTER')"},
"RA*": {"level":3,"req":"h.Exists('RA*')"},
"DEC*": {"level":3,"req":"h.Exists('DEC*')"},
# can be given as single keyword or integer + fraction; either ok
"TIMEZERO":{"level":3,"req":"h.Exists('TIMEZERO') or ( h.Exists('TIMEZERI') and h.Exists('TIMEZERF') )"},
# can be given as single keyword or integer + fraction; either ok
"TSTART": {"level":3,"req":"h.Exists('TSTART') or ( h.Exists('TSTARTI') and h.Exists('TSTARTF') )"},
# can be given as single keyword or integer + fraction; either ok
"TSTOP": {"level":3,"req":"h.Exists('TSTOP') or ( h.Exists('TSTOPI') and h.Exists('TSTARTF') )"},
"TIMESYS": {"level":3,"req":"h.Exists('TIMESYS')"},
"TIMEUNIT":{"level":3,"req":"h.Exists('TIMEUNIT')"},
"DATE-OBS":{"level":3,"req":"h.Exists('DATE-OBS')"},
"DATE-END":{"level":3,"req":"h.Exists('DATE-END')"},
"ONTIME": {"level":3,"req":"h.Exists('ONTIME')"},
"HDUCLASS":{"level":3,"req":"h.hasVal('HDUCLASS','OGIP')"},
"HDUCLAS1":{"level":3,"req":"h.hasVal('HDUCLAS1','GTI')"}
}
"""
Define requirements for columns
"""
reqcols = {
"START":{"level":1,"req":"h.hasCol('START')"},
"STOP": {"level":1,"req":"h.hasCol('STOP')"},
#
# Optional
#
"TIMEDEL":{"level":3,"req":"h.hasCol('TIMEDEL')"}
}
gti={"KEYWORDS":reqkeys, 'COLUMNS':reqcols}
"""
FOR ENEBANDS TABLE:
"""
"""
Define requirements for keywords
"""
reqkeys = {
"TELESCOP":{"level":1,"req":"h.Exists('TELESCOP')"},
"INSTRUME":{"level":1,"req":"h.Exists('INSTRUME')"},
#
# Optional
#
"DETNAM":{"level":3,"req":"h.Exists('DETNAM')"},
"FILTER":{"level":3,"req":"h.Exists('FILTER')"}
}
"""
Define requirements for columns
"""
reqcols = {
"E_MIN":{"level":1,"req":"h.hasCol('E_MIN')"},
"E_MAX":{"level":1,"req":"h.hasCol('E_MAX')"},
#
# Optional
#
"MINCHAN":{"level":3,"req":"h.hasCol('MINCHAN')"},
"MAXCHAN":{"level":3,"req":"h.hasCol('MAXCHAN')"}
}
eneband={'KEYWORDS':reqkeys, 'COLUMNS':reqcols}
"""
FOR TIMEREF TABLE:
"""
"""
Define requirements for keywords
"""
reqkeys = {
"TELESCOP":{"level":1,"req":"h.Exists('TELESCOP')"},
"INSTRUME":{"level":1,"req":"h.Exists('INSTRUME')"},
"TSTART": {"level":1,"req":"h.Exists('TSTART') or (h.Exists('TSTARTI') and h.Exists('TSTARTF') )"},
"TSTOP": {"level":1,"req":"h.Exists('TSTOP') or ( h.Exists('TSTOPI') and h.Exists(('TSTARTF') )"},
"TIMEUNIT":{"level":1,"req":"h.Exists('TIMEUNIT')"},
#
# Optional
#
"DETNAM":{"level":3,"req":"h.Exists('DETNAM')"},
"FILTER":{"level":3,"req":"h.Exists('FILTER')"},
"TIMEZERO":{"level":3,"req":"h.Exists('TIMEZERO') or ( h.Exists('TIMEZERI') and h.Exists('TIMEZERF') )"}
}
"""
Define requirements for columns
"""
reqcols = {
"TIME":{"level":1,"req":"h.hasCol('TIME')"},
"REFEARTH|REFSUN|REFBSOLS|BARYTIME":{"level":1,"req":"h.hasCol('REFEARTH') or h.hasCol('REFSUN') or h.hasCol('REFBSOLS') or h.hasCol('BARYTIME')"},
}
timeref={'KEYWORDS':reqkeys, 'COLUMNS':reqcols}
# Define which extensions must be present, and which are optional
extns={'REQUIRED':['RATE','EVENTS'],'OPTIONAL':['TIMEREF','ENEBAND','GTI']}
# Alternate extension names for those required. Will generate an
# error but allow checking to continue.
alt_extns={'RATE':['XTE_SA'],'EVENTS':['XTE_SE']}
ogip = {'EXTENSIONS':extns,
'ALT_EXTNS':alt_extns,
'RATE':rate,
'EVENTS':events,
'TIMEREF':timeref,
'ENEBAND':eneband,
'GTI':gti,
'REFERENCE':'OGIP/93-003',
'REFTITLE':'The Proposed Timing FITS File Format for High Energy Astrophysics Data',
'REFURL':'http://heasarc.gsfc.nasa.gov/FTP/caldb/docs/ogip/fits_formats/docs/rates/ogip_93_003/ogip_93_003.pdf'}
return ogip