Commit c07e93f04b627c95ed1346b5bdc2b4d7d7179eff
1 parent
39880731
update for GPL v3
Showing
7 changed files
with
142 additions
and
33 deletions
test/example_binned.py
| 1 | 1 | #! /usr/bin/env python |
| 2 | -# ===========================================================================================# | |
| 3 | -# This script illustrates how to build a binned analysis pipeline using CTAtools. | |
| 2 | +# ========================================================================== | |
| 3 | +# This script illustrates how to build a binned analysis pipeline using the | |
| 4 | +# ctatools. If matplotlib is installed, a counts spectrum and an offset | |
| 5 | +# histogram will be displayed. | |
| 4 | 6 | # |
| 5 | -# If matplotlib is installed, a counts spectrum and an offset histogram will be displayed. | |
| 6 | -# ===========================================================================================# | |
| 7 | +# Copyright (C) 2011 Jurgen Knodlseder | |
| 8 | +# | |
| 9 | +# This program is free software: you can redistribute it and/or modify | |
| 10 | +# it under the terms of the GNU General Public License as published by | |
| 11 | +# the Free Software Foundation, either version 3 of the License, or | |
| 12 | +# (at your option) any later version. | |
| 13 | +# | |
| 14 | +# This program is distributed in the hope that it will be useful, | |
| 15 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 16 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 17 | +# GNU General Public License for more details. | |
| 18 | +# | |
| 19 | +# You should have received a copy of the GNU General Public License | |
| 20 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| 21 | +# | |
| 22 | +# ========================================================================== | |
| 7 | 23 | from ctatools import * |
| 8 | 24 | from gammalib import * |
| 9 | 25 | from math import * | ... | ... |
test/example_models.py
| 1 | 1 | #! /usr/bin/env python |
| 2 | -# ===========================================================================================# | |
| 3 | -# This script illustrates how to build a unbinned analysis chain using CTAtools. | |
| 4 | -# ===========================================================================================# | |
| 2 | +# ========================================================================== | |
| 3 | +# This script performs an unbinned maximum likelihood analysis for a | |
| 4 | +# variety of models. This allows checking the models. | |
| 5 | +# | |
| 6 | +# Copyright (C) 2011 Jurgen Knodlseder | |
| 7 | +# | |
| 8 | +# This program is free software: you can redistribute it and/or modify | |
| 9 | +# it under the terms of the GNU General Public License as published by | |
| 10 | +# the Free Software Foundation, either version 3 of the License, or | |
| 11 | +# (at your option) any later version. | |
| 12 | +# | |
| 13 | +# This program is distributed in the hope that it will be useful, | |
| 14 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 16 | +# GNU General Public License for more details. | |
| 17 | +# | |
| 18 | +# You should have received a copy of the GNU General Public License | |
| 19 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| 20 | +# | |
| 21 | +# ========================================================================== | |
| 5 | 22 | from ctatools import * |
| 6 | 23 | from gammalib import * |
| 7 | 24 | from math import * | ... | ... |
test/example_survey.py
| 1 | 1 | #! /usr/bin/env python |
| 2 | -# ===========================================================================================# | |
| 3 | -# This script simulates CTA surveys. | |
| 2 | +# ========================================================================== | |
| 3 | +# This script simulates CTA surveys. It can be considered as the master | |
| 4 | +# script for CTA science simulations. Please modify as needed. | |
| 4 | 5 | # |
| 5 | -# If matplotlib is installed, the spectrum will be displayed on the screen. | |
| 6 | -# ===========================================================================================# | |
| 6 | +# Copyright (C) 2011 Jurgen Knodlseder | |
| 7 | +# | |
| 8 | +# This program is free software: you can redistribute it and/or modify | |
| 9 | +# it under the terms of the GNU General Public License as published by | |
| 10 | +# the Free Software Foundation, either version 3 of the License, or | |
| 11 | +# (at your option) any later version. | |
| 12 | +# | |
| 13 | +# This program is distributed in the hope that it will be useful, | |
| 14 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 16 | +# GNU General Public License for more details. | |
| 17 | +# | |
| 18 | +# You should have received a copy of the GNU General Public License | |
| 19 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| 20 | +# | |
| 21 | +# ========================================================================== | |
| 7 | 22 | from ctatools import * |
| 8 | 23 | from gammalib import * |
| 9 | 24 | from math import * |
| ... | ... | @@ -20,8 +35,7 @@ def plot_counts(obs): |
| 20 | 35 | Plot counts. |
| 21 | 36 | """ |
| 22 | 37 | # Only proceed if matplotlib is available |
| 23 | - if 1 == 1: | |
| 24 | - #try: | |
| 38 | + try: | |
| 25 | 39 | # Import matplotlib |
| 26 | 40 | import matplotlib.pyplot as plt |
| 27 | 41 | |
| ... | ... | @@ -155,8 +169,8 @@ def plot_counts(obs): |
| 155 | 169 | # Show counts spectra |
| 156 | 170 | plt.show() |
| 157 | 171 | |
| 158 | - #except: | |
| 159 | - # print "Matplotlib is not (correctly) installed on your system. No counts spectra are shown." | |
| 172 | + except ImportError: | |
| 173 | + print "Matplotlib is not (correctly) installed on your system." | |
| 160 | 174 | |
| 161 | 175 | # Return |
| 162 | 176 | return |
| ... | ... | @@ -244,7 +258,8 @@ def make_counts_map(obs): |
| 244 | 258 | # ================ # |
| 245 | 259 | def make_model_map(obs): |
| 246 | 260 | """ |
| 247 | - Make model map by combining all observations. | |
| 261 | + Make model map by combining all observations. The map will | |
| 262 | + be in units of [counts/(sr MeV s)]. | |
| 248 | 263 | """ |
| 249 | 264 | # Allocate model map |
| 250 | 265 | nxpix = 600 | ... | ... |
test/example_unbinned.py
| 1 | 1 | #! /usr/bin/env python |
| 2 | -# ===========================================================================================# | |
| 3 | -# This script illustrates how to build a unbinned analysis chain using CTAtools. | |
| 2 | +# ========================================================================== | |
| 3 | +# This script illustrates how to build an unbinned analysis pipeline with | |
| 4 | +# the ctatools. If matplotlib is installed, the spectrum will be displayed | |
| 5 | +# on the screen. | |
| 4 | 6 | # |
| 5 | -# If matplotlib is installed, the spectrum will be displayed on the screen. | |
| 6 | -# ===========================================================================================# | |
| 7 | +# Copyright (C) 2011 Jurgen Knodlseder | |
| 8 | +# | |
| 9 | +# This program is free software: you can redistribute it and/or modify | |
| 10 | +# it under the terms of the GNU General Public License as published by | |
| 11 | +# the Free Software Foundation, either version 3 of the License, or | |
| 12 | +# (at your option) any later version. | |
| 13 | +# | |
| 14 | +# This program is distributed in the hope that it will be useful, | |
| 15 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 16 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 17 | +# GNU General Public License for more details. | |
| 18 | +# | |
| 19 | +# You should have received a copy of the GNU General Public License | |
| 20 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| 21 | +# | |
| 22 | +# ========================================================================== | |
| 7 | 23 | from ctatools import * |
| 8 | 24 | from gammalib import * |
| 9 | 25 | from math import * |
| ... | ... | @@ -337,7 +353,7 @@ def plot_counts(observations): |
| 337 | 353 | # Show counts spectra |
| 338 | 354 | plt.show() |
| 339 | 355 | |
| 340 | - except: | |
| 356 | + except ImportError: | |
| 341 | 357 | print "Matplotlib is not (correctly) installed on your system. No counts spectra are shown." |
| 342 | 358 | |
| 343 | 359 | # Return | ... | ... |
test/test_coverage.py
| 1 | 1 | #! /usr/bin/env python |
| 2 | -# ===========================================================================================# | |
| 3 | -# This script illustrates how to build a binned analysis pipeline using CTAtools. | |
| 2 | +# ========================================================================== | |
| 3 | +# This script computes the pull distribution for models. | |
| 4 | 4 | # |
| 5 | -# If matplotlib is installed, a counts spectrum and an offset histogram will be displayed. | |
| 6 | -# ===========================================================================================# | |
| 5 | +# Copyright (C) 2011 Christoph Deil | |
| 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 | +# ========================================================================== | |
| 7 | 21 | from ctatools import * |
| 8 | 22 | from gammalib import * |
| 9 | 23 | from math import * | ... | ... |
test/test_ctatools.sh
| 1 | 1 | #! /bin/bash |
| 2 | +# ========================================================================== | |
| 3 | +# This script tests all ctatools executables. | |
| 2 | 4 | # |
| 3 | -# ctatools test script | |
| 4 | -# ==================================================================== | |
| 5 | +# Copyright (C) 2011 Jurgen Knodlseder | |
| 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 | +# ========================================================================== | |
| 5 | 21 | |
| 6 | 22 | # |
| 7 | 23 | # Print Header |
| ... | ... | @@ -21,7 +37,7 @@ rm -rf *.fits *.log *.xml |
| 21 | 37 | # Creates pfiles directory |
| 22 | 38 | # ======================== |
| 23 | 39 | mkdir -p pfiles |
| 24 | -cp -ru ../src/*/*.par pfiles/ | |
| 40 | +cp -r ../src/*/*.par pfiles/ | |
| 25 | 41 | export PFILES=pfiles |
| 26 | 42 | |
| 27 | 43 | # | ... | ... |
test/test_python.py
| 1 | 1 | #! /usr/bin/env python |
| 2 | -# ===========================================================================================# | |
| 3 | -# This script illustrates how to build a unbinned analysis chain using CTAtools. | |
| 2 | +# ========================================================================== | |
| 3 | +# This script illustrates how to build an unbinned analysis pipeline using | |
| 4 | +# the ctatools. | |
| 4 | 5 | # |
| 5 | -# If matplotlib is installed, the spectrum will be displayed on the screen. | |
| 6 | -# ===========================================================================================# | |
| 6 | +# Copyright (C) 2011 Jurgen Knodlseder | |
| 7 | +# | |
| 8 | +# This program is free software: you can redistribute it and/or modify | |
| 9 | +# it under the terms of the GNU General Public License as published by | |
| 10 | +# the Free Software Foundation, either version 3 of the License, or | |
| 11 | +# (at your option) any later version. | |
| 12 | +# | |
| 13 | +# This program is distributed in the hope that it will be useful, | |
| 14 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 16 | +# GNU General Public License for more details. | |
| 17 | +# | |
| 18 | +# You should have received a copy of the GNU General Public License | |
| 19 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| 20 | +# | |
| 21 | +# ========================================================================== | |
| 7 | 22 | from ctatools import * |
| 8 | 23 | from gammalib import * |
| 9 | 24 | from math import * |
| ... | ... | @@ -173,7 +188,7 @@ if __name__ == '__main__': |
| 173 | 188 | os.mkdir("pfiles") |
| 174 | 189 | except: |
| 175 | 190 | pass |
| 176 | - os.system("cp -ru ../src/*/*.par pfiles/") | |
| 191 | + os.system("cp -r ../src/*/*.par pfiles/") | |
| 177 | 192 | os.environ['PFILES'] = "pfiles" |
| 178 | 193 | |
| 179 | 194 | # Remove any existing result files | ... | ... |