Commit 97a1d815997ab4deed432c701b45ee97a371e563
1 parent
21d6a36b
Add HDUCLASS keywords to csroot2caldb script
Showing
1 changed file
with
59 additions
and
35 deletions
cscripts/csroot2caldb.py
| ... | ... | @@ -111,34 +111,48 @@ class csroot2caldb(ctools.cscript): |
| 111 | 111 | cal_zenith, cal_azimuth] |
| 112 | 112 | |
| 113 | 113 | # Set IRF information |
| 114 | - irf['CAL_TEL'] = 'CTA' | |
| 115 | - irf['CAL_INST'] = self['inst'].string().upper() | |
| 116 | - irf['CAL_OBSID'] = self['id'].string() | |
| 117 | - irf['CAL_DET'] = 'NONE' | |
| 118 | - irf['CAL_FLT'] = 'NONE' | |
| 119 | - irf['CAL_CLASS'] = 'BCF' | |
| 120 | - irf['CAL_TYPE'] = 'DATA' | |
| 121 | - irf['CAL_QUAL'] = 0 # 0=good, 1=bad, 2=dubious, ... | |
| 122 | - irf['CAL_DATE'] = '14/01/30' | |
| 123 | - irf['VAL_DATE'] = '2014-01-30' | |
| 124 | - irf['VAL_TIME'] = '00:00:00' | |
| 125 | - irf['REF_TIME'] = 51544.0 | |
| 126 | - irf['EA_NAME'] = 'EFF_AREA' | |
| 127 | - irf['EA_DOC'] = 'CAL/GEN/92-019' | |
| 128 | - irf['EA_BOUNDS'] = copy.deepcopy(cal_bounds) | |
| 129 | - irf['EA_DESC'] = 'CTA effective area' | |
| 130 | - irf['PSF_NAME'] = 'RPSF' | |
| 131 | - irf['PSF_DOC'] = 'CAL/GEN/92-020' | |
| 132 | - irf['PSF_BOUNDS'] = copy.deepcopy(cal_bounds) | |
| 133 | - irf['PSF_DESC'] = 'CTA point spread function' | |
| 134 | - irf['EDISP_NAME'] = 'EDISP' | |
| 135 | - irf['EDISP_DOC'] = '???' | |
| 136 | - irf['EDISP_BOUNDS'] = copy.deepcopy(cal_bounds) | |
| 137 | - irf['EDISP_DESC'] = 'CTA energy dispersion' | |
| 138 | - irf['BGD_NAME'] = 'BGD' | |
| 139 | - irf['BGD_DOC'] = '???' | |
| 140 | - irf['BGD_BOUNDS'] = copy.deepcopy(cal_bounds) | |
| 141 | - irf['BGD_DESC'] = 'CTA background' | |
| 114 | + irf['CAL_TEL'] = 'CTA' | |
| 115 | + irf['CAL_INST'] = self['inst'].string().upper() | |
| 116 | + irf['CAL_OBSID'] = self['id'].string() | |
| 117 | + irf['CAL_DET'] = 'NONE' | |
| 118 | + irf['CAL_FLT'] = 'NONE' | |
| 119 | + irf['CAL_CLASS'] = 'BCF' | |
| 120 | + irf['CAL_TYPE'] = 'DATA' | |
| 121 | + irf['CAL_QUAL'] = 0 # 0=good, 1=bad, 2=dubious, ... | |
| 122 | + irf['CAL_DATE'] = '14/01/30' | |
| 123 | + irf['VAL_DATE'] = '2014-01-30' | |
| 124 | + irf['VAL_TIME'] = '00:00:00' | |
| 125 | + irf['REF_TIME'] = 51544.0 | |
| 126 | + irf['EA_NAME'] = 'EFF_AREA' | |
| 127 | + irf['EA_HDUCLAS3'] = 'FULL-ENCLOSURE' | |
| 128 | + irf['EA_HDUCLAS4'] = 'AEFF_2D' | |
| 129 | + irf['EA_DOC'] = 'CAL/GEN/92-019' | |
| 130 | + irf['EA_BOUNDS'] = copy.deepcopy(cal_bounds) | |
| 131 | + irf['EA_DESC'] = 'CTA effective area' | |
| 132 | + irf['PSF_NAME'] = 'RPSF' | |
| 133 | + irf['PSF_HDUCLAS3'] = 'FULL-ENCLOSURE' | |
| 134 | + irf['PSF_HDUCLAS4'] = 'PSF_3GAUSS' | |
| 135 | + irf['PSF_DOC'] = 'CAL/GEN/92-020' | |
| 136 | + irf['PSF_BOUNDS'] = copy.deepcopy(cal_bounds) | |
| 137 | + irf['PSF_DESC'] = 'CTA point spread function' | |
| 138 | + irf['EDISP_NAME'] = 'EDISP' | |
| 139 | + irf['EDISP_HDUCLAS3'] = 'FULL-ENCLOSURE' | |
| 140 | + irf['EDISP_HDUCLAS4'] = 'EDISP_2D' | |
| 141 | + irf['EDISP_DOC'] = '???' | |
| 142 | + irf['EDISP_BOUNDS'] = copy.deepcopy(cal_bounds) | |
| 143 | + irf['EDISP_DESC'] = 'CTA energy dispersion' | |
| 144 | + irf['BGD_NAME'] = 'BGD' | |
| 145 | + irf['BGD_HDUCLAS3'] = 'FULL-ENCLOSURE' | |
| 146 | + irf['BGD_HDUCLAS4'] = 'BKG_3D' | |
| 147 | + irf['BGD_DOC'] = '???' | |
| 148 | + irf['BGD_BOUNDS'] = copy.deepcopy(cal_bounds) | |
| 149 | + irf['BGD_DESC'] = 'CTA background' | |
| 150 | + | |
| 151 | + # Set parameter dependent IRF information | |
| 152 | + if self['psftype'].string() == 'King': | |
| 153 | + irf['PSF_HDUCLAS4'] = 'PSF_KING' | |
| 154 | + else: | |
| 155 | + irf['PSF_HDUCLAS4'] = 'PSF_3GAUSS' | |
| 142 | 156 | |
| 143 | 157 | # Return metadata |
| 144 | 158 | return irf |
| ... | ... | @@ -268,16 +282,20 @@ class csroot2caldb(ctools.cscript): |
| 268 | 282 | |
| 269 | 283 | # Open HDUs |
| 270 | 284 | ds['HDU_EA'] = self._open_hdu(ds['EA_FITS'], "EFFECTIVE AREA", |
| 271 | - irf['EA_NAME'], irf['EA_DOC'], | |
| 285 | + irf['EA_NAME'], irf['EA_HDUCLAS3'], | |
| 286 | + irf['EA_HDUCLAS4'], irf['EA_DOC'], | |
| 272 | 287 | irf) |
| 273 | 288 | ds['HDU_PSF'] = self._open_hdu(ds['PSF_FITS'], "POINT SPREAD FUNCTION", |
| 274 | - irf['PSF_NAME'], irf['PSF_DOC'], | |
| 289 | + irf['PSF_NAME'], irf['PSF_HDUCLAS3'], | |
| 290 | + irf['PSF_HDUCLAS4'], irf['PSF_DOC'], | |
| 275 | 291 | irf) |
| 276 | 292 | ds['HDU_EDISP'] = self._open_hdu(ds['EDISP_FITS'], "ENERGY DISPERSION", |
| 277 | - irf['EDISP_NAME'], irf['EDISP_DOC'], | |
| 293 | + irf['EDISP_NAME'], irf['EDISP_HDUCLAS3'], | |
| 294 | + irf['EDISP_HDUCLAS4'], irf['EDISP_DOC'], | |
| 278 | 295 | irf) |
| 279 | 296 | ds['HDU_BGD'] = self._open_hdu(ds['BGD_FITS'], "BACKGROUND", |
| 280 | - irf['BGD_NAME'], irf['BGD_DOC'], | |
| 297 | + irf['BGD_NAME'], irf['BGD_HDUCLAS3'], | |
| 298 | + irf['BGD_HDUCLAS4'], irf['BGD_DOC'], | |
| 281 | 299 | irf) |
| 282 | 300 | |
| 283 | 301 | # Return |
| ... | ... | @@ -319,7 +337,7 @@ class csroot2caldb(ctools.cscript): |
| 319 | 337 | # Return |
| 320 | 338 | return |
| 321 | 339 | |
| 322 | - def _open_hdu(self, fits, extname, name, doc, irf): | |
| 340 | + def _open_hdu(self, fits, extname, name, hduclas3, hduclas4, doc, irf): | |
| 323 | 341 | """ |
| 324 | 342 | Open HDU |
| 325 | 343 | |
| ... | ... | @@ -334,6 +352,10 @@ class csroot2caldb(ctools.cscript): |
| 334 | 352 | Extension name |
| 335 | 353 | name : str |
| 336 | 354 | Name string |
| 355 | + hduclas3 : str | |
| 356 | + HDU class 3 string | |
| 357 | + hduclas4 : str | |
| 358 | + HDU class 4 string | |
| 337 | 359 | doc : str |
| 338 | 360 | Document string |
| 339 | 361 | irf : dict |
| ... | ... | @@ -354,7 +376,9 @@ class csroot2caldb(ctools.cscript): |
| 354 | 376 | table.extname(extname) |
| 355 | 377 | |
| 356 | 378 | # Set OGIP keywords |
| 357 | - self._set_ogip_keywords(table, doc, ['RESPONSE', name], irf) | |
| 379 | + self._set_ogip_keywords(table, doc, | |
| 380 | + ['RESPONSE', name, hduclas3, hduclas4], | |
| 381 | + irf) | |
| 358 | 382 | |
| 359 | 383 | # Append table to FITS file |
| 360 | 384 | fits.append(table) |
| ... | ... | @@ -391,7 +415,7 @@ class csroot2caldb(ctools.cscript): |
| 391 | 415 | for i, item in enumerate(hduclas): |
| 392 | 416 | key = 'HDUCLAS%d' % (i+1) |
| 393 | 417 | hdu.card(key, item, 'HDU class') |
| 394 | - hdu.card('HDUVERS', '1.0.0', 'HDU version') | |
| 418 | + hdu.card('HDUVERS', '0.2', 'HDU version') | |
| 395 | 419 | |
| 396 | 420 | # Return |
| 397 | 421 | return | ... | ... |