Commit 4706ee00c75b0173c17378fcbf7ab39076c571dd
1 parent
a92dd304
Add upper limit computation is csspec for NODES method (#2233)
Showing
4 changed files
with
44 additions
and
1 deletions
ChangeLog
| 1 | -2018-06-15 | |
| 1 | +2018-06-20 | |
| 2 | 2 | |
| 3 | 3 | * Version 1.6.0 released |
| 4 | 4 | ======================== |
| ... | ... | @@ -14,6 +14,7 @@ |
| 14 | 14 | Also compute TS in csspec for On/Off analysis using wstat statistic (#2312) |
| 15 | 15 | Allow specifying of input sky map in ctskymap (#2311) |
| 16 | 16 | Accelerate IRF and RING background methods in ctskymap (#2309) |
| 17 | + Add upper limit computation is csspec for NODES method (#2233) | |
| 17 | 18 | Define MET with respect to the observation time reference or "mjdref" |
| 18 | 19 | parameter (#2054) |
| 19 | 20 | ... | ... |
NEWS
| ... | ... | @@ -288,6 +288,10 @@ csspec now properly computes the Test Statistic for an On/Off analysis using |
| 288 | 288 | the "wstat" statistic in the case that the input model definition XML file |
| 289 | 289 | did not contain a background model (#2312). |
| 290 | 290 | |
| 291 | +csspec now computes upper limits also for the NODES method by fixing all node | |
| 292 | +intensities and varying each node until the log-likelihood increases by a | |
| 293 | +certain amount (#2233). | |
| 294 | + | |
| 291 | 295 | |
| 292 | 296 | cssrcdetect - Detects sources in sky map |
| 293 | 297 | ---------------------------------------- | ... | ... |
cscripts/csspec.py
| ... | ... | @@ -758,6 +758,42 @@ class csspec(ctools.csobservation): |
| 758 | 758 | result['flux'] = spectrum[i*2+1].value() * norm |
| 759 | 759 | result['flux_err'] = spectrum[i*2+1].error() * norm |
| 760 | 760 | |
| 761 | + # Compute upper flux limit | |
| 762 | + ulimit_value = -1.0 | |
| 763 | + if self['calc_ulim'].boolean(): | |
| 764 | + | |
| 765 | + # Logging information | |
| 766 | + self._log_header3(gammalib.EXPLICIT, 'Computing upper limit') | |
| 767 | + | |
| 768 | + # Copy observation container | |
| 769 | + obs = like.obs().copy() | |
| 770 | + | |
| 771 | + # Fix intensities of all nodes | |
| 772 | + spectral = obs.models()[self['srcname'].string()].spectral() | |
| 773 | + for par in spectral: | |
| 774 | + par.fix() | |
| 775 | + | |
| 776 | + # Create upper limit object | |
| 777 | + ulimit = ctools.ctulimit(obs) | |
| 778 | + ulimit['srcname'] = self['srcname'].string() | |
| 779 | + ulimit['parname'] = 'Intensity%d' % i | |
| 780 | + ulimit['eref'] = elogmean.TeV() | |
| 781 | + ulimit['tol'] = 1.0e-3 | |
| 782 | + | |
| 783 | + # Try to run upper limit and catch exceptions | |
| 784 | + try: | |
| 785 | + ulimit.run() | |
| 786 | + ulimit_value = ulimit.diff_ulimit() | |
| 787 | + except: | |
| 788 | + self._log_string(gammalib.EXPLICIT, 'Upper limit ' | |
| 789 | + 'calculation failed.') | |
| 790 | + ulimit_value = -1.0 | |
| 791 | + | |
| 792 | + # Compute upper limit | |
| 793 | + if ulimit_value > 0.0: | |
| 794 | + result['ulimit'] = ulimit_value * elogmean.MeV() * \ | |
| 795 | + elogmean.MeV() * gammalib.MeV2erg | |
| 796 | + | |
| 761 | 797 | # Compute TS |
| 762 | 798 | if self['calc_ts'].boolean(): |
| 763 | 799 | ... | ... |
doc/source/admin/release_history/1.6.rst
| ... | ... | @@ -41,6 +41,8 @@ Improvements |
| 41 | 41 | Allow specifying of input skymap to :ref:`ctskymap` tool |
| 42 | 42 | * [`2309 <https://cta-redmine.irap.omp.eu/issues/2309>`_] - |
| 43 | 43 | Accelerate `IRF` and `RING` background methods in :ref:`ctskymap` |
| 44 | +* [`2233 <https://cta-redmine.irap.omp.eu/issues/2233>`_] - | |
| 45 | + Add upper limit computation is :ref:`csspec` for ``NODES`` method | |
| 44 | 46 | * [`2045 <https://cta-redmine.irap.omp.eu/issues/2045>`_] - |
| 45 | 47 | Define MET with respect to the observation time reference or the ``mjdref`` |
| 46 | 48 | user parameter (#2054) | ... | ... |