Commit d670462b2a914f059da85a8df8c842d930d488d5
1 parent
6049bf07
Remove ERECO histogram from effective area IRF extension
Showing
1 changed file
with
15 additions
and
33 deletions
cscripts/csroot2caldb.py
| @@ -146,7 +146,7 @@ class csroot2caldb(ctools.cscript): | @@ -146,7 +146,7 @@ class csroot2caldb(ctools.cscript): | ||
| 146 | def _make_dirs(self, version, irf): | 146 | def _make_dirs(self, version, irf): |
| 147 | """ | 147 | """ |
| 148 | Generate CALDB directory structure for one observation identifier | 148 | Generate CALDB directory structure for one observation identifier |
| 149 | - | 149 | + |
| 150 | The structure is given by | 150 | The structure is given by |
| 151 | 151 | ||
| 152 | data/<tel>/<inst>/bcf/<obsid> | 152 | data/<tel>/<inst>/bcf/<obsid> |
| @@ -227,7 +227,7 @@ class csroot2caldb(ctools.cscript): | @@ -227,7 +227,7 @@ class csroot2caldb(ctools.cscript): | ||
| 227 | def _open(self, irf, ds): | 227 | def _open(self, irf, ds): |
| 228 | """ | 228 | """ |
| 229 | Open existing or create new calibration | 229 | Open existing or create new calibration |
| 230 | - | 230 | + |
| 231 | The actual version will put all calibrations in the same file, although | 231 | The actual version will put all calibrations in the same file, although |
| 232 | each part of the response function will have its own logical name. We | 232 | each part of the response function will have its own logical name. We |
| 233 | can thus easily modify the script to put each calibration information | 233 | can thus easily modify the script to put each calibration information |
| @@ -322,7 +322,7 @@ class csroot2caldb(ctools.cscript): | @@ -322,7 +322,7 @@ class csroot2caldb(ctools.cscript): | ||
| 322 | def _open_hdu(self, fits, extname, name, doc, irf): | 322 | def _open_hdu(self, fits, extname, name, doc, irf): |
| 323 | """ | 323 | """ |
| 324 | Open HDU | 324 | Open HDU |
| 325 | - | 325 | + |
| 326 | Opens a FITS binary table with given "extname". If HDU does not exist | 326 | Opens a FITS binary table with given "extname". If HDU does not exist |
| 327 | in the FITS file it will be created and appended to the FITS file. | 327 | in the FITS file it will be created and appended to the FITS file. |
| 328 | 328 | ||
| @@ -534,10 +534,9 @@ class csroot2caldb(ctools.cscript): | @@ -534,10 +534,9 @@ class csroot2caldb(ctools.cscript): | ||
| 534 | def _root2ea(self, tfile, irf, ds): | 534 | def _root2ea(self, tfile, irf, ds): |
| 535 | """ | 535 | """ |
| 536 | Translate ROOT to CALDB effective area extension | 536 | Translate ROOT to CALDB effective area extension |
| 537 | - | 537 | + |
| 538 | The following ROOT histograms are used: | 538 | The following ROOT histograms are used: |
| 539 | - EffectiveAreaEtrue_offaxis -> EFFAREA | 539 | - EffectiveAreaEtrue_offaxis -> EFFAREA |
| 540 | - - EffectiveArea_offaxis -> EFFAREA_RECO | ||
| 541 | 540 | ||
| 542 | Parameters | 541 | Parameters |
| 543 | ---------- | 542 | ---------- |
| @@ -555,16 +554,13 @@ class csroot2caldb(ctools.cscript): | @@ -555,16 +554,13 @@ class csroot2caldb(ctools.cscript): | ||
| 555 | 554 | ||
| 556 | # Get relevant ROOT histograms | 555 | # Get relevant ROOT histograms |
| 557 | etrue = tfile.Get('EffectiveAreaEtrue_offaxis') | 556 | etrue = tfile.Get('EffectiveAreaEtrue_offaxis') |
| 558 | - ereco = tfile.Get('EffectiveArea_offaxis') | ||
| 559 | 557 | ||
| 560 | # If requested then normalize the 2D histogram on the on-axis 1D | 558 | # If requested then normalize the 2D histogram on the on-axis 1D |
| 561 | # histogram. This assures that the 2D histogram has the same on-axis | 559 | # histogram. This assures that the 2D histogram has the same on-axis |
| 562 | # effective area dependence as the 1D histogram. | 560 | # effective area dependence as the 1D histogram. |
| 563 | if self['norm1d'].boolean(): | 561 | if self['norm1d'].boolean(): |
| 564 | etrue_1D = tfile.Get('EffectiveAreaEtrue') | 562 | etrue_1D = tfile.Get('EffectiveAreaEtrue') |
| 565 | - ereco_1D = tfile.Get('EffectiveArea') | ||
| 566 | self._renorm_onaxis(etrue, etrue_1D) | 563 | self._renorm_onaxis(etrue, etrue_1D) |
| 567 | - self._renorm_onaxis(ereco, ereco_1D) | ||
| 568 | 564 | ||
| 569 | # If requested then rebin the effective area Etrue histogram. This | 565 | # If requested then rebin the effective area Etrue histogram. This |
| 570 | # increases the number of bins by a factor 10. | 566 | # increases the number of bins by a factor 10. |
| @@ -589,17 +585,6 @@ class csroot2caldb(ctools.cscript): | @@ -589,17 +585,6 @@ class csroot2caldb(ctools.cscript): | ||
| 589 | for ieng in range(neng): | 585 | for ieng in range(neng): |
| 590 | value = etrue.GetBinContent(ieng+1,ioff+1) * eascale | 586 | value = etrue.GetBinContent(ieng+1,ioff+1) * eascale |
| 591 | etrue.SetBinContent(ieng+1,ioff+1,value) | 587 | etrue.SetBinContent(ieng+1,ioff+1,value) |
| 592 | - neng = ereco.GetXaxis().GetNbins() | ||
| 593 | - noffset = ereco.GetYaxis().GetNbins() | ||
| 594 | - for ioff in range(noffset): | ||
| 595 | - for ieng in range(neng): | ||
| 596 | - value = ereco.GetBinContent(ieng+1,ioff+1) * eascale | ||
| 597 | - ereco.SetBinContent(ieng+1,ioff+1,value) | ||
| 598 | - | ||
| 599 | - # Set boundaries (use Ereco boundaries) | ||
| 600 | - #bounds = self._make_2D(ereco, ds['HDU_EA'], None, 'm2') | ||
| 601 | - #for b in bounds: | ||
| 602 | - # irf['EA_BOUNDS'].append(b) | ||
| 603 | 588 | ||
| 604 | # Write boundary keywords | 589 | # Write boundary keywords |
| 605 | self._set_cif_keywords(ds['HDU_EA'], irf['EA_NAME'], | 590 | self._set_cif_keywords(ds['HDU_EA'], irf['EA_NAME'], |
| @@ -608,16 +593,13 @@ class csroot2caldb(ctools.cscript): | @@ -608,16 +593,13 @@ class csroot2caldb(ctools.cscript): | ||
| 608 | # Create "EFFAREA" data column | 593 | # Create "EFFAREA" data column |
| 609 | self._make_2D(etrue, ds['HDU_EA'], 'EFFAREA', 'm2') | 594 | self._make_2D(etrue, ds['HDU_EA'], 'EFFAREA', 'm2') |
| 610 | 595 | ||
| 611 | - # Create "EFFAREA_RECO" data column | ||
| 612 | - self._make_2D(ereco, ds['HDU_EA'], 'EFFAREA_RECO', 'm2') | ||
| 613 | - | ||
| 614 | # Return | 596 | # Return |
| 615 | return | 597 | return |
| 616 | 598 | ||
| 617 | def _root2psf(self, tfile, irf, ds): | 599 | def _root2psf(self, tfile, irf, ds): |
| 618 | """ | 600 | """ |
| 619 | Translate ROOT to CALDB point spread function extension | 601 | Translate ROOT to CALDB point spread function extension |
| 620 | - | 602 | + |
| 621 | Parameters | 603 | Parameters |
| 622 | ---------- | 604 | ---------- |
| 623 | tfile : `~ROOT.TFile` | 605 | tfile : `~ROOT.TFile` |
| @@ -646,7 +628,7 @@ class csroot2caldb(ctools.cscript): | @@ -646,7 +628,7 @@ class csroot2caldb(ctools.cscript): | ||
| 646 | def _root2psf_gauss(self, tfile, irf, ds): | 628 | def _root2psf_gauss(self, tfile, irf, ds): |
| 647 | """ | 629 | """ |
| 648 | Translate ROOT to CALDB point spread function extension | 630 | Translate ROOT to CALDB point spread function extension |
| 649 | - | 631 | + |
| 650 | The following ROOT histograms are used: | 632 | The following ROOT histograms are used: |
| 651 | - 1/(2*pi*SIGMA_1) -> SCALE | 633 | - 1/(2*pi*SIGMA_1) -> SCALE |
| 652 | - AngRes_offaxis -> SIGMA_1 (scaling: 1/0.8) | 634 | - AngRes_offaxis -> SIGMA_1 (scaling: 1/0.8) |
| @@ -729,7 +711,7 @@ class csroot2caldb(ctools.cscript): | @@ -729,7 +711,7 @@ class csroot2caldb(ctools.cscript): | ||
| 729 | def _root2psf_king(self, tfile, irf, ds): | 711 | def _root2psf_king(self, tfile, irf, ds): |
| 730 | """ | 712 | """ |
| 731 | Translate ROOT to CALDB point spread function extension | 713 | Translate ROOT to CALDB point spread function extension |
| 732 | - | 714 | + |
| 733 | The following ROOT histograms are used: | 715 | The following ROOT histograms are used: |
| 734 | - AngRes_offaxis | 716 | - AngRes_offaxis |
| 735 | - AngRes80_offaxis | 717 | - AngRes80_offaxis |
| @@ -853,7 +835,7 @@ class csroot2caldb(ctools.cscript): | @@ -853,7 +835,7 @@ class csroot2caldb(ctools.cscript): | ||
| 853 | def _root2edisp(self, tfile, irf, ds): | 835 | def _root2edisp(self, tfile, irf, ds): |
| 854 | """ | 836 | """ |
| 855 | Translate ROOT to CALDB energy dispersion extension | 837 | Translate ROOT to CALDB energy dispersion extension |
| 856 | - | 838 | + |
| 857 | The following ROOT histograms are used: | 839 | The following ROOT histograms are used: |
| 858 | - EestOverEtrue_offaxis -> MATRIX | 840 | - EestOverEtrue_offaxis -> MATRIX |
| 859 | 841 | ||
| @@ -892,7 +874,7 @@ class csroot2caldb(ctools.cscript): | @@ -892,7 +874,7 @@ class csroot2caldb(ctools.cscript): | ||
| 892 | def _root2bgd(self, tfile, irf, ds): | 874 | def _root2bgd(self, tfile, irf, ds): |
| 893 | """ | 875 | """ |
| 894 | Translate ROOT to CALDB background extension. | 876 | Translate ROOT to CALDB background extension. |
| 895 | - | 877 | + |
| 896 | The following ROOT histograms are used: | 878 | The following ROOT histograms are used: |
| 897 | - BGRatePerSqDeg_offaxis -> BGD | 879 | - BGRatePerSqDeg_offaxis -> BGD |
| 898 | 880 | ||
| @@ -945,7 +927,7 @@ class csroot2caldb(ctools.cscript): | @@ -945,7 +927,7 @@ class csroot2caldb(ctools.cscript): | ||
| 945 | def _append_column_axis(self, hdu, name, unit, axis, log=False): | 927 | def _append_column_axis(self, hdu, name, unit, axis, log=False): |
| 946 | """ | 928 | """ |
| 947 | Append column of ROOT axis values to HDU | 929 | Append column of ROOT axis values to HDU |
| 948 | - | 930 | + |
| 949 | Parameters | 931 | Parameters |
| 950 | ---------- | 932 | ---------- |
| 951 | hdu : `~gammalib.GFitsHDU` | 933 | hdu : `~gammalib.GFitsHDU` |
| @@ -991,7 +973,7 @@ class csroot2caldb(ctools.cscript): | @@ -991,7 +973,7 @@ class csroot2caldb(ctools.cscript): | ||
| 991 | def _append_column_values(self, hdu, name, unit, values): | 973 | def _append_column_values(self, hdu, name, unit, values): |
| 992 | """ | 974 | """ |
| 993 | Append column of values to HDU | 975 | Append column of values to HDU |
| 994 | - | 976 | + |
| 995 | Parameters | 977 | Parameters |
| 996 | ---------- | 978 | ---------- |
| 997 | hdu : `~gammalib.GFitsHDU` | 979 | hdu : `~gammalib.GFitsHDU` |
| @@ -1089,7 +1071,7 @@ class csroot2caldb(ctools.cscript): | @@ -1089,7 +1071,7 @@ class csroot2caldb(ctools.cscript): | ||
| 1089 | for ioff in range(noffset): | 1071 | for ioff in range(noffset): |
| 1090 | value = hist2D_copy.GetBinContent(ieng+1,ioff+1) / onaxis | 1072 | value = hist2D_copy.GetBinContent(ieng+1,ioff+1) / onaxis |
| 1091 | hist2D_copy.SetBinContent(ieng+1,ioff+1,value) | 1073 | hist2D_copy.SetBinContent(ieng+1,ioff+1,value) |
| 1092 | - | 1074 | + |
| 1093 | # Put back the energy dependence | 1075 | # Put back the energy dependence |
| 1094 | for ieng in range(neng): | 1076 | for ieng in range(neng): |
| 1095 | onaxis = hist1D.GetBinContent(ieng+1) | 1077 | onaxis = hist1D.GetBinContent(ieng+1) |
| @@ -1324,7 +1306,7 @@ class csroot2caldb(ctools.cscript): | @@ -1324,7 +1306,7 @@ class csroot2caldb(ctools.cscript): | ||
| 1324 | def _make_2D(self, array, hdu, name, unit, scale=1.0): | 1306 | def _make_2D(self, array, hdu, name, unit, scale=1.0): |
| 1325 | """ | 1307 | """ |
| 1326 | Make 2D data column as function of energy and offset angle | 1308 | Make 2D data column as function of energy and offset angle |
| 1327 | - | 1309 | + |
| 1328 | If the HDU has already the energy and offset angle columns, this method | 1310 | If the HDU has already the energy and offset angle columns, this method |
| 1329 | will simply add another data column. If name==None, the method will not | 1311 | will simply add another data column. If name==None, the method will not |
| 1330 | append any data column. | 1312 | append any data column. |
| @@ -1381,7 +1363,7 @@ class csroot2caldb(ctools.cscript): | @@ -1381,7 +1363,7 @@ class csroot2caldb(ctools.cscript): | ||
| 1381 | def _make_3D(self, array, hdu, name, unit): | 1363 | def _make_3D(self, array, hdu, name, unit): |
| 1382 | """ | 1364 | """ |
| 1383 | Make 3D data column as function of DETX, DETY and energy | 1365 | Make 3D data column as function of DETX, DETY and energy |
| 1384 | - | 1366 | + |
| 1385 | If the HDU has already the energy and offset angle columns, this method | 1367 | If the HDU has already the energy and offset angle columns, this method |
| 1386 | will simply add another data column. If name==None, the method will not | 1368 | will simply add another data column. If name==None, the method will not |
| 1387 | append any data column. | 1369 | append any data column. |
| @@ -1471,7 +1453,7 @@ class csroot2caldb(ctools.cscript): | @@ -1471,7 +1453,7 @@ class csroot2caldb(ctools.cscript): | ||
| 1471 | def _make_3D_migra(self, array, hdu, name, unit, scale=1.0): | 1453 | def _make_3D_migra(self, array, hdu, name, unit, scale=1.0): |
| 1472 | """ | 1454 | """ |
| 1473 | Make 3D data column as function of ETRUE, MIGRA and THETA | 1455 | Make 3D data column as function of ETRUE, MIGRA and THETA |
| 1474 | - | 1456 | + |
| 1475 | If the HDU has already the energy and offset angle columns, this method | 1457 | If the HDU has already the energy and offset angle columns, this method |
| 1476 | will simply add another data column. If name==None, the method will not | 1458 | will simply add another data column. If name==None, the method will not |
| 1477 | append any data column. | 1459 | append any data column. |