Commit 1691ebb4feed43b19e25a07407230dc915a37077
1 parent
4cf2e59e
Speed up ctools unit tests
Showing
36 changed files
with
237 additions
and
1835 deletions
examples/Makefile.am
| ... | ... | @@ -21,16 +21,7 @@ |
| 21 | 21 | |
| 22 | 22 | # Scripts to be install |
| 23 | 23 | scripts = README.md \ |
| 24 | - generate_prod3_irfs.py \ | |
| 25 | 24 | make_pointings.py \ |
| 26 | - make_spectrum.py \ | |
| 27 | - make_ts_distributions.py \ | |
| 28 | - pipeline_binned_disk.py \ | |
| 29 | - pipeline_binned_mem.py \ | |
| 30 | - pipeline_stacked_disk.py \ | |
| 31 | - pipeline_stacked_mem.py \ | |
| 32 | - pipeline_unbinned_disk.py \ | |
| 33 | - pipeline_unbinned_mem.py \ | |
| 34 | 25 | show_butterfly.py \ |
| 35 | 26 | show_irf.py \ |
| 36 | 27 | show_model.py \ | ... | ... |
examples/README.md
| ... | ... | @@ -4,47 +4,12 @@ ctools examples |
| 4 | 4 | This folder contains Python example scripts that illustrate the usage of |
| 5 | 5 | the ctools. |
| 6 | 6 | |
| 7 | -`generate_prod3_irfs.py` | |
| 8 | -> Generates Prod3 Instrument Response Functions from FITS files. | |
| 9 | - | |
| 10 | 7 | `make_pointings.py` |
| 11 | 8 | > Creates pointings for CTA surveys. For the moment the Galactic Plane |
| 12 | 9 | > Survey (gps), the Extragalactic Survey (extgal), the Galactic Centre |
| 13 | 10 | > Survey (gc) and the LMC survey (lmc) are implemented. The script outputs |
| 14 | 11 | > and ASCII file that can be used by csobsdef. |
| 15 | 12 | |
| 16 | -`make_spectrum.py` | |
| 17 | -> Simulates events and generates a spectrum from the using csspec. | |
| 18 | - | |
| 19 | -`make_ts_distributions.py` | |
| 20 | -> Creates TS distributions as function of energy for an OFF observaition | |
| 21 | -> of 50 hours effective observing time. If the Python processing module is | |
| 22 | -> installed the script can make use of multiple cores and runs in parallel. | |
| 23 | - | |
| 24 | -`pipeline_binned_disk.py` | |
| 25 | -> Example pipeline for simulating events and performing a binned analysis | |
| 26 | -> by saving intermediate results to disk. | |
| 27 | - | |
| 28 | -`pipeline_binned_mem.py` | |
| 29 | -> Example pipeline for simulating events and performing a binned analysis | |
| 30 | -> in memory. No files will be written to disk. | |
| 31 | - | |
| 32 | -`pipeline_stacked_disk.py` | |
| 33 | -> Example pipeline for simulating events and performing a stacked analysis | |
| 34 | -> by saving intermediate results to disk. | |
| 35 | - | |
| 36 | -`pipeline_stacked_mem.py` | |
| 37 | -> Example pipeline for simulating events and performing a stacked analysis | |
| 38 | -> in memory. No files will be written to disk. | |
| 39 | - | |
| 40 | -`pipeline_unbinned_disk.py` | |
| 41 | -> Example pipeline for simulating events and performing an unbinned analysis | |
| 42 | -> by saving intermediate results to disk. | |
| 43 | - | |
| 44 | -`pipeline_unbinned_mem.py` | |
| 45 | -> Example pipeline for simulating events and performing an unbinned analysis | |
| 46 | -> in memory. No files will be written to disk. | |
| 47 | - | |
| 48 | 13 | `show_butterfly.py` |
| 49 | 14 | > Displays a butterfly generated using the ctbutterfly tool. |
| 50 | 15 | ... | ... |
examples/generate_prod3_irfs.py deleted
| 1 | -#! /usr/bin/env python | |
| 2 | -# ========================================================================== | |
| 3 | -# Generates Prod3 IRFs from ROOT performance files | |
| 4 | -# | |
| 5 | -# Copyright (C) 2016 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 cscripts | |
| 23 | - | |
| 24 | - | |
| 25 | -# ======================= # | |
| 26 | -# Set Prod3 DESY database # | |
| 27 | -# ======================= # | |
| 28 | -def set_prod3_desy(datadir): | |
| 29 | - """ | |
| 30 | - Set Prod3 DESY database | |
| 31 | - | |
| 32 | - This function sets the calibration database. By adding dictionaries to | |
| 33 | - the "db" list a number of calibrations can be defined for which IRFs | |
| 34 | - should be generated. All calibrations will be added to the calibration | |
| 35 | - database. | |
| 36 | - | |
| 37 | - Parameters | |
| 38 | - ---------- | |
| 39 | - datadir : str | |
| 40 | - Data directory | |
| 41 | - | |
| 42 | - Returns | |
| 43 | - ------- | |
| 44 | - db : list of dict | |
| 45 | - Database | |
| 46 | - """ | |
| 47 | - # Set database content | |
| 48 | - db = [{'inst': 'prod3', 'id': 'South_50h', 'analysis': 'DESY', | |
| 49 | - 'oversample': 3, 'norm1d': False, 'bgdinfill': False, | |
| 50 | - 'bgdethres': 10.0, 'path': datadir, 'file': 'irf.root'}] | |
| 51 | - | |
| 52 | - # Return database | |
| 53 | - return db | |
| 54 | - | |
| 55 | - | |
| 56 | -# =================== # | |
| 57 | -# Generate Prod3 IRFs # | |
| 58 | -# =================== # | |
| 59 | -def generate_prod3_irfs(): | |
| 60 | - """ | |
| 61 | - Generate Prod3 IRFs | |
| 62 | - """ | |
| 63 | - # Get optional argument | |
| 64 | - if len(sys.argv) == 2: | |
| 65 | - datadir = sys.argv[1] | |
| 66 | - else: | |
| 67 | - datadir = 'data' | |
| 68 | - | |
| 69 | - # Get database | |
| 70 | - entries = set_prod3_desy(datadir) | |
| 71 | - | |
| 72 | - # Loop over entries | |
| 73 | - for entry in entries: | |
| 74 | - | |
| 75 | - # Set filename | |
| 76 | - filename = entry['path']+'/'+entry['file'] | |
| 77 | - | |
| 78 | - # Set-up csroot2caldb | |
| 79 | - caldb = cscripts.csroot2caldb() | |
| 80 | - caldb['infile'] = filename | |
| 81 | - caldb['outdir'] = 'prod3' | |
| 82 | - caldb['inst'] = entry['inst'] | |
| 83 | - caldb['id'] = entry['id'] | |
| 84 | - caldb['version'] = entry['inst'] | |
| 85 | - caldb['analysis'] = entry.setdefault('analysis', 'DESY') | |
| 86 | - caldb['zenith'] = entry.setdefault('zenith', 20.0) | |
| 87 | - caldb['azimuth'] = entry.setdefault('azimuth', 0.0) | |
| 88 | - caldb['psftype'] = entry.setdefault('psftype', 'Gauss') | |
| 89 | - caldb['norm1d'] = entry.setdefault('norm1d', False) | |
| 90 | - caldb['rebin'] = entry.setdefault('rebin', False) | |
| 91 | - caldb['eascale'] = entry.setdefault('eascale', 1.0) | |
| 92 | - caldb['bgdscale'] = entry.setdefault('bgdscale', 1.0) | |
| 93 | - caldb['bgdoversample'] = entry.setdefault('oversample', 1) | |
| 94 | - caldb['bgdethres'] = entry.setdefault('bgdethres', 1000.0) | |
| 95 | - caldb['bgdinfill'] = entry.setdefault('bgdinfill', False) | |
| 96 | - caldb['logfile'] = 'generate_prod3_irfs.log' | |
| 97 | - | |
| 98 | - # Add CALDB entry | |
| 99 | - caldb.execute() | |
| 100 | - | |
| 101 | - # Return | |
| 102 | - return | |
| 103 | - | |
| 104 | - | |
| 105 | -# ======================== # | |
| 106 | -# Main routine entry point # | |
| 107 | -# ======================== # | |
| 108 | -if __name__ == '__main__': | |
| 109 | - | |
| 110 | - # Generate Prod3 IRFs | |
| 111 | - generate_prod3_irfs() |
examples/make_spectrum.py deleted
| 1 | -#! /usr/bin/env python | |
| 2 | -# ========================================================================== | |
| 3 | -# Makes and optionally displays spectrum | |
| 4 | -# | |
| 5 | -# Copyright (C) 2014-2017 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 ctools | |
| 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 | -# Create spectrum # | |
| 35 | -# =============== # | |
| 36 | -def create_spectrum(datadir): | |
| 37 | - """ | |
| 38 | - Simulate events and generate a source spectrum | |
| 39 | - | |
| 40 | - Returns | |
| 41 | - ------- | |
| 42 | - datadir : str | |
| 43 | - Data directory | |
| 44 | - """ | |
| 45 | - # Set script parameters | |
| 46 | - model_name = datadir+'/crab.xml' | |
| 47 | - caldb = 'prod2' | |
| 48 | - irf = 'South_0.5h' | |
| 49 | - ra = 83.63 | |
| 50 | - dec = 22.01 | |
| 51 | - rad_sim = 3.0 | |
| 52 | - tstart = 0.0 | |
| 53 | - tstop = 1800.0 | |
| 54 | - emin = 0.1 | |
| 55 | - emax = 100.0 | |
| 56 | - enumbins = 10 | |
| 57 | - | |
| 58 | - # Simulate events | |
| 59 | - sim = ctools.ctobssim() | |
| 60 | - sim['inmodel'] = model_name | |
| 61 | - sim['caldb'] = caldb | |
| 62 | - sim['irf'] = irf | |
| 63 | - sim['ra'] = ra | |
| 64 | - sim['dec'] = dec | |
| 65 | - sim['rad'] = rad_sim | |
| 66 | - sim['tmin'] = tstart | |
| 67 | - sim['tmax'] = tstop | |
| 68 | - sim['emin'] = emin | |
| 69 | - sim['emax'] = emax | |
| 70 | - sim.run() | |
| 71 | - | |
| 72 | - # Create spectrum | |
| 73 | - spec = cscripts.csspec(sim.obs()) | |
| 74 | - spec['srcname'] = 'Crab' | |
| 75 | - spec['method'] = 'AUTO' | |
| 76 | - spec['outfile'] = 'example_spectrum.fits' | |
| 77 | - spec['expcube'] = 'NONE' | |
| 78 | - spec['psfcube'] = 'NONE' | |
| 79 | - spec['bkgcube'] = 'NONE' | |
| 80 | - spec['edisp'] = False | |
| 81 | - spec['emin'] = emin | |
| 82 | - spec['emax'] = emax | |
| 83 | - spec['enumbins'] = enumbins | |
| 84 | - spec['ebinalg'] = 'LOG' | |
| 85 | - spec.run() | |
| 86 | - spec.save() | |
| 87 | - | |
| 88 | - # Get copy of spectrum | |
| 89 | - spectrum = spec.spectrum().copy() | |
| 90 | - | |
| 91 | - # Return | |
| 92 | - return spectrum | |
| 93 | - | |
| 94 | - | |
| 95 | -# ============= # | |
| 96 | -# Plot spectrum # | |
| 97 | -# ============= # | |
| 98 | -def plot_spectrum(spectrum, plotfile): | |
| 99 | - """ | |
| 100 | - Plot spectrum | |
| 101 | - | |
| 102 | - Parameters | |
| 103 | - ---------- | |
| 104 | - spectrum : `~gammalib.GFits` | |
| 105 | - Spectrum FITS file | |
| 106 | - plotfile : str | |
| 107 | - Plot filename | |
| 108 | - """ | |
| 109 | - # Extract columns from spectrum file | |
| 110 | - table = spectrum.table(1) | |
| 111 | - c_energy = table['Energy'] | |
| 112 | - c_ed = table['ed_Energy'] | |
| 113 | - c_eu = table['eu_Energy'] | |
| 114 | - c_flux = table['Flux'] | |
| 115 | - c_eflux = table['e_Flux'] | |
| 116 | - c_ts = table['TS'] | |
| 117 | - c_upper = table['UpperLimit'] | |
| 118 | - | |
| 119 | - # Initialise arrays to be filled | |
| 120 | - energies = [] | |
| 121 | - flux = [] | |
| 122 | - ed_engs = [] | |
| 123 | - eu_engs = [] | |
| 124 | - e_flux = [] | |
| 125 | - ul_energies = [] | |
| 126 | - ul_ed_engs = [] | |
| 127 | - ul_eu_engs = [] | |
| 128 | - ul_flux = [] | |
| 129 | - | |
| 130 | - # Get number of spectral points | |
| 131 | - nrows = table.nrows() | |
| 132 | - | |
| 133 | - # Loop over rows of the file | |
| 134 | - for row in range(nrows): | |
| 135 | - | |
| 136 | - # Get TS value, flux and flux error | |
| 137 | - ts = c_ts.real(row) | |
| 138 | - flx = c_flux.real(row) | |
| 139 | - e_flx = c_eflux.real(row) | |
| 140 | - | |
| 141 | - # If the TS > 9 and the flux error is smaller than the flux then | |
| 142 | - # take the fitted flux and flux error and append them to the | |
| 143 | - # arrays | |
| 144 | - if ts > 9.0 and e_flx < flx: | |
| 145 | - | |
| 146 | - # Add information | |
| 147 | - energies.append(c_energy.real(row)) | |
| 148 | - flux.append(c_flux.real(row)) | |
| 149 | - ed_engs.append(c_ed.real(row)) | |
| 150 | - eu_engs.append(c_eu.real(row)) | |
| 151 | - e_flux.append(c_eflux.real(row)) | |
| 152 | - | |
| 153 | - # ... otherwise take the upper limit and append it to the upper | |
| 154 | - # limit array | |
| 155 | - else: | |
| 156 | - | |
| 157 | - # Add information | |
| 158 | - ul_energies.append(c_energy.real(row)) | |
| 159 | - ul_flux.append(c_upper.real(row)) | |
| 160 | - ul_ed_engs.append(c_ed.real(row)) | |
| 161 | - ul_eu_engs.append(c_eu.real(row)) | |
| 162 | - | |
| 163 | - # Create figure | |
| 164 | - plt.figure() | |
| 165 | - plt.title('Crab spectrum') | |
| 166 | - | |
| 167 | - # Plot the spectrum | |
| 168 | - plt.loglog() | |
| 169 | - plt.grid() | |
| 170 | - | |
| 171 | - # Plot error bars for flux points and upper limits for upper limit | |
| 172 | - # points | |
| 173 | - plt.errorbar(energies, flux, yerr=e_flux, xerr=[ed_engs, eu_engs], | |
| 174 | - fmt='ro') | |
| 175 | - plt.errorbar(ul_energies, ul_flux, xerr=[ul_ed_engs, ul_eu_engs], | |
| 176 | - yerr=1.0e-11, uplims=True, fmt='ro') | |
| 177 | - | |
| 178 | - # Add plot labels | |
| 179 | - plt.xlabel('Energy (TeV)') | |
| 180 | - plt.ylabel(r'E$^{2}$dN/dE (erg cm$^{-2}$ s$^{-1}$)') | |
| 181 | - | |
| 182 | - # Show spectrum or save it into file | |
| 183 | - if len(plotfile) > 0: | |
| 184 | - plt.savefig(plotfile) | |
| 185 | - else: | |
| 186 | - plt.show() | |
| 187 | - | |
| 188 | - # Return | |
| 189 | - return | |
| 190 | - | |
| 191 | - | |
| 192 | -# ============= # | |
| 193 | -# Make spectrum # | |
| 194 | -# ============= # | |
| 195 | -def make_spectrum(): | |
| 196 | - """ | |
| 197 | - Make spectrum | |
| 198 | - """ | |
| 199 | - # Set usage string | |
| 200 | - usage = 'make_spectrum.py [-d datadir] [-p plotfile]' | |
| 201 | - | |
| 202 | - # Set default options | |
| 203 | - options = [{'option': '-d', 'value': 'data'}, | |
| 204 | - {'option': '-p', 'value': ''}] | |
| 205 | - | |
| 206 | - # Get arguments and options from command line arguments | |
| 207 | - _, options = cscripts.ioutils.get_args_options(options, usage) | |
| 208 | - | |
| 209 | - # Extract script parameters from options | |
| 210 | - datadir = options[0]['value'] | |
| 211 | - plotfile = options[1]['value'] | |
| 212 | - | |
| 213 | - # Generate spectrum | |
| 214 | - spectrum = create_spectrum(datadir) | |
| 215 | - | |
| 216 | - # Plot spectrum | |
| 217 | - plot_spectrum(spectrum, plotfile) | |
| 218 | - | |
| 219 | - # Return | |
| 220 | - return | |
| 221 | - | |
| 222 | -# ======================== # | |
| 223 | -# Main routine entry point # | |
| 224 | -# ======================== # | |
| 225 | -if __name__ == '__main__': | |
| 226 | - | |
| 227 | - # Make spectrum | |
| 228 | - make_spectrum() |
examples/make_ts_distributions.py deleted
| 1 | -#! /usr/bin/env python | |
| 2 | -# ========================================================================== | |
| 3 | -# Generate TS distributions as function of energy for an OFF observation | |
| 4 | -# | |
| 5 | -# Copyright (C) 2011-2016 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 | -# ========================================================================== | |
| 21 | -import cscripts | |
| 22 | - | |
| 23 | - | |
| 24 | -# ====================== # | |
| 25 | -# Create TS distribution # | |
| 26 | -# ====================== # | |
| 27 | -def create_ts(datadir, loge, emin, emax, ntrials=100, duration=180000.0, | |
| 28 | - enumbins=0, log=False): | |
| 29 | - """ | |
| 30 | - Create TS distribution. | |
| 31 | - | |
| 32 | - Parameters | |
| 33 | - ---------- | |
| 34 | - datadir : str | |
| 35 | - Data directory | |
| 36 | - loge : float | |
| 37 | - Logarithm of mean energy (TeV) | |
| 38 | - emin : float | |
| 39 | - Minimum energy (TeV) | |
| 40 | - emax : float | |
| 41 | - Maximum energy (TeV) | |
| 42 | - ntrials : int, optional | |
| 43 | - Number of MC samples | |
| 44 | - durations : float, optional | |
| 45 | - Observation duration (s) | |
| 46 | - enumbins : int, optional | |
| 47 | - Number of energy bins | |
| 48 | - log : bool, optional | |
| 49 | - Create log file(s) | |
| 50 | - """ | |
| 51 | - # Generate output filename | |
| 52 | - outfile = 'ts_'+str(loge)+'.dat' | |
| 53 | - | |
| 54 | - # Setup cstsdist tool | |
| 55 | - tsdist = cscripts.cstsdist() | |
| 56 | - tsdist['inmodel'] = datadir+'/crab.xml' | |
| 57 | - tsdist['srcname'] = 'Crab' | |
| 58 | - tsdist['outfile'] = outfile | |
| 59 | - tsdist['ntrials'] = ntrials | |
| 60 | - tsdist['caldb'] = 'prod2' | |
| 61 | - tsdist['irf'] = 'South_50h' | |
| 62 | - tsdist['ra'] = 83.63 | |
| 63 | - tsdist['dec'] = 22.01 | |
| 64 | - tsdist['emin'] = emin | |
| 65 | - tsdist['emax'] = emax | |
| 66 | - tsdist['enumbins'] = enumbins | |
| 67 | - tsdist['tmin'] = 0 | |
| 68 | - tsdist['tmax'] = duration | |
| 69 | - tsdist['rad'] = 5.0 | |
| 70 | - tsdist['npix'] = 200 | |
| 71 | - tsdist['binsz'] = 0.05 | |
| 72 | - | |
| 73 | - # Optionally open the log file | |
| 74 | - if log: | |
| 75 | - tsdist.logFileOpen() | |
| 76 | - | |
| 77 | - # Run tool | |
| 78 | - tsdist.run() | |
| 79 | - | |
| 80 | - # Return | |
| 81 | - return | |
| 82 | - | |
| 83 | - | |
| 84 | -# ==================== # | |
| 85 | -# Make TS distribution # | |
| 86 | -# ==================== # | |
| 87 | -def make_ts_distribution(): | |
| 88 | - """ | |
| 89 | - Make TS distribution | |
| 90 | - """ | |
| 91 | - # Set usage string | |
| 92 | - usage = 'make_ts_distributions.py [-n ntrials] [-e enumbins]'\ | |
| 93 | - ' [-t duration] [-m max_threads] [-d datadir]' | |
| 94 | - | |
| 95 | - # Set default options | |
| 96 | - options = [{'option': '-n', 'value': '100'}, | |
| 97 | - {'option': '-e', 'value': '0'}, | |
| 98 | - {'option': '-t', 'value': '180000.0'}, | |
| 99 | - {'option': '-m', 'value': '1'}, | |
| 100 | - {'option': '-d', 'value': 'data'}] | |
| 101 | - | |
| 102 | - # Get arguments and options from command line arguments | |
| 103 | - _, options = cscripts.ioutils.get_args_options(options, usage) | |
| 104 | - | |
| 105 | - # Extract script parameters from options | |
| 106 | - ntrials = int(options[0]['value']) | |
| 107 | - enumbins = int(options[1]['value']) | |
| 108 | - duration = float(options[2]['value']) | |
| 109 | - #max_threads = int(options[3]['value']) | |
| 110 | - datadir = options[4]['value'] | |
| 111 | - | |
| 112 | - # Loop over energy bands. The energy bands are those that are also | |
| 113 | - # used for sensitivity computation. | |
| 114 | - for ieng in range(18): | |
| 115 | - | |
| 116 | - # Set energies | |
| 117 | - loge = -1.3 + ieng * 0.2 | |
| 118 | - emin = pow(10.0, loge-0.1) | |
| 119 | - emax = pow(10.0, loge+0.1) | |
| 120 | - if loge < 0: | |
| 121 | - loge = 'm'+str(abs(loge)) | |
| 122 | - else: | |
| 123 | - loge = 'p'+str(abs(loge)) | |
| 124 | - | |
| 125 | - # Create TS | |
| 126 | - create_ts(datadir, loge, emin, emax, ntrials=ntrials, | |
| 127 | - enumbins=enumbins, duration=duration) | |
| 128 | - | |
| 129 | - # Return | |
| 130 | - return | |
| 131 | - | |
| 132 | - | |
| 133 | -# ======================== # | |
| 134 | -# Main routine entry point # | |
| 135 | -# ======================== # | |
| 136 | -if __name__ == '__main__': | |
| 137 | - | |
| 138 | - # Make TS distribution | |
| 139 | - make_ts_distribution() |
examples/pipeline_binned_disk.py deleted
| 1 | -#! /usr/bin/env python | |
| 2 | -# ========================================================================== | |
| 3 | -# Perform binned analysis of simulated CTA data | |
| 4 | -# | |
| 5 | -# Copyright (C) 2015-2016 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 gammalib | |
| 22 | -import ctools | |
| 23 | -import cscripts | |
| 24 | - | |
| 25 | - | |
| 26 | -# ================================ # | |
| 27 | -# Simulation and analysis pipeline # | |
| 28 | -# ================================ # | |
| 29 | -def run_pipeline(obs, emin=0.1, emax=100.0, | |
| 30 | - enumbins=20, nxpix=200, nypix=200, binsz=0.02, | |
| 31 | - coordsys='CEL', proj='CAR', | |
| 32 | - model='data/crab.xml', | |
| 33 | - caldb='prod2', irf='South_0.5h', | |
| 34 | - debug=False): | |
| 35 | - """ | |
| 36 | - Simulation and binned analysis pipeline | |
| 37 | - | |
| 38 | - Parameters | |
| 39 | - ---------- | |
| 40 | - obs : `~gammalib.GObservations` | |
| 41 | - Observation container | |
| 42 | - emin : float, optional | |
| 43 | - Minimum energy (TeV) | |
| 44 | - emax : float, optional | |
| 45 | - Maximum energy (TeV) | |
| 46 | - enumbins : int, optional | |
| 47 | - Number of energy bins | |
| 48 | - nxpix : int, optional | |
| 49 | - Number of pixels in X axis | |
| 50 | - nypix : int, optional | |
| 51 | - Number of pixels in Y axis | |
| 52 | - binsz : float, optional | |
| 53 | - Pixel size (deg) | |
| 54 | - coordsys : str, optional | |
| 55 | - Coordinate system | |
| 56 | - proj : str, optional | |
| 57 | - Coordinate projection | |
| 58 | - model : str, optional | |
| 59 | - Model definition XML file | |
| 60 | - caldb : str, optional | |
| 61 | - Calibration database path | |
| 62 | - irf : str, optional | |
| 63 | - Instrument response function | |
| 64 | - debug : bool, optional | |
| 65 | - Debug function | |
| 66 | - """ | |
| 67 | - # Simulate events | |
| 68 | - sim = ctools.ctobssim(obs) | |
| 69 | - sim['debug'] = debug | |
| 70 | - sim['outevents'] = 'obs.xml' | |
| 71 | - sim.execute() | |
| 72 | - | |
| 73 | - # Bin events by looping over all observations in the container | |
| 74 | - sim_obs = gammalib.GObservations('obs.xml') | |
| 75 | - obs = gammalib.GObservations() | |
| 76 | - for run in sim_obs: | |
| 77 | - | |
| 78 | - # Get event filename and set counts cube filename | |
| 79 | - eventfile = run.eventfile().url() | |
| 80 | - cubefile = 'cube_'+eventfile | |
| 81 | - | |
| 82 | - # Bin events for that observation | |
| 83 | - binning = ctools.ctbin() | |
| 84 | - binning['inobs'] = eventfile | |
| 85 | - binning['outcube'] = cubefile | |
| 86 | - binning['ebinalg'] = 'LOG' | |
| 87 | - binning['emin'] = emin | |
| 88 | - binning['emax'] = emax | |
| 89 | - binning['enumbins'] = enumbins | |
| 90 | - binning['nxpix'] = nxpix | |
| 91 | - binning['nypix'] = nypix | |
| 92 | - binning['binsz'] = binsz | |
| 93 | - binning['coordsys'] = coordsys | |
| 94 | - binning['usepnt'] = True | |
| 95 | - binning['proj'] = proj | |
| 96 | - binning.execute() | |
| 97 | - | |
| 98 | - # Set observation ID | |
| 99 | - binning.obs()[0].id(cubefile) | |
| 100 | - binning.obs()[0].eventfile(cubefile) | |
| 101 | - | |
| 102 | - # Append result to observations | |
| 103 | - obs.extend(binning.obs()) | |
| 104 | - | |
| 105 | - # Save XML file | |
| 106 | - xml = gammalib.GXml() | |
| 107 | - obs.write(xml) | |
| 108 | - xml.save('obs_cube.xml') | |
| 109 | - | |
| 110 | - # Perform maximum likelihood fitting | |
| 111 | - like = ctools.ctlike() | |
| 112 | - like['inobs'] = 'obs_cube.xml' | |
| 113 | - like['inmodel'] = model | |
| 114 | - like['outmodel'] = 'fit_results.xml' | |
| 115 | - like['expcube'] = 'NONE' | |
| 116 | - like['psfcube'] = 'NONE' | |
| 117 | - like['bkgcube'] = 'NONE' | |
| 118 | - like['caldb'] = caldb | |
| 119 | - like['irf'] = irf | |
| 120 | - like['debug'] = True # Switch this always on for results in console | |
| 121 | - like.execute() | |
| 122 | - | |
| 123 | - # Return | |
| 124 | - return | |
| 125 | - | |
| 126 | - | |
| 127 | -# ===================================================== # | |
| 128 | -# Run binned pipeline with intermediate results on disk # | |
| 129 | -# ===================================================== # | |
| 130 | -def pipeline_binned_disk(): | |
| 131 | - """ | |
| 132 | - Run binned pipeline with intermediate results on disk | |
| 133 | - """ | |
| 134 | - # Set usage string | |
| 135 | - usage = 'pipeline_binned_disk.py [-d datadir]' | |
| 136 | - | |
| 137 | - # Set default options | |
| 138 | - options = [{'option': '-d', 'value': 'data'}] | |
| 139 | - | |
| 140 | - # Get arguments and options from command line arguments | |
| 141 | - _, options = cscripts.ioutils.get_args_options(options, usage) | |
| 142 | - | |
| 143 | - # Extract script parameters from options | |
| 144 | - datadir = options[0]['value'] | |
| 145 | - | |
| 146 | - # Setup observations | |
| 147 | - obs = cscripts.obsutils.set_observations(83.63, 22.01, 5.0, 0.0, 180.0, | |
| 148 | - 0.1, 100.0, 'South_0.5h', 'prod2', | |
| 149 | - pattern='four', offset=1.5) | |
| 150 | - | |
| 151 | - # Setup model | |
| 152 | - obs.models(gammalib.GModels(datadir+'/crab.xml')) | |
| 153 | - | |
| 154 | - # Run analysis pipeline | |
| 155 | - run_pipeline(obs, model=datadir+'/crab.xml', enumbins=10, nxpix=40, | |
| 156 | - nypix=40, binsz=0.1) | |
| 157 | - | |
| 158 | - # Return | |
| 159 | - return | |
| 160 | - | |
| 161 | - | |
| 162 | -# ======================== # | |
| 163 | -# Main routine entry point # | |
| 164 | -# ======================== # | |
| 165 | -if __name__ == '__main__': | |
| 166 | - | |
| 167 | - # Run binned pipeline with intermediate results on disk | |
| 168 | - pipeline_binned_disk() |
examples/pipeline_binned_mem.py deleted
| 1 | -#! /usr/bin/env python | |
| 2 | -# ========================================================================== | |
| 3 | -# Perform binned in-memory analysis of simulated CTA data. | |
| 4 | -# | |
| 5 | -# Copyright (C) 2015-2016 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 gammalib | |
| 22 | -import ctools | |
| 23 | -import cscripts | |
| 24 | - | |
| 25 | - | |
| 26 | -# ================================ # | |
| 27 | -# Simulation and analysis pipeline # | |
| 28 | -# ================================ # | |
| 29 | -def run_pipeline(obs, emin=0.1, emax=100.0, | |
| 30 | - enumbins=20, nxpix=200, nypix=200, binsz=0.02, | |
| 31 | - coordsys='CEL', proj='CAR', debug=False): | |
| 32 | - """ | |
| 33 | - Simulation and binned analysis pipeline | |
| 34 | - | |
| 35 | - Parameters | |
| 36 | - ---------- | |
| 37 | - obs : `~gammalib.GObservations` | |
| 38 | - Observation container | |
| 39 | - emin : float, optional | |
| 40 | - Minimum energy (TeV) | |
| 41 | - emax : float, optional | |
| 42 | - Maximum energy (TeV) | |
| 43 | - enumbins : int, optional | |
| 44 | - Number of energy bins | |
| 45 | - nxpix : int, optional | |
| 46 | - Number of pixels in X axis | |
| 47 | - nypix : int, optional | |
| 48 | - Number of pixels in Y axis | |
| 49 | - binsz : float, optional | |
| 50 | - Pixel size (deg) | |
| 51 | - coordsys : str, optional | |
| 52 | - Coordinate system | |
| 53 | - proj : str, optional | |
| 54 | - Coordinate projection | |
| 55 | - debug : bool, optional | |
| 56 | - Debug function | |
| 57 | - """ | |
| 58 | - # Simulate events | |
| 59 | - sim = ctools.ctobssim(obs) | |
| 60 | - sim['debug'] = debug | |
| 61 | - sim.run() | |
| 62 | - | |
| 63 | - # Bin events by looping over all observations in the container | |
| 64 | - obs = gammalib.GObservations() | |
| 65 | - obs.models(sim.obs().models()) | |
| 66 | - for run in sim.obs(): | |
| 67 | - | |
| 68 | - # Create container with a single observation | |
| 69 | - container = gammalib.GObservations() | |
| 70 | - container.append(run) | |
| 71 | - | |
| 72 | - # Bin events for that observation | |
| 73 | - binning = ctools.ctbin(container) | |
| 74 | - binning['ebinalg'] = 'LOG' | |
| 75 | - binning['emin'] = emin | |
| 76 | - binning['emax'] = emax | |
| 77 | - binning['enumbins'] = enumbins | |
| 78 | - binning['nxpix'] = nxpix | |
| 79 | - binning['nypix'] = nypix | |
| 80 | - binning['binsz'] = binsz | |
| 81 | - binning['coordsys'] = coordsys | |
| 82 | - binning['usepnt'] = True | |
| 83 | - binning['proj'] = proj | |
| 84 | - binning.run() | |
| 85 | - | |
| 86 | - # Append result to observations | |
| 87 | - obs.extend(binning.obs()) | |
| 88 | - | |
| 89 | - # Perform maximum likelihood fitting | |
| 90 | - like = ctools.ctlike(obs) | |
| 91 | - like['debug'] = True # Switch this always on for results in console | |
| 92 | - like.run() | |
| 93 | - | |
| 94 | - # Return | |
| 95 | - return | |
| 96 | - | |
| 97 | - | |
| 98 | -# ============================= # | |
| 99 | -# Run binned in-memory pipeline # | |
| 100 | -# ============================= # | |
| 101 | -def pipeline_binned_mem(): | |
| 102 | - """ | |
| 103 | - Run binned in-memory pipeline | |
| 104 | - """ | |
| 105 | - # Set usage string | |
| 106 | - usage = 'pipeline_binned_mem.py [-d datadir]' | |
| 107 | - | |
| 108 | - # Set default options | |
| 109 | - options = [{'option': '-d', 'value': 'data'}] | |
| 110 | - | |
| 111 | - # Get arguments and options from command line arguments | |
| 112 | - _, options = cscripts.ioutils.get_args_options(options, usage) | |
| 113 | - | |
| 114 | - # Extract script parameters from options | |
| 115 | - datadir = options[0]['value'] | |
| 116 | - | |
| 117 | - # Setup observations | |
| 118 | - obs = cscripts.obsutils.set_observations(83.63, 22.01, 5.0, 0.0, 180.0, | |
| 119 | - 0.1, 100.0, 'South_0.5h', 'prod2', | |
| 120 | - pattern='four', offset=1.5) | |
| 121 | - | |
| 122 | - # Setup model | |
| 123 | - obs.models(gammalib.GModels(datadir+'/crab.xml')) | |
| 124 | - | |
| 125 | - # Run analysis pipeline | |
| 126 | - run_pipeline(obs, enumbins=10, nxpix=40, nypix=40, binsz=0.1) | |
| 127 | - | |
| 128 | - # Return | |
| 129 | - return | |
| 130 | - | |
| 131 | - | |
| 132 | -# ======================== # | |
| 133 | -# Main routine entry point # | |
| 134 | -# ======================== # | |
| 135 | -if __name__ == '__main__': | |
| 136 | - | |
| 137 | - # Run binned in-memory pipeline | |
| 138 | - pipeline_binned_mem() |
examples/pipeline_stacked_disk.py deleted
| 1 | -#! /usr/bin/env python | |
| 2 | -# ========================================================================== | |
| 3 | -# Perform stacked analysis of simulated CTA data. | |
| 4 | -# | |
| 5 | -# Copyright (C) 2015-2016 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 gammalib | |
| 22 | -import ctools | |
| 23 | -import cscripts | |
| 24 | - | |
| 25 | - | |
| 26 | -# ================================ # | |
| 27 | -# Simulation and analysis pipeline # | |
| 28 | -# ================================ # | |
| 29 | -def run_pipeline(obs, ra=83.63, dec=22.01, emin=0.1, emax=100.0, | |
| 30 | - enumbins=20, nxpix=200, nypix=200, binsz=0.02, | |
| 31 | - coordsys='CEL', proj='CAR', | |
| 32 | - model='data/crab.xml', | |
| 33 | - caldb='prod2', irf='South_0.5h', | |
| 34 | - debug=False): | |
| 35 | - """ | |
| 36 | - Simulation and stacked analysis pipeline | |
| 37 | - | |
| 38 | - Parameters | |
| 39 | - ---------- | |
| 40 | - obs : `~gammalib.GObservations` | |
| 41 | - Observation container | |
| 42 | - ra : float, optional | |
| 43 | - Right Ascension of counts cube centre (deg) | |
| 44 | - dec : float, optional | |
| 45 | - Declination of Region of counts cube centre (deg) | |
| 46 | - emin : float, optional | |
| 47 | - Minimum energy (TeV) | |
| 48 | - emax : float, optional | |
| 49 | - Maximum energy (TeV) | |
| 50 | - enumbins : int, optional | |
| 51 | - Number of energy bins | |
| 52 | - nxpix : int, optional | |
| 53 | - Number of pixels in X axis | |
| 54 | - nypix : int, optional | |
| 55 | - Number of pixels in Y axis | |
| 56 | - binsz : float, optional | |
| 57 | - Pixel size (deg) | |
| 58 | - coordsys : str, optional | |
| 59 | - Coordinate system | |
| 60 | - proj : str, optional | |
| 61 | - Coordinate projection | |
| 62 | - model : str, optional | |
| 63 | - Model definition XML file | |
| 64 | - caldb : str, optional | |
| 65 | - Calibration database path | |
| 66 | - irf : str, optional | |
| 67 | - Instrument response function | |
| 68 | - debug : bool, optional | |
| 69 | - Debug function | |
| 70 | - """ | |
| 71 | - # Simulate events | |
| 72 | - sim = ctools.ctobssim(obs) | |
| 73 | - sim['debug'] = debug | |
| 74 | - sim['outevents'] = 'obs.xml' | |
| 75 | - sim.execute() | |
| 76 | - | |
| 77 | - # Bin events into counts map | |
| 78 | - binning = ctools.ctbin() | |
| 79 | - binning['inobs'] = 'obs.xml' | |
| 80 | - binning['outcube'] = 'cntcube.fits' | |
| 81 | - binning['ebinalg'] = 'LOG' | |
| 82 | - binning['emin'] = emin | |
| 83 | - binning['emax'] = emax | |
| 84 | - binning['enumbins'] = enumbins | |
| 85 | - binning['nxpix'] = nxpix | |
| 86 | - binning['nypix'] = nypix | |
| 87 | - binning['binsz'] = binsz | |
| 88 | - binning['coordsys'] = coordsys | |
| 89 | - binning['proj'] = proj | |
| 90 | - binning['xref'] = ra | |
| 91 | - binning['yref'] = dec | |
| 92 | - binning['debug'] = debug | |
| 93 | - binning.execute() | |
| 94 | - | |
| 95 | - # Create exposure cube | |
| 96 | - expcube = ctools.ctexpcube() | |
| 97 | - expcube['inobs'] = 'obs.xml' | |
| 98 | - expcube['incube'] = 'cntcube.fits' | |
| 99 | - expcube['outcube'] = 'expcube.fits' | |
| 100 | - expcube['caldb'] = caldb | |
| 101 | - expcube['irf'] = irf | |
| 102 | - expcube['ebinalg'] = 'LOG' | |
| 103 | - expcube['emin'] = emin | |
| 104 | - expcube['emax'] = emax | |
| 105 | - expcube['enumbins'] = enumbins | |
| 106 | - expcube['nxpix'] = nxpix | |
| 107 | - expcube['nypix'] = nypix | |
| 108 | - expcube['binsz'] = binsz | |
| 109 | - expcube['coordsys'] = coordsys | |
| 110 | - expcube['proj'] = proj | |
| 111 | - expcube['xref'] = ra | |
| 112 | - expcube['yref'] = dec | |
| 113 | - expcube['debug'] = debug | |
| 114 | - expcube.execute() | |
| 115 | - | |
| 116 | - # Create PSF cube | |
| 117 | - psfcube = ctools.ctpsfcube() | |
| 118 | - psfcube['inobs'] = 'obs.xml' | |
| 119 | - psfcube['incube'] = 'NONE' | |
| 120 | - psfcube['outcube'] = 'psfcube.fits' | |
| 121 | - psfcube['caldb'] = caldb | |
| 122 | - psfcube['irf'] = irf | |
| 123 | - psfcube['ebinalg'] = 'LOG' | |
| 124 | - psfcube['emin'] = emin | |
| 125 | - psfcube['emax'] = emax | |
| 126 | - psfcube['enumbins'] = enumbins | |
| 127 | - psfcube['nxpix'] = 10 | |
| 128 | - psfcube['nypix'] = 10 | |
| 129 | - psfcube['binsz'] = 1.0 | |
| 130 | - psfcube['coordsys'] = coordsys | |
| 131 | - psfcube['proj'] = proj | |
| 132 | - psfcube['xref'] = ra | |
| 133 | - psfcube['yref'] = dec | |
| 134 | - psfcube['debug'] = debug | |
| 135 | - psfcube.execute() | |
| 136 | - | |
| 137 | - # Create background cube | |
| 138 | - bkgcube = ctools.ctbkgcube() | |
| 139 | - bkgcube['inobs'] = 'obs.xml' | |
| 140 | - bkgcube['inmodel'] = model | |
| 141 | - bkgcube['incube'] = 'NONE' | |
| 142 | - bkgcube['outcube'] = 'bkgcube.fits' | |
| 143 | - bkgcube['outmodel'] = 'model_bkg.xml' | |
| 144 | - bkgcube['caldb'] = caldb | |
| 145 | - bkgcube['irf'] = irf | |
| 146 | - bkgcube['ebinalg'] = 'LOG' | |
| 147 | - bkgcube['emin'] = emin | |
| 148 | - bkgcube['emax'] = emax | |
| 149 | - bkgcube['enumbins'] = enumbins | |
| 150 | - bkgcube['nxpix'] = 10 | |
| 151 | - bkgcube['nypix'] = 10 | |
| 152 | - bkgcube['binsz'] = 1.0 | |
| 153 | - bkgcube['coordsys'] = coordsys | |
| 154 | - bkgcube['proj'] = proj | |
| 155 | - bkgcube['xref'] = ra | |
| 156 | - bkgcube['yref'] = dec | |
| 157 | - bkgcube['debug'] = debug | |
| 158 | - bkgcube.execute() | |
| 159 | - | |
| 160 | - # Perform maximum likelihood fitting | |
| 161 | - like = ctools.ctlike() | |
| 162 | - like['inobs'] = 'cntcube.fits' | |
| 163 | - like['inmodel'] = 'model_bkg.xml' | |
| 164 | - like['outmodel'] = 'fit_results.xml' | |
| 165 | - like['expcube'] = 'expcube.fits' | |
| 166 | - like['psfcube'] = 'psfcube.fits' | |
| 167 | - like['bkgcube'] = 'bkgcube.fits' | |
| 168 | - like['caldb'] = caldb | |
| 169 | - like['irf'] = irf | |
| 170 | - like['debug'] = True # Switch this always on for results in console | |
| 171 | - like.execute() | |
| 172 | - | |
| 173 | - # Return | |
| 174 | - return | |
| 175 | - | |
| 176 | - | |
| 177 | -# ====================================================== # | |
| 178 | -# Run stacked pipeline with intermediate results on disk # | |
| 179 | -# ====================================================== # | |
| 180 | -def pipeline_stacked_disk(): | |
| 181 | - """ | |
| 182 | - Run stacked pipeline with intermediate results on disk | |
| 183 | - """ | |
| 184 | - # Set usage string | |
| 185 | - usage = 'pipeline_stacked_disk.py [-d datadir]' | |
| 186 | - | |
| 187 | - # Set default options | |
| 188 | - options = [{'option': '-d', 'value': 'data'}] | |
| 189 | - | |
| 190 | - # Get arguments and options from command line arguments | |
| 191 | - _, options = cscripts.ioutils.get_args_options(options, usage) | |
| 192 | - | |
| 193 | - # Extract script parameters from options | |
| 194 | - datadir = options[0]['value'] | |
| 195 | - | |
| 196 | - # Setup observations | |
| 197 | - obs = cscripts.obsutils.set_observations(83.63, 22.01, 5.0, 0.0, 180.0, | |
| 198 | - 0.1, 100.0, 'South_0.5h', 'prod2', | |
| 199 | - pattern='four', offset=1.5) | |
| 200 | - | |
| 201 | - # Setup model | |
| 202 | - obs.models(gammalib.GModels(datadir+'/crab.xml')) | |
| 203 | - | |
| 204 | - # Run analysis pipeline | |
| 205 | - run_pipeline(obs, model=datadir+'/crab.xml', enumbins=10, nxpix=40, | |
| 206 | - nypix=40, binsz=0.1) | |
| 207 | - | |
| 208 | - # Return | |
| 209 | - return | |
| 210 | - | |
| 211 | - | |
| 212 | -# ======================== # | |
| 213 | -# Main routine entry point # | |
| 214 | -# ======================== # | |
| 215 | -if __name__ == '__main__': | |
| 216 | - | |
| 217 | - # Run stacked pipeline with intermediate results on disk | |
| 218 | - pipeline_stacked_disk() |
examples/pipeline_stacked_mem.py deleted
| 1 | -#! /usr/bin/env python | |
| 2 | -# ========================================================================== | |
| 3 | -# Perform stacked in-memory analysis of simulated CTA data | |
| 4 | -# | |
| 5 | -# Copyright (C) 2014-2016 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 gammalib | |
| 22 | -import ctools | |
| 23 | -import cscripts | |
| 24 | - | |
| 25 | - | |
| 26 | -# ================================ # | |
| 27 | -# Simulation and analysis pipeline # | |
| 28 | -# ================================ # | |
| 29 | -def run_pipeline(obs, ra=83.63, dec=22.01, emin=0.1, emax=100.0, | |
| 30 | - enumbins=20, nxpix=200, nypix=200, binsz=0.02, | |
| 31 | - coordsys='CEL', proj='CAR', debug=False): | |
| 32 | - """ | |
| 33 | - Simulation and stacked analysis pipeline | |
| 34 | - | |
| 35 | - Parameters | |
| 36 | - ---------- | |
| 37 | - obs : `~gammalib.GObservations` | |
| 38 | - Observation container | |
| 39 | - ra : float, optional | |
| 40 | - Right Ascension of counts cube centre (deg) | |
| 41 | - dec : float, optional | |
| 42 | - Declination of Region of counts cube centre (deg) | |
| 43 | - emin : float, optional | |
| 44 | - Minimum energy (TeV) | |
| 45 | - emax : float, optional | |
| 46 | - Maximum energy (TeV) | |
| 47 | - enumbins : int, optional | |
| 48 | - Number of energy bins | |
| 49 | - nxpix : int, optional | |
| 50 | - Number of pixels in X axis | |
| 51 | - nypix : int, optional | |
| 52 | - Number of pixels in Y axis | |
| 53 | - binsz : float, optional | |
| 54 | - Pixel size (deg) | |
| 55 | - coordsys : str, optional | |
| 56 | - Coordinate system | |
| 57 | - proj : str, optional | |
| 58 | - Coordinate projection | |
| 59 | - debug : bool, optional | |
| 60 | - Debug function | |
| 61 | - """ | |
| 62 | - # Simulate events | |
| 63 | - sim = ctools.ctobssim(obs) | |
| 64 | - sim['debug'] = debug | |
| 65 | - sim.run() | |
| 66 | - | |
| 67 | - # Bin events into counts map | |
| 68 | - binning = ctools.ctbin(sim.obs()) | |
| 69 | - binning['ebinalg'] = 'LOG' | |
| 70 | - binning['emin'] = emin | |
| 71 | - binning['emax'] = emax | |
| 72 | - binning['enumbins'] = enumbins | |
| 73 | - binning['nxpix'] = nxpix | |
| 74 | - binning['nypix'] = nypix | |
| 75 | - binning['binsz'] = binsz | |
| 76 | - binning['coordsys'] = coordsys | |
| 77 | - binning['proj'] = proj | |
| 78 | - binning['xref'] = ra | |
| 79 | - binning['yref'] = dec | |
| 80 | - binning['debug'] = debug | |
| 81 | - binning.run() | |
| 82 | - | |
| 83 | - # Create exposure cube | |
| 84 | - expcube = ctools.ctexpcube(sim.obs()) | |
| 85 | - expcube['incube'] = 'NONE' | |
| 86 | - expcube['ebinalg'] = 'LOG' | |
| 87 | - expcube['emin'] = emin | |
| 88 | - expcube['emax'] = emax | |
| 89 | - expcube['enumbins'] = enumbins | |
| 90 | - expcube['nxpix'] = nxpix | |
| 91 | - expcube['nypix'] = nypix | |
| 92 | - expcube['binsz'] = binsz | |
| 93 | - expcube['coordsys'] = coordsys | |
| 94 | - expcube['proj'] = proj | |
| 95 | - expcube['xref'] = ra | |
| 96 | - expcube['yref'] = dec | |
| 97 | - expcube['debug'] = debug | |
| 98 | - expcube.run() | |
| 99 | - | |
| 100 | - # Create PSF cube | |
| 101 | - psfcube = ctools.ctpsfcube(sim.obs()) | |
| 102 | - psfcube['incube'] = 'NONE' | |
| 103 | - psfcube['ebinalg'] = 'LOG' | |
| 104 | - psfcube['emin'] = emin | |
| 105 | - psfcube['emax'] = emax | |
| 106 | - psfcube['enumbins'] = enumbins | |
| 107 | - psfcube['nxpix'] = 10 | |
| 108 | - psfcube['nypix'] = 10 | |
| 109 | - psfcube['binsz'] = 1.0 | |
| 110 | - psfcube['coordsys'] = coordsys | |
| 111 | - psfcube['proj'] = proj | |
| 112 | - psfcube['xref'] = ra | |
| 113 | - psfcube['yref'] = dec | |
| 114 | - psfcube['debug'] = debug | |
| 115 | - psfcube.run() | |
| 116 | - | |
| 117 | - # Create background cube | |
| 118 | - bkgcube = ctools.ctbkgcube(sim.obs()) | |
| 119 | - bkgcube['incube'] = 'NONE' | |
| 120 | - bkgcube['ebinalg'] = 'LOG' | |
| 121 | - bkgcube['emin'] = emin | |
| 122 | - bkgcube['emax'] = emax | |
| 123 | - bkgcube['enumbins'] = enumbins | |
| 124 | - bkgcube['nxpix'] = 10 | |
| 125 | - bkgcube['nypix'] = 10 | |
| 126 | - bkgcube['binsz'] = 1.0 | |
| 127 | - bkgcube['coordsys'] = coordsys | |
| 128 | - bkgcube['proj'] = proj | |
| 129 | - bkgcube['xref'] = ra | |
| 130 | - bkgcube['yref'] = dec | |
| 131 | - bkgcube['debug'] = debug | |
| 132 | - bkgcube.run() | |
| 133 | - | |
| 134 | - # Attach background model to observation container | |
| 135 | - binning.obs().models(bkgcube.models()) | |
| 136 | - | |
| 137 | - # Set Exposure and Psf cube for first CTA observation | |
| 138 | - # (ctbin will create an observation with a single container) | |
| 139 | - binning.obs()[0].response(expcube.expcube(), psfcube.psfcube(), bkgcube.bkgcube()) | |
| 140 | - | |
| 141 | - # Perform maximum likelihood fitting | |
| 142 | - like = ctools.ctlike(binning.obs()) | |
| 143 | - like['debug'] = True # Switch this always on for results in console | |
| 144 | - like.run() | |
| 145 | - | |
| 146 | - # Return | |
| 147 | - return | |
| 148 | - | |
| 149 | - | |
| 150 | -# ============================== # | |
| 151 | -# Run stacked in-memory pipeline # | |
| 152 | -# ============================== # | |
| 153 | -def pipeline_stacked_mem(): | |
| 154 | - """ | |
| 155 | - Run stacked in-memory pipeline | |
| 156 | - """ | |
| 157 | - # Set usage string | |
| 158 | - usage = 'pipeline_stacked_mem.py [-d datadir]' | |
| 159 | - | |
| 160 | - # Set default options | |
| 161 | - options = [{'option': '-d', 'value': 'data'}] | |
| 162 | - | |
| 163 | - # Get arguments and options from command line arguments | |
| 164 | - _, options = cscripts.ioutils.get_args_options(options, usage) | |
| 165 | - | |
| 166 | - # Extract script parameters from options | |
| 167 | - datadir = options[0]['value'] | |
| 168 | - | |
| 169 | - # Setup observations | |
| 170 | - obs = cscripts.obsutils.set_observations(83.63, 22.01, 5.0, 0.0, 180.0, | |
| 171 | - 0.1, 100.0, 'South_0.5h', 'prod2', | |
| 172 | - pattern='four', offset=1.5) | |
| 173 | - | |
| 174 | - # Setup model | |
| 175 | - obs.models(gammalib.GModels(datadir+'/crab.xml')) | |
| 176 | - | |
| 177 | - # Run analysis pipeline | |
| 178 | - run_pipeline(obs, enumbins=10, nxpix=40, nypix=40, binsz=0.1) | |
| 179 | - | |
| 180 | - # Return | |
| 181 | - return | |
| 182 | - | |
| 183 | - | |
| 184 | -# ======================== # | |
| 185 | -# Main routine entry point # | |
| 186 | -# ======================== # | |
| 187 | -if __name__ == '__main__': | |
| 188 | - | |
| 189 | - # Run stacked in-memory pipeline | |
| 190 | - pipeline_stacked_mem() |
examples/pipeline_unbinned_disk.py deleted
| 1 | -#! /usr/bin/env python | |
| 2 | -# ========================================================================== | |
| 3 | -# Perform unbinned analysis of simulated CTA data. | |
| 4 | -# | |
| 5 | -# Copyright (C) 2015-2016 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 gammalib | |
| 22 | -import ctools | |
| 23 | -import cscripts | |
| 24 | - | |
| 25 | - | |
| 26 | -# ================================ # | |
| 27 | -# Simulation and analysis pipeline # | |
| 28 | -# ================================ # | |
| 29 | -def run_pipeline(obs, ra=83.63, dec=22.01, rad=3.0, | |
| 30 | - emin=0.1, emax=100.0, | |
| 31 | - tmin=0.0, tmax=0.0, | |
| 32 | - model='data/crab.xml', | |
| 33 | - caldb='prod2', irf='South_0.5h', | |
| 34 | - debug=False): | |
| 35 | - """ | |
| 36 | - Simulation and unbinned analysis pipeline | |
| 37 | - | |
| 38 | - Parameters | |
| 39 | - ---------- | |
| 40 | - obs : `~gammalib.GObservations` | |
| 41 | - Observation container | |
| 42 | - ra : float, optional | |
| 43 | - Right Ascension of Region of Interest centre (deg) | |
| 44 | - dec : float, optional | |
| 45 | - Declination of Region of Interest centre (deg) | |
| 46 | - rad : float, optional | |
| 47 | - Radius of Region of Interest (deg) | |
| 48 | - emin : float, optional | |
| 49 | - Minimum energy (TeV) | |
| 50 | - emax : float, optional | |
| 51 | - Maximum energy (TeV) | |
| 52 | - tmin : float, optional | |
| 53 | - Start time (s) | |
| 54 | - tmax : float, optional | |
| 55 | - Stop time (s) | |
| 56 | - model : str, optional | |
| 57 | - Model definition XML file | |
| 58 | - caldb : str, optional | |
| 59 | - Calibration database path | |
| 60 | - irf : str, optional | |
| 61 | - Instrument response function | |
| 62 | - debug : bool, optional | |
| 63 | - Debug function | |
| 64 | - """ | |
| 65 | - # Get model | |
| 66 | - | |
| 67 | - # Simulate events | |
| 68 | - sim = ctools.ctobssim(obs) | |
| 69 | - sim['debug'] = debug | |
| 70 | - sim['outevents'] = 'obs.xml' | |
| 71 | - sim.execute() | |
| 72 | - | |
| 73 | - # Select events | |
| 74 | - select = ctools.ctselect() | |
| 75 | - select['inobs'] = 'obs.xml' | |
| 76 | - select['outobs'] = 'obs_selected.xml' | |
| 77 | - select['ra'] = ra | |
| 78 | - select['dec'] = dec | |
| 79 | - select['rad'] = rad | |
| 80 | - select['emin'] = emin | |
| 81 | - select['emax'] = emax | |
| 82 | - select['tmin'] = tmin | |
| 83 | - select['tmax'] = tmax | |
| 84 | - select['debug'] = debug | |
| 85 | - select.execute() | |
| 86 | - | |
| 87 | - # Perform maximum likelihood fitting | |
| 88 | - like = ctools.ctlike() | |
| 89 | - like['inobs'] = 'obs_selected.xml' | |
| 90 | - like['inmodel'] = model | |
| 91 | - like['outmodel'] = 'fit_results.xml' | |
| 92 | - like['caldb'] = caldb | |
| 93 | - like['irf'] = irf | |
| 94 | - like['debug'] = True # Switch this always on for results in console | |
| 95 | - like.execute() | |
| 96 | - | |
| 97 | - # Return | |
| 98 | - return | |
| 99 | - | |
| 100 | - | |
| 101 | -# ======================================================= # | |
| 102 | -# Run unbinned pipeline with intermediate results on disk # | |
| 103 | -# ======================================================= # | |
| 104 | -def pipeline_unbinned_disk(): | |
| 105 | - """ | |
| 106 | - Run unbinned pipeline with intermediate results on disk | |
| 107 | - """ | |
| 108 | - # Set usage string | |
| 109 | - usage = 'pipeline_unbinned_disk.py [-d datadir]' | |
| 110 | - | |
| 111 | - # Set default options | |
| 112 | - options = [{'option': '-d', 'value': 'data'}] | |
| 113 | - | |
| 114 | - # Get arguments and options from command line arguments | |
| 115 | - _, options = cscripts.ioutils.get_args_options(options, usage) | |
| 116 | - | |
| 117 | - # Extract script parameters from options | |
| 118 | - datadir = options[0]['value'] | |
| 119 | - | |
| 120 | - # Setup observations | |
| 121 | - obs = cscripts.obsutils.set_observations(83.63, 22.01, 5.0, 0.0, 180.0, | |
| 122 | - 0.1, 100.0, 'South_0.5h', 'prod2', | |
| 123 | - pattern='four', offset=1.5) | |
| 124 | - | |
| 125 | - # Setup model | |
| 126 | - obs.models(gammalib.GModels(datadir+'/crab.xml')) | |
| 127 | - | |
| 128 | - # Run analysis pipeline | |
| 129 | - run_pipeline(obs, model=datadir+'/crab.xml') | |
| 130 | - | |
| 131 | - # Return | |
| 132 | - return | |
| 133 | - | |
| 134 | - | |
| 135 | -# ======================== # | |
| 136 | -# Main routine entry point # | |
| 137 | -# ======================== # | |
| 138 | -if __name__ == '__main__': | |
| 139 | - | |
| 140 | - # Run unbinned pipeline with intermediate results on disk | |
| 141 | - pipeline_unbinned_disk() |
examples/pipeline_unbinned_mem.py deleted
| 1 | -#! /usr/bin/env python | |
| 2 | -# ========================================================================== | |
| 3 | -# Perform unbinned in-memory analysis of simulated CTA data | |
| 4 | -# | |
| 5 | -# Copyright (C) 2015-2016 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 gammalib | |
| 22 | -import ctools | |
| 23 | -import cscripts | |
| 24 | - | |
| 25 | - | |
| 26 | -# ================================ # | |
| 27 | -# Simulation and analysis pipeline # | |
| 28 | -# ================================ # | |
| 29 | -def run_pipeline(obs, ra=83.63, dec=22.01, rad=3.0, | |
| 30 | - emin=0.1, emax=100.0, | |
| 31 | - tmin=0.0, tmax=0.0, | |
| 32 | - debug=False): | |
| 33 | - """ | |
| 34 | - Simulation and binned analysis pipeline | |
| 35 | - | |
| 36 | - Parameters | |
| 37 | - ---------- | |
| 38 | - obs : `~gammalib.GObservations` | |
| 39 | - Observation container | |
| 40 | - ra : float, optional | |
| 41 | - Right Ascension of Region of Interest centre (deg) | |
| 42 | - dec : float, optional | |
| 43 | - Declination of Region of Interest centre (deg) | |
| 44 | - rad : float, optional | |
| 45 | - Radius of Region of Interest (deg) | |
| 46 | - emin : float, optional | |
| 47 | - Minimum energy (TeV) | |
| 48 | - emax : float, optional | |
| 49 | - Maximum energy (TeV) | |
| 50 | - tmin : float, optional | |
| 51 | - Start time (s) | |
| 52 | - tmax : float, optional | |
| 53 | - Stop time (s) | |
| 54 | - debug : bool, optional | |
| 55 | - Debug function | |
| 56 | - """ | |
| 57 | - # Simulate events | |
| 58 | - sim = ctools.ctobssim(obs) | |
| 59 | - sim['debug'] = debug | |
| 60 | - sim.run() | |
| 61 | - | |
| 62 | - # Select events | |
| 63 | - select = ctools.ctselect(sim.obs()) | |
| 64 | - select['ra'] = ra | |
| 65 | - select['dec'] = dec | |
| 66 | - select['rad'] = rad | |
| 67 | - select['emin'] = emin | |
| 68 | - select['emax'] = emax | |
| 69 | - select['tmin'] = tmin | |
| 70 | - select['tmax'] = tmax | |
| 71 | - select['debug'] = debug | |
| 72 | - select.run() | |
| 73 | - | |
| 74 | - # Perform maximum likelihood fitting | |
| 75 | - like = ctools.ctlike(select.obs()) | |
| 76 | - like['debug'] = True # Switch this always on for results in console | |
| 77 | - like.run() | |
| 78 | - | |
| 79 | - # Return | |
| 80 | - return | |
| 81 | - | |
| 82 | - | |
| 83 | -# =============================== # | |
| 84 | -# Run unbinned in-memory pipeline # | |
| 85 | -# =============================== # | |
| 86 | -def pipeline_unbinned_mem(): | |
| 87 | - """ | |
| 88 | - Run unbinned in-memory pipeline | |
| 89 | - """ | |
| 90 | - # Set usage string | |
| 91 | - usage = 'pipeline_unbinned_mem.py [-d datadir]' | |
| 92 | - | |
| 93 | - # Set default options | |
| 94 | - options = [{'option': '-d', 'value': 'data'}] | |
| 95 | - | |
| 96 | - # Get arguments and options from command line arguments | |
| 97 | - _, options = cscripts.ioutils.get_args_options(options, usage) | |
| 98 | - | |
| 99 | - # Extract script parameters from options | |
| 100 | - datadir = options[0]['value'] | |
| 101 | - | |
| 102 | - # Setup observations | |
| 103 | - obs = cscripts.obsutils.set_observations(83.63, 22.01, 5.0, 0.0, 180.0, | |
| 104 | - 0.1, 100.0, 'South_0.5h', 'prod2', | |
| 105 | - pattern='four', offset=1.5) | |
| 106 | - | |
| 107 | - # Setup model | |
| 108 | - obs.models(gammalib.GModels(datadir+'/crab.xml')) | |
| 109 | - | |
| 110 | - # Run analysis pipeline | |
| 111 | - run_pipeline(obs) | |
| 112 | - | |
| 113 | - # Return | |
| 114 | - return | |
| 115 | - | |
| 116 | - | |
| 117 | -# ======================== # | |
| 118 | -# Main routine entry point # | |
| 119 | -# ======================== # | |
| 120 | -if __name__ == '__main__': | |
| 121 | - | |
| 122 | - # Run unbinned in-memory pipeline | |
| 123 | - pipeline_unbinned_mem() |
test/data/bkg_dummy.txt deleted
| 1 | -19952.6231497 0.00758611874475 | |
| 2 | -31622.7766017 0.0453646736765 | |
| 3 | -50118.7233627 0.0434482007416 | |
| 4 | -79432.8234724 0.0178479909838 | |
| 5 | -125892.541179 0.00670562887729 | |
| 6 | -199526.231497 0.00084045162152 | |
| 7 | -316227.766017 0.000323808025007 | |
| 8 | -501187.233627 9.59822836926e-05 | |
| 9 | -794328.234724 6.37799870129e-05 | |
| 10 | -1258925.41179 1.03541320942e-05 | |
| 11 | -1995262.31497 1.64149835388e-05 | |
| 12 | -3162277.66017 3.15232118872e-06 | |
| 13 | -5011872.33627 2.15432019088e-06 | |
| 14 | -7943282.34724 6.16894263439e-07 | |
| 15 | -12589254.1179 8.04369168326e-07 | |
| 16 | -19952623.1497 3.8166590852e-07 | |
| 17 | -31622776.6017 3.00652101748e-07 | |
| 18 | -50118723.3627 3.33564542808e-07 | |
| 19 | -79432823.4724 1.02704085801e-07 | |
| 20 | -125892541.179 2.78291918566e-08 | |
| 21 | -199526231.497 8.18076720102e-09 |
test/data/crab_events.fits.gz
No preview for this file type
test/data/disk.xml deleted
| 1 | -<?xml version="1.0" standalone="no"?> | |
| 2 | -<source_library title="source library"> | |
| 3 | - <source name="CrabDisk" type="ExtendedSource"> | |
| 4 | - <spectrum type="PowerLaw"> | |
| 5 | - <parameter name="Prefactor" scale="1e-16" value="5.7" min="1e-07" max="1000.0" free="1"/> | |
| 6 | - <parameter name="Index" scale="-1" value="2.48" min="0.0" max="+5.0" free="1"/> | |
| 7 | - <parameter name="PivotEnergy" scale="1e6" value="0.3" min="0.01" max="1000.0" free="0"/> | |
| 8 | - </spectrum> | |
| 9 | - <spatialModel type="RadialDisk"> | |
| 10 | - <parameter name="RA" scale="1.0" value="83.6331" min="-360" max="360" free="1"/> | |
| 11 | - <parameter name="DEC" scale="1.0" value="22.0145" min="-90" max="90" free="1"/> | |
| 12 | - <parameter name="Radius" scale="1.0" value="0.45" min="0.01" max="10" free="1"/> | |
| 13 | - </spatialModel> | |
| 14 | - </source> | |
| 15 | - <source name="Background" type="RadialAcceptance" instrument="CTA"> | |
| 16 | - <spectrum type="PowerLaw"> | |
| 17 | - <parameter name="Prefactor" scale="1e-6" value="61.8" min="0.0" max="1000.0" free="1"/> | |
| 18 | - <parameter name="Index" scale="-1" value="1.85" min="0.0" max="+5.0" free="1"/> | |
| 19 | - <parameter name="PivotEnergy" scale="1e6" value="1.0" min="0.01" max="1000.0" free="0"/> | |
| 20 | - </spectrum> | |
| 21 | - <radialModel type="Gaussian"> | |
| 22 | - <parameter name="Sigma" scale="1.0" value="3.0" min="0.01" max="10.0" free="1"/> | |
| 23 | - </radialModel> | |
| 24 | - </source> | |
| 25 | -</source_library> |
test/data/gauss.xml deleted
| 1 | -<?xml version="1.0" standalone="no"?> | |
| 2 | -<source_library title="source library"> | |
| 3 | - <source name="CrabGauss" type="ExtendedSource"> | |
| 4 | - <spectrum type="PowerLaw"> | |
| 5 | - <parameter name="Prefactor" scale="1e-16" value="5.7" min="1e-07" max="1000.0" free="1"/> | |
| 6 | - <parameter name="Index" scale="-1" value="2.48" min="0.0" max="+5.0" free="1"/> | |
| 7 | - <parameter name="PivotEnergy" scale="1e6" value="0.3" min="0.01" max="1000.0" free="0"/> | |
| 8 | - </spectrum> | |
| 9 | - <spatialModel type="RadialGaussian"> | |
| 10 | - <parameter name="RA" scale="1.0" value="83.6331" min="-360" max="360" free="1"/> | |
| 11 | - <parameter name="DEC" scale="1.0" value="22.0145" min="-90" max="90" free="1"/> | |
| 12 | - <parameter name="Sigma" scale="1.0" value="0.20" min="0.01" max="10" free="1"/> | |
| 13 | - </spatialModel> | |
| 14 | - </source> | |
| 15 | - <source name="Background" type="RadialAcceptance" instrument="CTA"> | |
| 16 | - <spectrum type="PowerLaw"> | |
| 17 | - <parameter name="Prefactor" scale="1e-6" value="61.8" min="0.0" max="1000.0" free="1"/> | |
| 18 | - <parameter name="Index" scale="-1" value="1.85" min="0.0" max="+5.0" free="1"/> | |
| 19 | - <parameter name="PivotEnergy" scale="1e6" value="1.0" min="0.01" max="1000.0" free="0"/> | |
| 20 | - </spectrum> | |
| 21 | - <radialModel type="Gaussian"> | |
| 22 | - <parameter name="Sigma" scale="1.0" value="3.0" min="0.01" max="10.0" free="1"/> | |
| 23 | - </radialModel> | |
| 24 | - </source> | |
| 25 | -</source_library> |
test/data/obs_stacked_two.xml
| ... | ... | @@ -3,7 +3,7 @@ |
| 3 | 3 | <observation name="Crab" id="000001" instrument="CTA"> |
| 4 | 4 | <parameter name="Pointing" ra="83.6331" dec="21.0145" /> |
| 5 | 5 | <parameter name="EnergyBoundaries" emin="50000" emax="1e+08" /> |
| 6 | - <parameter name="GoodTimeIntervals" tmin="0" tmax="1800" /> | |
| 6 | + <parameter name="GoodTimeIntervals" tmin="0" tmax="180" /> | |
| 7 | 7 | <parameter name="TimeReference" mjdrefi="51544" mjdreff="0.5" timeunit="s" timesys="TT" timeref="LOCAL" /> |
| 8 | 8 | <parameter name="RegionOfInterest" ra="83.6331" dec="21.0145" rad="1.5" /> |
| 9 | 9 | <parameter name="Deadtime" deadc="0.98" /> |
| ... | ... | @@ -12,7 +12,7 @@ |
| 12 | 12 | <observation name="Crab" id="000002" instrument="CTA"> |
| 13 | 13 | <parameter name="Pointing" ra="83.6331" dec="23.0145" /> |
| 14 | 14 | <parameter name="EnergyBoundaries" emin="70000" emax="1e+08" /> |
| 15 | - <parameter name="GoodTimeIntervals" tmin="1800" tmax="3600" /> | |
| 15 | + <parameter name="GoodTimeIntervals" tmin="180" tmax="360" /> | |
| 16 | 16 | <parameter name="TimeReference" mjdrefi="51544" mjdreff="0.5" timeunit="s" timesys="TT" timeref="LOCAL" /> |
| 17 | 17 | <parameter name="RegionOfInterest" ra="83.6331" dec="23.0145" rad="1.5" /> |
| 18 | 18 | <parameter name="Deadtime" deadc="0.98" /> | ... | ... |
test/data/shell.xml deleted
| 1 | -<?xml version="1.0" standalone="no"?> | |
| 2 | -<source_library title="source library"> | |
| 3 | - <source name="CrabShell" type="ExtendedSource"> | |
| 4 | - <spectrum type="PowerLaw"> | |
| 5 | - <parameter name="Prefactor" scale="1e-16" value="5.7" min="1e-07" max="1000.0" free="1"/> | |
| 6 | - <parameter name="Index" scale="-1" value="2.48" min="0.0" max="+5.0" free="1"/> | |
| 7 | - <parameter name="PivotEnergy" scale="1e6" value="0.3" min="0.01" max="1000.0" free="0"/> | |
| 8 | - </spectrum> | |
| 9 | - <spatialModel type="RadialShell"> | |
| 10 | - <parameter name="RA" scale="1.0" value="83.6331" min="-360" max="360" free="1"/> | |
| 11 | - <parameter name="DEC" scale="1.0" value="22.0145" min="-90" max="90" free="1"/> | |
| 12 | - <parameter name="Radius" scale="1.0" value="0.30" min="0.01" max="10" free="1"/> | |
| 13 | - <parameter name="Width" scale="1.0" value="0.10" min="0.01" max="10" free="1"/> | |
| 14 | - </spatialModel> | |
| 15 | - </source> | |
| 16 | - <source name="Background" type="RadialAcceptance" instrument="CTA"> | |
| 17 | - <spectrum type="PowerLaw"> | |
| 18 | - <parameter name="Prefactor" scale="1e-6" value="61.8" min="0.0" max="1000.0" free="1"/> | |
| 19 | - <parameter name="Index" scale="-1" value="1.85" min="0.0" max="+5.0" free="1"/> | |
| 20 | - <parameter name="PivotEnergy" scale="1e6" value="1.0" min="0.01" max="1000.0" free="0"/> | |
| 21 | - </spectrum> | |
| 22 | - <radialModel type="Gaussian"> | |
| 23 | - <parameter name="Sigma" scale="1.0" value="3.0" min="0.01" max="10.0" free="1"/> | |
| 24 | - </radialModel> | |
| 25 | - </source> | |
| 26 | -</source_library> |
test/data/source1.xml deleted
| 1 | -<?xml version="1.0" standalone="no"?> | |
| 2 | -<source_library title="source library"> | |
| 3 | - <source name="Source1" type="PointSource"> | |
| 4 | - <spectrum type="PowerLaw"> | |
| 5 | - <parameter scale="1e-07" name="Prefactor" min="1e-07" max="1000.0" value="1.0" free="1"/> | |
| 6 | - <parameter scale="1.0" name="Index" min="-5.0" max="+5.0" value="-2.1" free="1"/> | |
| 7 | - <parameter scale="1.0" name="PivotEnergy" min="10.0" max="1000000.0" value="100.0" free="0"/> | |
| 8 | - </spectrum> | |
| 9 | - <spatialModel type="PointSource"> | |
| 10 | - <parameter free="0" max="360" min="-360" name="RA" scale="1" value="117.0" /> | |
| 11 | - <parameter free="0" max="90" min="-90" name="DEC" scale="1" value="-33.0" /> | |
| 12 | - </spatialModel> | |
| 13 | - </source> | |
| 14 | -</source_library> | |
| 15 | - |
test/data/workflow.xml
| ... | ... | @@ -8,12 +8,12 @@ |
| 8 | 8 | <parameter name="edisp" value="no" /> |
| 9 | 9 | <parameter name="deadc" value="0.98" /> |
| 10 | 10 | <parameter name="ra" value="83.63" /> |
| 11 | - <parameter name="dec" value="22.01" /> | |
| 11 | + <parameter name="dec" value="22.51" /> | |
| 12 | 12 | <parameter name="target" value="Crab" /> |
| 13 | 13 | <parameter name="emin" value="0.1" /> |
| 14 | 14 | <parameter name="emax" value="100.0" /> |
| 15 | 15 | <parameter name="tmin" value="0.0" /> |
| 16 | - <parameter name="tmax" value="1800.0" /> | |
| 16 | + <parameter name="tmax" value="300.0" /> | |
| 17 | 17 | <parameter name="chatter" value="2" /> |
| 18 | 18 | <parameter name="clobber" value="yes" /> |
| 19 | 19 | <parameter name="debug" value="no" /> |
| ... | ... | @@ -31,7 +31,7 @@ |
| 31 | 31 | <parameter name="seed" value="1" /> |
| 32 | 32 | <parameter name="ra" value="ra" actor="input" /> |
| 33 | 33 | <parameter name="dec" value="dec" actor="input" /> |
| 34 | - <parameter name="rad" value="5.0" /> | |
| 34 | + <parameter name="rad" value="3.0" /> | |
| 35 | 35 | <parameter name="tmin" value="tmin" actor="input" /> |
| 36 | 36 | <parameter name="tmax" value="tmax" actor="input" /> |
| 37 | 37 | <parameter name="emin" value="emin" actor="input" /> |
| ... | ... | @@ -56,7 +56,7 @@ |
| 56 | 56 | <parameter name="usepnt" value="no" /> |
| 57 | 57 | <parameter name="ra" value="ra" actor="input" /> |
| 58 | 58 | <parameter name="dec" value="dec" actor="input" /> |
| 59 | - <parameter name="rad" value="3.0" /> | |
| 59 | + <parameter name="rad" value="2.0" /> | |
| 60 | 60 | <parameter name="tmin" value="tmin" actor="input" /> |
| 61 | 61 | <parameter name="tmax" value="tmax" actor="input" /> |
| 62 | 62 | <parameter name="emin" value="emin" actor="input" /> | ... | ... |
test/test_cslightcrv.py
| ... | ... | @@ -77,7 +77,7 @@ class Test(test): |
| 77 | 77 | ' inmodel="'+self._model+'" srcname="Crab"'+ \ |
| 78 | 78 | ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \ |
| 79 | 79 | ' tbinalg=LIN '+ \ |
| 80 | - ' tmin=2020-01-01T00:00:00 tmax=2020-01-01T00:30:00'+ \ | |
| 80 | + ' tmin=2020-01-01T00:00:00 tmax=2020-01-01T00:05:00'+ \ | |
| 81 | 81 | ' tbins=3 method=3D enumbins=0 emin=0.1 emax=100.0'+ \ |
| 82 | 82 | ' outfile="lightcurve_cmd1.fits"'+ \ |
| 83 | 83 | ' logfile="cslightcrv_cmd1.log" chatter=1' |
| ... | ... | @@ -98,7 +98,7 @@ class Test(test): |
| 98 | 98 | ' inmodel="'+self._model+'" srcname="Crab"'+ \ |
| 99 | 99 | ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \ |
| 100 | 100 | ' tbinalg=LIN '+ \ |
| 101 | - ' tmin=2020-01-01T00:00:00 tmax=2020-01-01T00:30:00'+ \ | |
| 101 | + ' tmin=2020-01-01T00:00:00 tmax=2020-01-01T00:05:00'+ \ | |
| 102 | 102 | ' tbins=3 method=3D enumbins=0 emin=0.1 emax=100.0'+ \ |
| 103 | 103 | ' outfile="lightcurve_cmd1.fits"'+ \ |
| 104 | 104 | ' logfile="cslightcrv_cmd2.log" debug=yes' |
| ... | ... | @@ -127,7 +127,7 @@ class Test(test): |
| 127 | 127 | lcrv['irf'] = self._irf |
| 128 | 128 | lcrv['tbinalg'] = 'LIN' |
| 129 | 129 | lcrv['tmin'] = '2020-01-01T00:00:00' |
| 130 | - lcrv['tmax'] = '2020-01-01T00:30:00' | |
| 130 | + lcrv['tmax'] = '2020-01-01T00:05:00' | |
| 131 | 131 | lcrv['tbins'] = 3 |
| 132 | 132 | lcrv['method'] = '3D' |
| 133 | 133 | lcrv['enumbins'] = 0 |
| ... | ... | @@ -151,7 +151,7 @@ class Test(test): |
| 151 | 151 | # is saved into the file "lightcurve_py2.dat". |
| 152 | 152 | csv = gammalib.GCsv(2,2) |
| 153 | 153 | tmin = 58849.00 |
| 154 | - tdelta = 0.0104166 | |
| 154 | + tdelta = 0.0017361 | |
| 155 | 155 | for i in range(csv.nrows()): |
| 156 | 156 | csv[i,0] = '%.5f' % (tmin + i * tdelta) |
| 157 | 157 | csv[i,1] = '%.5f' % (tmin + (i+1) * tdelta) |
| ... | ... | @@ -219,7 +219,7 @@ class Test(test): |
| 219 | 219 | lcrv['irf'] = self._irf |
| 220 | 220 | lcrv['tbinalg'] = 'LIN' |
| 221 | 221 | lcrv['tmin'] = '2020-01-01T00:00:00' |
| 222 | - lcrv['tmax'] = '2020-01-01T00:30:00' | |
| 222 | + lcrv['tmax'] = '2020-01-01T00:05:00' | |
| 223 | 223 | lcrv['tbins'] = 2 |
| 224 | 224 | lcrv['method'] = '3D' |
| 225 | 225 | lcrv['emin'] = 0.1 |
| ... | ... | @@ -250,8 +250,8 @@ class Test(test): |
| 250 | 250 | lcrv['caldb'] = self._caldb |
| 251 | 251 | lcrv['irf'] = self._irf |
| 252 | 252 | lcrv['tbinalg'] = 'LIN' |
| 253 | - lcrv['tmin'] = 'MJD 58849.0008' | |
| 254 | - lcrv['tmax'] = 'MJD 58849.0112' | |
| 253 | + lcrv['tmin'] = '2020-01-01T00:00:00' | |
| 254 | + lcrv['tmax'] = '2020-01-01T00:05:00' | |
| 255 | 255 | lcrv['tbins'] = 2 |
| 256 | 256 | lcrv['method'] = 'ONOFF' |
| 257 | 257 | lcrv['emin'] = 0.1 |
| ... | ... | @@ -261,6 +261,9 @@ class Test(test): |
| 261 | 261 | lcrv['xref'] = 83.63 |
| 262 | 262 | lcrv['yref'] = 22.01 |
| 263 | 263 | lcrv['rad'] = 0.2 |
| 264 | + lcrv['etruemin'] = 0.05 | |
| 265 | + lcrv['etruemax'] = 150.0 | |
| 266 | + lcrv['etruebins'] = 5 | |
| 264 | 267 | lcrv['statistic'] = 'WSTAT' |
| 265 | 268 | lcrv['outfile'] = 'cslightcrv_py5.fits' |
| 266 | 269 | lcrv['logfile'] = 'cslightcrv_py5.log' | ... | ... |
test/test_csphagen.py
| ... | ... | @@ -49,7 +49,7 @@ class Test(test): |
| 49 | 49 | self._nreg_with_excl = 5 |
| 50 | 50 | self._nreg_wo_excl = 8 |
| 51 | 51 | self._nreg_mul = [self._nreg_with_excl, 6] |
| 52 | - self._nbins = 20 | |
| 52 | + self._nbins = 10 | |
| 53 | 53 | # number of expected background regions with/wo exclusion, |
| 54 | 54 | # and for two different runs |
| 55 | 55 | |
| ... | ... | @@ -84,6 +84,7 @@ class Test(test): |
| 84 | 84 | '" caldb="' + self._caldb + '" irf="' + self._irf + \ |
| 85 | 85 | '" ebinalg="LOG" emin=0.1 emax=100. enumbins=' + \ |
| 86 | 86 | str(self._nbins) + \ |
| 87 | + ' etruemin=0.05 etruemax=150 etruebins=5'+ \ | |
| 87 | 88 | ' coordsys="CEL" ra=83.633 dec=22.0145' + \ |
| 88 | 89 | ' rad=0.2 stack="no" inexclusion="' + \ |
| 89 | 90 | self._exclusion + \ |
| ... | ... | @@ -107,6 +108,7 @@ class Test(test): |
| 107 | 108 | 'caldb="' + self._caldb + '" irf="' + self._irf + \ |
| 108 | 109 | '" ebinalg="LOG" emin=0.1 emax=100. enumbins=' + \ |
| 109 | 110 | str(self._nbins) + \ |
| 111 | + ' etruemin=0.05 etruemax=150 etruebins=5'+ \ | |
| 110 | 112 | ' coordsys="CEL" ra=83.633 dec=22.0145' + \ |
| 111 | 113 | ' rad=0.2 stack="no" inexclusion="' + \ |
| 112 | 114 | self._exclusion + \ |
| ... | ... | @@ -142,6 +144,9 @@ class Test(test): |
| 142 | 144 | phagen['rad'] = 0.2 |
| 143 | 145 | phagen['stack'] = False |
| 144 | 146 | phagen['inexclusion'] = self._exclusion |
| 147 | + phagen['etruemin'] = 0.05 | |
| 148 | + phagen['etruemax'] = 150.0 | |
| 149 | + phagen['etruebins'] = 5 | |
| 145 | 150 | phagen['outobs'] = 'csphagen_py1.xml' |
| 146 | 151 | phagen['prefix'] = 'csphagen_py1' |
| 147 | 152 | phagen['logfile'] = 'csphagen_py1.log' |
| ... | ... | @@ -156,22 +161,25 @@ class Test(test): |
| 156 | 161 | |
| 157 | 162 | # Now test without exclusion region |
| 158 | 163 | phagen = cscripts.csphagen() |
| 159 | - phagen['inobs'] = self._myevents1 | |
| 160 | - phagen['caldb'] = self._caldb | |
| 161 | - phagen['irf'] = self._irf | |
| 162 | - phagen['ebinalg'] = 'LOG' | |
| 163 | - phagen['emin'] = 0.1 | |
| 164 | - phagen['emax'] = 100.0 | |
| 165 | - phagen['enumbins'] = self._nbins | |
| 166 | - phagen['coordsys'] = 'CEL' | |
| 167 | - phagen['ra'] = 83.633 | |
| 168 | - phagen['dec'] = 22.0145 | |
| 169 | - phagen['rad'] = 0.2 | |
| 170 | - phagen['stack'] = False | |
| 171 | - phagen['outobs'] = 'csphagen_py2.xml' | |
| 172 | - phagen['prefix'] = 'csphagen_py2' | |
| 173 | - phagen['logfile'] = 'csphagen_py2.log' | |
| 174 | - phagen['chatter'] = 2 | |
| 164 | + phagen['inobs'] = self._myevents1 | |
| 165 | + phagen['caldb'] = self._caldb | |
| 166 | + phagen['irf'] = self._irf | |
| 167 | + phagen['ebinalg'] = 'LOG' | |
| 168 | + phagen['emin'] = 0.1 | |
| 169 | + phagen['emax'] = 100.0 | |
| 170 | + phagen['enumbins'] = self._nbins | |
| 171 | + phagen['coordsys'] = 'CEL' | |
| 172 | + phagen['ra'] = 83.633 | |
| 173 | + phagen['dec'] = 22.0145 | |
| 174 | + phagen['rad'] = 0.2 | |
| 175 | + phagen['stack'] = False | |
| 176 | + phagen['etruemin'] = 0.05 | |
| 177 | + phagen['etruemax'] = 150.0 | |
| 178 | + phagen['etruebins'] = 5 | |
| 179 | + phagen['outobs'] = 'csphagen_py2.xml' | |
| 180 | + phagen['prefix'] = 'csphagen_py2' | |
| 181 | + phagen['logfile'] = 'csphagen_py2.log' | |
| 182 | + phagen['chatter'] = 2 | |
| 175 | 183 | |
| 176 | 184 | # Run script |
| 177 | 185 | phagen.execute() |
| ... | ... | @@ -201,6 +209,9 @@ class Test(test): |
| 201 | 209 | phagen['rad'] = 0.2 |
| 202 | 210 | phagen['stack'] = False |
| 203 | 211 | phagen['inexclusion'] = self._exclusion |
| 212 | + phagen['etruemin'] = 0.05 | |
| 213 | + phagen['etruemax'] = 150.0 | |
| 214 | + phagen['etruebins'] = 5 | |
| 204 | 215 | phagen['outobs'] = 'csphagen_py3.xml' |
| 205 | 216 | phagen['prefix'] = 'csphagen_py3' |
| 206 | 217 | phagen['logfile'] = 'csphagen_py3.log' |
| ... | ... | @@ -228,6 +239,9 @@ class Test(test): |
| 228 | 239 | phagen['rad'] = 0.2 |
| 229 | 240 | phagen['stack'] = True |
| 230 | 241 | phagen['inexclusion'] = self._exclusion |
| 242 | + phagen['etruemin'] = 0.05 | |
| 243 | + phagen['etruemax'] = 150.0 | |
| 244 | + phagen['etruebins'] = 5 | |
| 231 | 245 | phagen['outobs'] = 'csphagen_py4.xml' |
| 232 | 246 | phagen['prefix'] = 'csphagen_py4' |
| 233 | 247 | phagen['logfile'] = 'csphagen_py4.log' |
| ... | ... | @@ -339,7 +353,7 @@ class Test(test): |
| 339 | 353 | # Return |
| 340 | 354 | return |
| 341 | 355 | |
| 342 | - def _check_rmf(self, filename, bins, etruebins=102): | |
| 356 | + def _check_rmf(self, filename, bins, etruebins=17): | |
| 343 | 357 | """ |
| 344 | 358 | Check RMF file |
| 345 | 359 | """ |
| ... | ... | @@ -386,7 +400,7 @@ class Test(test): |
| 386 | 400 | # OGIP files |
| 387 | 401 | self._check_pha(filenameroot + '_pha_on.fits', bins) |
| 388 | 402 | self._check_pha(filenameroot + '_pha_off.fits', bins) |
| 389 | - self._check_arf(filenameroot + '_arf.fits', 102) | |
| 403 | + self._check_arf(filenameroot + '_arf.fits', 17) | |
| 390 | 404 | self._check_rmf(filenameroot + '_rmf.fits', bins) |
| 391 | 405 | |
| 392 | 406 | # Optionally check for regions | ... | ... |
test/test_csphasecrv.py
| ... | ... | @@ -45,7 +45,7 @@ class Test(test): |
| 45 | 45 | # Set test data |
| 46 | 46 | self._phased_events = self._datadir + '/phased_events.fits' |
| 47 | 47 | self._offaxis_events = self._datadir + '/crab_offaxis1.fits' |
| 48 | - self._model_onoff = self._datadir + '/crab_onoff.xml' | |
| 48 | + self._model_onoff = self._datadir + '/crab_onoff.xml' | |
| 49 | 49 | |
| 50 | 50 | # Return |
| 51 | 51 | return |
| ... | ... | @@ -258,6 +258,9 @@ class Test(test): |
| 258 | 258 | pcrv['xref'] = 83.63 |
| 259 | 259 | pcrv['yref'] = 22.01 |
| 260 | 260 | pcrv['rad'] = 0.2 |
| 261 | + pcrv['etruemin'] = 0.05 | |
| 262 | + pcrv['etruemax'] = 150.0 | |
| 263 | + pcrv['etruebins'] = 5 | |
| 261 | 264 | pcrv['outfile'] = 'csphasecrv_py5.fits' |
| 262 | 265 | pcrv['logfile'] = 'csphasecrv_py5.log' |
| 263 | 266 | pcrv['chatter'] = 4 | ... | ... |
test/test_cssens.py
| ... | ... | @@ -72,7 +72,7 @@ class Test(test): |
| 72 | 72 | cmd = cssens+' inmodel="'+self._model+'"'+ \ |
| 73 | 73 | ' srcname="Crab"'+ \ |
| 74 | 74 | ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \ |
| 75 | - ' duration=1800.0 rad=3.0 emin=1.0 emax=10.0 bins=1'+ \ | |
| 75 | + ' duration=180.0 rad=3.0 emin=1.0 emax=10.0 bins=1'+ \ | |
| 76 | 76 | ' outfile="cssens_cmd1.dat"'+ \ |
| 77 | 77 | ' logfile="cssens_cmd1.log" chatter=1' |
| 78 | 78 | |
| ... | ... | @@ -91,7 +91,7 @@ class Test(test): |
| 91 | 91 | cmd = cssens+' inmodel="model_that_does_not_exist.xml"'+ \ |
| 92 | 92 | ' srcname="Crab"'+ \ |
| 93 | 93 | ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \ |
| 94 | - ' duration=1800.0 rad=3.0 emin=1.0 emax=10.0 bins=1'+ \ | |
| 94 | + ' duration=180.0 rad=3.0 emin=1.0 emax=10.0 bins=1'+ \ | |
| 95 | 95 | ' outfile="cssens_cmd2.dat"'+ \ |
| 96 | 96 | ' logfile="cssens_cmd2.log" debug=yes chatter=2' |
| 97 | 97 | |
| ... | ... | @@ -118,7 +118,7 @@ class Test(test): |
| 118 | 118 | sens['caldb'] = self._caldb |
| 119 | 119 | sens['irf'] = self._irf |
| 120 | 120 | sens['outfile'] = 'cssens_py1.dat' |
| 121 | - sens['duration'] = 1800.0 | |
| 121 | + sens['duration'] = 180.0 | |
| 122 | 122 | sens['rad'] = 3.0 |
| 123 | 123 | sens['emin'] = 1.0 |
| 124 | 124 | sens['emax'] = 10.0 |
| ... | ... | @@ -142,7 +142,7 @@ class Test(test): |
| 142 | 142 | sens['caldb'] = self._caldb |
| 143 | 143 | sens['irf'] = self._irf |
| 144 | 144 | sens['outfile'] = 'cssens_py2.dat' |
| 145 | - sens['duration'] = 1800.0 | |
| 145 | + sens['duration'] = 180.0 | |
| 146 | 146 | sens['rad'] = 3.0 |
| 147 | 147 | sens['emin'] = 1.0 |
| 148 | 148 | sens['emax'] = 10.0 | ... | ... |
test/test_csworkflow.py
| ... | ... | @@ -144,13 +144,17 @@ class Test(test): |
| 144 | 144 | |
| 145 | 145 | # Check fit result values |
| 146 | 146 | self.test_value(models['Crab'][2].value(), |
| 147 | - 5.71055e-16, 1.0e-5, 'Crab prefactor') | |
| 147 | + 5.65431687851392e-16, 1.0e-4 * 5.65431687851392e-16, | |
| 148 | + 'Check Crab prefactor') | |
| 148 | 149 | self.test_value(models['Crab'][3].value(), |
| 149 | - -2.46174095362681, 1.0e-5, 'Crab index') | |
| 150 | + -2.45753747320273, 1.0e-4 * 2.45753747320273, | |
| 151 | + 'Check Crab index') | |
| 150 | 152 | self.test_value(models['CTABackgroundModel'][0].value(), |
| 151 | - 1.01831847752743, 1.0e-5, 'Background model prefactor') | |
| 153 | + 1.0444753409474, 1.0e-4 * 1.0444753409474, | |
| 154 | + 'Check background model prefactor') | |
| 152 | 155 | self.test_value(models['CTABackgroundModel'][1].value(), |
| 153 | - 0.00742512418279459, 1.0e-5, 'Background model index') | |
| 156 | + 0.0126628793551562, 1.0e-4 * 0.0126628793551562, | |
| 157 | + 'Check background model index') | |
| 154 | 158 | |
| 155 | 159 | # Return |
| 156 | 160 | return | ... | ... |
test/test_ctbin.py
| ... | ... | @@ -87,7 +87,7 @@ class Test(test): |
| 87 | 87 | |
| 88 | 88 | # Load counts cube and check content. |
| 89 | 89 | evt = gammalib.GCTAEventCube('cntmap_cmd1.fits') |
| 90 | - self._check_cube(evt, 18483) | |
| 90 | + self._check_cube(evt, 3105) | |
| 91 | 91 | |
| 92 | 92 | # Setup ctbin command |
| 93 | 93 | cmd = ctbin+' inobs="events_that_do_not_exist.fits"'+ \ |
| ... | ... | @@ -115,7 +115,7 @@ class Test(test): |
| 115 | 115 | |
| 116 | 116 | # Load counts cube and check content. |
| 117 | 117 | evt = gammalib.GCTAEventCube('cntmap_cmd3.fits') |
| 118 | - self._check_cube(evt, 3689) | |
| 118 | + self._check_cube(evt, 617) | |
| 119 | 119 | |
| 120 | 120 | # Check ctbin --help |
| 121 | 121 | self._check_help(ctbin) |
| ... | ... | @@ -174,15 +174,15 @@ class Test(test): |
| 174 | 174 | binning.run() |
| 175 | 175 | |
| 176 | 176 | # Check content of observation container and counts cube |
| 177 | - self._check_observation(binning, 18483) | |
| 178 | - self._check_cube(binning.cube(), 18483) | |
| 177 | + self._check_observation(binning, 3105) | |
| 178 | + self._check_cube(binning.cube(), 3105) | |
| 179 | 179 | |
| 180 | 180 | # Copy ctbin tool |
| 181 | 181 | cpy_bin = binning.copy() |
| 182 | 182 | |
| 183 | 183 | # Check content of observation container and counts cube |
| 184 | - self._check_observation(cpy_bin, 18483) | |
| 185 | - self._check_cube(cpy_bin.cube(), 18483) | |
| 184 | + self._check_observation(cpy_bin, 3105) | |
| 185 | + self._check_cube(cpy_bin.cube(), 3105) | |
| 186 | 186 | |
| 187 | 187 | # Run copy of ctbin tool again |
| 188 | 188 | cpy_bin['logfile'] = 'ctbin_py2.log' |
| ... | ... | @@ -201,7 +201,7 @@ class Test(test): |
| 201 | 201 | |
| 202 | 202 | # Load counts cube and check content |
| 203 | 203 | evt = gammalib.GCTAEventCube('ctbin_py1.fits') |
| 204 | - self._check_cube(evt, 18483) | |
| 204 | + self._check_cube(evt, 3105) | |
| 205 | 205 | |
| 206 | 206 | # Now clear ctbin tool |
| 207 | 207 | binning.clear() |
| ... | ... | @@ -241,12 +241,12 @@ class Test(test): |
| 241 | 241 | |
| 242 | 242 | # Check content of observation and cube (need multiplier=3 since |
| 243 | 243 | # three identical observations have been appended) |
| 244 | - self._check_observation(binning, 18483, multiplier=3) | |
| 245 | - self._check_cube(binning.cube(), 18483, multiplier=3) | |
| 244 | + self._check_observation(binning, 3105, multiplier=3) | |
| 245 | + self._check_cube(binning.cube(), 3105, multiplier=3) | |
| 246 | 246 | |
| 247 | 247 | # Load counts cube and check content. |
| 248 | 248 | evt = gammalib.GCTAEventCube('ctbin_py3.fits') |
| 249 | - self._check_cube(evt, 18483, multiplier=3) | |
| 249 | + self._check_cube(evt, 3105, multiplier=3) | |
| 250 | 250 | |
| 251 | 251 | # And finally go for a fully Pythonic version with all parameters |
| 252 | 252 | # being specified in a dictionary |
| ... | ... | @@ -262,7 +262,7 @@ class Test(test): |
| 262 | 262 | |
| 263 | 263 | # Load counts cube and check content |
| 264 | 264 | evt = gammalib.GCTAEventCube('ctbin_py4.fits') |
| 265 | - self._check_cube(evt, 18483) | |
| 265 | + self._check_cube(evt, 3105) | |
| 266 | 266 | |
| 267 | 267 | # Return |
| 268 | 268 | return |
| ... | ... | @@ -288,9 +288,9 @@ class Test(test): |
| 288 | 288 | 'Check that there is one observation on the observation container') |
| 289 | 289 | self.test_value(obs.instrument(), 'CTA', |
| 290 | 290 | 'Check that the one observation is a CTA observation') |
| 291 | - self.test_value(obs.ontime(), 1800.0*multiplier, 1.0e-6, | |
| 291 | + self.test_value(obs.ontime(), 300.0*multiplier, 1.0e-6, | |
| 292 | 292 | 'Check ontime of observation') |
| 293 | - self.test_value(obs.livetime(), 1764.0*multiplier, 1.0e-6, | |
| 293 | + self.test_value(obs.livetime(), 294.0*multiplier, 1.0e-6, | |
| 294 | 294 | 'Check livetime of observation') |
| 295 | 295 | self.test_value(pnt.dir().ra_deg(), 83.63, 1.0e-6, |
| 296 | 296 | 'Check pointing Right Ascension of observation') | ... | ... |
test/test_cterror.py
| ... | ... | @@ -264,28 +264,28 @@ class Test(test): |
| 264 | 264 | # If there are models in the container then check them |
| 265 | 265 | if nmodels > 0: |
| 266 | 266 | self.test_value(models['Crab']['Prefactor'].value(), |
| 267 | - 5.767533e-16, 1.0e-4 * 5.767533e-16, | |
| 267 | + 5.6530206356786e-16, 1.0e-4 * 5.6530206356786e-16, | |
| 268 | 268 | 'Check fitted Crab Prefactor') |
| 269 | 269 | self.test_value(models['Crab']['Prefactor'].error(), |
| 270 | - 1.011887e-17, 1.0e-4 * 1.011887e-17, | |
| 270 | + 2.45970361827369e-17, 1.0e-3 * 2.45970361827369e-17, | |
| 271 | 271 | 'Check Crab Prefactor error') |
| 272 | 272 | self.test_value(models['Crab']['Index'].value(), |
| 273 | - -2.462279, 1.0e-4 * 2.462279, | |
| 273 | + -2.45716228083265, 1.0e-4 * 2.45716228083265, | |
| 274 | 274 | 'Check fitted Crab Index') |
| 275 | 275 | self.test_value(models['Crab']['Index'].error(), |
| 276 | - 0.0148518, 1.0e-4 * 0.0148518, | |
| 276 | + 0.0366617454398694, 1.0e-3 * 0.0366617454398694, | |
| 277 | 277 | 'Check Crab Index error') |
| 278 | 278 | self.test_value(models['CTABackgroundModel']['Prefactor'].value(), |
| 279 | - 1.0197698, 1.0e-4 * 1.0197698, | |
| 279 | + 1.01525433446138, 1.0e-4 * 1.01525433446138, | |
| 280 | 280 | 'Check fitted background Prefactor') |
| 281 | 281 | self.test_value(models['CTABackgroundModel']['Prefactor'].error(), |
| 282 | - 0.013578, 1.0e-4 * 0.013578, | |
| 282 | + 0.0334412516391298, 1.0e-4 * 0.0334412516391298, | |
| 283 | 283 | 'Check background Prefactor error') |
| 284 | 284 | self.test_value(models['CTABackgroundModel']['Index'].value(), |
| 285 | - 0.00836407, 1.0e-4 * 0.00836407, | |
| 285 | + -0.005132848897274, 1.0e-3 * 0.005132848897274, | |
| 286 | 286 | 'Check fitted background Index') |
| 287 | 287 | self.test_value(models['CTABackgroundModel']['Index'].error(), |
| 288 | - 0.00811674, 1.0e-4 * 0.00811674, | |
| 288 | + 0.0200624490548333, 1.0e-4 * 0.0200624490548333, | |
| 289 | 289 | 'Check background Index error') |
| 290 | 290 | |
| 291 | 291 | # Return | ... | ... |
test/test_ctlike.py
| ... | ... | @@ -254,28 +254,28 @@ class Test(test): |
| 254 | 254 | # If there are models in the container then check them |
| 255 | 255 | if nmodels > 0: |
| 256 | 256 | self.test_value(models['Crab']['Prefactor'].value(), |
| 257 | - 5.767533e-16, 1.0e-4 * 5.767533e-16, | |
| 257 | + 5.6530206356786e-16, 1.0e-4 * 5.6530206356786e-16, | |
| 258 | 258 | 'Check fitted Crab Prefactor') |
| 259 | 259 | self.test_value(models['Crab']['Prefactor'].error(), |
| 260 | - 1.018351e-17, 1.0e-4 * 1.018351e-17, | |
| 260 | + 2.48304276536022e-17, 1.0e-4 * 2.48304276536022e-17, | |
| 261 | 261 | 'Check Crab Prefactor error') |
| 262 | 262 | self.test_value(models['Crab']['Index'].value(), |
| 263 | - -2.462279, 1.0e-4 * 2.462279, | |
| 263 | + -2.45716228083265, 1.0e-4 * 2.45716228083265, | |
| 264 | 264 | 'Check fitted Crab Index') |
| 265 | 265 | self.test_value(models['Crab']['Index'].error(), |
| 266 | - 0.0151608, 1.0e-4 * 0.0151608, | |
| 266 | + 0.0386777873333435, 1.0e-4 * 0.0386777873333435, | |
| 267 | 267 | 'Check Crab Index error') |
| 268 | 268 | self.test_value(models['CTABackgroundModel']['Prefactor'].value(), |
| 269 | - 1.0197698, 1.0e-4 * 1.0197698, | |
| 269 | + 1.01525433446138, 1.0e-4 * 1.01525433446138, | |
| 270 | 270 | 'Check fitted background Prefactor') |
| 271 | 271 | self.test_value(models['CTABackgroundModel']['Prefactor'].error(), |
| 272 | - 0.013578, 1.0e-4 * 0.013578, | |
| 272 | + 0.0334412516391298, 1.0e-4 * 0.0334412516391298, | |
| 273 | 273 | 'Check background Prefactor error') |
| 274 | 274 | self.test_value(models['CTABackgroundModel']['Index'].value(), |
| 275 | - 0.00836407, 1.0e-4 * 0.00836407, | |
| 275 | + -0.005132848897274, 1.0e-3 * 0.005132848897274, | |
| 276 | 276 | 'Check fitted background Index') |
| 277 | 277 | self.test_value(models['CTABackgroundModel']['Index'].error(), |
| 278 | - 0.00811674, 1.0e-4 * 0.00811674, | |
| 278 | + 0.0200624490548333, 1.0e-4 * 0.0200624490548333, | |
| 279 | 279 | 'Check background Index error') |
| 280 | 280 | |
| 281 | 281 | # Return | ... | ... |
test/test_ctobssim.py
| ... | ... | @@ -74,9 +74,9 @@ class Test(test): |
| 74 | 74 | cmd = ctobssim+' inmodel="'+self._model+'" '+ \ |
| 75 | 75 | ' outevents="ctobssim_cmd1.fits"'+ \ |
| 76 | 76 | ' caldb="'+self._caldb+'" irf="'+self._irf+'" '+ \ |
| 77 | - ' ra=83.63 dec=22.01 rad=10.0'+ \ | |
| 77 | + ' ra=83.63 dec=22.01 rad=3.0'+ \ | |
| 78 | 78 | ' tmin="2020-01-01T00:00:00"'+ \ |
| 79 | - ' tmax="2020-01-01T00:30:00"'+ \ | |
| 79 | + ' tmax="2020-01-01T00:05:00"'+ \ | |
| 80 | 80 | ' emin=0.1 emax=100.0'+ \ |
| 81 | 81 | ' logfile="ctobssim_cmd1.log" chatter=1' |
| 82 | 82 | |
| ... | ... | @@ -90,15 +90,15 @@ class Test(test): |
| 90 | 90 | |
| 91 | 91 | # Load counts cube and check content. |
| 92 | 92 | evt = gammalib.GCTAEventList('ctobssim_cmd1.fits') |
| 93 | - self._test_list(evt, 23822) | |
| 93 | + self._test_list(evt, 3776) | |
| 94 | 94 | |
| 95 | 95 | # Setup ctobssim command |
| 96 | 96 | cmd = ctobssim+' inmodel="model_that_does_not_exist.xml"'+ \ |
| 97 | 97 | ' outevents="ctobssim_cmd2.fits"'+ \ |
| 98 | 98 | ' caldb="'+self._caldb+'" irf="'+self._irf+'" '+ \ |
| 99 | - ' ra=83.63 dec=22.01 rad=10.0'+ \ | |
| 99 | + ' ra=83.63 dec=22.01 rad=3.0'+ \ | |
| 100 | 100 | ' tmin="2020-01-01T00:00:00"'+ \ |
| 101 | - ' tmax="2020-01-01T00:30:00"'+ \ | |
| 101 | + ' tmax="2020-01-01T00:05:00"'+ \ | |
| 102 | 102 | ' emin=0.1 emax=100.0'+ \ |
| 103 | 103 | ' logfile="ctobssim_cmd2.log" debug=yes chatter=1' |
| 104 | 104 | |
| ... | ... | @@ -141,9 +141,9 @@ class Test(test): |
| 141 | 141 | sim['irf'] = self._irf |
| 142 | 142 | sim['ra'] = 83.63 |
| 143 | 143 | sim['dec'] = 22.01 |
| 144 | - sim['rad'] = 10.0 | |
| 144 | + sim['rad'] = 3.0 | |
| 145 | 145 | sim['tmin'] = '2020-01-01T00:00:00' |
| 146 | - sim['tmax'] = '2020-01-01T00:30:00' | |
| 146 | + sim['tmax'] = '2020-01-01T00:05:00' | |
| 147 | 147 | sim['emin'] = 0.1 |
| 148 | 148 | sim['emax'] = 100.0 |
| 149 | 149 | sim['outevents'] = 'ctobssim_py1.fits' |
| ... | ... | @@ -156,33 +156,52 @@ class Test(test): |
| 156 | 156 | |
| 157 | 157 | # Check content of observation |
| 158 | 158 | self._test_observation(sim) |
| 159 | - self._test_list(sim.obs()[0].events(), 23822) | |
| 159 | + self._test_list(sim.obs()[0].events(), 3776) | |
| 160 | 160 | |
| 161 | 161 | # Save events |
| 162 | 162 | sim.save() |
| 163 | 163 | |
| 164 | 164 | # Load counts cube and check content. |
| 165 | 165 | evt = gammalib.GCTAEventList('ctobssim_py1.fits') |
| 166 | - self._test_list(evt, 23822) | |
| 166 | + self._test_list(evt, 3776) | |
| 167 | + | |
| 168 | + # Copy ctobssim tool | |
| 169 | + cpy_sim = sim.copy() | |
| 170 | + | |
| 171 | + # Retrieve observation and check content of copy | |
| 172 | + self._test_observation(cpy_sim) | |
| 173 | + self._test_list(cpy_sim.obs()[0].events(), 3776) | |
| 174 | + | |
| 175 | + # Execute copy of ctobssim tool again, now with a higher chatter | |
| 176 | + # level than before | |
| 177 | + cpy_sim['outevents'] = 'ctobssim_py2.fits' | |
| 178 | + cpy_sim['logfile'] = 'ctobssim_py2.log' | |
| 179 | + cpy_sim['chatter'] = 3 | |
| 180 | + cpy_sim['publish'] = True | |
| 181 | + cpy_sim.logFileOpen() # Needed to get a new log file | |
| 182 | + cpy_sim.execute() | |
| 183 | + | |
| 184 | + # Load counts cube and check content. | |
| 185 | + evt = gammalib.GCTAEventList('ctobssim_py2.fits') | |
| 186 | + self._test_list(evt, 3776) | |
| 167 | 187 | |
| 168 | 188 | # Set-up observation container |
| 169 | 189 | pnts = [{'ra': 83.63, 'dec': 21.01}, |
| 170 | - {'ra': 84.63, 'dec': 22.01}, | |
| 171 | - {'ra': 83.63, 'dec': 23.01}, | |
| 172 | - {'ra': 82.63, 'dec': 22.01}] | |
| 173 | - obs = obsutils.set_obs_list(pnts, caldb=self._caldb, irf=self._irf) | |
| 190 | + {'ra': 84.63, 'dec': 22.01}] | |
| 191 | + obs = obsutils.set_obs_list(pnts, caldb=self._caldb, irf=self._irf, | |
| 192 | + duration=300.0, rad=3.0) | |
| 174 | 193 | |
| 175 | 194 | # Set-up ctobssim tool from observation container |
| 176 | 195 | sim = ctools.ctobssim(obs) |
| 177 | 196 | sim['inmodel'] = self._model |
| 178 | - sim['outevents'] = 'ctobssim_py2.xml' | |
| 179 | - sim['logfile'] = 'ctobssim_py2.log' | |
| 197 | + sim['outevents'] = 'ctobssim_py3.xml' | |
| 198 | + sim['logfile'] = 'ctobssim_py3.log' | |
| 180 | 199 | sim['chatter'] = 3 |
| 181 | 200 | |
| 182 | 201 | # Double maximum event range |
| 183 | 202 | max_rate = sim.max_rate() |
| 184 | - sim.max_rate(2*max_rate) | |
| 185 | - self.test_value(sim.max_rate(), 2*max_rate, 1.0e-3, | |
| 203 | + sim.max_rate(2.0*max_rate) | |
| 204 | + self.test_value(sim.max_rate(), 2.0*max_rate, 1.0e-3, | |
| 186 | 205 | 'Check setting of maximum event rate') |
| 187 | 206 | |
| 188 | 207 | # Run ctobssim tool |
| ... | ... | @@ -190,57 +209,27 @@ class Test(test): |
| 190 | 209 | sim.run() |
| 191 | 210 | |
| 192 | 211 | # Retrieve observation and check content |
| 193 | - self._test_observation(sim, nobs=4, pnts=pnts) | |
| 194 | - self._test_list(sim.obs()[0].events(), 22904) | |
| 195 | - self._test_list(sim.obs()[1].events(), 23130) | |
| 196 | - self._test_list(sim.obs()[2].events(), 22672) | |
| 197 | - self._test_list(sim.obs()[3].events(), 22549) | |
| 212 | + self._test_observation(sim, nobs=2, pnts=pnts) | |
| 213 | + self._test_list(sim.obs()[0].events(), 3569) | |
| 214 | + self._test_list(sim.obs()[1].events(), 3515) | |
| 198 | 215 | |
| 199 | 216 | # Save events |
| 200 | 217 | sim.save() |
| 201 | 218 | |
| 202 | 219 | # Load events |
| 203 | - obs = gammalib.GObservations('ctobssim_py2.xml') | |
| 220 | + obs = gammalib.GObservations('ctobssim_py3.xml') | |
| 204 | 221 | |
| 205 | 222 | # Retrieve observation and check content |
| 206 | - self._test_list(obs[0].events(), 22904) | |
| 207 | - self._test_list(obs[1].events(), 23130) | |
| 208 | - self._test_list(obs[2].events(), 22672) | |
| 209 | - self._test_list(obs[3].events(), 22549) | |
| 210 | - | |
| 211 | - # Copy ctobssim tool | |
| 212 | - cpy_sim = sim.copy() | |
| 213 | - | |
| 214 | - # Retrieve observation and check content of copy | |
| 215 | - self._test_observation(cpy_sim, nobs=4, pnts=pnts) | |
| 216 | - self._test_list(cpy_sim.obs()[0].events(), 22904) | |
| 217 | - self._test_list(cpy_sim.obs()[1].events(), 23130) | |
| 218 | - self._test_list(cpy_sim.obs()[2].events(), 22672) | |
| 219 | - self._test_list(cpy_sim.obs()[3].events(), 22549) | |
| 220 | - | |
| 221 | - # Execute copy of ctobssim tool again, now with a higher chatter | |
| 222 | - # level than before | |
| 223 | - cpy_sim['outevents'] = 'ctobssim_py3.xml' | |
| 224 | - cpy_sim['logfile'] = 'ctobssim_py3.log' | |
| 225 | - cpy_sim['chatter'] = 4 | |
| 226 | - cpy_sim['publish'] = True | |
| 227 | - cpy_sim.logFileOpen() # Needed to get a new log file | |
| 228 | - cpy_sim.execute() | |
| 229 | - | |
| 230 | - # Check result file | |
| 231 | - obs = gammalib.GObservations('ctobssim_py3.xml') | |
| 232 | - self.test_value(obs.size(), 4, 'Check for number of observations') | |
| 233 | - self._test_list(obs[0].events(), 22904) | |
| 234 | - self._test_list(obs[1].events(), 23130) | |
| 235 | - self._test_list(obs[2].events(), 22672) | |
| 236 | - self._test_list(obs[3].events(), 22549) | |
| 223 | + self._test_list(obs[0].events(), 3569) | |
| 224 | + self._test_list(obs[1].events(), 3515) | |
| 237 | 225 | |
| 238 | 226 | # Return |
| 239 | 227 | return |
| 240 | 228 | |
| 241 | 229 | # Check observation |
| 242 | 230 | def _test_observation(self, obssim, nobs=1, |
| 243 | - pnts=[{'ra': 83.63, 'dec': 22.01}]): | |
| 231 | + pnts=[{'ra': 83.63, 'dec': 22.01}], | |
| 232 | + ontime=300.0, livetime=294.0): | |
| 244 | 233 | """ |
| 245 | 234 | Test content of an observation |
| 246 | 235 | |
| ... | ... | @@ -255,20 +244,21 @@ class Test(test): |
| 255 | 244 | """ |
| 256 | 245 | # Test observation container |
| 257 | 246 | self.test_value(obssim.obs().size(), nobs, |
| 258 | - 'There is one observation') | |
| 259 | - for i in range(obssim.obs().size()): | |
| 260 | - obs = gammalib.GCTAObservation(obssim.obs()[i]) | |
| 261 | - pnt = obs.pointing() | |
| 247 | + 'Check number of observations') | |
| 248 | + for i, obs in enumerate(obssim.obs()): | |
| 249 | + pnt = obs.pointing().dir() | |
| 250 | + ra = pnts[i]['ra'] | |
| 251 | + dec = pnts[i]['dec'] | |
| 262 | 252 | self.test_assert(obs.instrument() == 'CTA', |
| 263 | - 'Observation is CTA observation') | |
| 264 | - self.test_value(obs.ontime(), 1800.0, 1.0e-6, | |
| 265 | - 'Ontime is 1800 sec') | |
| 266 | - self.test_value(obs.livetime(), 1764.0, 1.0e-6, | |
| 267 | - 'Livetime is 1764 sec') | |
| 268 | - self.test_value(pnt.dir().ra_deg(), pnts[i]['ra'], 1.0e-6, | |
| 269 | - 'Pointing Right Ascension is '+str(pnts[i]['ra'])+' deg') | |
| 270 | - self.test_value(pnt.dir().dec_deg(), pnts[i]['dec'], 1.0e-6, | |
| 271 | - 'Pointing Declination is '+str(pnts[i]['dec'])+' deg') | |
| 253 | + 'Check if observation is CTA observation') | |
| 254 | + self.test_value(obs.ontime(), ontime, 1.0e-6, | |
| 255 | + 'Check if ontime is %f sec' % ontime) | |
| 256 | + self.test_value(obs.livetime(), livetime, 1.0e-6, | |
| 257 | + 'Check if livetime is %f sec' % livetime) | |
| 258 | + self.test_value(pnt.ra_deg(), ra, 1.0e-6, | |
| 259 | + 'Check if pointing Right Ascension is %f deg' % ra) | |
| 260 | + self.test_value(pnt.dec_deg(), dec, 1.0e-6, | |
| 261 | + 'Check if pointing Declination is %f deg' % dec) | |
| 272 | 262 | |
| 273 | 263 | # Return |
| 274 | 264 | return | ... | ... |
test/test_ctphase.py
test/test_ctprob.py
test/test_ctselect.py
| ... | ... | @@ -73,7 +73,7 @@ class Test(test): |
| 73 | 73 | cmd = ctselect+' inobs="'+self._events+'"'+ \ |
| 74 | 74 | ' outobs="ctselect_cmd1.fits"'+ \ |
| 75 | 75 | ' ra=83.63 dec=22.01 rad=2.0'+ \ |
| 76 | - ' tmin=2020-01-01T00:08:20 tmax=2020-01-01T00:16:40'+ \ | |
| 76 | + ' tmin=2020-01-01T00:01:10 tmax=2020-01-01T00:03:40'+ \ | |
| 77 | 77 | ' emin=0.2 emax=80.0'+ \ |
| 78 | 78 | ' logfile="ctselect_cmd1.log" chatter=1' |
| 79 | 79 | |
| ... | ... | @@ -92,7 +92,7 @@ class Test(test): |
| 92 | 92 | cmd = ctselect+' inobs="event_file_that_does_not_exist.fits"'+ \ |
| 93 | 93 | ' outobs="ctselect_cmd2.fits"'+ \ |
| 94 | 94 | ' ra=83.63 dec=22.01 rad=2.0'+ \ |
| 95 | - ' tmin=2020-01-01T00:08:20 tmax=2020-01-01T00:16:40'+ \ | |
| 95 | + ' tmin=2020-01-01T00:01:10 tmax=2020-01-01T00:03:40'+ \ | |
| 96 | 96 | ' emin=0.2 emax=80.0'+ \ |
| 97 | 97 | ' logfile="ctselect_cmd2.log" debug=yes chatter=1' |
| 98 | 98 | |
| ... | ... | @@ -133,8 +133,8 @@ class Test(test): |
| 133 | 133 | select['ra'] = 83.63 |
| 134 | 134 | select['dec'] = 22.01 |
| 135 | 135 | select['rad'] = 2.0 |
| 136 | - select['tmin'] = '2020-01-01T00:08:20' | |
| 137 | - select['tmax'] = '2020-01-01T00:16:40' | |
| 136 | + select['tmin'] = '2020-01-01T00:01:10' | |
| 137 | + select['tmax'] = '2020-01-01T00:03:40' | |
| 138 | 138 | select['emin'] = 0.2 |
| 139 | 139 | select['emax'] = 80.0 |
| 140 | 140 | select['outobs'] = 'ctselect_py1.fits' |
| ... | ... | @@ -181,7 +181,7 @@ class Test(test): |
| 181 | 181 | # to valid event selections, but since the maximum values are still |
| 182 | 182 | # 'NONE', no event selections should occur. |
| 183 | 183 | cpy_select['usepnt'] = True |
| 184 | - cpy_select['tmin'] = '2020-01-01T00:08:20' | |
| 184 | + cpy_select['tmin'] = '2020-01-01T00:01:10' | |
| 185 | 185 | cpy_select['emin'] = 0.2 |
| 186 | 186 | cpy_select['usethres'] = 'USER' |
| 187 | 187 | cpy_select['outobs'] = 'ctselect_py3.fits' |
| ... | ... | @@ -214,8 +214,8 @@ class Test(test): |
| 214 | 214 | select['ra'] = 83.63 |
| 215 | 215 | select['dec'] = 22.01 |
| 216 | 216 | select['rad'] = 2.0 |
| 217 | - select['tmin'] = '2020-01-01T00:08:20' | |
| 218 | - select['tmax'] = '2020-01-01T00:16:40' | |
| 217 | + select['tmin'] = '2020-01-01T00:01:10' | |
| 218 | + select['tmax'] = '2020-01-01T00:03:40' | |
| 219 | 219 | select['emin'] = 120.0 |
| 220 | 220 | select['emax'] = 130.0 |
| 221 | 221 | select['expr'] = 'DETX == 0' |
| ... | ... | @@ -237,8 +237,8 @@ class Test(test): |
| 237 | 237 | select['ra'] = 83.63 |
| 238 | 238 | select['dec'] = 22.01 |
| 239 | 239 | select['rad'] = 2.0 |
| 240 | - select['tmin'] = '2020-01-01T00:08:20' | |
| 241 | - select['tmax'] = '2020-01-01T00:16:40' | |
| 240 | + select['tmin'] = '2020-01-01T00:01:10' | |
| 241 | + select['tmax'] = '2020-01-01T00:03:40' | |
| 242 | 242 | select['emin'] = 0.2 |
| 243 | 243 | select['emax'] = 80.0 |
| 244 | 244 | select['outobs'] = 'ctselect_py5.fits' |
| ... | ... | @@ -261,8 +261,8 @@ class Test(test): |
| 261 | 261 | select['ra'] = 83.63 |
| 262 | 262 | select['dec'] = 22.01 |
| 263 | 263 | select['rad'] = 2.0 |
| 264 | - select['tmin'] = '2020-01-01T00:08:20' | |
| 265 | - select['tmax'] = '2020-01-01T00:16:40' | |
| 264 | + select['tmin'] = '2020-01-01T00:01:10' | |
| 265 | + select['tmax'] = '2020-01-01T00:03:40' | |
| 266 | 266 | select['emin'] = 0.2 |
| 267 | 267 | select['emax'] = 0.0 # Signals that "emax" should be ignored |
| 268 | 268 | select['outobs'] = 'ctselect_py6.fits' |
| ... | ... | @@ -282,8 +282,8 @@ class Test(test): |
| 282 | 282 | select['ra'] = 83.63 |
| 283 | 283 | select['dec'] = 22.01 |
| 284 | 284 | select['rad'] = 2.0 |
| 285 | - select['tmin'] = '2020-01-01T00:08:20' | |
| 286 | - select['tmax'] = '2020-01-01T00:16:40' | |
| 285 | + select['tmin'] = '2020-01-01T00:01:10' | |
| 286 | + select['tmax'] = '2020-01-01T00:03:40' | |
| 287 | 287 | select['emin'] = 0.0 # Signals that "emin" should be ignored |
| 288 | 288 | select['emax'] = 80.0 |
| 289 | 289 | select['outobs'] = 'ctselect_py7.fits' |
| ... | ... | @@ -295,7 +295,7 @@ class Test(test): |
| 295 | 295 | select.execute() |
| 296 | 296 | |
| 297 | 297 | # Check result file |
| 298 | - self._check_result_file('ctselect_py7.fits', nevents=4709) | |
| 298 | + self._check_result_file('ctselect_py7.fits', nevents=1460) | |
| 299 | 299 | |
| 300 | 300 | # Now set "emin > emax" |
| 301 | 301 | select['emin'] = 150.0 |
| ... | ... | @@ -319,8 +319,8 @@ class Test(test): |
| 319 | 319 | select['ra'] = 83.63 |
| 320 | 320 | select['dec'] = 24.01 |
| 321 | 321 | select['rad'] = 3.0 |
| 322 | - select['tmin'] = '2020-01-01T00:08:20' | |
| 323 | - select['tmax'] = '2020-01-01T00:16:40' | |
| 322 | + select['tmin'] = '2020-01-01T00:01:10' | |
| 323 | + select['tmax'] = '2020-01-01T00:03:40' | |
| 324 | 324 | select['emin'] = 0.2 |
| 325 | 325 | select['emax'] = 80.0 |
| 326 | 326 | select['outobs'] = 'ctselect_py9.fits' |
| ... | ... | @@ -332,7 +332,7 @@ class Test(test): |
| 332 | 332 | select.execute() |
| 333 | 333 | |
| 334 | 334 | # Check result file |
| 335 | - self._check_result_file('ctselect_py9.fits', nevents=781, dec=24.01, | |
| 335 | + self._check_result_file('ctselect_py9.fits', nevents=240, dec=24.01, | |
| 336 | 336 | rad=1.5) |
| 337 | 337 | |
| 338 | 338 | # Now put the RoI outside the existing RoI. This should leave to |
| ... | ... | @@ -483,7 +483,7 @@ class Test(test): |
| 483 | 483 | return |
| 484 | 484 | |
| 485 | 485 | # Check result file |
| 486 | - def _check_result_file(self, filename, nevents=2307, dec=22.01, rad=2.0): | |
| 486 | + def _check_result_file(self, filename, nevents=719, dec=22.01, rad=2.0): | |
| 487 | 487 | """ |
| 488 | 488 | Check result file |
| 489 | 489 | |
| ... | ... | @@ -508,7 +508,7 @@ class Test(test): |
| 508 | 508 | return |
| 509 | 509 | |
| 510 | 510 | # Check observation and event list |
| 511 | - def _check_obs(self, obs, nobs=1, nevents=2307): | |
| 511 | + def _check_obs(self, obs, nobs=1, nevents=719): | |
| 512 | 512 | """ |
| 513 | 513 | Check observation and event list |
| 514 | 514 | |
| ... | ... | @@ -533,7 +533,7 @@ class Test(test): |
| 533 | 533 | return |
| 534 | 534 | |
| 535 | 535 | # Check events |
| 536 | - def _check_events(self, events, nevents=2307, dec=22.01, rad=2.0): | |
| 536 | + def _check_events(self, events, nevents=719, dec=22.01, rad=2.0): | |
| 537 | 537 | """ |
| 538 | 538 | Check event list |
| 539 | 539 | ... | ... |
test/test_ctskymap.py
| ... | ... | @@ -68,8 +68,8 @@ class Test(test): |
| 68 | 68 | # Setup ctskymap command |
| 69 | 69 | cmd = ctskymap+' inobs="'+self._events+'"'+\ |
| 70 | 70 | ' outmap="ctskymap_cmd1.fits"'+ \ |
| 71 | - ' emin=0.1 emax=100.0 nxpix=200 nypix=200'+ \ | |
| 72 | - ' binsz=0.02 coordsys="CEL" proj="CAR"'+ \ | |
| 71 | + ' emin=0.1 emax=100.0 nxpix=20 nypix=20'+ \ | |
| 72 | + ' binsz=0.2 coordsys="CEL" proj="CAR"'+ \ | |
| 73 | 73 | ' xref=83.63 yref=22.01 bkgsubtract="NONE"'+ \ |
| 74 | 74 | ' logfile="ctskymap_cmd1.log" chatter=1' |
| 75 | 75 | |
| ... | ... | @@ -87,8 +87,8 @@ class Test(test): |
| 87 | 87 | # Setup ctskymap command |
| 88 | 88 | cmd = ctskymap+' inobs="event_file_that_does_not_exist.fits"'+\ |
| 89 | 89 | ' outmap="ctskymap_cmd2.fits"'+ \ |
| 90 | - ' emin=0.1 emax=100.0 nxpix=200 nypix=200'+ \ | |
| 91 | - ' binsz=0.02 coordsys="CEL" proj="CAR"'+ \ | |
| 90 | + ' emin=0.1 emax=100.0 nxpix=20 nypix=20'+ \ | |
| 91 | + ' binsz=0.2 coordsys="CEL" proj="CAR"'+ \ | |
| 92 | 92 | ' xref=83.63 yref=22.01 bkgsubtract="NONE"'+ \ |
| 93 | 93 | ' logfile="ctskymap_cmd2.log" debug=yes chatter=2' |
| 94 | 94 | |
| ... | ... | @@ -128,9 +128,9 @@ class Test(test): |
| 128 | 128 | skymap['inobs'] = self._events |
| 129 | 129 | skymap['emin'] = 0.1 |
| 130 | 130 | skymap['emax'] = 100 |
| 131 | - skymap['nxpix'] = 200 | |
| 132 | - skymap['nypix'] = 200 | |
| 133 | - skymap['binsz'] = 0.02 | |
| 131 | + skymap['nxpix'] = 20 | |
| 132 | + skymap['nypix'] = 20 | |
| 133 | + skymap['binsz'] = 0.2 | |
| 134 | 134 | skymap['coordsys'] = 'CEL' |
| 135 | 135 | skymap['proj'] = 'CAR' |
| 136 | 136 | skymap['xref'] = 83.63 |
| ... | ... | @@ -184,9 +184,9 @@ class Test(test): |
| 184 | 184 | skymap = ctools.ctskymap(obs) |
| 185 | 185 | skymap['emin'] = 0.1 |
| 186 | 186 | skymap['emax'] = 100 |
| 187 | - skymap['nxpix'] = 200 | |
| 188 | - skymap['nypix'] = 200 | |
| 189 | - skymap['binsz'] = 0.02 | |
| 187 | + skymap['nxpix'] = 20 | |
| 188 | + skymap['nypix'] = 20 | |
| 189 | + skymap['binsz'] = 0.2 | |
| 190 | 190 | skymap['coordsys'] = 'GAL' |
| 191 | 191 | skymap['proj'] = 'CAR' |
| 192 | 192 | skymap['xref'] = 184.5575 |
| ... | ... | @@ -214,9 +214,9 @@ class Test(test): |
| 214 | 214 | skymap = ctools.ctskymap(obs) |
| 215 | 215 | skymap['emin'] = 0.1 |
| 216 | 216 | skymap['emax'] = 100 |
| 217 | - skymap['nxpix'] = 200 | |
| 218 | - skymap['nypix'] = 200 | |
| 219 | - skymap['binsz'] = 0.02 | |
| 217 | + skymap['nxpix'] = 20 | |
| 218 | + skymap['nypix'] = 20 | |
| 219 | + skymap['binsz'] = 0.2 | |
| 220 | 220 | skymap['coordsys'] = 'GAL' |
| 221 | 221 | skymap['proj'] = 'CAR' |
| 222 | 222 | skymap['xref'] = 184.5575 |
| ... | ... | @@ -241,9 +241,9 @@ class Test(test): |
| 241 | 241 | skymap = ctools.ctskymap(obs) |
| 242 | 242 | skymap['emin'] = 0.1 |
| 243 | 243 | skymap['emax'] = 100 |
| 244 | - skymap['nxpix'] = 100 # Make region smaller since the 'RING' | |
| 245 | - skymap['nypix'] = 100 # method takes longer to run than 'IRF' | |
| 246 | - skymap['binsz'] = 0.02 | |
| 244 | + skymap['nxpix'] = 10 # Make region smaller since the 'RING' | |
| 245 | + skymap['nypix'] = 10 # method takes longer to run than 'IRF' | |
| 246 | + skymap['binsz'] = 0.2 | |
| 247 | 247 | skymap['coordsys'] = 'CEL' |
| 248 | 248 | skymap['proj'] = 'CAR' |
| 249 | 249 | skymap['xref'] = 83.63 |
| ... | ... | @@ -264,15 +264,15 @@ class Test(test): |
| 264 | 264 | skymap.execute() |
| 265 | 265 | |
| 266 | 266 | # Check result file |
| 267 | - self._check_result_file('ctskymap_py5.fits', 100, 100) | |
| 268 | - self._check_result_file('ctskymap_py5.fits[BACKGROUND]', 100, 100) | |
| 269 | - self._check_result_file('ctskymap_py5.fits[SIGNIFICANCE]', 100, 100) | |
| 267 | + self._check_result_file('ctskymap_py5.fits', 10, 10) | |
| 268 | + self._check_result_file('ctskymap_py5.fits[BACKGROUND]', 10, 10) | |
| 269 | + self._check_result_file('ctskymap_py5.fits[SIGNIFICANCE]', 10, 10) | |
| 270 | 270 | |
| 271 | 271 | # Return |
| 272 | 272 | return |
| 273 | 273 | |
| 274 | 274 | # Check result file |
| 275 | - def _check_result_file(self, filename, nx=200, ny=200): | |
| 275 | + def _check_result_file(self, filename, nx=20, ny=20): | |
| 276 | 276 | """ |
| 277 | 277 | Check result file |
| 278 | 278 | |
| ... | ... | @@ -295,7 +295,7 @@ class Test(test): |
| 295 | 295 | return |
| 296 | 296 | |
| 297 | 297 | # Check sky map |
| 298 | - def _check_map(self, skymap, nx=200, ny=200): | |
| 298 | + def _check_map(self, skymap, nx=20, ny=20): | |
| 299 | 299 | """ |
| 300 | 300 | Check sky map |
| 301 | 301 | ... | ... |
test/test_ctulimit.py
| ... | ... | @@ -143,11 +143,11 @@ class Test(test): |
| 143 | 143 | ulimit.save() |
| 144 | 144 | |
| 145 | 145 | # Check results |
| 146 | - self.test_value(ulimit.diff_ulimit(), 3.05020546110845e-17, 1.0e-21, | |
| 146 | + self.test_value(ulimit.diff_ulimit(), 3.11978988143113e-17, 1.0e-21, | |
| 147 | 147 | 'Check differential upper limit') |
| 148 | - self.test_value(ulimit.flux_ulimit(), 2.07242046724517e-11, 1.0e-16, | |
| 148 | + self.test_value(ulimit.flux_ulimit(), 2.11102478123946e-11, 1.0e-16, | |
| 149 | 149 | 'Check upper limit on photon flux') |
| 150 | - self.test_value(ulimit.eflux_ulimit(), 9.20229587739368e-11, 1.0e-16, | |
| 150 | + self.test_value(ulimit.eflux_ulimit(), 9.32520808361777e-11, 1.0e-16, | |
| 151 | 151 | 'Check upper limit on energy flux') |
| 152 | 152 | |
| 153 | 153 | # Check obs() method |
| ... | ... | @@ -161,19 +161,19 @@ class Test(test): |
| 161 | 161 | cpy_ulimit = ulimit.copy() |
| 162 | 162 | |
| 163 | 163 | # Check results of copy |
| 164 | - self.test_value(cpy_ulimit.diff_ulimit(), 3.05020546110845e-17, 1.0e-21, | |
| 164 | + self.test_value(cpy_ulimit.diff_ulimit(), 3.11978988143113e-17, 1.0e-21, | |
| 165 | 165 | 'Check differential upper limit') |
| 166 | - self.test_value(cpy_ulimit.flux_ulimit(), 2.07242046724517e-11, 1.0e-16, | |
| 166 | + self.test_value(cpy_ulimit.flux_ulimit(), 2.11102478123946e-11, 1.0e-16, | |
| 167 | 167 | 'Check upper limit on photon flux') |
| 168 | - self.test_value(cpy_ulimit.eflux_ulimit(), 9.20229587739368e-11, 1.0e-16, | |
| 168 | + self.test_value(cpy_ulimit.eflux_ulimit(), 9.32520808361777e-11, 1.0e-16, | |
| 169 | 169 | 'Check upper limit on energy flux') |
| 170 | 170 | |
| 171 | 171 | # Check results |
| 172 | - self.test_value(cpy_ulimit.diff_ulimit(), 3.05020546110845e-17, 1.0e-21, | |
| 172 | + self.test_value(cpy_ulimit.diff_ulimit(), 3.11978988143113e-17, 1.0e-21, | |
| 173 | 173 | 'Check differential upper limit') |
| 174 | - self.test_value(cpy_ulimit.flux_ulimit(), 2.07242046724517e-11, 1.0e-16, | |
| 174 | + self.test_value(cpy_ulimit.flux_ulimit(), 2.11102478123946e-11, 1.0e-16, | |
| 175 | 175 | 'Check upper limit on photon flux') |
| 176 | - self.test_value(cpy_ulimit.eflux_ulimit(), 9.20229587739368e-11, 1.0e-16, | |
| 176 | + self.test_value(cpy_ulimit.eflux_ulimit(), 9.32520808361777e-11, 1.0e-16, | |
| 177 | 177 | 'Check upper limit on energy flux') |
| 178 | 178 | |
| 179 | 179 | # Now clear copy of ctulimit tool |
| ... | ... | @@ -208,11 +208,11 @@ class Test(test): |
| 208 | 208 | ulimit.execute() |
| 209 | 209 | |
| 210 | 210 | # Check results |
| 211 | - self.test_value(ulimit.diff_ulimit(), 3.05020546110845e-17, 1.0e-21, | |
| 211 | + self.test_value(ulimit.diff_ulimit(), 3.11978988143113e-17, 1.0e-21, | |
| 212 | 212 | 'Check differential upper limit') |
| 213 | - self.test_value(ulimit.flux_ulimit(), 2.07242046724517e-11, 1.0e-16, | |
| 213 | + self.test_value(ulimit.flux_ulimit(), 2.11102478123946e-11, 1.0e-16, | |
| 214 | 214 | 'Check upper limit on photon flux') |
| 215 | - self.test_value(ulimit.eflux_ulimit(), 9.20229587739368e-11, 1.0e-16, | |
| 215 | + self.test_value(ulimit.eflux_ulimit(), 9.32520808361777e-11, 1.0e-16, | |
| 216 | 216 | 'Check upper limit on energy flux') |
| 217 | 217 | |
| 218 | 218 | # Test invalid model name | ... | ... |
test/test_examples.py.in
| ... | ... | @@ -89,26 +89,26 @@ class Test(gammalib.GPythonTestSuite): |
| 89 | 89 | self.name('examples') |
| 90 | 90 | |
| 91 | 91 | # Append tests |
| 92 | - self.append(self.test_generate_prod3_irfs, | |
| 93 | - 'Test generate_prod3_irfs.py') | |
| 92 | + #self.append(self.test_generate_prod3_irfs, | |
| 93 | + # 'Test generate_prod3_irfs.py') | |
| 94 | 94 | self.append(self.test_make_pointings, |
| 95 | 95 | 'Test make_pointings.py') |
| 96 | - self.append(self.test_make_spectrum, | |
| 97 | - 'Test make_spectrum.py') | |
| 98 | - self.append(self.test_make_ts_distributions, | |
| 99 | - 'Test make_ts_distributions.py') | |
| 100 | - self.append(self.test_pipeline_binned_disk, | |
| 101 | - 'Test pipeline_binned_disk.py') | |
| 102 | - self.append(self.test_pipeline_binned_mem, | |
| 103 | - 'Test pipeline_binned_mem.py') | |
| 104 | - self.append(self.test_pipeline_stacked_disk, | |
| 105 | - 'Test pipeline_stacked_disk.py') | |
| 106 | - self.append(self.test_pipeline_stacked_mem, | |
| 107 | - 'Test pipeline_stacked_mem.py') | |
| 108 | - self.append(self.test_pipeline_unbinned_disk, | |
| 109 | - 'Test pipeline_unbinned_disk.py') | |
| 110 | - self.append(self.test_pipeline_unbinned_mem, | |
| 111 | - 'Test pipeline_unbinned_mem.py') | |
| 96 | + #self.append(self.test_make_spectrum, | |
| 97 | + # 'Test make_spectrum.py') | |
| 98 | + #self.append(self.test_make_ts_distributions, | |
| 99 | + # 'Test make_ts_distributions.py') | |
| 100 | + #self.append(self.test_pipeline_binned_disk, | |
| 101 | + # 'Test pipeline_binned_disk.py') | |
| 102 | + #self.append(self.test_pipeline_binned_mem, | |
| 103 | + # 'Test pipeline_binned_mem.py') | |
| 104 | + #self.append(self.test_pipeline_stacked_disk, | |
| 105 | + # 'Test pipeline_stacked_disk.py') | |
| 106 | + #self.append(self.test_pipeline_stacked_mem, | |
| 107 | + # 'Test pipeline_stacked_mem.py') | |
| 108 | + #self.append(self.test_pipeline_unbinned_disk, | |
| 109 | + # 'Test pipeline_unbinned_disk.py') | |
| 110 | + #self.append(self.test_pipeline_unbinned_mem, | |
| 111 | + # 'Test pipeline_unbinned_mem.py') | |
| 112 | 112 | self.append(self.test_show_butterfly, |
| 113 | 113 | 'Test show_butterfly.py') |
| 114 | 114 | self.append(self.test_show_irf, | ... | ... |
test/test_obsutils.py
| ... | ... | @@ -89,7 +89,7 @@ class Test(test): |
| 89 | 89 | pnt = gammalib.GSkyDir() |
| 90 | 90 | pnt.radec_deg(83.6331, 22.0145) |
| 91 | 91 | obs = gammalib.GObservations() |
| 92 | - run = obsutils.set_obs(pnt, duration=100.0, emin=1.0, emax=10.0) | |
| 92 | + run = obsutils.set_obs(pnt, duration=20.0, emin=1.0, emax=10.0) | |
| 93 | 93 | run.id('0') |
| 94 | 94 | obs.append(run) |
| 95 | 95 | if two: |
| ... | ... | @@ -113,14 +113,14 @@ class Test(test): |
| 113 | 113 | # Check simulation results |
| 114 | 114 | self.test_value(res.size(), 1, 'Check number of observations') |
| 115 | 115 | self.test_value(res.models().size(), 2, 'Check number of models') |
| 116 | - self.test_value(res.nobserved(), 48, 'Check number of observed events') | |
| 116 | + self.test_value(res.nobserved(), 6, 'Check number of observed events') | |
| 117 | 117 | self.test_value(res.npred(), 0.0, 'Check number of predicted events') |
| 118 | 118 | self.test_value(res[0].eventtype(), 'EventList', 'Check event type') |
| 119 | 119 | self.test_value(res[0].events().ebounds().emin().TeV(), 1.0, |
| 120 | 120 | 'Check minimum energy') |
| 121 | 121 | self.test_value(res[0].events().ebounds().emax().TeV(), 10.0, |
| 122 | 122 | 'Check minimum energy') |
| 123 | - self.test_value(res[0].events().number(), 48, | |
| 123 | + self.test_value(res[0].events().number(), 6, | |
| 124 | 124 | 'Check number of events in list') |
| 125 | 125 | |
| 126 | 126 | # Check energy dispersion flag |
| ... | ... | @@ -144,7 +144,7 @@ class Test(test): |
| 144 | 144 | # Check simulation results |
| 145 | 145 | self.test_value(res.size(), 1, 'Check number of observations') |
| 146 | 146 | self.test_value(res.models().size(), 2, 'Check number of models') |
| 147 | - self.test_value(res.nobserved(), 48, 'Check number of observed events') | |
| 147 | + self.test_value(res.nobserved(), 6, 'Check number of observed events') | |
| 148 | 148 | self.test_value(res.npred(), 0.0, 'Check number of predicted events') |
| 149 | 149 | self.test_value(res[0].eventtype(), 'CountsCube', 'Check event type') |
| 150 | 150 | self.test_value(res[0].events().ebounds().emin().TeV(), 1.0, |
| ... | ... | @@ -153,7 +153,7 @@ class Test(test): |
| 153 | 153 | 'Check minimum energy') |
| 154 | 154 | self.test_value(res[0].events().ebounds().size(), 5, |
| 155 | 155 | 'Check number of energy bins') |
| 156 | - self.test_value(res[0].events().number(), 48, | |
| 156 | + self.test_value(res[0].events().number(), 6, | |
| 157 | 157 | 'Check number of events in cube') |
| 158 | 158 | |
| 159 | 159 | # Check energy dispersion flag |
| ... | ... | @@ -177,7 +177,7 @@ class Test(test): |
| 177 | 177 | # Check simulation results |
| 178 | 178 | self.test_value(res.size(), 1, 'Check number of observations') |
| 179 | 179 | self.test_value(res.models().size(), 2, 'Check number of models') |
| 180 | - self.test_value(res.nobserved(), 96, 'Check number of observed events') | |
| 180 | + self.test_value(res.nobserved(), 19, 'Check number of observed events') | |
| 181 | 181 | self.test_value(res.npred(), 0.0, 'Check number of predicted events') |
| 182 | 182 | self.test_value(res[0].eventtype(), 'CountsCube', 'Check event type') |
| 183 | 183 | self.test_value(res[0].events().ebounds().emin().TeV(), 1.0, |
| ... | ... | @@ -186,7 +186,7 @@ class Test(test): |
| 186 | 186 | 'Check minimum energy') |
| 187 | 187 | self.test_value(res[0].events().ebounds().size(), 5, |
| 188 | 188 | 'Check number of energy bins') |
| 189 | - self.test_value(res[0].events().number(), 96, | |
| 189 | + self.test_value(res[0].events().number(), 19, | |
| 190 | 190 | 'Check number of events in cube') |
| 191 | 191 | |
| 192 | 192 | # Check energy dispersion flag |
| ... | ... | @@ -211,7 +211,7 @@ class Test(test): |
| 211 | 211 | # Check simulation results |
| 212 | 212 | self.test_value(res.size(), 1, 'Check number of observations') |
| 213 | 213 | self.test_value(res.models().size(), 2, 'Check number of models') |
| 214 | - self.test_value(res.nobserved(), 98, 'Check number of observed events') | |
| 214 | + self.test_value(res.nobserved(), 28, 'Check number of observed events') | |
| 215 | 215 | self.test_value(res.npred(), 0.0, 'Check number of predicted events') |
| 216 | 216 | self.test_value(res[0].eventtype(), 'CountsCube', 'Check event type') |
| 217 | 217 | self.test_value(res[0].events().ebounds().emin().TeV(), 1.0, |
| ... | ... | @@ -220,7 +220,7 @@ class Test(test): |
| 220 | 220 | 'Check minimum energy') |
| 221 | 221 | self.test_value(res[0].events().ebounds().size(), 5, |
| 222 | 222 | 'Check number of energy bins') |
| 223 | - self.test_value(res[0].events().number(), 98, | |
| 223 | + self.test_value(res[0].events().number(), 28, | |
| 224 | 224 | 'Check number of events in cube') |
| 225 | 225 | |
| 226 | 226 | # Check energy dispersion flag |
| ... | ... | @@ -306,7 +306,7 @@ class Test(test): |
| 306 | 306 | # Check simulation results |
| 307 | 307 | self.test_value(res.size(), 1, 'Check number of observations') |
| 308 | 308 | self.test_value(res.models().size(), 2, 'Check number of models') |
| 309 | - self.test_value(res.nobserved(), 48, 'Check number of observed events') | |
| 309 | + self.test_value(res.nobserved(), 6, 'Check number of observed events') | |
| 310 | 310 | self.test_value(res.npred(), 0.0, 'Check number of predicted events') |
| 311 | 311 | self.test_value(res[0].eventtype(), 'EventList', 'Check event type') |
| 312 | 312 | self.test_value(res[0].events().ebounds().emin().TeV(), 1.0, | ... | ... |
test/test_pipelines.py
| ... | ... | @@ -80,7 +80,7 @@ class Test(gammalib.GPythonTestSuite): |
| 80 | 80 | rad_sim = 10.0 |
| 81 | 81 | rad_select = 3.0 |
| 82 | 82 | tstart = 0.0 |
| 83 | - tstop = 1800.0 | |
| 83 | + tstop = 300.0 | |
| 84 | 84 | emin = 0.1 |
| 85 | 85 | emax = 100.0 |
| 86 | 86 | |
| ... | ... | @@ -135,7 +135,7 @@ class Test(gammalib.GPythonTestSuite): |
| 135 | 135 | rad_sim = 10.0 |
| 136 | 136 | rad_select = 3.0 |
| 137 | 137 | tstart = 0.0 |
| 138 | - tstop = 1800.0 | |
| 138 | + tstop = 300.0 | |
| 139 | 139 | emin = 0.1 |
| 140 | 140 | emax = 100.0 |
| 141 | 141 | ... | ... |