From 1691ebb4feed43b19e25a07407230dc915a37077 Mon Sep 17 00:00:00 2001 From: Jürgen Knödlseder Date: Thu, 30 Nov 2017 11:15:44 +0100 Subject: [PATCH] Speed up ctools unit tests --- examples/Makefile.am | 9 --------- examples/README.md | 35 ----------------------------------- examples/generate_prod3_irfs.py | 111 --------------------------------------------------------------------------------------------------------------- examples/make_spectrum.py | 228 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ examples/make_ts_distributions.py | 139 ------------------------------------------------------------------------------------------------------------------------------------------- examples/pipeline_binned_disk.py | 168 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ examples/pipeline_binned_mem.py | 138 ------------------------------------------------------------------------------------------------------------------------------------------ examples/pipeline_stacked_disk.py | 218 -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- examples/pipeline_stacked_mem.py | 190 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- examples/pipeline_unbinned_disk.py | 141 --------------------------------------------------------------------------------------------------------------------------------------------- examples/pipeline_unbinned_mem.py | 123 --------------------------------------------------------------------------------------------------------------------------- test/data/bkg_dummy.txt | 21 --------------------- test/data/crab_events.fits.gz | Bin 608925 -> 0 bytes test/data/disk.xml | 25 ------------------------- test/data/gauss.xml | 25 ------------------------- test/data/obs_stacked_two.xml | 4 ++-- test/data/shell.xml | 26 -------------------------- test/data/source1.xml | 15 --------------- test/data/workflow.xml | 8 ++++---- test/test_cslightcrv.py | 17 ++++++++++------- test/test_csphagen.py | 52 +++++++++++++++++++++++++++++++++------------------- test/test_csphasecrv.py | 5 ++++- test/test_cssens.py | 8 ++++---- test/test_csworkflow.py | 12 ++++++++---- test/test_ctbin.py | 26 +++++++++++++------------- test/test_cterror.py | 16 ++++++++-------- test/test_ctlike.py | 16 ++++++++-------- test/test_ctobssim.py | 126 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------------------------------------------- test/test_ctphase.py | 2 +- test/test_ctprob.py | 2 +- test/test_ctselect.py | 40 ++++++++++++++++++++-------------------- test/test_ctskymap.py | 42 +++++++++++++++++++++--------------------- test/test_ctulimit.py | 24 ++++++++++++------------ test/test_examples.py.in | 36 ++++++++++++++++++------------------ test/test_obsutils.py | 20 ++++++++++---------- test/test_pipelines.py | 4 ++-- 36 files changed, 237 insertions(+), 1835 deletions(-) delete mode 100755 examples/generate_prod3_irfs.py delete mode 100755 examples/make_spectrum.py delete mode 100755 examples/make_ts_distributions.py delete mode 100755 examples/pipeline_binned_disk.py delete mode 100755 examples/pipeline_binned_mem.py delete mode 100755 examples/pipeline_stacked_disk.py delete mode 100755 examples/pipeline_stacked_mem.py delete mode 100755 examples/pipeline_unbinned_disk.py delete mode 100755 examples/pipeline_unbinned_mem.py delete mode 100644 test/data/bkg_dummy.txt delete mode 100644 test/data/disk.xml delete mode 100644 test/data/gauss.xml delete mode 100644 test/data/shell.xml delete mode 100644 test/data/source1.xml diff --git a/examples/Makefile.am b/examples/Makefile.am index 7192f84..aebc2c3 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -21,16 +21,7 @@ # Scripts to be install scripts = README.md \ - generate_prod3_irfs.py \ make_pointings.py \ - make_spectrum.py \ - make_ts_distributions.py \ - pipeline_binned_disk.py \ - pipeline_binned_mem.py \ - pipeline_stacked_disk.py \ - pipeline_stacked_mem.py \ - pipeline_unbinned_disk.py \ - pipeline_unbinned_mem.py \ show_butterfly.py \ show_irf.py \ show_model.py \ diff --git a/examples/README.md b/examples/README.md index 6b03d85..edf76bb 100644 --- a/examples/README.md +++ b/examples/README.md @@ -4,47 +4,12 @@ ctools examples This folder contains Python example scripts that illustrate the usage of the ctools. -`generate_prod3_irfs.py` -> Generates Prod3 Instrument Response Functions from FITS files. - `make_pointings.py` > Creates pointings for CTA surveys. For the moment the Galactic Plane > Survey (gps), the Extragalactic Survey (extgal), the Galactic Centre > Survey (gc) and the LMC survey (lmc) are implemented. The script outputs > and ASCII file that can be used by csobsdef. -`make_spectrum.py` -> Simulates events and generates a spectrum from the using csspec. - -`make_ts_distributions.py` -> Creates TS distributions as function of energy for an OFF observaition -> of 50 hours effective observing time. If the Python processing module is -> installed the script can make use of multiple cores and runs in parallel. - -`pipeline_binned_disk.py` -> Example pipeline for simulating events and performing a binned analysis -> by saving intermediate results to disk. - -`pipeline_binned_mem.py` -> Example pipeline for simulating events and performing a binned analysis -> in memory. No files will be written to disk. - -`pipeline_stacked_disk.py` -> Example pipeline for simulating events and performing a stacked analysis -> by saving intermediate results to disk. - -`pipeline_stacked_mem.py` -> Example pipeline for simulating events and performing a stacked analysis -> in memory. No files will be written to disk. - -`pipeline_unbinned_disk.py` -> Example pipeline for simulating events and performing an unbinned analysis -> by saving intermediate results to disk. - -`pipeline_unbinned_mem.py` -> Example pipeline for simulating events and performing an unbinned analysis -> in memory. No files will be written to disk. - `show_butterfly.py` > Displays a butterfly generated using the ctbutterfly tool. diff --git a/examples/generate_prod3_irfs.py b/examples/generate_prod3_irfs.py deleted file mode 100755 index f68f0e3..0000000 --- a/examples/generate_prod3_irfs.py +++ /dev/null @@ -1,111 +0,0 @@ -#! /usr/bin/env python -# ========================================================================== -# Generates Prod3 IRFs from ROOT performance files -# -# Copyright (C) 2016 Juergen Knoedlseder -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# -# ========================================================================== -import sys -import cscripts - - -# ======================= # -# Set Prod3 DESY database # -# ======================= # -def set_prod3_desy(datadir): - """ - Set Prod3 DESY database - - This function sets the calibration database. By adding dictionaries to - the "db" list a number of calibrations can be defined for which IRFs - should be generated. All calibrations will be added to the calibration - database. - - Parameters - ---------- - datadir : str - Data directory - - Returns - ------- - db : list of dict - Database - """ - # Set database content - db = [{'inst': 'prod3', 'id': 'South_50h', 'analysis': 'DESY', - 'oversample': 3, 'norm1d': False, 'bgdinfill': False, - 'bgdethres': 10.0, 'path': datadir, 'file': 'irf.root'}] - - # Return database - return db - - -# =================== # -# Generate Prod3 IRFs # -# =================== # -def generate_prod3_irfs(): - """ - Generate Prod3 IRFs - """ - # Get optional argument - if len(sys.argv) == 2: - datadir = sys.argv[1] - else: - datadir = 'data' - - # Get database - entries = set_prod3_desy(datadir) - - # Loop over entries - for entry in entries: - - # Set filename - filename = entry['path']+'/'+entry['file'] - - # Set-up csroot2caldb - caldb = cscripts.csroot2caldb() - caldb['infile'] = filename - caldb['outdir'] = 'prod3' - caldb['inst'] = entry['inst'] - caldb['id'] = entry['id'] - caldb['version'] = entry['inst'] - caldb['analysis'] = entry.setdefault('analysis', 'DESY') - caldb['zenith'] = entry.setdefault('zenith', 20.0) - caldb['azimuth'] = entry.setdefault('azimuth', 0.0) - caldb['psftype'] = entry.setdefault('psftype', 'Gauss') - caldb['norm1d'] = entry.setdefault('norm1d', False) - caldb['rebin'] = entry.setdefault('rebin', False) - caldb['eascale'] = entry.setdefault('eascale', 1.0) - caldb['bgdscale'] = entry.setdefault('bgdscale', 1.0) - caldb['bgdoversample'] = entry.setdefault('oversample', 1) - caldb['bgdethres'] = entry.setdefault('bgdethres', 1000.0) - caldb['bgdinfill'] = entry.setdefault('bgdinfill', False) - caldb['logfile'] = 'generate_prod3_irfs.log' - - # Add CALDB entry - caldb.execute() - - # Return - return - - -# ======================== # -# Main routine entry point # -# ======================== # -if __name__ == '__main__': - - # Generate Prod3 IRFs - generate_prod3_irfs() diff --git a/examples/make_spectrum.py b/examples/make_spectrum.py deleted file mode 100755 index 2aae62e..0000000 --- a/examples/make_spectrum.py +++ /dev/null @@ -1,228 +0,0 @@ -#! /usr/bin/env python -# ========================================================================== -# Makes and optionally displays spectrum -# -# Copyright (C) 2014-2017 Juergen Knoedlseder -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# -# ========================================================================== -import sys -import ctools -import cscripts -try: - import matplotlib.pyplot as plt - plt.figure() - plt.close() -except (ImportError, RuntimeError): - print('This script needs the "matplotlib" module') - sys.exit() - - -# =============== # -# Create spectrum # -# =============== # -def create_spectrum(datadir): - """ - Simulate events and generate a source spectrum - - Returns - ------- - datadir : str - Data directory - """ - # Set script parameters - model_name = datadir+'/crab.xml' - caldb = 'prod2' - irf = 'South_0.5h' - ra = 83.63 - dec = 22.01 - rad_sim = 3.0 - tstart = 0.0 - tstop = 1800.0 - emin = 0.1 - emax = 100.0 - enumbins = 10 - - # Simulate events - sim = ctools.ctobssim() - sim['inmodel'] = model_name - sim['caldb'] = caldb - sim['irf'] = irf - sim['ra'] = ra - sim['dec'] = dec - sim['rad'] = rad_sim - sim['tmin'] = tstart - sim['tmax'] = tstop - sim['emin'] = emin - sim['emax'] = emax - sim.run() - - # Create spectrum - spec = cscripts.csspec(sim.obs()) - spec['srcname'] = 'Crab' - spec['method'] = 'AUTO' - spec['outfile'] = 'example_spectrum.fits' - spec['expcube'] = 'NONE' - spec['psfcube'] = 'NONE' - spec['bkgcube'] = 'NONE' - spec['edisp'] = False - spec['emin'] = emin - spec['emax'] = emax - spec['enumbins'] = enumbins - spec['ebinalg'] = 'LOG' - spec.run() - spec.save() - - # Get copy of spectrum - spectrum = spec.spectrum().copy() - - # Return - return spectrum - - -# ============= # -# Plot spectrum # -# ============= # -def plot_spectrum(spectrum, plotfile): - """ - Plot spectrum - - Parameters - ---------- - spectrum : `~gammalib.GFits` - Spectrum FITS file - plotfile : str - Plot filename - """ - # Extract columns from spectrum file - table = spectrum.table(1) - c_energy = table['Energy'] - c_ed = table['ed_Energy'] - c_eu = table['eu_Energy'] - c_flux = table['Flux'] - c_eflux = table['e_Flux'] - c_ts = table['TS'] - c_upper = table['UpperLimit'] - - # Initialise arrays to be filled - energies = [] - flux = [] - ed_engs = [] - eu_engs = [] - e_flux = [] - ul_energies = [] - ul_ed_engs = [] - ul_eu_engs = [] - ul_flux = [] - - # Get number of spectral points - nrows = table.nrows() - - # Loop over rows of the file - for row in range(nrows): - - # Get TS value, flux and flux error - ts = c_ts.real(row) - flx = c_flux.real(row) - e_flx = c_eflux.real(row) - - # If the TS > 9 and the flux error is smaller than the flux then - # take the fitted flux and flux error and append them to the - # arrays - if ts > 9.0 and e_flx < flx: - - # Add information - energies.append(c_energy.real(row)) - flux.append(c_flux.real(row)) - ed_engs.append(c_ed.real(row)) - eu_engs.append(c_eu.real(row)) - e_flux.append(c_eflux.real(row)) - - # ... otherwise take the upper limit and append it to the upper - # limit array - else: - - # Add information - ul_energies.append(c_energy.real(row)) - ul_flux.append(c_upper.real(row)) - ul_ed_engs.append(c_ed.real(row)) - ul_eu_engs.append(c_eu.real(row)) - - # Create figure - plt.figure() - plt.title('Crab spectrum') - - # Plot the spectrum - plt.loglog() - plt.grid() - - # Plot error bars for flux points and upper limits for upper limit - # points - plt.errorbar(energies, flux, yerr=e_flux, xerr=[ed_engs, eu_engs], - fmt='ro') - plt.errorbar(ul_energies, ul_flux, xerr=[ul_ed_engs, ul_eu_engs], - yerr=1.0e-11, uplims=True, fmt='ro') - - # Add plot labels - plt.xlabel('Energy (TeV)') - plt.ylabel(r'E$^{2}$dN/dE (erg cm$^{-2}$ s$^{-1}$)') - - # Show spectrum or save it into file - if len(plotfile) > 0: - plt.savefig(plotfile) - else: - plt.show() - - # Return - return - - -# ============= # -# Make spectrum # -# ============= # -def make_spectrum(): - """ - Make spectrum - """ - # Set usage string - usage = 'make_spectrum.py [-d datadir] [-p plotfile]' - - # Set default options - options = [{'option': '-d', 'value': 'data'}, - {'option': '-p', 'value': ''}] - - # Get arguments and options from command line arguments - _, options = cscripts.ioutils.get_args_options(options, usage) - - # Extract script parameters from options - datadir = options[0]['value'] - plotfile = options[1]['value'] - - # Generate spectrum - spectrum = create_spectrum(datadir) - - # Plot spectrum - plot_spectrum(spectrum, plotfile) - - # Return - return - -# ======================== # -# Main routine entry point # -# ======================== # -if __name__ == '__main__': - - # Make spectrum - make_spectrum() diff --git a/examples/make_ts_distributions.py b/examples/make_ts_distributions.py deleted file mode 100755 index 8106502..0000000 --- a/examples/make_ts_distributions.py +++ /dev/null @@ -1,139 +0,0 @@ -#! /usr/bin/env python -# ========================================================================== -# Generate TS distributions as function of energy for an OFF observation -# -# Copyright (C) 2011-2016 Jurgen Knodlseder -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# -# ========================================================================== -import cscripts - - -# ====================== # -# Create TS distribution # -# ====================== # -def create_ts(datadir, loge, emin, emax, ntrials=100, duration=180000.0, - enumbins=0, log=False): - """ - Create TS distribution. - - Parameters - ---------- - datadir : str - Data directory - loge : float - Logarithm of mean energy (TeV) - emin : float - Minimum energy (TeV) - emax : float - Maximum energy (TeV) - ntrials : int, optional - Number of MC samples - durations : float, optional - Observation duration (s) - enumbins : int, optional - Number of energy bins - log : bool, optional - Create log file(s) - """ - # Generate output filename - outfile = 'ts_'+str(loge)+'.dat' - - # Setup cstsdist tool - tsdist = cscripts.cstsdist() - tsdist['inmodel'] = datadir+'/crab.xml' - tsdist['srcname'] = 'Crab' - tsdist['outfile'] = outfile - tsdist['ntrials'] = ntrials - tsdist['caldb'] = 'prod2' - tsdist['irf'] = 'South_50h' - tsdist['ra'] = 83.63 - tsdist['dec'] = 22.01 - tsdist['emin'] = emin - tsdist['emax'] = emax - tsdist['enumbins'] = enumbins - tsdist['tmin'] = 0 - tsdist['tmax'] = duration - tsdist['rad'] = 5.0 - tsdist['npix'] = 200 - tsdist['binsz'] = 0.05 - - # Optionally open the log file - if log: - tsdist.logFileOpen() - - # Run tool - tsdist.run() - - # Return - return - - -# ==================== # -# Make TS distribution # -# ==================== # -def make_ts_distribution(): - """ - Make TS distribution - """ - # Set usage string - usage = 'make_ts_distributions.py [-n ntrials] [-e enumbins]'\ - ' [-t duration] [-m max_threads] [-d datadir]' - - # Set default options - options = [{'option': '-n', 'value': '100'}, - {'option': '-e', 'value': '0'}, - {'option': '-t', 'value': '180000.0'}, - {'option': '-m', 'value': '1'}, - {'option': '-d', 'value': 'data'}] - - # Get arguments and options from command line arguments - _, options = cscripts.ioutils.get_args_options(options, usage) - - # Extract script parameters from options - ntrials = int(options[0]['value']) - enumbins = int(options[1]['value']) - duration = float(options[2]['value']) - #max_threads = int(options[3]['value']) - datadir = options[4]['value'] - - # Loop over energy bands. The energy bands are those that are also - # used for sensitivity computation. - for ieng in range(18): - - # Set energies - loge = -1.3 + ieng * 0.2 - emin = pow(10.0, loge-0.1) - emax = pow(10.0, loge+0.1) - if loge < 0: - loge = 'm'+str(abs(loge)) - else: - loge = 'p'+str(abs(loge)) - - # Create TS - create_ts(datadir, loge, emin, emax, ntrials=ntrials, - enumbins=enumbins, duration=duration) - - # Return - return - - -# ======================== # -# Main routine entry point # -# ======================== # -if __name__ == '__main__': - - # Make TS distribution - make_ts_distribution() diff --git a/examples/pipeline_binned_disk.py b/examples/pipeline_binned_disk.py deleted file mode 100755 index 8834f0e..0000000 --- a/examples/pipeline_binned_disk.py +++ /dev/null @@ -1,168 +0,0 @@ -#! /usr/bin/env python -# ========================================================================== -# Perform binned analysis of simulated CTA data -# -# Copyright (C) 2015-2016 Juergen Knoedlseder -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# -# ========================================================================== -import gammalib -import ctools -import cscripts - - -# ================================ # -# Simulation and analysis pipeline # -# ================================ # -def run_pipeline(obs, emin=0.1, emax=100.0, - enumbins=20, nxpix=200, nypix=200, binsz=0.02, - coordsys='CEL', proj='CAR', - model='data/crab.xml', - caldb='prod2', irf='South_0.5h', - debug=False): - """ - Simulation and binned analysis pipeline - - Parameters - ---------- - obs : `~gammalib.GObservations` - Observation container - emin : float, optional - Minimum energy (TeV) - emax : float, optional - Maximum energy (TeV) - enumbins : int, optional - Number of energy bins - nxpix : int, optional - Number of pixels in X axis - nypix : int, optional - Number of pixels in Y axis - binsz : float, optional - Pixel size (deg) - coordsys : str, optional - Coordinate system - proj : str, optional - Coordinate projection - model : str, optional - Model definition XML file - caldb : str, optional - Calibration database path - irf : str, optional - Instrument response function - debug : bool, optional - Debug function - """ - # Simulate events - sim = ctools.ctobssim(obs) - sim['debug'] = debug - sim['outevents'] = 'obs.xml' - sim.execute() - - # Bin events by looping over all observations in the container - sim_obs = gammalib.GObservations('obs.xml') - obs = gammalib.GObservations() - for run in sim_obs: - - # Get event filename and set counts cube filename - eventfile = run.eventfile().url() - cubefile = 'cube_'+eventfile - - # Bin events for that observation - binning = ctools.ctbin() - binning['inobs'] = eventfile - binning['outcube'] = cubefile - binning['ebinalg'] = 'LOG' - binning['emin'] = emin - binning['emax'] = emax - binning['enumbins'] = enumbins - binning['nxpix'] = nxpix - binning['nypix'] = nypix - binning['binsz'] = binsz - binning['coordsys'] = coordsys - binning['usepnt'] = True - binning['proj'] = proj - binning.execute() - - # Set observation ID - binning.obs()[0].id(cubefile) - binning.obs()[0].eventfile(cubefile) - - # Append result to observations - obs.extend(binning.obs()) - - # Save XML file - xml = gammalib.GXml() - obs.write(xml) - xml.save('obs_cube.xml') - - # Perform maximum likelihood fitting - like = ctools.ctlike() - like['inobs'] = 'obs_cube.xml' - like['inmodel'] = model - like['outmodel'] = 'fit_results.xml' - like['expcube'] = 'NONE' - like['psfcube'] = 'NONE' - like['bkgcube'] = 'NONE' - like['caldb'] = caldb - like['irf'] = irf - like['debug'] = True # Switch this always on for results in console - like.execute() - - # Return - return - - -# ===================================================== # -# Run binned pipeline with intermediate results on disk # -# ===================================================== # -def pipeline_binned_disk(): - """ - Run binned pipeline with intermediate results on disk - """ - # Set usage string - usage = 'pipeline_binned_disk.py [-d datadir]' - - # Set default options - options = [{'option': '-d', 'value': 'data'}] - - # Get arguments and options from command line arguments - _, options = cscripts.ioutils.get_args_options(options, usage) - - # Extract script parameters from options - datadir = options[0]['value'] - - # Setup observations - obs = cscripts.obsutils.set_observations(83.63, 22.01, 5.0, 0.0, 180.0, - 0.1, 100.0, 'South_0.5h', 'prod2', - pattern='four', offset=1.5) - - # Setup model - obs.models(gammalib.GModels(datadir+'/crab.xml')) - - # Run analysis pipeline - run_pipeline(obs, model=datadir+'/crab.xml', enumbins=10, nxpix=40, - nypix=40, binsz=0.1) - - # Return - return - - -# ======================== # -# Main routine entry point # -# ======================== # -if __name__ == '__main__': - - # Run binned pipeline with intermediate results on disk - pipeline_binned_disk() diff --git a/examples/pipeline_binned_mem.py b/examples/pipeline_binned_mem.py deleted file mode 100755 index 88097d4..0000000 --- a/examples/pipeline_binned_mem.py +++ /dev/null @@ -1,138 +0,0 @@ -#! /usr/bin/env python -# ========================================================================== -# Perform binned in-memory analysis of simulated CTA data. -# -# Copyright (C) 2015-2016 Juergen Knoedlseder -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# -# ========================================================================== -import gammalib -import ctools -import cscripts - - -# ================================ # -# Simulation and analysis pipeline # -# ================================ # -def run_pipeline(obs, emin=0.1, emax=100.0, - enumbins=20, nxpix=200, nypix=200, binsz=0.02, - coordsys='CEL', proj='CAR', debug=False): - """ - Simulation and binned analysis pipeline - - Parameters - ---------- - obs : `~gammalib.GObservations` - Observation container - emin : float, optional - Minimum energy (TeV) - emax : float, optional - Maximum energy (TeV) - enumbins : int, optional - Number of energy bins - nxpix : int, optional - Number of pixels in X axis - nypix : int, optional - Number of pixels in Y axis - binsz : float, optional - Pixel size (deg) - coordsys : str, optional - Coordinate system - proj : str, optional - Coordinate projection - debug : bool, optional - Debug function - """ - # Simulate events - sim = ctools.ctobssim(obs) - sim['debug'] = debug - sim.run() - - # Bin events by looping over all observations in the container - obs = gammalib.GObservations() - obs.models(sim.obs().models()) - for run in sim.obs(): - - # Create container with a single observation - container = gammalib.GObservations() - container.append(run) - - # Bin events for that observation - binning = ctools.ctbin(container) - binning['ebinalg'] = 'LOG' - binning['emin'] = emin - binning['emax'] = emax - binning['enumbins'] = enumbins - binning['nxpix'] = nxpix - binning['nypix'] = nypix - binning['binsz'] = binsz - binning['coordsys'] = coordsys - binning['usepnt'] = True - binning['proj'] = proj - binning.run() - - # Append result to observations - obs.extend(binning.obs()) - - # Perform maximum likelihood fitting - like = ctools.ctlike(obs) - like['debug'] = True # Switch this always on for results in console - like.run() - - # Return - return - - -# ============================= # -# Run binned in-memory pipeline # -# ============================= # -def pipeline_binned_mem(): - """ - Run binned in-memory pipeline - """ - # Set usage string - usage = 'pipeline_binned_mem.py [-d datadir]' - - # Set default options - options = [{'option': '-d', 'value': 'data'}] - - # Get arguments and options from command line arguments - _, options = cscripts.ioutils.get_args_options(options, usage) - - # Extract script parameters from options - datadir = options[0]['value'] - - # Setup observations - obs = cscripts.obsutils.set_observations(83.63, 22.01, 5.0, 0.0, 180.0, - 0.1, 100.0, 'South_0.5h', 'prod2', - pattern='four', offset=1.5) - - # Setup model - obs.models(gammalib.GModels(datadir+'/crab.xml')) - - # Run analysis pipeline - run_pipeline(obs, enumbins=10, nxpix=40, nypix=40, binsz=0.1) - - # Return - return - - -# ======================== # -# Main routine entry point # -# ======================== # -if __name__ == '__main__': - - # Run binned in-memory pipeline - pipeline_binned_mem() diff --git a/examples/pipeline_stacked_disk.py b/examples/pipeline_stacked_disk.py deleted file mode 100755 index 85513e4..0000000 --- a/examples/pipeline_stacked_disk.py +++ /dev/null @@ -1,218 +0,0 @@ -#! /usr/bin/env python -# ========================================================================== -# Perform stacked analysis of simulated CTA data. -# -# Copyright (C) 2015-2016 Juergen Knoedlseder -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# -# ========================================================================== -import gammalib -import ctools -import cscripts - - -# ================================ # -# Simulation and analysis pipeline # -# ================================ # -def run_pipeline(obs, ra=83.63, dec=22.01, emin=0.1, emax=100.0, - enumbins=20, nxpix=200, nypix=200, binsz=0.02, - coordsys='CEL', proj='CAR', - model='data/crab.xml', - caldb='prod2', irf='South_0.5h', - debug=False): - """ - Simulation and stacked analysis pipeline - - Parameters - ---------- - obs : `~gammalib.GObservations` - Observation container - ra : float, optional - Right Ascension of counts cube centre (deg) - dec : float, optional - Declination of Region of counts cube centre (deg) - emin : float, optional - Minimum energy (TeV) - emax : float, optional - Maximum energy (TeV) - enumbins : int, optional - Number of energy bins - nxpix : int, optional - Number of pixels in X axis - nypix : int, optional - Number of pixels in Y axis - binsz : float, optional - Pixel size (deg) - coordsys : str, optional - Coordinate system - proj : str, optional - Coordinate projection - model : str, optional - Model definition XML file - caldb : str, optional - Calibration database path - irf : str, optional - Instrument response function - debug : bool, optional - Debug function - """ - # Simulate events - sim = ctools.ctobssim(obs) - sim['debug'] = debug - sim['outevents'] = 'obs.xml' - sim.execute() - - # Bin events into counts map - binning = ctools.ctbin() - binning['inobs'] = 'obs.xml' - binning['outcube'] = 'cntcube.fits' - binning['ebinalg'] = 'LOG' - binning['emin'] = emin - binning['emax'] = emax - binning['enumbins'] = enumbins - binning['nxpix'] = nxpix - binning['nypix'] = nypix - binning['binsz'] = binsz - binning['coordsys'] = coordsys - binning['proj'] = proj - binning['xref'] = ra - binning['yref'] = dec - binning['debug'] = debug - binning.execute() - - # Create exposure cube - expcube = ctools.ctexpcube() - expcube['inobs'] = 'obs.xml' - expcube['incube'] = 'cntcube.fits' - expcube['outcube'] = 'expcube.fits' - expcube['caldb'] = caldb - expcube['irf'] = irf - expcube['ebinalg'] = 'LOG' - expcube['emin'] = emin - expcube['emax'] = emax - expcube['enumbins'] = enumbins - expcube['nxpix'] = nxpix - expcube['nypix'] = nypix - expcube['binsz'] = binsz - expcube['coordsys'] = coordsys - expcube['proj'] = proj - expcube['xref'] = ra - expcube['yref'] = dec - expcube['debug'] = debug - expcube.execute() - - # Create PSF cube - psfcube = ctools.ctpsfcube() - psfcube['inobs'] = 'obs.xml' - psfcube['incube'] = 'NONE' - psfcube['outcube'] = 'psfcube.fits' - psfcube['caldb'] = caldb - psfcube['irf'] = irf - psfcube['ebinalg'] = 'LOG' - psfcube['emin'] = emin - psfcube['emax'] = emax - psfcube['enumbins'] = enumbins - psfcube['nxpix'] = 10 - psfcube['nypix'] = 10 - psfcube['binsz'] = 1.0 - psfcube['coordsys'] = coordsys - psfcube['proj'] = proj - psfcube['xref'] = ra - psfcube['yref'] = dec - psfcube['debug'] = debug - psfcube.execute() - - # Create background cube - bkgcube = ctools.ctbkgcube() - bkgcube['inobs'] = 'obs.xml' - bkgcube['inmodel'] = model - bkgcube['incube'] = 'NONE' - bkgcube['outcube'] = 'bkgcube.fits' - bkgcube['outmodel'] = 'model_bkg.xml' - bkgcube['caldb'] = caldb - bkgcube['irf'] = irf - bkgcube['ebinalg'] = 'LOG' - bkgcube['emin'] = emin - bkgcube['emax'] = emax - bkgcube['enumbins'] = enumbins - bkgcube['nxpix'] = 10 - bkgcube['nypix'] = 10 - bkgcube['binsz'] = 1.0 - bkgcube['coordsys'] = coordsys - bkgcube['proj'] = proj - bkgcube['xref'] = ra - bkgcube['yref'] = dec - bkgcube['debug'] = debug - bkgcube.execute() - - # Perform maximum likelihood fitting - like = ctools.ctlike() - like['inobs'] = 'cntcube.fits' - like['inmodel'] = 'model_bkg.xml' - like['outmodel'] = 'fit_results.xml' - like['expcube'] = 'expcube.fits' - like['psfcube'] = 'psfcube.fits' - like['bkgcube'] = 'bkgcube.fits' - like['caldb'] = caldb - like['irf'] = irf - like['debug'] = True # Switch this always on for results in console - like.execute() - - # Return - return - - -# ====================================================== # -# Run stacked pipeline with intermediate results on disk # -# ====================================================== # -def pipeline_stacked_disk(): - """ - Run stacked pipeline with intermediate results on disk - """ - # Set usage string - usage = 'pipeline_stacked_disk.py [-d datadir]' - - # Set default options - options = [{'option': '-d', 'value': 'data'}] - - # Get arguments and options from command line arguments - _, options = cscripts.ioutils.get_args_options(options, usage) - - # Extract script parameters from options - datadir = options[0]['value'] - - # Setup observations - obs = cscripts.obsutils.set_observations(83.63, 22.01, 5.0, 0.0, 180.0, - 0.1, 100.0, 'South_0.5h', 'prod2', - pattern='four', offset=1.5) - - # Setup model - obs.models(gammalib.GModels(datadir+'/crab.xml')) - - # Run analysis pipeline - run_pipeline(obs, model=datadir+'/crab.xml', enumbins=10, nxpix=40, - nypix=40, binsz=0.1) - - # Return - return - - -# ======================== # -# Main routine entry point # -# ======================== # -if __name__ == '__main__': - - # Run stacked pipeline with intermediate results on disk - pipeline_stacked_disk() diff --git a/examples/pipeline_stacked_mem.py b/examples/pipeline_stacked_mem.py deleted file mode 100755 index f0d26cc..0000000 --- a/examples/pipeline_stacked_mem.py +++ /dev/null @@ -1,190 +0,0 @@ -#! /usr/bin/env python -# ========================================================================== -# Perform stacked in-memory analysis of simulated CTA data -# -# Copyright (C) 2014-2016 Juergen Knoedlseder -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# -# ========================================================================== -import gammalib -import ctools -import cscripts - - -# ================================ # -# Simulation and analysis pipeline # -# ================================ # -def run_pipeline(obs, ra=83.63, dec=22.01, emin=0.1, emax=100.0, - enumbins=20, nxpix=200, nypix=200, binsz=0.02, - coordsys='CEL', proj='CAR', debug=False): - """ - Simulation and stacked analysis pipeline - - Parameters - ---------- - obs : `~gammalib.GObservations` - Observation container - ra : float, optional - Right Ascension of counts cube centre (deg) - dec : float, optional - Declination of Region of counts cube centre (deg) - emin : float, optional - Minimum energy (TeV) - emax : float, optional - Maximum energy (TeV) - enumbins : int, optional - Number of energy bins - nxpix : int, optional - Number of pixels in X axis - nypix : int, optional - Number of pixels in Y axis - binsz : float, optional - Pixel size (deg) - coordsys : str, optional - Coordinate system - proj : str, optional - Coordinate projection - debug : bool, optional - Debug function - """ - # Simulate events - sim = ctools.ctobssim(obs) - sim['debug'] = debug - sim.run() - - # Bin events into counts map - binning = ctools.ctbin(sim.obs()) - binning['ebinalg'] = 'LOG' - binning['emin'] = emin - binning['emax'] = emax - binning['enumbins'] = enumbins - binning['nxpix'] = nxpix - binning['nypix'] = nypix - binning['binsz'] = binsz - binning['coordsys'] = coordsys - binning['proj'] = proj - binning['xref'] = ra - binning['yref'] = dec - binning['debug'] = debug - binning.run() - - # Create exposure cube - expcube = ctools.ctexpcube(sim.obs()) - expcube['incube'] = 'NONE' - expcube['ebinalg'] = 'LOG' - expcube['emin'] = emin - expcube['emax'] = emax - expcube['enumbins'] = enumbins - expcube['nxpix'] = nxpix - expcube['nypix'] = nypix - expcube['binsz'] = binsz - expcube['coordsys'] = coordsys - expcube['proj'] = proj - expcube['xref'] = ra - expcube['yref'] = dec - expcube['debug'] = debug - expcube.run() - - # Create PSF cube - psfcube = ctools.ctpsfcube(sim.obs()) - psfcube['incube'] = 'NONE' - psfcube['ebinalg'] = 'LOG' - psfcube['emin'] = emin - psfcube['emax'] = emax - psfcube['enumbins'] = enumbins - psfcube['nxpix'] = 10 - psfcube['nypix'] = 10 - psfcube['binsz'] = 1.0 - psfcube['coordsys'] = coordsys - psfcube['proj'] = proj - psfcube['xref'] = ra - psfcube['yref'] = dec - psfcube['debug'] = debug - psfcube.run() - - # Create background cube - bkgcube = ctools.ctbkgcube(sim.obs()) - bkgcube['incube'] = 'NONE' - bkgcube['ebinalg'] = 'LOG' - bkgcube['emin'] = emin - bkgcube['emax'] = emax - bkgcube['enumbins'] = enumbins - bkgcube['nxpix'] = 10 - bkgcube['nypix'] = 10 - bkgcube['binsz'] = 1.0 - bkgcube['coordsys'] = coordsys - bkgcube['proj'] = proj - bkgcube['xref'] = ra - bkgcube['yref'] = dec - bkgcube['debug'] = debug - bkgcube.run() - - # Attach background model to observation container - binning.obs().models(bkgcube.models()) - - # Set Exposure and Psf cube for first CTA observation - # (ctbin will create an observation with a single container) - binning.obs()[0].response(expcube.expcube(), psfcube.psfcube(), bkgcube.bkgcube()) - - # Perform maximum likelihood fitting - like = ctools.ctlike(binning.obs()) - like['debug'] = True # Switch this always on for results in console - like.run() - - # Return - return - - -# ============================== # -# Run stacked in-memory pipeline # -# ============================== # -def pipeline_stacked_mem(): - """ - Run stacked in-memory pipeline - """ - # Set usage string - usage = 'pipeline_stacked_mem.py [-d datadir]' - - # Set default options - options = [{'option': '-d', 'value': 'data'}] - - # Get arguments and options from command line arguments - _, options = cscripts.ioutils.get_args_options(options, usage) - - # Extract script parameters from options - datadir = options[0]['value'] - - # Setup observations - obs = cscripts.obsutils.set_observations(83.63, 22.01, 5.0, 0.0, 180.0, - 0.1, 100.0, 'South_0.5h', 'prod2', - pattern='four', offset=1.5) - - # Setup model - obs.models(gammalib.GModels(datadir+'/crab.xml')) - - # Run analysis pipeline - run_pipeline(obs, enumbins=10, nxpix=40, nypix=40, binsz=0.1) - - # Return - return - - -# ======================== # -# Main routine entry point # -# ======================== # -if __name__ == '__main__': - - # Run stacked in-memory pipeline - pipeline_stacked_mem() diff --git a/examples/pipeline_unbinned_disk.py b/examples/pipeline_unbinned_disk.py deleted file mode 100755 index 52473e4..0000000 --- a/examples/pipeline_unbinned_disk.py +++ /dev/null @@ -1,141 +0,0 @@ -#! /usr/bin/env python -# ========================================================================== -# Perform unbinned analysis of simulated CTA data. -# -# Copyright (C) 2015-2016 Juergen Knoedlseder -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# -# ========================================================================== -import gammalib -import ctools -import cscripts - - -# ================================ # -# Simulation and analysis pipeline # -# ================================ # -def run_pipeline(obs, ra=83.63, dec=22.01, rad=3.0, - emin=0.1, emax=100.0, - tmin=0.0, tmax=0.0, - model='data/crab.xml', - caldb='prod2', irf='South_0.5h', - debug=False): - """ - Simulation and unbinned analysis pipeline - - Parameters - ---------- - obs : `~gammalib.GObservations` - Observation container - ra : float, optional - Right Ascension of Region of Interest centre (deg) - dec : float, optional - Declination of Region of Interest centre (deg) - rad : float, optional - Radius of Region of Interest (deg) - emin : float, optional - Minimum energy (TeV) - emax : float, optional - Maximum energy (TeV) - tmin : float, optional - Start time (s) - tmax : float, optional - Stop time (s) - model : str, optional - Model definition XML file - caldb : str, optional - Calibration database path - irf : str, optional - Instrument response function - debug : bool, optional - Debug function - """ - # Get model - - # Simulate events - sim = ctools.ctobssim(obs) - sim['debug'] = debug - sim['outevents'] = 'obs.xml' - sim.execute() - - # Select events - select = ctools.ctselect() - select['inobs'] = 'obs.xml' - select['outobs'] = 'obs_selected.xml' - select['ra'] = ra - select['dec'] = dec - select['rad'] = rad - select['emin'] = emin - select['emax'] = emax - select['tmin'] = tmin - select['tmax'] = tmax - select['debug'] = debug - select.execute() - - # Perform maximum likelihood fitting - like = ctools.ctlike() - like['inobs'] = 'obs_selected.xml' - like['inmodel'] = model - like['outmodel'] = 'fit_results.xml' - like['caldb'] = caldb - like['irf'] = irf - like['debug'] = True # Switch this always on for results in console - like.execute() - - # Return - return - - -# ======================================================= # -# Run unbinned pipeline with intermediate results on disk # -# ======================================================= # -def pipeline_unbinned_disk(): - """ - Run unbinned pipeline with intermediate results on disk - """ - # Set usage string - usage = 'pipeline_unbinned_disk.py [-d datadir]' - - # Set default options - options = [{'option': '-d', 'value': 'data'}] - - # Get arguments and options from command line arguments - _, options = cscripts.ioutils.get_args_options(options, usage) - - # Extract script parameters from options - datadir = options[0]['value'] - - # Setup observations - obs = cscripts.obsutils.set_observations(83.63, 22.01, 5.0, 0.0, 180.0, - 0.1, 100.0, 'South_0.5h', 'prod2', - pattern='four', offset=1.5) - - # Setup model - obs.models(gammalib.GModels(datadir+'/crab.xml')) - - # Run analysis pipeline - run_pipeline(obs, model=datadir+'/crab.xml') - - # Return - return - - -# ======================== # -# Main routine entry point # -# ======================== # -if __name__ == '__main__': - - # Run unbinned pipeline with intermediate results on disk - pipeline_unbinned_disk() diff --git a/examples/pipeline_unbinned_mem.py b/examples/pipeline_unbinned_mem.py deleted file mode 100755 index 68ee239..0000000 --- a/examples/pipeline_unbinned_mem.py +++ /dev/null @@ -1,123 +0,0 @@ -#! /usr/bin/env python -# ========================================================================== -# Perform unbinned in-memory analysis of simulated CTA data -# -# Copyright (C) 2015-2016 Juergen Knoedlseder -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# -# ========================================================================== -import gammalib -import ctools -import cscripts - - -# ================================ # -# Simulation and analysis pipeline # -# ================================ # -def run_pipeline(obs, ra=83.63, dec=22.01, rad=3.0, - emin=0.1, emax=100.0, - tmin=0.0, tmax=0.0, - debug=False): - """ - Simulation and binned analysis pipeline - - Parameters - ---------- - obs : `~gammalib.GObservations` - Observation container - ra : float, optional - Right Ascension of Region of Interest centre (deg) - dec : float, optional - Declination of Region of Interest centre (deg) - rad : float, optional - Radius of Region of Interest (deg) - emin : float, optional - Minimum energy (TeV) - emax : float, optional - Maximum energy (TeV) - tmin : float, optional - Start time (s) - tmax : float, optional - Stop time (s) - debug : bool, optional - Debug function - """ - # Simulate events - sim = ctools.ctobssim(obs) - sim['debug'] = debug - sim.run() - - # Select events - select = ctools.ctselect(sim.obs()) - select['ra'] = ra - select['dec'] = dec - select['rad'] = rad - select['emin'] = emin - select['emax'] = emax - select['tmin'] = tmin - select['tmax'] = tmax - select['debug'] = debug - select.run() - - # Perform maximum likelihood fitting - like = ctools.ctlike(select.obs()) - like['debug'] = True # Switch this always on for results in console - like.run() - - # Return - return - - -# =============================== # -# Run unbinned in-memory pipeline # -# =============================== # -def pipeline_unbinned_mem(): - """ - Run unbinned in-memory pipeline - """ - # Set usage string - usage = 'pipeline_unbinned_mem.py [-d datadir]' - - # Set default options - options = [{'option': '-d', 'value': 'data'}] - - # Get arguments and options from command line arguments - _, options = cscripts.ioutils.get_args_options(options, usage) - - # Extract script parameters from options - datadir = options[0]['value'] - - # Setup observations - obs = cscripts.obsutils.set_observations(83.63, 22.01, 5.0, 0.0, 180.0, - 0.1, 100.0, 'South_0.5h', 'prod2', - pattern='four', offset=1.5) - - # Setup model - obs.models(gammalib.GModels(datadir+'/crab.xml')) - - # Run analysis pipeline - run_pipeline(obs) - - # Return - return - - -# ======================== # -# Main routine entry point # -# ======================== # -if __name__ == '__main__': - - # Run unbinned in-memory pipeline - pipeline_unbinned_mem() diff --git a/test/data/bkg_dummy.txt b/test/data/bkg_dummy.txt deleted file mode 100644 index 1a728ea..0000000 --- a/test/data/bkg_dummy.txt +++ /dev/null @@ -1,21 +0,0 @@ -19952.6231497 0.00758611874475 -31622.7766017 0.0453646736765 -50118.7233627 0.0434482007416 -79432.8234724 0.0178479909838 -125892.541179 0.00670562887729 -199526.231497 0.00084045162152 -316227.766017 0.000323808025007 -501187.233627 9.59822836926e-05 -794328.234724 6.37799870129e-05 -1258925.41179 1.03541320942e-05 -1995262.31497 1.64149835388e-05 -3162277.66017 3.15232118872e-06 -5011872.33627 2.15432019088e-06 -7943282.34724 6.16894263439e-07 -12589254.1179 8.04369168326e-07 -19952623.1497 3.8166590852e-07 -31622776.6017 3.00652101748e-07 -50118723.3627 3.33564542808e-07 -79432823.4724 1.02704085801e-07 -125892541.179 2.78291918566e-08 -199526231.497 8.18076720102e-09 diff --git a/test/data/crab_events.fits.gz b/test/data/crab_events.fits.gz index 1888505..e35b054 100644 Binary files a/test/data/crab_events.fits.gz and b/test/data/crab_events.fits.gz differ diff --git a/test/data/disk.xml b/test/data/disk.xml deleted file mode 100644 index 2b99025..0000000 --- a/test/data/disk.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/test/data/gauss.xml b/test/data/gauss.xml deleted file mode 100644 index 889764f..0000000 --- a/test/data/gauss.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/test/data/obs_stacked_two.xml b/test/data/obs_stacked_two.xml index 96e8b2f..7f2a2fc 100644 --- a/test/data/obs_stacked_two.xml +++ b/test/data/obs_stacked_two.xml @@ -3,7 +3,7 @@ - + @@ -12,7 +12,7 @@ - + diff --git a/test/data/shell.xml b/test/data/shell.xml deleted file mode 100644 index 5fc7c0a..0000000 --- a/test/data/shell.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/test/data/source1.xml b/test/data/source1.xml deleted file mode 100644 index ca07f3b..0000000 --- a/test/data/source1.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/test/data/workflow.xml b/test/data/workflow.xml index 3524efa..875cdc4 100644 --- a/test/data/workflow.xml +++ b/test/data/workflow.xml @@ -8,12 +8,12 @@ - + - + @@ -31,7 +31,7 @@ - + @@ -56,7 +56,7 @@ - + diff --git a/test/test_cslightcrv.py b/test/test_cslightcrv.py index d2ee79e..4a8c872 100755 --- a/test/test_cslightcrv.py +++ b/test/test_cslightcrv.py @@ -77,7 +77,7 @@ class Test(test): ' inmodel="'+self._model+'" srcname="Crab"'+ \ ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \ ' tbinalg=LIN '+ \ - ' tmin=2020-01-01T00:00:00 tmax=2020-01-01T00:30:00'+ \ + ' tmin=2020-01-01T00:00:00 tmax=2020-01-01T00:05:00'+ \ ' tbins=3 method=3D enumbins=0 emin=0.1 emax=100.0'+ \ ' outfile="lightcurve_cmd1.fits"'+ \ ' logfile="cslightcrv_cmd1.log" chatter=1' @@ -98,7 +98,7 @@ class Test(test): ' inmodel="'+self._model+'" srcname="Crab"'+ \ ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \ ' tbinalg=LIN '+ \ - ' tmin=2020-01-01T00:00:00 tmax=2020-01-01T00:30:00'+ \ + ' tmin=2020-01-01T00:00:00 tmax=2020-01-01T00:05:00'+ \ ' tbins=3 method=3D enumbins=0 emin=0.1 emax=100.0'+ \ ' outfile="lightcurve_cmd1.fits"'+ \ ' logfile="cslightcrv_cmd2.log" debug=yes' @@ -127,7 +127,7 @@ class Test(test): lcrv['irf'] = self._irf lcrv['tbinalg'] = 'LIN' lcrv['tmin'] = '2020-01-01T00:00:00' - lcrv['tmax'] = '2020-01-01T00:30:00' + lcrv['tmax'] = '2020-01-01T00:05:00' lcrv['tbins'] = 3 lcrv['method'] = '3D' lcrv['enumbins'] = 0 @@ -151,7 +151,7 @@ class Test(test): # is saved into the file "lightcurve_py2.dat". csv = gammalib.GCsv(2,2) tmin = 58849.00 - tdelta = 0.0104166 + tdelta = 0.0017361 for i in range(csv.nrows()): csv[i,0] = '%.5f' % (tmin + i * tdelta) csv[i,1] = '%.5f' % (tmin + (i+1) * tdelta) @@ -219,7 +219,7 @@ class Test(test): lcrv['irf'] = self._irf lcrv['tbinalg'] = 'LIN' lcrv['tmin'] = '2020-01-01T00:00:00' - lcrv['tmax'] = '2020-01-01T00:30:00' + lcrv['tmax'] = '2020-01-01T00:05:00' lcrv['tbins'] = 2 lcrv['method'] = '3D' lcrv['emin'] = 0.1 @@ -250,8 +250,8 @@ class Test(test): lcrv['caldb'] = self._caldb lcrv['irf'] = self._irf lcrv['tbinalg'] = 'LIN' - lcrv['tmin'] = 'MJD 58849.0008' - lcrv['tmax'] = 'MJD 58849.0112' + lcrv['tmin'] = '2020-01-01T00:00:00' + lcrv['tmax'] = '2020-01-01T00:05:00' lcrv['tbins'] = 2 lcrv['method'] = 'ONOFF' lcrv['emin'] = 0.1 @@ -261,6 +261,9 @@ class Test(test): lcrv['xref'] = 83.63 lcrv['yref'] = 22.01 lcrv['rad'] = 0.2 + lcrv['etruemin'] = 0.05 + lcrv['etruemax'] = 150.0 + lcrv['etruebins'] = 5 lcrv['statistic'] = 'WSTAT' lcrv['outfile'] = 'cslightcrv_py5.fits' lcrv['logfile'] = 'cslightcrv_py5.log' diff --git a/test/test_csphagen.py b/test/test_csphagen.py index 24d8088..cc47967 100644 --- a/test/test_csphagen.py +++ b/test/test_csphagen.py @@ -49,7 +49,7 @@ class Test(test): self._nreg_with_excl = 5 self._nreg_wo_excl = 8 self._nreg_mul = [self._nreg_with_excl, 6] - self._nbins = 20 + self._nbins = 10 # number of expected background regions with/wo exclusion, # and for two different runs @@ -84,6 +84,7 @@ class Test(test): '" caldb="' + self._caldb + '" irf="' + self._irf + \ '" ebinalg="LOG" emin=0.1 emax=100. enumbins=' + \ str(self._nbins) + \ + ' etruemin=0.05 etruemax=150 etruebins=5'+ \ ' coordsys="CEL" ra=83.633 dec=22.0145' + \ ' rad=0.2 stack="no" inexclusion="' + \ self._exclusion + \ @@ -107,6 +108,7 @@ class Test(test): 'caldb="' + self._caldb + '" irf="' + self._irf + \ '" ebinalg="LOG" emin=0.1 emax=100. enumbins=' + \ str(self._nbins) + \ + ' etruemin=0.05 etruemax=150 etruebins=5'+ \ ' coordsys="CEL" ra=83.633 dec=22.0145' + \ ' rad=0.2 stack="no" inexclusion="' + \ self._exclusion + \ @@ -142,6 +144,9 @@ class Test(test): phagen['rad'] = 0.2 phagen['stack'] = False phagen['inexclusion'] = self._exclusion + phagen['etruemin'] = 0.05 + phagen['etruemax'] = 150.0 + phagen['etruebins'] = 5 phagen['outobs'] = 'csphagen_py1.xml' phagen['prefix'] = 'csphagen_py1' phagen['logfile'] = 'csphagen_py1.log' @@ -156,22 +161,25 @@ class Test(test): # Now test without exclusion region phagen = cscripts.csphagen() - phagen['inobs'] = self._myevents1 - phagen['caldb'] = self._caldb - phagen['irf'] = self._irf - phagen['ebinalg'] = 'LOG' - phagen['emin'] = 0.1 - phagen['emax'] = 100.0 - phagen['enumbins'] = self._nbins - phagen['coordsys'] = 'CEL' - phagen['ra'] = 83.633 - phagen['dec'] = 22.0145 - phagen['rad'] = 0.2 - phagen['stack'] = False - phagen['outobs'] = 'csphagen_py2.xml' - phagen['prefix'] = 'csphagen_py2' - phagen['logfile'] = 'csphagen_py2.log' - phagen['chatter'] = 2 + phagen['inobs'] = self._myevents1 + phagen['caldb'] = self._caldb + phagen['irf'] = self._irf + phagen['ebinalg'] = 'LOG' + phagen['emin'] = 0.1 + phagen['emax'] = 100.0 + phagen['enumbins'] = self._nbins + phagen['coordsys'] = 'CEL' + phagen['ra'] = 83.633 + phagen['dec'] = 22.0145 + phagen['rad'] = 0.2 + phagen['stack'] = False + phagen['etruemin'] = 0.05 + phagen['etruemax'] = 150.0 + phagen['etruebins'] = 5 + phagen['outobs'] = 'csphagen_py2.xml' + phagen['prefix'] = 'csphagen_py2' + phagen['logfile'] = 'csphagen_py2.log' + phagen['chatter'] = 2 # Run script phagen.execute() @@ -201,6 +209,9 @@ class Test(test): phagen['rad'] = 0.2 phagen['stack'] = False phagen['inexclusion'] = self._exclusion + phagen['etruemin'] = 0.05 + phagen['etruemax'] = 150.0 + phagen['etruebins'] = 5 phagen['outobs'] = 'csphagen_py3.xml' phagen['prefix'] = 'csphagen_py3' phagen['logfile'] = 'csphagen_py3.log' @@ -228,6 +239,9 @@ class Test(test): phagen['rad'] = 0.2 phagen['stack'] = True phagen['inexclusion'] = self._exclusion + phagen['etruemin'] = 0.05 + phagen['etruemax'] = 150.0 + phagen['etruebins'] = 5 phagen['outobs'] = 'csphagen_py4.xml' phagen['prefix'] = 'csphagen_py4' phagen['logfile'] = 'csphagen_py4.log' @@ -339,7 +353,7 @@ class Test(test): # Return return - def _check_rmf(self, filename, bins, etruebins=102): + def _check_rmf(self, filename, bins, etruebins=17): """ Check RMF file """ @@ -386,7 +400,7 @@ class Test(test): # OGIP files self._check_pha(filenameroot + '_pha_on.fits', bins) self._check_pha(filenameroot + '_pha_off.fits', bins) - self._check_arf(filenameroot + '_arf.fits', 102) + self._check_arf(filenameroot + '_arf.fits', 17) self._check_rmf(filenameroot + '_rmf.fits', bins) # Optionally check for regions diff --git a/test/test_csphasecrv.py b/test/test_csphasecrv.py index bb318c1..3635642 100755 --- a/test/test_csphasecrv.py +++ b/test/test_csphasecrv.py @@ -45,7 +45,7 @@ class Test(test): # Set test data self._phased_events = self._datadir + '/phased_events.fits' self._offaxis_events = self._datadir + '/crab_offaxis1.fits' - self._model_onoff = self._datadir + '/crab_onoff.xml' + self._model_onoff = self._datadir + '/crab_onoff.xml' # Return return @@ -258,6 +258,9 @@ class Test(test): pcrv['xref'] = 83.63 pcrv['yref'] = 22.01 pcrv['rad'] = 0.2 + pcrv['etruemin'] = 0.05 + pcrv['etruemax'] = 150.0 + pcrv['etruebins'] = 5 pcrv['outfile'] = 'csphasecrv_py5.fits' pcrv['logfile'] = 'csphasecrv_py5.log' pcrv['chatter'] = 4 diff --git a/test/test_cssens.py b/test/test_cssens.py index 37441d4..23f1bc2 100755 --- a/test/test_cssens.py +++ b/test/test_cssens.py @@ -72,7 +72,7 @@ class Test(test): cmd = cssens+' inmodel="'+self._model+'"'+ \ ' srcname="Crab"'+ \ ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \ - ' duration=1800.0 rad=3.0 emin=1.0 emax=10.0 bins=1'+ \ + ' duration=180.0 rad=3.0 emin=1.0 emax=10.0 bins=1'+ \ ' outfile="cssens_cmd1.dat"'+ \ ' logfile="cssens_cmd1.log" chatter=1' @@ -91,7 +91,7 @@ class Test(test): cmd = cssens+' inmodel="model_that_does_not_exist.xml"'+ \ ' srcname="Crab"'+ \ ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \ - ' duration=1800.0 rad=3.0 emin=1.0 emax=10.0 bins=1'+ \ + ' duration=180.0 rad=3.0 emin=1.0 emax=10.0 bins=1'+ \ ' outfile="cssens_cmd2.dat"'+ \ ' logfile="cssens_cmd2.log" debug=yes chatter=2' @@ -118,7 +118,7 @@ class Test(test): sens['caldb'] = self._caldb sens['irf'] = self._irf sens['outfile'] = 'cssens_py1.dat' - sens['duration'] = 1800.0 + sens['duration'] = 180.0 sens['rad'] = 3.0 sens['emin'] = 1.0 sens['emax'] = 10.0 @@ -142,7 +142,7 @@ class Test(test): sens['caldb'] = self._caldb sens['irf'] = self._irf sens['outfile'] = 'cssens_py2.dat' - sens['duration'] = 1800.0 + sens['duration'] = 180.0 sens['rad'] = 3.0 sens['emin'] = 1.0 sens['emax'] = 10.0 diff --git a/test/test_csworkflow.py b/test/test_csworkflow.py index dcab1c7..0cbad1b 100755 --- a/test/test_csworkflow.py +++ b/test/test_csworkflow.py @@ -144,13 +144,17 @@ class Test(test): # Check fit result values self.test_value(models['Crab'][2].value(), - 5.71055e-16, 1.0e-5, 'Crab prefactor') + 5.65431687851392e-16, 1.0e-4 * 5.65431687851392e-16, + 'Check Crab prefactor') self.test_value(models['Crab'][3].value(), - -2.46174095362681, 1.0e-5, 'Crab index') + -2.45753747320273, 1.0e-4 * 2.45753747320273, + 'Check Crab index') self.test_value(models['CTABackgroundModel'][0].value(), - 1.01831847752743, 1.0e-5, 'Background model prefactor') + 1.0444753409474, 1.0e-4 * 1.0444753409474, + 'Check background model prefactor') self.test_value(models['CTABackgroundModel'][1].value(), - 0.00742512418279459, 1.0e-5, 'Background model index') + 0.0126628793551562, 1.0e-4 * 0.0126628793551562, + 'Check background model index') # Return return diff --git a/test/test_ctbin.py b/test/test_ctbin.py index 3163f58..b14c5b1 100755 --- a/test/test_ctbin.py +++ b/test/test_ctbin.py @@ -87,7 +87,7 @@ class Test(test): # Load counts cube and check content. evt = gammalib.GCTAEventCube('cntmap_cmd1.fits') - self._check_cube(evt, 18483) + self._check_cube(evt, 3105) # Setup ctbin command cmd = ctbin+' inobs="events_that_do_not_exist.fits"'+ \ @@ -115,7 +115,7 @@ class Test(test): # Load counts cube and check content. evt = gammalib.GCTAEventCube('cntmap_cmd3.fits') - self._check_cube(evt, 3689) + self._check_cube(evt, 617) # Check ctbin --help self._check_help(ctbin) @@ -174,15 +174,15 @@ class Test(test): binning.run() # Check content of observation container and counts cube - self._check_observation(binning, 18483) - self._check_cube(binning.cube(), 18483) + self._check_observation(binning, 3105) + self._check_cube(binning.cube(), 3105) # Copy ctbin tool cpy_bin = binning.copy() # Check content of observation container and counts cube - self._check_observation(cpy_bin, 18483) - self._check_cube(cpy_bin.cube(), 18483) + self._check_observation(cpy_bin, 3105) + self._check_cube(cpy_bin.cube(), 3105) # Run copy of ctbin tool again cpy_bin['logfile'] = 'ctbin_py2.log' @@ -201,7 +201,7 @@ class Test(test): # Load counts cube and check content evt = gammalib.GCTAEventCube('ctbin_py1.fits') - self._check_cube(evt, 18483) + self._check_cube(evt, 3105) # Now clear ctbin tool binning.clear() @@ -241,12 +241,12 @@ class Test(test): # Check content of observation and cube (need multiplier=3 since # three identical observations have been appended) - self._check_observation(binning, 18483, multiplier=3) - self._check_cube(binning.cube(), 18483, multiplier=3) + self._check_observation(binning, 3105, multiplier=3) + self._check_cube(binning.cube(), 3105, multiplier=3) # Load counts cube and check content. evt = gammalib.GCTAEventCube('ctbin_py3.fits') - self._check_cube(evt, 18483, multiplier=3) + self._check_cube(evt, 3105, multiplier=3) # And finally go for a fully Pythonic version with all parameters # being specified in a dictionary @@ -262,7 +262,7 @@ class Test(test): # Load counts cube and check content evt = gammalib.GCTAEventCube('ctbin_py4.fits') - self._check_cube(evt, 18483) + self._check_cube(evt, 3105) # Return return @@ -288,9 +288,9 @@ class Test(test): 'Check that there is one observation on the observation container') self.test_value(obs.instrument(), 'CTA', 'Check that the one observation is a CTA observation') - self.test_value(obs.ontime(), 1800.0*multiplier, 1.0e-6, + self.test_value(obs.ontime(), 300.0*multiplier, 1.0e-6, 'Check ontime of observation') - self.test_value(obs.livetime(), 1764.0*multiplier, 1.0e-6, + self.test_value(obs.livetime(), 294.0*multiplier, 1.0e-6, 'Check livetime of observation') self.test_value(pnt.dir().ra_deg(), 83.63, 1.0e-6, 'Check pointing Right Ascension of observation') diff --git a/test/test_cterror.py b/test/test_cterror.py index baf3b1d..6ba9600 100755 --- a/test/test_cterror.py +++ b/test/test_cterror.py @@ -264,28 +264,28 @@ class Test(test): # If there are models in the container then check them if nmodels > 0: self.test_value(models['Crab']['Prefactor'].value(), - 5.767533e-16, 1.0e-4 * 5.767533e-16, + 5.6530206356786e-16, 1.0e-4 * 5.6530206356786e-16, 'Check fitted Crab Prefactor') self.test_value(models['Crab']['Prefactor'].error(), - 1.011887e-17, 1.0e-4 * 1.011887e-17, + 2.45970361827369e-17, 1.0e-3 * 2.45970361827369e-17, 'Check Crab Prefactor error') self.test_value(models['Crab']['Index'].value(), - -2.462279, 1.0e-4 * 2.462279, + -2.45716228083265, 1.0e-4 * 2.45716228083265, 'Check fitted Crab Index') self.test_value(models['Crab']['Index'].error(), - 0.0148518, 1.0e-4 * 0.0148518, + 0.0366617454398694, 1.0e-3 * 0.0366617454398694, 'Check Crab Index error') self.test_value(models['CTABackgroundModel']['Prefactor'].value(), - 1.0197698, 1.0e-4 * 1.0197698, + 1.01525433446138, 1.0e-4 * 1.01525433446138, 'Check fitted background Prefactor') self.test_value(models['CTABackgroundModel']['Prefactor'].error(), - 0.013578, 1.0e-4 * 0.013578, + 0.0334412516391298, 1.0e-4 * 0.0334412516391298, 'Check background Prefactor error') self.test_value(models['CTABackgroundModel']['Index'].value(), - 0.00836407, 1.0e-4 * 0.00836407, + -0.005132848897274, 1.0e-3 * 0.005132848897274, 'Check fitted background Index') self.test_value(models['CTABackgroundModel']['Index'].error(), - 0.00811674, 1.0e-4 * 0.00811674, + 0.0200624490548333, 1.0e-4 * 0.0200624490548333, 'Check background Index error') # Return diff --git a/test/test_ctlike.py b/test/test_ctlike.py index 98b850b..53ef4a4 100755 --- a/test/test_ctlike.py +++ b/test/test_ctlike.py @@ -254,28 +254,28 @@ class Test(test): # If there are models in the container then check them if nmodels > 0: self.test_value(models['Crab']['Prefactor'].value(), - 5.767533e-16, 1.0e-4 * 5.767533e-16, + 5.6530206356786e-16, 1.0e-4 * 5.6530206356786e-16, 'Check fitted Crab Prefactor') self.test_value(models['Crab']['Prefactor'].error(), - 1.018351e-17, 1.0e-4 * 1.018351e-17, + 2.48304276536022e-17, 1.0e-4 * 2.48304276536022e-17, 'Check Crab Prefactor error') self.test_value(models['Crab']['Index'].value(), - -2.462279, 1.0e-4 * 2.462279, + -2.45716228083265, 1.0e-4 * 2.45716228083265, 'Check fitted Crab Index') self.test_value(models['Crab']['Index'].error(), - 0.0151608, 1.0e-4 * 0.0151608, + 0.0386777873333435, 1.0e-4 * 0.0386777873333435, 'Check Crab Index error') self.test_value(models['CTABackgroundModel']['Prefactor'].value(), - 1.0197698, 1.0e-4 * 1.0197698, + 1.01525433446138, 1.0e-4 * 1.01525433446138, 'Check fitted background Prefactor') self.test_value(models['CTABackgroundModel']['Prefactor'].error(), - 0.013578, 1.0e-4 * 0.013578, + 0.0334412516391298, 1.0e-4 * 0.0334412516391298, 'Check background Prefactor error') self.test_value(models['CTABackgroundModel']['Index'].value(), - 0.00836407, 1.0e-4 * 0.00836407, + -0.005132848897274, 1.0e-3 * 0.005132848897274, 'Check fitted background Index') self.test_value(models['CTABackgroundModel']['Index'].error(), - 0.00811674, 1.0e-4 * 0.00811674, + 0.0200624490548333, 1.0e-4 * 0.0200624490548333, 'Check background Index error') # Return diff --git a/test/test_ctobssim.py b/test/test_ctobssim.py index 1b51ac9..bbd3e84 100755 --- a/test/test_ctobssim.py +++ b/test/test_ctobssim.py @@ -74,9 +74,9 @@ class Test(test): cmd = ctobssim+' inmodel="'+self._model+'" '+ \ ' outevents="ctobssim_cmd1.fits"'+ \ ' caldb="'+self._caldb+'" irf="'+self._irf+'" '+ \ - ' ra=83.63 dec=22.01 rad=10.0'+ \ + ' ra=83.63 dec=22.01 rad=3.0'+ \ ' tmin="2020-01-01T00:00:00"'+ \ - ' tmax="2020-01-01T00:30:00"'+ \ + ' tmax="2020-01-01T00:05:00"'+ \ ' emin=0.1 emax=100.0'+ \ ' logfile="ctobssim_cmd1.log" chatter=1' @@ -90,15 +90,15 @@ class Test(test): # Load counts cube and check content. evt = gammalib.GCTAEventList('ctobssim_cmd1.fits') - self._test_list(evt, 23822) + self._test_list(evt, 3776) # Setup ctobssim command cmd = ctobssim+' inmodel="model_that_does_not_exist.xml"'+ \ ' outevents="ctobssim_cmd2.fits"'+ \ ' caldb="'+self._caldb+'" irf="'+self._irf+'" '+ \ - ' ra=83.63 dec=22.01 rad=10.0'+ \ + ' ra=83.63 dec=22.01 rad=3.0'+ \ ' tmin="2020-01-01T00:00:00"'+ \ - ' tmax="2020-01-01T00:30:00"'+ \ + ' tmax="2020-01-01T00:05:00"'+ \ ' emin=0.1 emax=100.0'+ \ ' logfile="ctobssim_cmd2.log" debug=yes chatter=1' @@ -141,9 +141,9 @@ class Test(test): sim['irf'] = self._irf sim['ra'] = 83.63 sim['dec'] = 22.01 - sim['rad'] = 10.0 + sim['rad'] = 3.0 sim['tmin'] = '2020-01-01T00:00:00' - sim['tmax'] = '2020-01-01T00:30:00' + sim['tmax'] = '2020-01-01T00:05:00' sim['emin'] = 0.1 sim['emax'] = 100.0 sim['outevents'] = 'ctobssim_py1.fits' @@ -156,33 +156,52 @@ class Test(test): # Check content of observation self._test_observation(sim) - self._test_list(sim.obs()[0].events(), 23822) + self._test_list(sim.obs()[0].events(), 3776) # Save events sim.save() # Load counts cube and check content. evt = gammalib.GCTAEventList('ctobssim_py1.fits') - self._test_list(evt, 23822) + self._test_list(evt, 3776) + + # Copy ctobssim tool + cpy_sim = sim.copy() + + # Retrieve observation and check content of copy + self._test_observation(cpy_sim) + self._test_list(cpy_sim.obs()[0].events(), 3776) + + # Execute copy of ctobssim tool again, now with a higher chatter + # level than before + cpy_sim['outevents'] = 'ctobssim_py2.fits' + cpy_sim['logfile'] = 'ctobssim_py2.log' + cpy_sim['chatter'] = 3 + cpy_sim['publish'] = True + cpy_sim.logFileOpen() # Needed to get a new log file + cpy_sim.execute() + + # Load counts cube and check content. + evt = gammalib.GCTAEventList('ctobssim_py2.fits') + self._test_list(evt, 3776) # Set-up observation container pnts = [{'ra': 83.63, 'dec': 21.01}, - {'ra': 84.63, 'dec': 22.01}, - {'ra': 83.63, 'dec': 23.01}, - {'ra': 82.63, 'dec': 22.01}] - obs = obsutils.set_obs_list(pnts, caldb=self._caldb, irf=self._irf) + {'ra': 84.63, 'dec': 22.01}] + obs = obsutils.set_obs_list(pnts, caldb=self._caldb, irf=self._irf, + duration=300.0, rad=3.0) # Set-up ctobssim tool from observation container sim = ctools.ctobssim(obs) sim['inmodel'] = self._model - sim['outevents'] = 'ctobssim_py2.xml' - sim['logfile'] = 'ctobssim_py2.log' + sim['outevents'] = 'ctobssim_py3.xml' + sim['logfile'] = 'ctobssim_py3.log' sim['chatter'] = 3 # Double maximum event range max_rate = sim.max_rate() - sim.max_rate(2*max_rate) - self.test_value(sim.max_rate(), 2*max_rate, 1.0e-3, + sim.max_rate(2.0*max_rate) + self.test_value(sim.max_rate(), 2.0*max_rate, 1.0e-3, 'Check setting of maximum event rate') # Run ctobssim tool @@ -190,57 +209,27 @@ class Test(test): sim.run() # Retrieve observation and check content - self._test_observation(sim, nobs=4, pnts=pnts) - self._test_list(sim.obs()[0].events(), 22904) - self._test_list(sim.obs()[1].events(), 23130) - self._test_list(sim.obs()[2].events(), 22672) - self._test_list(sim.obs()[3].events(), 22549) + self._test_observation(sim, nobs=2, pnts=pnts) + self._test_list(sim.obs()[0].events(), 3569) + self._test_list(sim.obs()[1].events(), 3515) # Save events sim.save() # Load events - obs = gammalib.GObservations('ctobssim_py2.xml') + obs = gammalib.GObservations('ctobssim_py3.xml') # Retrieve observation and check content - self._test_list(obs[0].events(), 22904) - self._test_list(obs[1].events(), 23130) - self._test_list(obs[2].events(), 22672) - self._test_list(obs[3].events(), 22549) - - # Copy ctobssim tool - cpy_sim = sim.copy() - - # Retrieve observation and check content of copy - self._test_observation(cpy_sim, nobs=4, pnts=pnts) - self._test_list(cpy_sim.obs()[0].events(), 22904) - self._test_list(cpy_sim.obs()[1].events(), 23130) - self._test_list(cpy_sim.obs()[2].events(), 22672) - self._test_list(cpy_sim.obs()[3].events(), 22549) - - # Execute copy of ctobssim tool again, now with a higher chatter - # level than before - cpy_sim['outevents'] = 'ctobssim_py3.xml' - cpy_sim['logfile'] = 'ctobssim_py3.log' - cpy_sim['chatter'] = 4 - cpy_sim['publish'] = True - cpy_sim.logFileOpen() # Needed to get a new log file - cpy_sim.execute() - - # Check result file - obs = gammalib.GObservations('ctobssim_py3.xml') - self.test_value(obs.size(), 4, 'Check for number of observations') - self._test_list(obs[0].events(), 22904) - self._test_list(obs[1].events(), 23130) - self._test_list(obs[2].events(), 22672) - self._test_list(obs[3].events(), 22549) + self._test_list(obs[0].events(), 3569) + self._test_list(obs[1].events(), 3515) # Return return # Check observation def _test_observation(self, obssim, nobs=1, - pnts=[{'ra': 83.63, 'dec': 22.01}]): + pnts=[{'ra': 83.63, 'dec': 22.01}], + ontime=300.0, livetime=294.0): """ Test content of an observation @@ -255,20 +244,21 @@ class Test(test): """ # Test observation container self.test_value(obssim.obs().size(), nobs, - 'There is one observation') - for i in range(obssim.obs().size()): - obs = gammalib.GCTAObservation(obssim.obs()[i]) - pnt = obs.pointing() + 'Check number of observations') + for i, obs in enumerate(obssim.obs()): + pnt = obs.pointing().dir() + ra = pnts[i]['ra'] + dec = pnts[i]['dec'] self.test_assert(obs.instrument() == 'CTA', - 'Observation is CTA observation') - self.test_value(obs.ontime(), 1800.0, 1.0e-6, - 'Ontime is 1800 sec') - self.test_value(obs.livetime(), 1764.0, 1.0e-6, - 'Livetime is 1764 sec') - self.test_value(pnt.dir().ra_deg(), pnts[i]['ra'], 1.0e-6, - 'Pointing Right Ascension is '+str(pnts[i]['ra'])+' deg') - self.test_value(pnt.dir().dec_deg(), pnts[i]['dec'], 1.0e-6, - 'Pointing Declination is '+str(pnts[i]['dec'])+' deg') + 'Check if observation is CTA observation') + self.test_value(obs.ontime(), ontime, 1.0e-6, + 'Check if ontime is %f sec' % ontime) + self.test_value(obs.livetime(), livetime, 1.0e-6, + 'Check if livetime is %f sec' % livetime) + self.test_value(pnt.ra_deg(), ra, 1.0e-6, + 'Check if pointing Right Ascension is %f deg' % ra) + self.test_value(pnt.dec_deg(), dec, 1.0e-6, + 'Check if pointing Declination is %f deg' % dec) # Return return diff --git a/test/test_ctphase.py b/test/test_ctphase.py index 00f3cc2..d1824c0 100644 --- a/test/test_ctphase.py +++ b/test/test_ctphase.py @@ -252,7 +252,7 @@ class Test(test): return # Check result file - def _check_result_file(self, filename, nevents=22220): + def _check_result_file(self, filename, nevents=3736): """ Check result file diff --git a/test/test_ctprob.py b/test/test_ctprob.py index 214772d..24c21a3 100755 --- a/test/test_ctprob.py +++ b/test/test_ctprob.py @@ -202,7 +202,7 @@ class Test(test): return # Check result file - def _check_result_file(self, filename, nevents=22220): + def _check_result_file(self, filename, nevents=3736): """ Check result file diff --git a/test/test_ctselect.py b/test/test_ctselect.py index a815996..9dcbcd2 100755 --- a/test/test_ctselect.py +++ b/test/test_ctselect.py @@ -73,7 +73,7 @@ class Test(test): cmd = ctselect+' inobs="'+self._events+'"'+ \ ' outobs="ctselect_cmd1.fits"'+ \ ' ra=83.63 dec=22.01 rad=2.0'+ \ - ' tmin=2020-01-01T00:08:20 tmax=2020-01-01T00:16:40'+ \ + ' tmin=2020-01-01T00:01:10 tmax=2020-01-01T00:03:40'+ \ ' emin=0.2 emax=80.0'+ \ ' logfile="ctselect_cmd1.log" chatter=1' @@ -92,7 +92,7 @@ class Test(test): cmd = ctselect+' inobs="event_file_that_does_not_exist.fits"'+ \ ' outobs="ctselect_cmd2.fits"'+ \ ' ra=83.63 dec=22.01 rad=2.0'+ \ - ' tmin=2020-01-01T00:08:20 tmax=2020-01-01T00:16:40'+ \ + ' tmin=2020-01-01T00:01:10 tmax=2020-01-01T00:03:40'+ \ ' emin=0.2 emax=80.0'+ \ ' logfile="ctselect_cmd2.log" debug=yes chatter=1' @@ -133,8 +133,8 @@ class Test(test): select['ra'] = 83.63 select['dec'] = 22.01 select['rad'] = 2.0 - select['tmin'] = '2020-01-01T00:08:20' - select['tmax'] = '2020-01-01T00:16:40' + select['tmin'] = '2020-01-01T00:01:10' + select['tmax'] = '2020-01-01T00:03:40' select['emin'] = 0.2 select['emax'] = 80.0 select['outobs'] = 'ctselect_py1.fits' @@ -181,7 +181,7 @@ class Test(test): # to valid event selections, but since the maximum values are still # 'NONE', no event selections should occur. cpy_select['usepnt'] = True - cpy_select['tmin'] = '2020-01-01T00:08:20' + cpy_select['tmin'] = '2020-01-01T00:01:10' cpy_select['emin'] = 0.2 cpy_select['usethres'] = 'USER' cpy_select['outobs'] = 'ctselect_py3.fits' @@ -214,8 +214,8 @@ class Test(test): select['ra'] = 83.63 select['dec'] = 22.01 select['rad'] = 2.0 - select['tmin'] = '2020-01-01T00:08:20' - select['tmax'] = '2020-01-01T00:16:40' + select['tmin'] = '2020-01-01T00:01:10' + select['tmax'] = '2020-01-01T00:03:40' select['emin'] = 120.0 select['emax'] = 130.0 select['expr'] = 'DETX == 0' @@ -237,8 +237,8 @@ class Test(test): select['ra'] = 83.63 select['dec'] = 22.01 select['rad'] = 2.0 - select['tmin'] = '2020-01-01T00:08:20' - select['tmax'] = '2020-01-01T00:16:40' + select['tmin'] = '2020-01-01T00:01:10' + select['tmax'] = '2020-01-01T00:03:40' select['emin'] = 0.2 select['emax'] = 80.0 select['outobs'] = 'ctselect_py5.fits' @@ -261,8 +261,8 @@ class Test(test): select['ra'] = 83.63 select['dec'] = 22.01 select['rad'] = 2.0 - select['tmin'] = '2020-01-01T00:08:20' - select['tmax'] = '2020-01-01T00:16:40' + select['tmin'] = '2020-01-01T00:01:10' + select['tmax'] = '2020-01-01T00:03:40' select['emin'] = 0.2 select['emax'] = 0.0 # Signals that "emax" should be ignored select['outobs'] = 'ctselect_py6.fits' @@ -282,8 +282,8 @@ class Test(test): select['ra'] = 83.63 select['dec'] = 22.01 select['rad'] = 2.0 - select['tmin'] = '2020-01-01T00:08:20' - select['tmax'] = '2020-01-01T00:16:40' + select['tmin'] = '2020-01-01T00:01:10' + select['tmax'] = '2020-01-01T00:03:40' select['emin'] = 0.0 # Signals that "emin" should be ignored select['emax'] = 80.0 select['outobs'] = 'ctselect_py7.fits' @@ -295,7 +295,7 @@ class Test(test): select.execute() # Check result file - self._check_result_file('ctselect_py7.fits', nevents=4709) + self._check_result_file('ctselect_py7.fits', nevents=1460) # Now set "emin > emax" select['emin'] = 150.0 @@ -319,8 +319,8 @@ class Test(test): select['ra'] = 83.63 select['dec'] = 24.01 select['rad'] = 3.0 - select['tmin'] = '2020-01-01T00:08:20' - select['tmax'] = '2020-01-01T00:16:40' + select['tmin'] = '2020-01-01T00:01:10' + select['tmax'] = '2020-01-01T00:03:40' select['emin'] = 0.2 select['emax'] = 80.0 select['outobs'] = 'ctselect_py9.fits' @@ -332,7 +332,7 @@ class Test(test): select.execute() # Check result file - self._check_result_file('ctselect_py9.fits', nevents=781, dec=24.01, + self._check_result_file('ctselect_py9.fits', nevents=240, dec=24.01, rad=1.5) # Now put the RoI outside the existing RoI. This should leave to @@ -483,7 +483,7 @@ class Test(test): return # Check result file - def _check_result_file(self, filename, nevents=2307, dec=22.01, rad=2.0): + def _check_result_file(self, filename, nevents=719, dec=22.01, rad=2.0): """ Check result file @@ -508,7 +508,7 @@ class Test(test): return # Check observation and event list - def _check_obs(self, obs, nobs=1, nevents=2307): + def _check_obs(self, obs, nobs=1, nevents=719): """ Check observation and event list @@ -533,7 +533,7 @@ class Test(test): return # Check events - def _check_events(self, events, nevents=2307, dec=22.01, rad=2.0): + def _check_events(self, events, nevents=719, dec=22.01, rad=2.0): """ Check event list diff --git a/test/test_ctskymap.py b/test/test_ctskymap.py index ef2c261..b8f0287 100755 --- a/test/test_ctskymap.py +++ b/test/test_ctskymap.py @@ -68,8 +68,8 @@ class Test(test): # Setup ctskymap command cmd = ctskymap+' inobs="'+self._events+'"'+\ ' outmap="ctskymap_cmd1.fits"'+ \ - ' emin=0.1 emax=100.0 nxpix=200 nypix=200'+ \ - ' binsz=0.02 coordsys="CEL" proj="CAR"'+ \ + ' emin=0.1 emax=100.0 nxpix=20 nypix=20'+ \ + ' binsz=0.2 coordsys="CEL" proj="CAR"'+ \ ' xref=83.63 yref=22.01 bkgsubtract="NONE"'+ \ ' logfile="ctskymap_cmd1.log" chatter=1' @@ -87,8 +87,8 @@ class Test(test): # Setup ctskymap command cmd = ctskymap+' inobs="event_file_that_does_not_exist.fits"'+\ ' outmap="ctskymap_cmd2.fits"'+ \ - ' emin=0.1 emax=100.0 nxpix=200 nypix=200'+ \ - ' binsz=0.02 coordsys="CEL" proj="CAR"'+ \ + ' emin=0.1 emax=100.0 nxpix=20 nypix=20'+ \ + ' binsz=0.2 coordsys="CEL" proj="CAR"'+ \ ' xref=83.63 yref=22.01 bkgsubtract="NONE"'+ \ ' logfile="ctskymap_cmd2.log" debug=yes chatter=2' @@ -128,9 +128,9 @@ class Test(test): skymap['inobs'] = self._events skymap['emin'] = 0.1 skymap['emax'] = 100 - skymap['nxpix'] = 200 - skymap['nypix'] = 200 - skymap['binsz'] = 0.02 + skymap['nxpix'] = 20 + skymap['nypix'] = 20 + skymap['binsz'] = 0.2 skymap['coordsys'] = 'CEL' skymap['proj'] = 'CAR' skymap['xref'] = 83.63 @@ -184,9 +184,9 @@ class Test(test): skymap = ctools.ctskymap(obs) skymap['emin'] = 0.1 skymap['emax'] = 100 - skymap['nxpix'] = 200 - skymap['nypix'] = 200 - skymap['binsz'] = 0.02 + skymap['nxpix'] = 20 + skymap['nypix'] = 20 + skymap['binsz'] = 0.2 skymap['coordsys'] = 'GAL' skymap['proj'] = 'CAR' skymap['xref'] = 184.5575 @@ -214,9 +214,9 @@ class Test(test): skymap = ctools.ctskymap(obs) skymap['emin'] = 0.1 skymap['emax'] = 100 - skymap['nxpix'] = 200 - skymap['nypix'] = 200 - skymap['binsz'] = 0.02 + skymap['nxpix'] = 20 + skymap['nypix'] = 20 + skymap['binsz'] = 0.2 skymap['coordsys'] = 'GAL' skymap['proj'] = 'CAR' skymap['xref'] = 184.5575 @@ -241,9 +241,9 @@ class Test(test): skymap = ctools.ctskymap(obs) skymap['emin'] = 0.1 skymap['emax'] = 100 - skymap['nxpix'] = 100 # Make region smaller since the 'RING' - skymap['nypix'] = 100 # method takes longer to run than 'IRF' - skymap['binsz'] = 0.02 + skymap['nxpix'] = 10 # Make region smaller since the 'RING' + skymap['nypix'] = 10 # method takes longer to run than 'IRF' + skymap['binsz'] = 0.2 skymap['coordsys'] = 'CEL' skymap['proj'] = 'CAR' skymap['xref'] = 83.63 @@ -264,15 +264,15 @@ class Test(test): skymap.execute() # Check result file - self._check_result_file('ctskymap_py5.fits', 100, 100) - self._check_result_file('ctskymap_py5.fits[BACKGROUND]', 100, 100) - self._check_result_file('ctskymap_py5.fits[SIGNIFICANCE]', 100, 100) + self._check_result_file('ctskymap_py5.fits', 10, 10) + self._check_result_file('ctskymap_py5.fits[BACKGROUND]', 10, 10) + self._check_result_file('ctskymap_py5.fits[SIGNIFICANCE]', 10, 10) # Return return # Check result file - def _check_result_file(self, filename, nx=200, ny=200): + def _check_result_file(self, filename, nx=20, ny=20): """ Check result file @@ -295,7 +295,7 @@ class Test(test): return # Check sky map - def _check_map(self, skymap, nx=200, ny=200): + def _check_map(self, skymap, nx=20, ny=20): """ Check sky map diff --git a/test/test_ctulimit.py b/test/test_ctulimit.py index 98f2aed..4484477 100755 --- a/test/test_ctulimit.py +++ b/test/test_ctulimit.py @@ -143,11 +143,11 @@ class Test(test): ulimit.save() # Check results - self.test_value(ulimit.diff_ulimit(), 3.05020546110845e-17, 1.0e-21, + self.test_value(ulimit.diff_ulimit(), 3.11978988143113e-17, 1.0e-21, 'Check differential upper limit') - self.test_value(ulimit.flux_ulimit(), 2.07242046724517e-11, 1.0e-16, + self.test_value(ulimit.flux_ulimit(), 2.11102478123946e-11, 1.0e-16, 'Check upper limit on photon flux') - self.test_value(ulimit.eflux_ulimit(), 9.20229587739368e-11, 1.0e-16, + self.test_value(ulimit.eflux_ulimit(), 9.32520808361777e-11, 1.0e-16, 'Check upper limit on energy flux') # Check obs() method @@ -161,19 +161,19 @@ class Test(test): cpy_ulimit = ulimit.copy() # Check results of copy - self.test_value(cpy_ulimit.diff_ulimit(), 3.05020546110845e-17, 1.0e-21, + self.test_value(cpy_ulimit.diff_ulimit(), 3.11978988143113e-17, 1.0e-21, 'Check differential upper limit') - self.test_value(cpy_ulimit.flux_ulimit(), 2.07242046724517e-11, 1.0e-16, + self.test_value(cpy_ulimit.flux_ulimit(), 2.11102478123946e-11, 1.0e-16, 'Check upper limit on photon flux') - self.test_value(cpy_ulimit.eflux_ulimit(), 9.20229587739368e-11, 1.0e-16, + self.test_value(cpy_ulimit.eflux_ulimit(), 9.32520808361777e-11, 1.0e-16, 'Check upper limit on energy flux') # Check results - self.test_value(cpy_ulimit.diff_ulimit(), 3.05020546110845e-17, 1.0e-21, + self.test_value(cpy_ulimit.diff_ulimit(), 3.11978988143113e-17, 1.0e-21, 'Check differential upper limit') - self.test_value(cpy_ulimit.flux_ulimit(), 2.07242046724517e-11, 1.0e-16, + self.test_value(cpy_ulimit.flux_ulimit(), 2.11102478123946e-11, 1.0e-16, 'Check upper limit on photon flux') - self.test_value(cpy_ulimit.eflux_ulimit(), 9.20229587739368e-11, 1.0e-16, + self.test_value(cpy_ulimit.eflux_ulimit(), 9.32520808361777e-11, 1.0e-16, 'Check upper limit on energy flux') # Now clear copy of ctulimit tool @@ -208,11 +208,11 @@ class Test(test): ulimit.execute() # Check results - self.test_value(ulimit.diff_ulimit(), 3.05020546110845e-17, 1.0e-21, + self.test_value(ulimit.diff_ulimit(), 3.11978988143113e-17, 1.0e-21, 'Check differential upper limit') - self.test_value(ulimit.flux_ulimit(), 2.07242046724517e-11, 1.0e-16, + self.test_value(ulimit.flux_ulimit(), 2.11102478123946e-11, 1.0e-16, 'Check upper limit on photon flux') - self.test_value(ulimit.eflux_ulimit(), 9.20229587739368e-11, 1.0e-16, + self.test_value(ulimit.eflux_ulimit(), 9.32520808361777e-11, 1.0e-16, 'Check upper limit on energy flux') # Test invalid model name diff --git a/test/test_examples.py.in b/test/test_examples.py.in index 7486ed7..935ac61 100755 --- a/test/test_examples.py.in +++ b/test/test_examples.py.in @@ -89,26 +89,26 @@ class Test(gammalib.GPythonTestSuite): self.name('examples') # Append tests - self.append(self.test_generate_prod3_irfs, - 'Test generate_prod3_irfs.py') + #self.append(self.test_generate_prod3_irfs, + # 'Test generate_prod3_irfs.py') self.append(self.test_make_pointings, 'Test make_pointings.py') - self.append(self.test_make_spectrum, - 'Test make_spectrum.py') - self.append(self.test_make_ts_distributions, - 'Test make_ts_distributions.py') - self.append(self.test_pipeline_binned_disk, - 'Test pipeline_binned_disk.py') - self.append(self.test_pipeline_binned_mem, - 'Test pipeline_binned_mem.py') - self.append(self.test_pipeline_stacked_disk, - 'Test pipeline_stacked_disk.py') - self.append(self.test_pipeline_stacked_mem, - 'Test pipeline_stacked_mem.py') - self.append(self.test_pipeline_unbinned_disk, - 'Test pipeline_unbinned_disk.py') - self.append(self.test_pipeline_unbinned_mem, - 'Test pipeline_unbinned_mem.py') + #self.append(self.test_make_spectrum, + # 'Test make_spectrum.py') + #self.append(self.test_make_ts_distributions, + # 'Test make_ts_distributions.py') + #self.append(self.test_pipeline_binned_disk, + # 'Test pipeline_binned_disk.py') + #self.append(self.test_pipeline_binned_mem, + # 'Test pipeline_binned_mem.py') + #self.append(self.test_pipeline_stacked_disk, + # 'Test pipeline_stacked_disk.py') + #self.append(self.test_pipeline_stacked_mem, + # 'Test pipeline_stacked_mem.py') + #self.append(self.test_pipeline_unbinned_disk, + # 'Test pipeline_unbinned_disk.py') + #self.append(self.test_pipeline_unbinned_mem, + # 'Test pipeline_unbinned_mem.py') self.append(self.test_show_butterfly, 'Test show_butterfly.py') self.append(self.test_show_irf, diff --git a/test/test_obsutils.py b/test/test_obsutils.py index cd74947..fcc5fff 100755 --- a/test/test_obsutils.py +++ b/test/test_obsutils.py @@ -89,7 +89,7 @@ class Test(test): pnt = gammalib.GSkyDir() pnt.radec_deg(83.6331, 22.0145) obs = gammalib.GObservations() - run = obsutils.set_obs(pnt, duration=100.0, emin=1.0, emax=10.0) + run = obsutils.set_obs(pnt, duration=20.0, emin=1.0, emax=10.0) run.id('0') obs.append(run) if two: @@ -113,14 +113,14 @@ class Test(test): # Check simulation results self.test_value(res.size(), 1, 'Check number of observations') self.test_value(res.models().size(), 2, 'Check number of models') - self.test_value(res.nobserved(), 48, 'Check number of observed events') + self.test_value(res.nobserved(), 6, 'Check number of observed events') self.test_value(res.npred(), 0.0, 'Check number of predicted events') self.test_value(res[0].eventtype(), 'EventList', 'Check event type') self.test_value(res[0].events().ebounds().emin().TeV(), 1.0, 'Check minimum energy') self.test_value(res[0].events().ebounds().emax().TeV(), 10.0, 'Check minimum energy') - self.test_value(res[0].events().number(), 48, + self.test_value(res[0].events().number(), 6, 'Check number of events in list') # Check energy dispersion flag @@ -144,7 +144,7 @@ class Test(test): # Check simulation results self.test_value(res.size(), 1, 'Check number of observations') self.test_value(res.models().size(), 2, 'Check number of models') - self.test_value(res.nobserved(), 48, 'Check number of observed events') + self.test_value(res.nobserved(), 6, 'Check number of observed events') self.test_value(res.npred(), 0.0, 'Check number of predicted events') self.test_value(res[0].eventtype(), 'CountsCube', 'Check event type') self.test_value(res[0].events().ebounds().emin().TeV(), 1.0, @@ -153,7 +153,7 @@ class Test(test): 'Check minimum energy') self.test_value(res[0].events().ebounds().size(), 5, 'Check number of energy bins') - self.test_value(res[0].events().number(), 48, + self.test_value(res[0].events().number(), 6, 'Check number of events in cube') # Check energy dispersion flag @@ -177,7 +177,7 @@ class Test(test): # Check simulation results self.test_value(res.size(), 1, 'Check number of observations') self.test_value(res.models().size(), 2, 'Check number of models') - self.test_value(res.nobserved(), 96, 'Check number of observed events') + self.test_value(res.nobserved(), 19, 'Check number of observed events') self.test_value(res.npred(), 0.0, 'Check number of predicted events') self.test_value(res[0].eventtype(), 'CountsCube', 'Check event type') self.test_value(res[0].events().ebounds().emin().TeV(), 1.0, @@ -186,7 +186,7 @@ class Test(test): 'Check minimum energy') self.test_value(res[0].events().ebounds().size(), 5, 'Check number of energy bins') - self.test_value(res[0].events().number(), 96, + self.test_value(res[0].events().number(), 19, 'Check number of events in cube') # Check energy dispersion flag @@ -211,7 +211,7 @@ class Test(test): # Check simulation results self.test_value(res.size(), 1, 'Check number of observations') self.test_value(res.models().size(), 2, 'Check number of models') - self.test_value(res.nobserved(), 98, 'Check number of observed events') + self.test_value(res.nobserved(), 28, 'Check number of observed events') self.test_value(res.npred(), 0.0, 'Check number of predicted events') self.test_value(res[0].eventtype(), 'CountsCube', 'Check event type') self.test_value(res[0].events().ebounds().emin().TeV(), 1.0, @@ -220,7 +220,7 @@ class Test(test): 'Check minimum energy') self.test_value(res[0].events().ebounds().size(), 5, 'Check number of energy bins') - self.test_value(res[0].events().number(), 98, + self.test_value(res[0].events().number(), 28, 'Check number of events in cube') # Check energy dispersion flag @@ -306,7 +306,7 @@ class Test(test): # Check simulation results self.test_value(res.size(), 1, 'Check number of observations') self.test_value(res.models().size(), 2, 'Check number of models') - self.test_value(res.nobserved(), 48, 'Check number of observed events') + self.test_value(res.nobserved(), 6, 'Check number of observed events') self.test_value(res.npred(), 0.0, 'Check number of predicted events') self.test_value(res[0].eventtype(), 'EventList', 'Check event type') self.test_value(res[0].events().ebounds().emin().TeV(), 1.0, diff --git a/test/test_pipelines.py b/test/test_pipelines.py index 680eed5..147f3e3 100755 --- a/test/test_pipelines.py +++ b/test/test_pipelines.py @@ -80,7 +80,7 @@ class Test(gammalib.GPythonTestSuite): rad_sim = 10.0 rad_select = 3.0 tstart = 0.0 - tstop = 1800.0 + tstop = 300.0 emin = 0.1 emax = 100.0 @@ -135,7 +135,7 @@ class Test(gammalib.GPythonTestSuite): rad_sim = 10.0 rad_select = 3.0 tstart = 0.0 - tstop = 1800.0 + tstop = 300.0 emin = 0.1 emax = 100.0 -- libgit2 0.21.4