From ba197c905c9c38f808f0bce26b94bc723366972b Mon Sep 17 00:00:00 2001 From: Jürgen Knödlseder Date: Fri, 7 May 2021 22:07:43 +0200 Subject: [PATCH] Integrate code --- AUTHORS | 1 + ChangeLog | 3 ++- NEWS | 6 ++++-- README.md | 8 +++++--- cscripts/cssens.py | 52 ++++++++++++++++++++++++++++++++-------------------- doc/source/admin/release_history/2.0.rst | 6 ++++-- 6 files changed, 48 insertions(+), 28 deletions(-) diff --git a/AUTHORS b/AUTHORS index 1fc0d2f..37a2e56 100755 --- a/AUTHORS +++ b/AUTHORS @@ -14,6 +14,7 @@ Chia-Chun Lu (Chia-Chun.Lu@mpi-hd.mpg.de) Pierrick Martin (pierrick.martin@irap.omp.eu) Michael Mayer (michael.mayer@physik.hu-berlin.de) Stefan Ohm (stefan.ohm81@gmail.com) +Iftach Sadeh (iftach.sadeh@desy.de) David Sanchez (david.sanchez@lapp.in2p3.fr) Hubert Siejkowski (h.siejkowski@cyfronet.pl) Andreas Specovius (andreas.specovius@fau.de) diff --git a/ChangeLog b/ChangeLog index c1e231f..25233f6 100755 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,9 @@ -2021-04-30 +2021-05-07 * Version 2.0.0 released ======================== + Use test source position in cssens (#3555) Add ASCL shields to "About" page (#3630) Use file function constructor in csspec (#3626) Add BINS method to csspec (#3606) diff --git a/NEWS b/NEWS index cc92779..ea0c796 100755 --- a/NEWS +++ b/NEWS @@ -1,6 +1,6 @@ New Features and Important Changes in ctools 2.0.0 -30 April 2021 +7 May 2021 Introduction @@ -282,7 +282,9 @@ the width, height and position angle of the rectangular sky regions (#3248). cssens - Computes sensitivity curve ----------------------------------- -None +The test source position is now used as pointing direction, eventually offset +in galactic latitude by a number of degrees specified using the "offset" +parameter (#3555). csspec - Generates Spectral Energy Distribution diff --git a/README.md b/README.md index 89f17ce..8465e42 100755 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ctools information ================== -* Version: 2.0.0.dev (30 April 2021) +* Version: 2.0.0.dev (7 May 2021) * GammaLib dependency: 2.0.0.dev [![Build Status](https://cta-jenkins.irap.omp.eu/buildStatus/icon?job=ctools-integrate-os)](https://cta-jenkins.irap.omp.eu/job/ctools-integrate-os/) @@ -63,6 +63,7 @@ The following scripts are available: cscaldb - lists available instrument response functions csebins - generates energy boundaries for stacked analysis cslightcrv - computes light curve + csinfo - checks ctools and GammaLib installations csmodelinfo - shows model container content csmodelmerge - merges several model containers into one file csmodelselect - select models from model definition file @@ -76,6 +77,7 @@ The following scripts are available: csresmap - generates residual map csresspec - generates residual spectrum csroot2caldb - creates a caldb entry from a ROOT file + csscs - Performs spectral component separation cssens - computes CTA sensitivity csspec - computes spectral points cssrcdetect - detects sources in sky map @@ -159,8 +161,8 @@ The `make check` command will run an extensive unit test to verify that ctools was correctly built. Make sure that all tests were successful. -Macintosh OS X Installation -============================ +Macintosh OS Installation +========================== ctools is known to work on various flavors of Mac OS. To cope with different system versions and architectures, there are two Mac specific configure options: diff --git a/cscripts/cssens.py b/cscripts/cssens.py index 4addf45..a7d6f25 100755 --- a/cscripts/cssens.py +++ b/cscripts/cssens.py @@ -2,7 +2,7 @@ # ========================================================================== # Computes the array sensitivity using the Test Statistic for a test source # -# Copyright (C) 2011-2019 Juergen Knoedlseder +# Copyright (C) 2011-2021 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 @@ -189,16 +189,38 @@ class cssens(ctools.csobservation): # ... otherwise allocate a single observation else: - # set the coordinates of the test source model - if lpnt is None and bpnt is None: - container = gammalib.GModels(self['inmodel'].filename()) - src_model = container[self['srcname'].string()] - pntdir = gammalib.GSkyDir() - pntdir.radec_deg(src_model['RA'].value(), src_model['DEC'].value()) + # If no pointing is specified and if the test source has a position + # then set the pointing to the position of the test source + if lpnt is None and bpnt is None: + models = gammalib.GModels(self['inmodel'].filename()) + source = models[self['srcname'].string()] + if source.has_par('RA') and source.has_par('DEC'): + pntdir = gammalib.GSkyDir() + pntdir.radec_deg(source['RA'].value(), source['DEC'].value()) + lpnt = pntdir.l_deg() + bpnt = pntdir.b_deg() + elif source.has_par('GLON') and source.has_par('GLAT'): + lpnt = source['GLON'].value() + bpnt = source['GLAT'].value() + else: + lpnt = 0.0 + bpnt = 0.0 - lpnt = pntdir.l_deg() - bpnt = pntdir.b_deg() + # Set source position + srcdir = gammalib.GSkyDir() + srcdir.lb_deg(lpnt, bpnt) + self._ra = srcdir.ra_deg() + self._dec = srcdir.dec_deg() + + # Set pointing direction offset in galactic latitude + offset = self['offset'].real() + bpnt += offset + if bpnt > 90.0: + bpnt = 180.0 - bpnt + lpnt += 180.0 + pntdir = gammalib.GSkyDir() + pntdir.lb_deg(lpnt, bpnt) # Read relevant user parameters caldb = self['caldb'].string() @@ -210,10 +232,6 @@ class cssens(ctools.csobservation): # Allocate observation container obs = gammalib.GObservations() - # Set single pointing - pntdir = gammalib.GSkyDir() - pntdir.lb_deg(lpnt, bpnt) - # Create CTA observation run = obsutils.set_obs(pntdir, caldb=caldb, irf=irf, duration=duration, deadc=deadc, @@ -222,12 +240,6 @@ class cssens(ctools.csobservation): # Append observation to container obs.append(run) - # Set source position - offset = self['offset'].real() - pntdir.lb_deg(lpnt, bpnt+offset) - self._ra = pntdir.ra_deg() - self._dec = pntdir.dec_deg() - # Return observation container return obs @@ -632,7 +644,7 @@ class cssens(ctools.csobservation): def _e_bin(self, ieng): """ Determines sensivity in energy bin - + Parameters ---------- ieng : int diff --git a/doc/source/admin/release_history/2.0.rst b/doc/source/admin/release_history/2.0.rst index 272f7d3..25ffe35 100644 --- a/doc/source/admin/release_history/2.0.rst +++ b/doc/source/admin/release_history/2.0.rst @@ -1,7 +1,7 @@ .. _2.0: -ctools 2.0 release (30 April 2021) -================================== +ctools 2.0 release (7 May 2021) +=============================== Overview -------- @@ -24,6 +24,8 @@ Bug fixes Improvements ------------ +* [`3555 `_] - + Use test source position in :ref:`cssens` * [`3630 `_] - Add ASCL shields to **About** page * [`3626 `_] - -- libgit2 0.21.4