diff --git a/ChangeLog b/ChangeLog index 640b2b9..41d28f9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -12,6 +12,7 @@ * Bug fix version 1.3.1 released ================================ + ctbkgcube creates XML files compliant with non-CTA instruments (#2140) Reduce computation time of ctmodel and parallelize using OpenMP (#2147) Fix csresmap significance computation error (#2136) Use MigMatrixNoTheta2cut_offaxis and AngularPSF2DEtrue_offaxis histograms to diff --git a/cscripts/cscaldb.py b/cscripts/cscaldb.py index 7b61a27..4693653 100755 --- a/cscripts/cscaldb.py +++ b/cscripts/cscaldb.py @@ -204,6 +204,9 @@ class cscaldb(ctools.cscript): # Open logfile self.logFileOpen() + # Read ahead output parameters + self._read_ahead(True) + # Run the script self.run() diff --git a/cscripts/csebins.py b/cscripts/csebins.py index b9507ca..a0580c3 100755 --- a/cscripts/csebins.py +++ b/cscripts/csebins.py @@ -272,25 +272,6 @@ class csebins(ctools.cscript): # Return return - def execute(self): - """ - Execute the script - """ - # Open logfile - self.logFileOpen() - - # Read ahead output parameters - self._read_ahead(True) - - # Run the scrip - self.run() - - # Save energy boundaries - self.save() - - # Return - return - def save(self): """ Save energy boundaries @@ -322,6 +303,25 @@ class csebins(ctools.cscript): # Return return self._ebounds + def execute(self): + """ + Execute the script + """ + # Open logfile + self.logFileOpen() + + # Read ahead output parameters + self._read_ahead(True) + + # Run the scrip + self.run() + + # Save energy boundaries + self.save() + + # Return + return + # ======================== # # Main routine entry point # diff --git a/cscripts/csiactcopy.py b/cscripts/csiactcopy.py index 05bd4f7..7b84b1d 100755 --- a/cscripts/csiactcopy.py +++ b/cscripts/csiactcopy.py @@ -743,6 +743,9 @@ class csiactcopy(ctools.cscript): # Open logfile self.logFileOpen() + # Read ahead output parameters + self._read_ahead(True) + # Run the script self.run() diff --git a/cscripts/csiactdata.py b/cscripts/csiactdata.py index 934d760..a48dd44 100755 --- a/cscripts/csiactdata.py +++ b/cscripts/csiactdata.py @@ -184,6 +184,9 @@ class csiactdata(ctools.cscript): # Open logfile self.logFileOpen() + # Read ahead output parameters + self._read_ahead(True) + # Run the script self.run() diff --git a/cscripts/csobs2caldb.py b/cscripts/csobs2caldb.py index 3cde977..4daa71e 100755 --- a/cscripts/csobs2caldb.py +++ b/cscripts/csobs2caldb.py @@ -400,6 +400,9 @@ class csobs2caldb(ctools.cscript): # Open logfile self.logFileOpen() + # Read ahead output parameters + self._read_ahead(True) + # Run the script self.run() diff --git a/cscripts/cspull.py b/cscripts/cspull.py index 56eb1ac..5669185 100755 --- a/cscripts/cspull.py +++ b/cscripts/cspull.py @@ -329,6 +329,9 @@ class cspull(ctools.cscript): # Open logfile self.logFileOpen() + # Read ahead output parameters + self._read_ahead(True) + # Run the script self.run() diff --git a/cscripts/csresmap.py b/cscripts/csresmap.py index 2e0c380..0020d3d 100755 --- a/cscripts/csresmap.py +++ b/cscripts/csresmap.py @@ -246,21 +246,33 @@ class csresmap(ctools.cscript): # Compute sign map signmap = (self._resmap - modelmap).sign() - # Compute logarithm of map. For that we mask pixels - #logmap = self._resmap/modelmap - logmap = self._resmap.copy() # Python 3.x kluge - logmap /= modelmap - for i in range(logmap.npix()): - if logmap[i] > 0.0: - logmap[i] = math.log(logmap[i]) + # Loop over every bin in the map + for i in range(self._resmap.npix()): + + # If the model value > 0.0 do the computation as normal ... + model_val = modelmap[i] + if model_val > 0.0: + + # If the data value is also > 0 then compute the + # significance^2 and save it to the map ... + data_val = self._resmap[i] + if data_val > 0.0: + log_val = math.log(data_val/model_val) + self._resmap[i] = (data_val*log_val) + model_val - data_val + + # ... otherwise compute the reduced value of the above + # expression. This is necessary to avoid computing log(0). + else: + self._resmap[i] = model_val + + # ... otherwise hard-code the significance to 0 else: - logmap[i] = 0.0 - + self._resmap[i] = 0.0 + # Compute significance map - signif_squared_map = (self._resmap*logmap) + modelmap - self._resmap - signif_squared_map *= 2.0 - unsigned_resmap = signif_squared_map.sqrt() - self._resmap = unsigned_resmap * signmap + self._resmap *= 2.0 + self._resmap = self._resmap.sqrt() + self._resmap = self._resmap * signmap # Raise exception if algorithm is unknown else: diff --git a/cscripts/csroot2caldb.py b/cscripts/csroot2caldb.py index 38d1b66..42281f5 100755 --- a/cscripts/csroot2caldb.py +++ b/cscripts/csroot2caldb.py @@ -29,7 +29,7 @@ from cscripts import calutils # Optional ROOT import try: - from ROOT import TFile + from ROOT import TFile, TH2F, TH3F _has_root = True except ImportError: _has_root = False @@ -651,6 +651,78 @@ class csroot2caldb(ctools.cscript): # Return return + def _root2psf_get_r68_and_r80(self, tfile): + """ + Generates 68% and 80% containment radii histograms from + AngularPSF2DEtrue_offaxis histogram + + Parameters + ---------- + tfile : `~ROOT.TFile` + ROOT file + + Returns + ------- + r68, r80 : Tuple of `~ROOT.THF2` + 68% and 80% containment radius ROOT histograms + """ + # Get relevant ROOT histograms + psf = tfile.Get('AngularPSF2DEtrue_offaxis') + + # Extract axes + energies = psf.GetXaxis() + dists = psf.GetYaxis() + offsets = psf.GetZaxis() + + # Extract number of bins in histogram + neng = energies.GetNbins() + ndist = dists.GetNbins() + noffset = offsets.GetNbins() + + # Create r68 and r80 histograms + r68 = TH2F('AngRes68Etrue_offaxis', + 'Angular resolution (68% containment)', + neng, energies.GetBinLowEdge(1), energies.GetBinUpEdge(neng), + noffset, offsets.GetBinLowEdge(1), offsets.GetBinUpEdge(noffset)) + r80 = TH2F('AngRes80Etrue_offaxis', + 'Angular resolution (80% containment)', + neng, energies.GetBinLowEdge(1), energies.GetBinUpEdge(neng), + noffset, offsets.GetBinLowEdge(1), offsets.GetBinUpEdge(noffset)) + + # Loop over all energy and offset angle bins + for ieng in range(neng): + for ioff in range(noffset): + + # Compute PDF integral + pdf_integral = 0.0 + for idist in range(ndist): + pdf_integral += psf.GetBinContent(ieng+1,idist+1,ioff+1) + + # Compute 68% containment radius + pdf_68 = 0.0 + r68_angle = 0.0 + for idist in range(ndist): + pdf_68 += psf.GetBinContent(ieng+1,idist+1,ioff+1) + if pdf_68 > 0.68*pdf_integral: + r68_angle = dists.GetBinLowEdge(idist+1) + break + + # Compute 80% containment radius + pdf_80 = 0.0 + r80_angle = 0.0 + for idist in range(ndist): + pdf_80 += psf.GetBinContent(ieng+1,idist+1,ioff+1) + if pdf_80 > 0.80*pdf_integral: + r80_angle = dists.GetBinLowEdge(idist+1) + break + + # Set histogram values + r68.SetBinContent(ieng+1,ioff+1,r68_angle) + r80.SetBinContent(ieng+1,ioff+1,r80_angle) + + # Return + return r68, r80 + def _root2psf_gauss(self, tfile, irf, ds): """ Translate ROOT to CALDB point spread function extension @@ -677,7 +749,8 @@ class csroot2caldb(ctools.cscript): 'Generate Gaussian point spread function extension') # Get relevant ROOT histograms - r68 = tfile.Get('AngRes_offaxis') + #r68 = tfile.Get('AngRes_offaxis') + r68, _ = self._root2psf_get_r68_and_r80(tfile) # Extract number of bins in histogram neng = r68.GetXaxis().GetNbins() @@ -757,8 +830,9 @@ class csroot2caldb(ctools.cscript): 'Generate King point spread function extension') # Get relevant ROOT histograms - r68 = tfile.Get('AngRes_offaxis') - r80 = tfile.Get('AngRes80_offaxis') + #r68 = tfile.Get('AngRes_offaxis') + #r80 = tfile.Get('AngRes80_offaxis') + r68, r80 = self._root2psf_get_r68_and_r80(tfile) # Extract number of bins in histogram neng = r68.GetXaxis().GetNbins() @@ -869,6 +943,80 @@ class csroot2caldb(ctools.cscript): # Return return + def _root2edisp_get_migra(self, tfile): + """ + Generates migration matrix histogram from AngularPSF2DEtrue_offaxis + histogram + + Parameters + ---------- + tfile : `~ROOT.TFile` + ROOT file + + Returns + ------- + migra : `~ROOT.TH3F` + Migration matrix + """ + # Get relevant ROOT histograms + matrix = tfile.Get('MigMatrixNoTheta2cut_offaxis') + + # Extract axes + ereco = matrix.GetXaxis() + etrue = matrix.GetYaxis() + offsets = matrix.GetZaxis() + + # Extract number of bins in histogram + nereco = ereco.GetNbins() + netrue = etrue.GetNbins() + noffset = offsets.GetNbins() + + # Set number of migration bins + nmigra = 300 + + # Create migra histograms + migra = TH3F('EestOverEtrue_offaxis', + 'Migration', + netrue, etrue.GetBinLowEdge(1), etrue.GetBinUpEdge(netrue), + nmigra, 0.0, 3.0, + noffset, offsets.GetBinLowEdge(1), offsets.GetBinUpEdge(noffset)) + + # Loop over true energies + for ietrue in range(netrue): + + # Get true energy in TeV + e_true = math.pow(10.0, migra.GetXaxis().GetBinCenter(ietrue+1)) + + # Loop over migration values + for imigra in range(nmigra): + + # Get migration value + migration = migra.GetYaxis().GetBinCenter(imigra+1) + + # Compute reconstructed energy in TeV + e_reco = e_true * migration + + # Continue only if reconstructed energy is positive + if e_reco > 0.0: + + # Get reconstructed bin + ireco = ereco.FindFixBin(math.log10(e_reco)) + + # Continue only if bin is valid + if ireco > 0 and ireco <= nereco: + + # Loop over offset angles + for ioff in range(noffset): + + # Get bin value + value = matrix.GetBinContent(ireco,ietrue+1,ioff+1) + + # Set bin value + migra.SetBinContent(ietrue+1,imigra+1,ioff+1,value) + + # Return + return migra + def _root2edisp(self, tfile, irf, ds): """ Translate ROOT to CALDB energy dispersion extension @@ -889,7 +1037,8 @@ class csroot2caldb(ctools.cscript): self._log_header1(gammalib.TERSE, 'Generate energy dispersion extension') # Get relevant ROOT histograms - matrix = tfile.Get('EestOverEtrue_offaxis') + matrix = self._root2edisp_get_migra(tfile) + #matrix = tfile.Get('EestOverEtrue_offaxis') # Write boundary keywords self._set_cif_keywords(ds['HDU_EDISP'], irf['EDISP_NAME'], @@ -1635,6 +1784,9 @@ class csroot2caldb(ctools.cscript): # Open logfile self.logFileOpen() + # Read ahead output parameters + self._read_ahead(True) + # Run the script self.run() diff --git a/cscripts/cssens.py b/cscripts/cssens.py index 4165895..e615d47 100755 --- a/cscripts/cssens.py +++ b/cscripts/cssens.py @@ -649,6 +649,9 @@ class cssens(ctools.cscript): # Open logfile self.logFileOpen() + # Read ahead output parameters + self._read_ahead(True) + # Run the script self.run() diff --git a/cscripts/cstsdist.py b/cscripts/cstsdist.py index f35029a..2ccd0f4 100755 --- a/cscripts/cstsdist.py +++ b/cscripts/cstsdist.py @@ -295,6 +295,9 @@ class cstsdist(ctools.cscript): # Open logfile self.logFileOpen() + # Read ahead output parameters + self._read_ahead(True) + # Run the script self.run() diff --git a/cscripts/cstsmapsplit.py b/cscripts/cstsmapsplit.py index 48e8310..3a17b61 100755 --- a/cscripts/cstsmapsplit.py +++ b/cscripts/cstsmapsplit.py @@ -255,19 +255,6 @@ class cstsmapsplit(ctools.cscript): # Return return - def execute(self): - """ - Execute the script - """ - # Run the script - self.run() - - # Save results - self.save() - - # Return - return - def save(self): """ Save commands to ASCII file @@ -291,6 +278,25 @@ class cstsmapsplit(ctools.cscript): # Return return + def execute(self): + """ + Execute the script + """ + # Open logfile + self.logFileOpen() + + # Read ahead output parameters + self._read_ahead(True) + + # Run the script + self.run() + + # Save results + self.save() + + # Return + return + # ======================== # # Main routine entry point # diff --git a/cscripts/csviscube.py b/cscripts/csviscube.py index 9e3ae2a..8cd55b0 100755 --- a/cscripts/csviscube.py +++ b/cscripts/csviscube.py @@ -519,6 +519,9 @@ class csviscube(ctools.cscript): # Open logfile self.logFileOpen() + # Read ahead output parameters + self._read_ahead(True) + # Run the script self.run() diff --git a/cscripts/csworkflow.py b/cscripts/csworkflow.py index 98a9939..76a23d2 100755 --- a/cscripts/csworkflow.py +++ b/cscripts/csworkflow.py @@ -360,6 +360,9 @@ class csworkflow(ctools.cscript): # Open logfile self.logFileOpen() + # Read ahead output parameters + self._read_ahead(True) + # Run the script self.run() diff --git a/dev/make_root_irf.py b/dev/make_root_irf.py new file mode 100755 index 0000000..2d3745c --- /dev/null +++ b/dev/make_root_irf.py @@ -0,0 +1,45 @@ +#! /usr/bin/env python +# ========================================================================== +# Generates ROOT IRF test file +# +# Copyright (C) 2017 Juergen Knoedlseder +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# ========================================================================== +from ROOT import TFile + +# Open input file +filename = '/project-data/cta/performance/prod3b/CTA-Performance-North-E-20170502/CTA-Performance-North-20deg-average-50h_20170502.root' +infile = TFile(filename) + +# Open output file +outfile = TFile('irf.root', 'RECREATE') + +# Open histograms +aeff1 = infile.Get('EffectiveAreaEtrueNoTheta2cut_offaxis') +aeff2 = infile.Get('EffectiveAreaEtrueNoTheta2cut') +psf1 = infile.Get('AngRes_offaxis') +psf2 = infile.Get('AngRes80_offaxis') +psf3 = infile.Get('AngularPSF2DEtrue_offaxis') +edisp1 = infile.Get('EestOverEtrue_offaxis') +edisp2 = infile.Get('MigMatrixNoTheta2cut_offaxis') +bkg1 = infile.Get('BGRatePerSqDeg_offaxis') +bkg2 = infile.Get('BGRatePerSqDeg') + +# Write histograms +infile.GetList().Write() + +# Close output file +outfile.Close() diff --git a/doc/source/admin/download.rst b/doc/source/admin/download.rst index a9de8ff..8264082 100644 --- a/doc/source/admin/download.rst +++ b/doc/source/admin/download.rst @@ -13,7 +13,7 @@ bugs. Releases -------- -The latest ctools release is ``ctools-1.3.0`` (7 June 2017). +The latest ctools release is ``ctools-1.3.1`` (20 July 2017). Below a table of ctools releases. Please read the :ref:`sec_release` to learn more about new features and corrected bugs in a given release. @@ -31,6 +31,9 @@ learn more about new features and corrected bugs in a given release. * - ctools - gammalib - Mac OS X package + * - `1.3.1 `_ + - `1.3.1 `_ + - `ctools-1.3.1-macosx10.7.dmg `_ * - `1.3.0 `_ - `1.3.0 `_ - `ctools-1.3.0-macosx10.7.dmg `_ diff --git a/doc/source/admin/release_history/1.3.1.rst b/doc/source/admin/release_history/1.3.1.rst index 0110917..810a8ca 100644 --- a/doc/source/admin/release_history/1.3.1.rst +++ b/doc/source/admin/release_history/1.3.1.rst @@ -1,7 +1,7 @@ .. _1.3.1: -ctools 1.3.1 release -==================== +ctools 1.3.1 release (20 July 2017) +=================================== Overview -------- diff --git a/doc/source/develop/index.rst b/doc/source/develop/index.rst index 436ecd4..bf475b1 100644 --- a/doc/source/develop/index.rst +++ b/doc/source/develop/index.rst @@ -45,7 +45,7 @@ Links: * `GitHub `_ * `Redmine `_ * `Open HUB `_ -* `Source code documentation (Doxygen) `_ +* `Source code documentation (Doxygen) <../doxygen/index.html>`_ And here some status shields: diff --git a/doc/source/users/reference_manual/csroot2caldb.rst b/doc/source/users/reference_manual/csroot2caldb.rst new file mode 100644 index 0000000..ccf4e94 --- /dev/null +++ b/doc/source/users/reference_manual/csroot2caldb.rst @@ -0,0 +1,108 @@ +.. _csroot2caldb: + +csroot2caldb +============ + +Creates a caldb entry from a ROOT performance file. + + +Synopsis +-------- + +This script creates an entry in the local calibration database from a ROOT +performance file. + + +General parameters +------------------ + +``infile [file]`` + Input ROOT performance file file. + +``(outdir = ) [string]`` + Output CALDB directory. + +``inst [string]`` + Instrument name. + +``id [string]`` + Instrument Response Function identifier. + +``version [string]`` + Instrument Response Function version. + +``analysis [string]`` + Instrument Response Function analysis. + +``zenith [real]`` + Zenith angle (in degrees). + +``azimuth [real]`` + Azimuth angle (in degrees). + +``(emin = UNDEF) [real]`` + Minimum energy threshold (TeV). + +``(emax = UNDEF) [real]`` + Maximum energy threshold (TeV). + +``(psftype = Gauss) [string]`` + Point spread function type. + +``(split = no) [boolean]`` + Split IRF components into different files. + +``(norm1d = no) [boolean]`` + Normalize on 1D histograms. + +``(rebin = no) [boolean]`` + Rebin. + +``(eascale = 1.0) [real]`` + Scaling factor for effective areas. + +``(bgdscale = 1.0) [real]`` + Scaling factor for background rates. + +``(bgdoversample = 1) [integer]`` + Spatial oversampling factor for background template. + +``(bgdethres = 1000.0) [real]`` + Energy above which to replace background by power law (TeV). + +``(bgdinfill = no) [boolean]`` + Infill of background template?. + + +Standard parameters +------------------- + +``(chatter = 2) [integer]`` + Verbosity of the executable: + ``chatter = 0``: no information will be logged + + ``chatter = 1``: only errors will be logged + + ``chatter = 2``: errors and actions will be logged + + ``chatter = 3``: report about the task execution + + ``chatter = 4``: detailed report about the task execution + +``(clobber = yes) [boolean]`` + Specifies whether an existing output file should be overwritten. + +``(debug = no) [boolean]`` + Enables debug mode. In debug mode the executable will dump any log file output to the console. + +``(mode = ql) [string]`` + Mode of automatic parameters (default is "ql", i.e. "query and learn"). + +``(logfile = csroot2caldb.log) [filename]`` + Log filename. + + +Related tools or scripts +------------------------ + +:doc:`cscaldb` diff --git a/doc/source/users/reference_manual/index.rst b/doc/source/users/reference_manual/index.rst index f81202a..9e6c17b 100644 --- a/doc/source/users/reference_manual/index.rst +++ b/doc/source/users/reference_manual/index.rst @@ -53,6 +53,7 @@ cscripts csphasecrv --- Computes phase curve cspull --- Generates pull distribution csresmap --- Generates residual map + csroot2caldb --- Creates a caldb entry from a ROOT file cssens --- Computes CTA sensitivity csspec --- Computes spectral points cssrcdetect --- Detects sources in sky map diff --git a/doc/source/users/user_manual/getting_started/index.rst b/doc/source/users/user_manual/getting_started/index.rst deleted file mode 100644 index 2ce9cfd..0000000 --- a/doc/source/users/user_manual/getting_started/index.rst +++ /dev/null @@ -1,12 +0,0 @@ -.. _sec_using: - -Using ctools -============ - -.. toctree:: - :maxdepth: 1 - - python - models - response - diff --git a/doc/source/users/user_manual/index.rst b/doc/source/users/user_manual/index.rst index 243ca69..993b830 100644 --- a/doc/source/users/user_manual/index.rst +++ b/doc/source/users/user_manual/index.rst @@ -1,4 +1,5 @@ -=========== +.. _sec_user_manual: + User Manual =========== @@ -6,6 +7,7 @@ User Manual :maxdepth: 1 introduction - getting_started/index + response + models plotting - + python diff --git a/doc/source/users/user_manual/introduction.rst b/doc/source/users/user_manual/introduction.rst index 52515ab..03f1d1a 100644 --- a/doc/source/users/user_manual/introduction.rst +++ b/doc/source/users/user_manual/introduction.rst @@ -53,8 +53,7 @@ command line or used as Python classes, as illustrated below: >>> import cscripts >>> pull = cscripts.cspull() -In this User Manual you will now learn how to install and use the ctools -package. +In this User Manual you will now learn how to use the ctools package. If you encounter any problems, please read the :ref:`sec_help` section. And you should read the :ref:`sec_develop` section if you would like to contribute to the ctools developments. diff --git a/doc/source/users/user_manual/getting_started/irf-aeff.png b/doc/source/users/user_manual/irf-aeff.png index eabbe69..eabbe69 100644 --- a/doc/source/users/user_manual/getting_started/irf-aeff.png +++ b/doc/source/users/user_manual/irf-aeff.png diff --git a/doc/source/users/user_manual/getting_started/irf-file.png b/doc/source/users/user_manual/irf-file.png index 31f1599..31f1599 100644 --- a/doc/source/users/user_manual/getting_started/irf-file.png +++ b/doc/source/users/user_manual/irf-file.png diff --git a/doc/source/users/user_manual/getting_started/irfs.jpg b/doc/source/users/user_manual/irfs.jpg index c60bb63..c60bb63 100644 --- a/doc/source/users/user_manual/getting_started/irfs.jpg +++ b/doc/source/users/user_manual/irfs.jpg diff --git a/doc/source/users/user_manual/getting_started/model_lightcurve.png b/doc/source/users/user_manual/model_lightcurve.png index 27119e0..27119e0 100644 --- a/doc/source/users/user_manual/getting_started/model_lightcurve.png +++ b/doc/source/users/user_manual/model_lightcurve.png diff --git a/doc/source/users/user_manual/getting_started/model_phasecurve.png b/doc/source/users/user_manual/model_phasecurve.png index 9ddaa6f..9ddaa6f 100644 --- a/doc/source/users/user_manual/getting_started/model_phasecurve.png +++ b/doc/source/users/user_manual/model_phasecurve.png diff --git a/doc/source/users/user_manual/getting_started/models.rst b/doc/source/users/user_manual/models.rst index f9ebdd2..f9ebdd2 100644 --- a/doc/source/users/user_manual/getting_started/models.rst +++ b/doc/source/users/user_manual/models.rst diff --git a/doc/source/users/user_manual/getting_started/python.rst b/doc/source/users/user_manual/python.rst index 8263211..c530fc9 100644 --- a/doc/source/users/user_manual/getting_started/python.rst +++ b/doc/source/users/user_manual/python.rst @@ -303,8 +303,9 @@ Here an example of how to use ``obsutils``: Number of predicted events : 0 >>> obs.models(gammalib.GModels("${CTOOLS}/share/models/crab.xml")) >>> obs = obsutils.sim(obs) - >>> like = obsutils.fit(obs) - >>> print(like.obs().models()) + >>> like = ctools.ctlike(obs) + >>> like.run() + >>> print(like.obs().models()) === GModels === Number of models ..........: 2 Number of parameters ......: 10 @@ -320,13 +321,10 @@ cover the 0.1-100 TeV energy range and a field of view of 5°. The ``South_0.5h`` IRF from the Prod2 calibration database will be used. A model is then appended to the observation container using the ``obs.models()`` method. -The ``obsutils.sim()`` function then simulates the event data, the -``obsutils.fit()`` function performs a maximum likelihood fit. - -.. note:: - - The ``obsutils`` module is not yet fully developed and more convenience - functions will be added in the future. +The ``obsutils.sim()`` function then simulates the event data and returns +an observation container with the simulated observations. +The observation container is then passed to ``ctlike`` for maximum likelihood +fitting. Access analysis results @@ -365,13 +363,21 @@ In the following it is assumed that you have a ctlike object called .. code-block:: python - like.opt().value() # Returns likelihood value + logL = like.opt().value() # Returns log-likelihood value + print(logL) + + or alternatively + + .. code-block:: python + + logL = like.obs().function().value() # Returns log-likelihood value + print(logL) * Curvature Matrix (aka Hessian) .. code-block:: python - curvature = like.opt().curvature().invert() # Return GMatrix object + curvature = like.obs().function().curvature() # Return GMatrixSparse object print(curvature) To get the covariance matrix, the curvature matrix needs to be diff --git a/doc/source/users/user_manual/getting_started/response.rst b/doc/source/users/user_manual/response.rst index 599cd09..599cd09 100644 --- a/doc/source/users/user_manual/getting_started/response.rst +++ b/doc/source/users/user_manual/response.rst diff --git a/src/ctbkgcube/ctbkgcube.cpp b/src/ctbkgcube/ctbkgcube.cpp index 9e02ddd..7bb7ea5 100644 --- a/src/ctbkgcube/ctbkgcube.cpp +++ b/src/ctbkgcube/ctbkgcube.cpp @@ -315,7 +315,8 @@ void ctbkgcube::run(void) model.name("BackgroundModel"); // Set model instruments - model.instruments(instruments); + //model.instruments(instruments); + model.instruments("CTA,HESS,MAGIC,VERITAS"); // Temporary fix for #2140 // Append model to output container m_outmdl.append(model); diff --git a/test/data/irf.root b/test/data/irf.root index e34aa8e..c390c01 100644 --- a/test/data/irf.root +++ b/test/data/irf.root