Commit 358726aa9c6630ec7c45913fab9e4e17ec8ca84f
Merge branch 'devel' of https://cta-gitlab.irap.omp.eu/ctools/ctools into devel
Showing
13 changed files
with
209 additions
and
95 deletions
ChangeLog
| 1 | -2018-02-14 | 1 | +2018-04-10 |
| 2 | 2 | ||
| 3 | * Version 1.6.0 released | 3 | * Version 1.6.0 released |
| 4 | ======================== | 4 | ======================== |
| 5 | 5 | ||
| 6 | + Keep existing library path in installation script on Mac OS X (#2420) | ||
| 7 | + Add show_rmf.py example script | ||
| 6 | Allow specifying of input sky map in ctskymap (#2311) | 8 | Allow specifying of input sky map in ctskymap (#2311) |
| 7 | Add ras() and decs() methods to csobsinfo (#2313) | 9 | Add ras() and decs() methods to csobsinfo (#2313) |
| 8 | Accelerate IRF and RING background methods in ctskymap (#2309) | 10 | Accelerate IRF and RING background methods in ctskymap (#2309) |
| 9 | 11 | ||
| 10 | 12 | ||
| 11 | -2018-02-16 | 13 | +2018-03-26 |
| 12 | 14 | ||
| 13 | * Bug fix version 1.5.1 released | 15 | * Bug fix version 1.5.1 released |
| 14 | ================================ | 16 | ================================ |
| 15 | 17 | ||
| 18 | + Fix MANPATH for Mac OS X systems (#2420) | ||
| 16 | Take energy dispersion in csresspec modelling into account (#2341) | 19 | Take energy dispersion in csresspec modelling into account (#2341) |
| 17 | Enable using csphagen for HESS, VERITAS and MAGIC observations (#2307) | 20 | Enable using csphagen for HESS, VERITAS and MAGIC observations (#2307) |
| 18 | 21 |
NEWS
| 1 | New Features and Important Changes in ctools 1.6.0 | 1 | New Features and Important Changes in ctools 1.6.0 |
| 2 | 2 | ||
| 3 | -14 February 2018 | 3 | +10 April 2018 |
| 4 | 4 | ||
| 5 | 5 | ||
| 6 | Introduction | 6 | Introduction |
| @@ -11,7 +11,7 @@ ctools release with respect to the precedent release. | @@ -11,7 +11,7 @@ ctools release with respect to the precedent release. | ||
| 11 | 11 | ||
| 12 | Configuration | 12 | Configuration |
| 13 | ------------- | 13 | ------------- |
| 14 | -None | 14 | +Keep existing library path in installation script on Mac OS X (#2420) |
| 15 | 15 | ||
| 16 | 16 | ||
| 17 | Python interface | 17 | Python interface |
| @@ -306,7 +306,7 @@ None | @@ -306,7 +306,7 @@ None | ||
| 306 | 306 | ||
| 307 | Examples | 307 | Examples |
| 308 | -------- | 308 | -------- |
| 309 | -None | 309 | +Added show_rmf.py script. |
| 310 | 310 | ||
| 311 | 311 | ||
| 312 | caldb | 312 | caldb |
cscripts/csresspec.py
| @@ -253,42 +253,15 @@ class csresspec(ctools.csobservation): | @@ -253,42 +253,15 @@ class csresspec(ctools.csobservation): | ||
| 253 | cntcube['ebinfile'] = self['ebinfile'].filename() | 253 | cntcube['ebinfile'] = self['ebinfile'].filename() |
| 254 | else: | 254 | else: |
| 255 | cntcube['enumbins'] = self['enumbins'].integer() | 255 | cntcube['enumbins'] = self['enumbins'].integer() |
| 256 | - cntcube['emin'] = self['emin'].real() | ||
| 257 | - cntcube['emax'] = self['emax'].real() | 256 | + cntcube['emin'] = self['emin'].real() |
| 257 | + cntcube['emax'] = self['emax'].real() | ||
| 258 | cntcube.run() | 258 | cntcube.run() |
| 259 | 259 | ||
| 260 | # Retrieve the binned observation container | 260 | # Retrieve the binned observation container |
| 261 | binned_obs = cntcube.obs().copy() | 261 | binned_obs = cntcube.obs().copy() |
| 262 | 262 | ||
| 263 | - # Log response computation | ||
| 264 | - self._log_string(gammalib.EXPLICIT, 'Computing binned response') | ||
| 265 | - | ||
| 266 | - # Compute binned response | ||
| 267 | - response = obsutils.get_stacked_response(obs, ra, dec, | ||
| 268 | - binsz=0.02, | ||
| 269 | - nxpix=npix, | ||
| 270 | - nypix=npix, | ||
| 271 | - coordsys='CEL', | ||
| 272 | - proj='TAN', | ||
| 273 | - emin=self['emin'].real(), | ||
| 274 | - emax=self['emax'].real(), | ||
| 275 | - edisp=self['edisp'].boolean()) | ||
| 276 | - | ||
| 277 | - if self['edisp'].boolean(): | ||
| 278 | - binned_obs[0].response(response['expcube'], response['psfcube'], | ||
| 279 | - response['edispcube'], response['bkgcube']) | ||
| 280 | - else: | ||
| 281 | - binned_obs[0].response(response['expcube'], response['psfcube'], | ||
| 282 | - response['bkgcube']) | ||
| 283 | - | ||
| 284 | - # Get new models | ||
| 285 | - models = response['models'] | ||
| 286 | - | ||
| 287 | - # Set models for observation container | ||
| 288 | - binned_obs.models(models) | ||
| 289 | - | ||
| 290 | - # Check if energy boundaries provided by user extend beyond | ||
| 291 | - # the content of the event list | 263 | + # Check if energy boundaries provided by user extend beyond the |
| 264 | + # content of the event list | ||
| 292 | if self['emin'].real() > obs[0].events().emin().TeV(): | 265 | if self['emin'].real() > obs[0].events().emin().TeV(): |
| 293 | emin = 'INDEF' | 266 | emin = 'INDEF' |
| 294 | else: | 267 | else: |
| @@ -601,21 +574,24 @@ class csresspec(ctools.csobservation): | @@ -601,21 +574,24 @@ class csresspec(ctools.csobservation): | ||
| 601 | # Calculate models of individual components if requested | 574 | # Calculate models of individual components if requested |
| 602 | if self['components'].boolean(): | 575 | if self['components'].boolean(): |
| 603 | for component in obs.models(): | 576 | for component in obs.models(): |
| 577 | + | ||
| 578 | + # Log component | ||
| 604 | self._log_value(gammalib.NORMAL, | 579 | self._log_value(gammalib.NORMAL, |
| 605 | - 'Computing model for component', | 580 | + 'Computing model component', |
| 606 | component.name()) | 581 | component.name()) |
| 607 | - # Set model cube models to | ||
| 608 | - # individual component | 582 | + |
| 583 | + # Set model cube models to individual component | ||
| 609 | model_cont = gammalib.GModels() | 584 | model_cont = gammalib.GModels() |
| 610 | model_cont.append(component) | 585 | model_cont.append(component) |
| 611 | modelcube.obs().models(model_cont) | 586 | modelcube.obs().models(model_cont) |
| 612 | 587 | ||
| 613 | # Run model cube | 588 | # Run model cube |
| 589 | + modelcube['edisp'] = self['edisp'].boolean() | ||
| 614 | modelcube.run() | 590 | modelcube.run() |
| 615 | 591 | ||
| 616 | # Extract spectrum of individual component | 592 | # Extract spectrum of individual component |
| 617 | modcube = modelcube.cube().copy() | 593 | modcube = modelcube.cube().copy() |
| 618 | - model = self._cube_to_spectrum(modcube, evlist_info) | 594 | + model = self._cube_to_spectrum(modcube, evlist_info) |
| 619 | 595 | ||
| 620 | # append component to table | 596 | # append component to table |
| 621 | table = self._append_column(table, component.name(), | 597 | table = self._append_column(table, component.name(), |
doc/source/admin/download.rst
| @@ -3,7 +3,7 @@ | @@ -3,7 +3,7 @@ | ||
| 3 | Download | 3 | Download |
| 4 | ======== | 4 | ======== |
| 5 | 5 | ||
| 6 | -The latest ctools release is ``ctools-1.5.0`` (28 January 2018). | 6 | +The latest ctools release is ``ctools-1.5.1`` (26 March 2018). |
| 7 | 7 | ||
| 8 | Below a table of ctools releases. Please read the :ref:`sec_release` to | 8 | Below a table of ctools releases. Please read the :ref:`sec_release` to |
| 9 | learn more about new features and corrected bugs in a given release. | 9 | learn more about new features and corrected bugs in a given release. |
| @@ -23,6 +23,9 @@ learn more about new features and corrected bugs in a given release. | @@ -23,6 +23,9 @@ learn more about new features and corrected bugs in a given release. | ||
| 23 | * - ctools | 23 | * - ctools |
| 24 | - gammalib | 24 | - gammalib |
| 25 | - Mac OS X (10.7+) binary disk image | 25 | - Mac OS X (10.7+) binary disk image |
| 26 | + * - `1.5.1 <http://cta.irap.omp.eu/ctools/releases/ctools/ctools-1.5.1.tar.gz>`_ | ||
| 27 | + - `1.5.1 <http://cta.irap.omp.eu/ctools/releases/gammalib/gammalib-1.5.1.tar.gz>`_ | ||
| 28 | + - `ctools-1.5.1-macosx10.7.dmg <http://cta.irap.omp.eu/ctools/releases/ctools/ctools-1.5.1-macosx10.7.dmg>`_ | ||
| 26 | * - `1.5.0 <http://cta.irap.omp.eu/ctools/releases/ctools/ctools-1.5.0.tar.gz>`_ | 29 | * - `1.5.0 <http://cta.irap.omp.eu/ctools/releases/ctools/ctools-1.5.0.tar.gz>`_ |
| 27 | - `1.5.0 <http://cta.irap.omp.eu/ctools/releases/gammalib/gammalib-1.5.0.tar.gz>`_ | 30 | - `1.5.0 <http://cta.irap.omp.eu/ctools/releases/gammalib/gammalib-1.5.0.tar.gz>`_ |
| 28 | - `ctools-1.5.0-macosx10.7.dmg <http://cta.irap.omp.eu/ctools/releases/ctools/ctools-1.5.0-macosx10.7.dmg>`_ | 31 | - `ctools-1.5.0-macosx10.7.dmg <http://cta.irap.omp.eu/ctools/releases/ctools/ctools-1.5.0-macosx10.7.dmg>`_ |
doc/source/admin/release_history/1.5.1.rst
| 1 | .. _1.5.1: | 1 | .. _1.5.1: |
| 2 | 2 | ||
| 3 | -ctools 1.5.1 release | ||
| 4 | -==================== | 3 | +ctools 1.5.1 release (26 March 2018) |
| 4 | +==================================== | ||
| 5 | 5 | ||
| 6 | Overview | 6 | Overview |
| 7 | -------- | 7 | -------- |
| @@ -10,6 +10,8 @@ ctools 1.5.1 is a bug fix release for ctools release 1.5. | @@ -10,6 +10,8 @@ ctools 1.5.1 is a bug fix release for ctools release 1.5. | ||
| 10 | 10 | ||
| 11 | The following bugs were fixed: | 11 | The following bugs were fixed: |
| 12 | 12 | ||
| 13 | +* [`2420 <https://cta-redmine.irap.omp.eu/issues/2420>`_] - | ||
| 14 | + Fix ``MANPATH`` for Mac OS X systems | ||
| 13 | * [`2341 <https://cta-redmine.irap.omp.eu/issues/2341>`_] - | 15 | * [`2341 <https://cta-redmine.irap.omp.eu/issues/2341>`_] - |
| 14 | Take energy dispersion in :ref:`csresspec` modelling into account | 16 | Take energy dispersion in :ref:`csresspec` modelling into account |
| 15 | 17 |
doc/source/admin/release_history/1.6.rst
| @@ -16,12 +16,14 @@ In particular, this release provides: | @@ -16,12 +16,14 @@ In particular, this release provides: | ||
| 16 | Bug fixes | 16 | Bug fixes |
| 17 | --------- | 17 | --------- |
| 18 | 18 | ||
| 19 | -* ... | 19 | +* [`2420 <https://cta-redmine.irap.omp.eu/issues/2420>`_] - |
| 20 | + Keep existing library path in installation script on Mac OS X | ||
| 20 | 21 | ||
| 21 | 22 | ||
| 22 | Improvements | 23 | Improvements |
| 23 | ------------ | 24 | ------------ |
| 24 | 25 | ||
| 26 | +* Add ``show_rmf.py`` example script | ||
| 25 | * [`2313 <https://cta-redmine.irap.omp.eu/issues/2313>`_] - | 27 | * [`2313 <https://cta-redmine.irap.omp.eu/issues/2313>`_] - |
| 26 | Add `ras()` and `decs()` methods to :ref:`csobsinfo` | 28 | Add `ras()` and `decs()` methods to :ref:`csobsinfo` |
| 27 | * [`2311 <https://cta-redmine.irap.omp.eu/issues/2311>`_] - | 29 | * [`2311 <https://cta-redmine.irap.omp.eu/issues/2311>`_] - |
examples/Makefile.am
| @@ -26,6 +26,7 @@ scripts = README.md \ | @@ -26,6 +26,7 @@ scripts = README.md \ | ||
| 26 | show_irf.py \ | 26 | show_irf.py \ |
| 27 | show_model.py \ | 27 | show_model.py \ |
| 28 | show_pha.py \ | 28 | show_pha.py \ |
| 29 | + show_rmf.py \ | ||
| 29 | show_pull_evolution.py \ | 30 | show_pull_evolution.py \ |
| 30 | show_pull_histogram.py \ | 31 | show_pull_histogram.py \ |
| 31 | show_residuals.py \ | 32 | show_residuals.py \ |
| @@ -51,4 +52,4 @@ install-data-hook: | @@ -51,4 +52,4 @@ install-data-hook: | ||
| 51 | for p in $$list; do \ | 52 | for p in $$list; do \ |
| 52 | chmod +x "$(DESTDIR)$(scriptsdir)/$$p"; \ | 53 | chmod +x "$(DESTDIR)$(scriptsdir)/$$p"; \ |
| 53 | done | 54 | done |
| 54 | - | 55 | + |
examples/show_rmf.py
0 โ 100755
| 1 | +#! /usr/bin/env python | ||
| 2 | +# ========================================================================== | ||
| 3 | +# Display Redistribution Matrix File | ||
| 4 | +# | ||
| 5 | +# Copyright (C) 2018 Juergen Knoedlseder | ||
| 6 | +# | ||
| 7 | +# This program is free software: you can redistribute it and/or modify | ||
| 8 | +# it under the terms of the GNU General Public License as published by | ||
| 9 | +# the Free Software Foundation, either version 3 of the License, or | ||
| 10 | +# (at your option) any later version. | ||
| 11 | +# | ||
| 12 | +# This program is distributed in the hope that it will be useful, | ||
| 13 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | +# GNU General Public License for more details. | ||
| 16 | +# | ||
| 17 | +# You should have received a copy of the GNU General Public License | ||
| 18 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 19 | +# | ||
| 20 | +# ========================================================================== | ||
| 21 | +import sys | ||
| 22 | +import gammalib | ||
| 23 | +import cscripts | ||
| 24 | +try: | ||
| 25 | + import matplotlib.pyplot as plt | ||
| 26 | + plt.figure() | ||
| 27 | + plt.close() | ||
| 28 | +except (ImportError, RuntimeError): | ||
| 29 | + print('This script needs the "matplotlib" module') | ||
| 30 | + sys.exit() | ||
| 31 | + | ||
| 32 | + | ||
| 33 | +# ======== # | ||
| 34 | +# Plot RMF # | ||
| 35 | +# ======== # | ||
| 36 | +def plot_rmf(rmf, plotfile): | ||
| 37 | + """ | ||
| 38 | + Plot Redistribution Matrix File | ||
| 39 | + | ||
| 40 | + Parameters | ||
| 41 | + ---------- | ||
| 42 | + rmf : `~gammalib.GRmf` | ||
| 43 | + Redistribution Matrix File | ||
| 44 | + plotfile : str | ||
| 45 | + Plot filename | ||
| 46 | + """ | ||
| 47 | + # Build title | ||
| 48 | + | ||
| 49 | + # Set energy range | ||
| 50 | + etrue_min = rmf.etrue().emin().log10TeV() | ||
| 51 | + etrue_max = rmf.etrue().emax().log10TeV() | ||
| 52 | + ereco_min = rmf.emeasured().emin().log10TeV() | ||
| 53 | + ereco_max = rmf.emeasured().emax().log10TeV() | ||
| 54 | + aspect = (etrue_max-etrue_min)/(ereco_max-ereco_min) | ||
| 55 | + | ||
| 56 | + # Set number of bins | ||
| 57 | + netrue = rmf.etrue().size() | ||
| 58 | + nereco = rmf.emeasured().size() | ||
| 59 | + | ||
| 60 | + # Set image | ||
| 61 | + image = [] | ||
| 62 | + for ireco in range(nereco-1,-1,-1): | ||
| 63 | + row = [] | ||
| 64 | + for itrue in range(netrue): | ||
| 65 | + row.append(rmf[itrue,ireco]) | ||
| 66 | + image.append(row) | ||
| 67 | + | ||
| 68 | + # Create figure | ||
| 69 | + fig = plt.figure() | ||
| 70 | + | ||
| 71 | + # Plot image | ||
| 72 | + c = plt.imshow(image, extent=[etrue_min,etrue_max,ereco_min,ereco_max], | ||
| 73 | + interpolation='nearest', aspect=aspect) | ||
| 74 | + cbar = plt.colorbar(c, orientation='vertical', shrink=0.8) | ||
| 75 | + | ||
| 76 | + # Plot title and axis | ||
| 77 | + plt.title('Redistribution Matrix File') | ||
| 78 | + plt.xlabel('log10(Etrue/TeV)') | ||
| 79 | + plt.ylabel('log10(Ereco/TeV)') | ||
| 80 | + | ||
| 81 | + # Show plots or save it into file | ||
| 82 | + if len(plotfile) > 0: | ||
| 83 | + plt.savefig(plotfile) | ||
| 84 | + else: | ||
| 85 | + plt.show() | ||
| 86 | + | ||
| 87 | + # Return | ||
| 88 | + return | ||
| 89 | + | ||
| 90 | + | ||
| 91 | +# ======== # | ||
| 92 | +# Show RMF # | ||
| 93 | +# ======== # | ||
| 94 | +def show_rmf(): | ||
| 95 | + """ | ||
| 96 | + Show Redistribution Matrix File | ||
| 97 | + """ | ||
| 98 | + # Set usage string | ||
| 99 | + usage = 'show_rmf.py [-p plotfile] file' | ||
| 100 | + | ||
| 101 | + # Set default options | ||
| 102 | + options = [{'option': '-p', 'value': ''}] | ||
| 103 | + | ||
| 104 | + # Get arguments and options from command line arguments | ||
| 105 | + args, options = cscripts.ioutils.get_args_options(options, usage) | ||
| 106 | + | ||
| 107 | + # Extract script parameters from options | ||
| 108 | + plotfile = options[0]['value'] | ||
| 109 | + | ||
| 110 | + # Get RMF | ||
| 111 | + rmf = gammalib.GRmf(args[0]) | ||
| 112 | + | ||
| 113 | + # Plot RMF | ||
| 114 | + plot_rmf(rmf, plotfile) | ||
| 115 | + | ||
| 116 | + # Return | ||
| 117 | + return | ||
| 118 | + | ||
| 119 | + | ||
| 120 | +# ======================== # | ||
| 121 | +# Main routine entry point # | ||
| 122 | +# ======================== # | ||
| 123 | +if __name__ == '__main__': | ||
| 124 | + | ||
| 125 | + # Show RMF | ||
| 126 | + show_rmf() |
src/ctools-init.csh
| 1 | -# Filename: ctools-init.csh | 1 | +# Filename: ctools-init.csh |
| 2 | # Description: C-shell flavor initialization for ctools | 2 | # Description: C-shell flavor initialization for ctools |
| 3 | # runs ctools-setup to generate a temporary csh script | 3 | # runs ctools-setup to generate a temporary csh script |
| 4 | # tailored specifically to this user and ctools | 4 | # tailored specifically to this user and ctools |
src/ctools-init.sh
| 1 | -# Filename: ctools-init.sh | 1 | +# Filename: ctools-init.sh |
| 2 | # Description: Bourne-shell flavor initialization for ctools. | 2 | # Description: Bourne-shell flavor initialization for ctools. |
| 3 | # Runs ctools-setup to generate a sh script tailored | 3 | # Runs ctools-setup to generate a sh script tailored |
| 4 | # specifically to this user and ctools installation, | 4 | # specifically to this user and ctools installation, |
src/ctools-setup.in
| 1 | -#! /bin/sh | ||
| 2 | -# Filename: ctools-setup(.in) | 1 | +# Filename: ctools-setup(.in) |
| 3 | # Description: Writes an initialization script for ctools software | 2 | # Description: Writes an initialization script for ctools software |
| 4 | # which is custom fit to the user and the particular | 3 | # which is custom fit to the user and the particular |
| 5 | # software installation. Note that this script is | 4 | # software installation. Note that this script is |
| @@ -98,12 +97,10 @@ fi | @@ -98,12 +97,10 @@ fi | ||
| 98 | # | 97 | # |
| 99 | # Set LD_LIBRARY_PATH | 98 | # Set LD_LIBRARY_PATH |
| 100 | # =================== | 99 | # =================== |
| 101 | -if [ "x$LD_LIBRARY_PATH" = x ]; then | ||
| 102 | - LD_LIBRARY_PATH="$ctools_lib" | 100 | +if [ -z "${LD_LIBRARY_PATH}" ]; then |
| 101 | + LD_LIBRARY_PATH=$ctools_lib | ||
| 103 | else | 102 | else |
| 104 | - LD_LIBRARY_PATH=`echo ":$LD_LIBRARY_PATH:" | \ | ||
| 105 | - sed "s%:$ctools_lib:%:%g" | sed "s%::*$%%"` | ||
| 106 | - LD_LIBRARY_PATH="$ctools_lib$LD_LIBRARY_PATH" | 103 | + LD_LIBRARY_PATH=$ctools_lib:$LD_LIBRARY_PATH |
| 107 | fi | 104 | fi |
| 108 | 105 | ||
| 109 | # | 106 | # |
| @@ -111,20 +108,17 @@ fi | @@ -111,20 +108,17 @@ fi | ||
| 111 | # ================================= | 108 | # ================================= |
| 112 | case $uname_system in | 109 | case $uname_system in |
| 113 | Darwin*) | 110 | Darwin*) |
| 114 | - if [ "x$DYLD_LIBRARY_PATH" = x ]; then | ||
| 115 | - DYLD_LIBRARY_PATH="$ctools_lib" | 111 | + if [ -z "${DYLD_LIBRARY_PATH}" ]; then |
| 112 | + DYLD_LIBRARY_PATH=$ctools_lib | ||
| 116 | else | 113 | else |
| 117 | - DYLD_LIBRARY_PATH=`echo ":$DYLD_LIBRARY_PATH:" | \ | ||
| 118 | - sed "s%:$ctools_lib:%:%g" | sed "s%::*$%%"` | ||
| 119 | - DYLD_LIBRARY_PATH="$ctools_lib$DYLD_LIBRARY_PATH" | 114 | + DYLD_LIBRARY_PATH=$ctools_lib:$DYLD_LIBRARY_PATH |
| 120 | fi | 115 | fi |
| 121 | ;; | 116 | ;; |
| 122 | CYGWIN*) | 117 | CYGWIN*) |
| 123 | - if [ "x$PATH" = x ]; then | ||
| 124 | - PATH="$ctools_lib" | 118 | + if [ -z "${PATH}" ]; then |
| 119 | + PATH=$ctools_lib | ||
| 125 | else | 120 | else |
| 126 | - PATH=`echo ":$PATH:" | sed "s%:$ctools_lib:%:%g" | sed "s%::*$%%"` | ||
| 127 | - PATH="$ctools_lib$PATH" | 121 | + PATH=$ctools_lib:$PATH |
| 128 | fi | 122 | fi |
| 129 | ;; | 123 | ;; |
| 130 | esac | 124 | esac |
| @@ -132,60 +126,51 @@ esac | @@ -132,60 +126,51 @@ esac | ||
| 132 | # | 126 | # |
| 133 | # Set PYTHONPATH | 127 | # Set PYTHONPATH |
| 134 | # ============== | 128 | # ============== |
| 135 | -if [ "x$PYTHONPATH" = x ]; then | ||
| 136 | - PYTHONPATH="$python_dir" | 129 | +if [ -z "${PYTHONPATH}" ]; then |
| 130 | + PYTHONPATH=$python_dir:$python_exec_dir | ||
| 137 | else | 131 | else |
| 138 | - PYTHONPATH=`echo ":$PYTHONPATH:" | \ | ||
| 139 | - sed "s%:$python_dir:%:%g" | sed "s%::*$%%"` | ||
| 140 | - PYTHONPATH="$python_dir$PYTHONPATH" | ||
| 141 | -fi | ||
| 142 | -if [ "x$PYTHONPATH" = x ]; then | ||
| 143 | - PYTHONPATH="$python_exec_dir" | ||
| 144 | -else | ||
| 145 | - PYTHONPATH=`echo ":$PYTHONPATH:" | \ | ||
| 146 | - sed "s%:$python_exec_dir:%:%g" | sed "s%::*$%%"` | ||
| 147 | - PYTHONPATH="$python_exec_dir$PYTHONPATH" | 132 | + PYTHONPATH=$python_dir:$python_exec_dir:$PYTHONPATH |
| 148 | fi | 133 | fi |
| 149 | 134 | ||
| 150 | # | 135 | # |
| 151 | # Set PKG_CONFIG_PATH | 136 | # Set PKG_CONFIG_PATH |
| 152 | # =================== | 137 | # =================== |
| 153 | -if [ "x$PKG_CONFIG_PATH" = x ]; then | ||
| 154 | - PKG_CONFIG_PATH="$pkgconfig_dir" | 138 | +if [ -z "${PKG_CONFIG_PATH}" ]; then |
| 139 | + PKG_CONFIG_PATH=$pkgconfig_dir | ||
| 155 | else | 140 | else |
| 156 | - PKG_CONFIG_PATH=`echo ":$PKG_CONFIG_PATH:" | \ | ||
| 157 | - sed "s%:$pkgconfig_dir:%:%g" | sed "s%::*$%%"` | ||
| 158 | - PKG_CONFIG_PATH="$pkgconfig_dir$PKG_CONFIG_PATH" | 141 | + PKG_CONFIG_PATH=$pkgconfig_dir:$PKG_CONFIG_PATH |
| 159 | fi | 142 | fi |
| 160 | 143 | ||
| 161 | # | 144 | # |
| 162 | # Set PATH | 145 | # Set PATH |
| 163 | # ======== | 146 | # ======== |
| 164 | -if [ "x$PATH" = x ]; then | ||
| 165 | - PATH="$ctools_bin" | 147 | +if [ -z "${PATH}" ]; then |
| 148 | + PATH=$ctools_bin | ||
| 166 | else | 149 | else |
| 167 | - PATH=`echo ":$PATH:" | \ | ||
| 168 | - sed "s%:$ctools_bin:%:%g" | sed "s%::*$%%"` | ||
| 169 | - PATH="$ctools_bin$PATH" | 150 | + PATH=$ctools_bin:$PATH |
| 170 | fi | 151 | fi |
| 171 | 152 | ||
| 172 | # | 153 | # |
| 173 | # Set MANPATH | 154 | # Set MANPATH |
| 174 | # ============== | 155 | # ============== |
| 175 | -if [ "x$MANPATH" = x ]; then | ||
| 176 | - manpath=${manpath:-} | ||
| 177 | - MANPATH="$man_dir:${manpath}" | 156 | +if [ -z "${MANPATH}" ]; then |
| 157 | + if `which manpath > /dev/null 2>&1` ; then | ||
| 158 | + default_manpath=`manpath` | ||
| 159 | + else | ||
| 160 | + default_manpath=`man -w 2> /dev/null` | ||
| 161 | + fi | ||
| 162 | +fi | ||
| 163 | +if [ -z "${MANPATH}" ]; then | ||
| 164 | + MANPATH=$man_dir:${default_manpath}; export MANPATH | ||
| 178 | else | 165 | else |
| 179 | - MANPATH=`echo ":$MANPATH:" | \ | ||
| 180 | - sed "s%:$man_dir:%:%g" | sed "s%::*$%%"` | ||
| 181 | - MANPATH="$man_dir$MANPATH" | 166 | + MANPATH=$man_dir:$MANPATH; export MANPATH |
| 182 | fi | 167 | fi |
| 183 | 168 | ||
| 184 | # | 169 | # |
| 185 | # Set CALDB (if not yet set) | 170 | # Set CALDB (if not yet set) |
| 186 | # ========================== | 171 | # ========================== |
| 187 | -if [ "x$CALDB" = x ]; then | ||
| 188 | - CALDB="$caldb_dir" | 172 | +if [ -z "${CALDB}" ]; then |
| 173 | + CALDB=$caldb_dir | ||
| 189 | fi | 174 | fi |
| 190 | 175 | ||
| 191 | # | 176 | # |
test/test_examples.py.in
| @@ -109,6 +109,8 @@ class Test(gammalib.GPythonTestSuite): | @@ -109,6 +109,8 @@ class Test(gammalib.GPythonTestSuite): | ||
| 109 | 'Test show_residuals.py') | 109 | 'Test show_residuals.py') |
| 110 | self.append(self.test_show_response, | 110 | self.append(self.test_show_response, |
| 111 | 'Test show_response.py') | 111 | 'Test show_response.py') |
| 112 | + self.append(self.test_show_rmf, | ||
| 113 | + 'Test show_rmf.py') | ||
| 112 | self.append(self.test_show_sensitivity, | 114 | self.append(self.test_show_sensitivity, |
| 113 | 'Test show_sensitivity.py') | 115 | 'Test show_sensitivity.py') |
| 114 | self.append(self.test_show_spectrum, | 116 | self.append(self.test_show_spectrum, |
| @@ -403,6 +405,20 @@ class Test(gammalib.GPythonTestSuite): | @@ -403,6 +405,20 @@ class Test(gammalib.GPythonTestSuite): | ||
| 403 | # Return | 405 | # Return |
| 404 | return | 406 | return |
| 405 | 407 | ||
| 408 | + # Test show_rmf | ||
| 409 | + def test_show_rmf(self): | ||
| 410 | + """ | ||
| 411 | + Test show_rmf | ||
| 412 | + """ | ||
| 413 | + # Set arguments | ||
| 414 | + args = ('-p example_show_rmf.eps %s/onoff_rmf.fits' % self._datadir) | ||
| 415 | + | ||
| 416 | + # Execute script | ||
| 417 | + self._execute_python('show_rmf', args=args) | ||
| 418 | + | ||
| 419 | + # Return | ||
| 420 | + return | ||
| 421 | + | ||
| 406 | # Test show_sensitivity | 422 | # Test show_sensitivity |
| 407 | def test_show_sensitivity(self): | 423 | def test_show_sensitivity(self): |
| 408 | """ | 424 | """ |
test/test_obsutils.py
| @@ -214,7 +214,7 @@ class Test(test): | @@ -214,7 +214,7 @@ class Test(test): | ||
| 214 | # Check simulation results | 214 | # Check simulation results |
| 215 | self.test_value(res.size(), 1, 'Check number of observations') | 215 | self.test_value(res.size(), 1, 'Check number of observations') |
| 216 | self.test_value(res.models().size(), 2, 'Check number of models') | 216 | self.test_value(res.models().size(), 2, 'Check number of models') |
| 217 | - self.test_value(res.nobserved(), 23, 'Check number of observed events') | 217 | + self.test_value(res.nobserved(), 20, 'Check number of observed events') |
| 218 | self.test_value(res.npred(), 0.0, 'Check number of predicted events') | 218 | self.test_value(res.npred(), 0.0, 'Check number of predicted events') |
| 219 | self.test_value(res[0].eventtype(), 'CountsCube', 'Check event type') | 219 | self.test_value(res[0].eventtype(), 'CountsCube', 'Check event type') |
| 220 | self.test_value(res[0].events().ebounds().emin().TeV(), 1.0, | 220 | self.test_value(res[0].events().ebounds().emin().TeV(), 1.0, |
| @@ -223,7 +223,7 @@ class Test(test): | @@ -223,7 +223,7 @@ class Test(test): | ||
| 223 | 'Check minimum energy') | 223 | 'Check minimum energy') |
| 224 | self.test_value(res[0].events().ebounds().size(), 5, | 224 | self.test_value(res[0].events().ebounds().size(), 5, |
| 225 | 'Check number of energy bins') | 225 | 'Check number of energy bins') |
| 226 | - self.test_value(res[0].events().number(), 23, | 226 | + self.test_value(res[0].events().number(), 20, |
| 227 | 'Check number of events in cube') | 227 | 'Check number of events in cube') |
| 228 | 228 | ||
| 229 | # Check energy dispersion flag | 229 | # Check energy dispersion flag |