Commit 820f238962666b9637a0cf9fb3b7b70fd671e5d7

Authored by Jürgen Knödlseder
1 parent a033f692

Adapt to GammaLib interface change

cscripts/Makefile.am
1 1 #############################################################################
2 2 # Makefile for cscripts scripts #
3 3 # ------------------------------------------------------------------------- #
4   -# Copyright (C) 2016-2019 Juergen Knoedlseder #
  4 +# Copyright (C) 2016-2020 Juergen Knoedlseder #
5 5 # ------------------------------------------------------------------------- #
6 6 # #
7 7 # This program is free software: you can redistribute it and/or modify #
... ... @@ -19,10 +19,7 @@
19 19 # #
20 20 #############################################################################
21 21  
22   -
23   -
24 22 # Scripts to be distributed in $(pyexecdir)/cscripts
25   -
26 23 pythonscripts = $(top_builddir)/cscripts/__init__.py \
27 24 $(srcdir)/csbkgmodel.py \
28 25 $(srcdir)/cscaldb.py \
... ... @@ -62,10 +59,7 @@ pythonscripts = $(top_builddir)/cscripts/__init__.py \
62 59 $(srcdir)/ioutils.py \
63 60 $(srcdir)/mputils.py
64 61  
65   -
66   -
67 62 # Parfiles to be distributed in $(prefix)/syspfiles
68   -
69 63 parfiles = $(srcdir)/csbkgmodel.par \
70 64 $(srcdir)/cscaldb.par \
71 65 $(srcdir)/csebins.par \
... ... @@ -98,10 +92,7 @@ parfiles = $(srcdir)/csbkgmodel.par \
98 92 $(srcdir)/csiactdata.par \
99 93 $(srcdir)/csiactobs.par
100 94  
101   -
102   -
103 95 # Scripts for which symbolic links will be created in bindir
104   -
105 96 linkscripts = csbkgmodel \
106 97 cscaldb \
107 98 csebins \
... ... @@ -135,10 +126,7 @@ linkscripts = csbkgmodel \
135 126 csiactdata \
136 127 csiactobs
137 128  
138   -
139   -
140 129 # Test scripts to be distributed in $(pyexecdir)/cscripts/tests
141   -
142 130 testscripts = $(srcdir)/tests/__init__.py \
143 131 $(top_srcdir)/test/testing.py \
144 132 $(top_srcdir)/test/test_python_cscripts.py \
... ... @@ -178,10 +166,7 @@ testscripts = $(srcdir)/tests/__init__.py \
178 166 $(top_srcdir)/test/test_csiactdata.py \
179 167 $(top_srcdir)/test/test_csiactobs.py
180 168  
181   -
182   -
183 169 # Test data to be distributed in $(pyexecdir)/cscripts/tests/data
184   -
185 170 testdata = $(top_srcdir)/test/data/crab.xml \
186 171 $(top_srcdir)/test/data/obs_unbinned.xml \
187 172 $(top_srcdir)/test/data/obs_unbinned_two.xml \
... ... @@ -258,18 +243,12 @@ testdata = $(top_srcdir)/test/data/crab.xml \
258 243 $(top_srcdir)/test/data/viscube.fits.gz \
259 244 $(top_srcdir)/test/data/hess_bkg_lookup.fits
260 245  
261   -
262   -
263 246 # Test data to be distributed in $(pyexecdir)/cscripts/tests/data/iactdata
264   -
265 247 testiactdata = $(top_srcdir)/test/data/iactdata/hdu-index.fits.gz \
266 248 $(top_srcdir)/test/data/iactdata/master.json \
267 249 $(top_srcdir)/test/data/iactdata/obs-index.fits.gz
268 250  
269   -
270   -
271 251 # Test data to be distributed in $(pyexecdir)/cscripts/tests/data/iactdata/events
272   -
273 252 testiactevents = $(top_srcdir)/test/data/iactdata/events/irf_file.fits.gz \
274 253 $(top_srcdir)/test/data/iactdata/events/events_0.fits.gz \
275 254 $(top_srcdir)/test/data/iactdata/events/events_1.fits.gz \
... ... @@ -281,11 +260,9 @@ testiactevents = $(top_srcdir)/test/data/iactdata/events/irf_file.fits.gz \
281 260 $(top_srcdir)/test/data/iactdata/events/events_7.fits.gz \
282 261 $(top_srcdir)/test/data/iactdata/events/events_8.fits.gz
283 262  
284   -
285 263 # Install scripts, parfiles, test scripts and test data. Note that we don't
286 264 # need to prepend $(DESTDIR) here (not fully clear why, but that's the way
287 265 # it is)
288   -
289 266 binscriptsdir = $(bindir)
290 267 binscripts_DATA = $(binscripts)
291 268 pythonscriptsdir = $(pyexecdir)/cscripts
... ... @@ -301,18 +278,13 @@ testiactdata_DATA = $(testiactdata)
301 278 testiacteventsdir = $(pyexecdir)/cscripts/tests/data/iactdata/events
302 279 testiactevents_DATA = $(testiactevents)
303 280  
304   -
305 281 # Files to be distributed in the tar file
306 282 EXTRA_DIST = $(binscripts) $(pythonscripts) $(parfiles) \
307 283 $(testscripts) $(testdata) $(testiactdata) \
308 284 $(testiactevents)
309 285  
310   -
311   -
312 286 # Add install hook rule to copy cscripts without .py into the bindir
313   -
314 287 install-data-hook:
315   -
316 288 @binlist='$(binscripts)';\
317 289 for p in $$binlist; do \
318 290 chmod +x "$(DESTDIR)$(bindir)/$$p"; \
... ... @@ -325,23 +297,15 @@ install-data-hook:
325 297 chmod +x "$(DESTDIR)$(bindir)/$$p"; \
326 298 done
327 299  
328   -
329   -
330 300 # Uninstall hook rule to remove the cscripts from the bindir
331   -
332 301 uninstall-hook:
333   -
334 302 @linklist='$(linkscripts)';\
335 303 for p in $$linklist; do \
336 304 rm -rf "$(DESTDIR)$(bindir)/$$p"; \
337 305 done
338 306  
339   -
340   -
341 307 # Files to be removed in build directory
342   -
343 308 clean-local:
344   -
345 309 @if ! [ '@top_srcdir@' -ef '@top_builddir@' ]; then \
346 310 rm -rf $(top_builddir)/cscripts/cs*.py; \
347 311 rm -rf $(top_builddir)/cscripts/obsutils.py; \
... ... @@ -351,16 +315,11 @@ clean-local:
351 315 rm -rf $(top_builddir)/cscripts/mputils.py; \
352 316 rm -rf $(top_builddir)/cscripts/*.par; \
353 317 fi
354   -
355 318 rm -rf $(top_builddir)/cscripts/*.pyc
356 319 rm -rf $(top_builddir)/cscripts/__pycache__
357 320  
358   -
359   -
360 321 # Uninstall the cscripts Python module
361   -
362 322 uninstall-local:
363   -
364 323 rm -rf $(DESTDIR)$(pyexecdir)/cscripts/*.pyc
365 324 rm -rf $(DESTDIR)$(pyexecdir)/cscripts/*.pyc
366 325 rm -rf $(DESTDIR)$(pyexecdir)/cscripts/__pycache__
... ...
cscripts/csspec.py
... ... @@ -752,8 +752,8 @@ class csspec(ctools.csobservation):
752 752 # If the source model is a cube then multiply-in the cube
753 753 # spectrum
754 754 if source.spatial().classname() == 'GModelSpatialDiffuseCube':
755   - dir = gammalib.GSkyDir()
756   - source.spatial().set_mc_cone(dir, 180.0)
  755 + region = gammalib.GSkyRegionCircle(0.0, 0.0, 180.0)
  756 + source.spatial().mc_cone(region)
757 757 norm = source.spatial().spectrum().eval(elogmean)
758 758 fitted_flux *= norm
759 759 e_flux *= norm
... ...
src/ctfindvar/ctfindvar.cpp
1 1 /***************************************************************************
2 2 * ctfindvar - Time variability search tool *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2018-2019 by Simon Bonnefoy *
  4 + * copyright (C) 2018-2020 by Simon Bonnefoy *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -817,9 +817,9 @@ std::vector<int> ctfindvar::get_pixels(void)
817 817 if (model != NULL) {
818 818  
819 819 // Get the source position
820   - GModelSpatial* spatial = model->spatial();
821   - GSkyRegion* region = spatial->region();
822   - GSkyRegionCircle* circle = dynamic_cast<GSkyRegionCircle*>(region);
  820 + const GModelSpatial* spatial = model->spatial();
  821 + const GSkyRegion* region = spatial->region();
  822 + const GSkyRegionCircle* circle = dynamic_cast<const GSkyRegionCircle*>(region);
823 823  
824 824 // If region circle is valid then
825 825 if (circle != NULL) {
... ... @@ -1338,9 +1338,9 @@ void ctfindvar::write_source_histograms(GFits&amp; fits)
1338 1338 if (model != NULL) {
1339 1339  
1340 1340 // Get the source position
1341   - GModelSpatial* spatial = model->spatial();
1342   - GSkyRegion* region = spatial->region();
1343   - GSkyRegionCircle* circle = dynamic_cast<GSkyRegionCircle*>(region);
  1341 + const GModelSpatial* spatial = model->spatial();
  1342 + const GSkyRegion* region = spatial->region();
  1343 + const GSkyRegionCircle* circle = dynamic_cast<const GSkyRegionCircle*>(region);
1344 1344  
1345 1345 // If region circle is valid then extract source name and
1346 1346 // sky direction
... ...
src/ctobssim/ctobssim.cpp
1 1 /***************************************************************************
2 2 * ctobssim - Observation simulator tool *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2011-2019 by Juergen Knoedlseder *
  4 + * copyright (C) 2011-2020 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -1403,7 +1403,7 @@ double ctobssim::get_model_flux(const GModelSky* model,
1403 1403 if (cube != NULL) {
1404 1404  
1405 1405 // Set MC cone
1406   - cube->set_mc_cone(centre, radius);
  1406 + cube->mc_cone(GSkyRegionCircle(centre, radius));
1407 1407  
1408 1408 // Allocate node function to replace the spectral component
1409 1409 GModelSpectralNodes* nodes =
... ...
src/ctulimit/ctulimit.cpp
1 1 /***************************************************************************
2 2 * ctulimit - Upper limit calculation tool *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2015-2019 by Michael Mayer *
  4 + * copyright (C) 2015-2020 by Michael Mayer *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -769,7 +769,7 @@ void ctulimit::compute_ulimit(void)
769 769  
770 770 // Set MC cone to the entire sky. This method call is needed to
771 771 // set-up the cube spectrum
772   - cube->set_mc_cone(GSkyDir(), 180.0);
  772 + cube->mc_cone(GSkyRegionCircle(0.0, 0.0, 180.0));
773 773  
774 774 // Allocate node function to replace the spectral component
775 775 nodes = new GModelSpectralNodes(cube->spectrum());
... ...
test/test_csscs.py
... ... @@ -18,15 +18,15 @@
18 18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 19 #
20 20 # ==========================================================================
21   -import cscripts
22   -import gammalib
23 21 import os
  22 +import gammalib
  23 +import cscripts
24 24 from testing import test
25 25  
26 26  
27   -# ========================= #
  27 +# =========================== #
28 28 # Test class for csscs script #
29   -# ========================= #
  29 +# =========================== #
30 30 class Test(test):
31 31 """
32 32 Test class for csscs script
... ... @@ -45,11 +45,11 @@ class Test(test):
45 45  
46 46 # Set test datasets and parameters
47 47 self._evs_offaxis = self._datadir + '/crab_offaxis1.fits'
48   - self._exclusion = self._datadir + '/crab_exclusion.fits'
49   - self._expcube = self._datadir + '/crab_expcube.fits'
50   - self._psfcube = self._datadir + '/crab_psfcube.fits'
51   - self._bkgcube = self._datadir + '/crab_bkgcube.fits'
52   - self._bkgmodel = self._datadir + '/crab_bkgcube.xml'
  48 + self._exclusion = self._datadir + '/crab_exclusion.fits'
  49 + self._expcube = self._datadir + '/crab_expcube.fits'
  50 + self._psfcube = self._datadir + '/crab_psfcube.fits'
  51 + self._bkgcube = self._datadir + '/crab_bkgcube.fits'
  52 + self._bkgmodel = self._datadir + '/crab_bkgcube.xml'
53 53 self._edispcube = self._datadir + '/crab_edispcube.fits'
54 54  
55 55 # Return
... ... @@ -168,26 +168,26 @@ class Test(test):
168 168  
169 169 # Set up for same test without TS computation
170 170 script = cscripts.csscs()
171   - script['logfile'] = 'csscs_py2.log'
172   - script['inobs'] = self._cntcube
173   - script['expcube'] = self._expcube
174   - script['psfcube'] = self._psfcube
175   - script['bkgcube'] = self._bkgcube
176   - script['inmodel'] = self._bkgmodel
  171 + script['logfile'] = 'csscs_py2.log'
  172 + script['inobs'] = self._cntcube
  173 + script['expcube'] = self._expcube
  174 + script['psfcube'] = self._psfcube
  175 + script['bkgcube'] = self._bkgcube
  176 + script['inmodel'] = self._bkgmodel
177 177 script['srcnames'] = 'Crab'
178   - script['emin'] = 1.
179   - script['emax'] = 100.
180   - script['nxpix'] = 2
181   - script['nypix'] = 2
182   - script['binsz'] = 0.1
  178 + script['emin'] = 1.
  179 + script['emax'] = 100.
  180 + script['nxpix'] = 2
  181 + script['nypix'] = 2
  182 + script['binsz'] = 0.1
183 183 script['coordsys'] = 'CEL'
184   - script['proj'] = 'CAR'
185   - script['xref'] = 83.63
186   - script['yref'] = 22.01
187   - script['rad'] = 0.2
188   - script['calc_ts'] = False
189   - script['outfile'] = 'csscs_py2.fits'
190   - script['chatter'] = 2
  184 + script['proj'] = 'CAR'
  185 + script['xref'] = 83.63
  186 + script['yref'] = 22.01
  187 + script['rad'] = 0.2
  188 + script['calc_ts'] = False
  189 + script['outfile'] = 'csscs_py2.fits'
  190 + script['chatter'] = 2
191 191  
192 192 # Run csscs script and save results
193 193 script.logFileOpen()
... ... @@ -198,27 +198,27 @@ class Test(test):
198 198  
199 199 # # Set up for same test with upper limit computation
200 200 script = cscripts.csscs()
201   - script['logfile'] = 'csscs_py3.log'
202   - script['inobs'] = self._cntcube
203   - script['expcube'] = self._expcube
204   - script['psfcube'] = self._psfcube
205   - script['bkgcube'] = self._bkgcube
206   - script['inmodel'] = self._bkgmodel
207   - script['srcnames'] = 'Crab'
208   - script['emin'] = 1.
209   - script['emax'] = 100.
210   - script['nxpix'] = 2
211   - script['nypix'] = 2
212   - script['binsz'] = 0.1
213   - script['coordsys'] = 'CEL'
214   - script['proj'] = 'CAR'
215   - script['xref'] = 83.63
216   - script['yref'] = 22.01
217   - script['rad'] = 0.2
218   - script['calc_ts'] = True
  201 + script['logfile'] = 'csscs_py3.log'
  202 + script['inobs'] = self._cntcube
  203 + script['expcube'] = self._expcube
  204 + script['psfcube'] = self._psfcube
  205 + script['bkgcube'] = self._bkgcube
  206 + script['inmodel'] = self._bkgmodel
  207 + script['srcnames'] = 'Crab'
  208 + script['emin'] = 1.
  209 + script['emax'] = 100.
  210 + script['nxpix'] = 2
  211 + script['nypix'] = 2
  212 + script['binsz'] = 0.1
  213 + script['coordsys'] = 'CEL'
  214 + script['proj'] = 'CAR'
  215 + script['xref'] = 83.63
  216 + script['yref'] = 22.01
  217 + script['rad'] = 0.2
  218 + script['calc_ts'] = True
219 219 script['calc_ulim'] = True
220   - script['outfile'] = 'csscs_py3.fits'
221   - script['chatter'] = 2
  220 + script['outfile'] = 'csscs_py3.fits'
  221 + script['chatter'] = 2
222 222  
223 223 # Run csscs script and save results
224 224 script.logFileOpen()
... ... @@ -232,26 +232,26 @@ class Test(test):
232 232  
233 233 # Set up for test without multiprocessing
234 234 script = cscripts.csscs()
235   - script['logfile'] = 'csscs_py4.log'
236   - script['inobs'] = self._cntcube
237   - script['expcube'] = self._expcube
238   - script['psfcube'] = self._psfcube
239   - script['bkgcube'] = self._bkgcube
240   - script['inmodel'] = self._bkgmodel
  235 + script['logfile'] = 'csscs_py4.log'
  236 + script['inobs'] = self._cntcube
  237 + script['expcube'] = self._expcube
  238 + script['psfcube'] = self._psfcube
  239 + script['bkgcube'] = self._bkgcube
  240 + script['inmodel'] = self._bkgmodel
241 241 script['srcnames'] = 'Crab'
242   - script['emin'] = 1.
243   - script['emax'] = 100.
244   - script['nxpix'] = 2
245   - script['nypix'] = 2
246   - script['binsz'] = 0.1
  242 + script['emin'] = 1.
  243 + script['emax'] = 100.
  244 + script['nxpix'] = 2
  245 + script['nypix'] = 2
  246 + script['binsz'] = 0.1
247 247 script['coordsys'] = 'CEL'
248   - script['proj'] = 'CAR'
249   - script['xref'] = 83.63
250   - script['yref'] = 22.01
251   - script['rad'] = 0.2
252   - script['outfile'] = 'csscs_py4.fits'
  248 + script['proj'] = 'CAR'
  249 + script['xref'] = 83.63
  250 + script['yref'] = 22.01
  251 + script['rad'] = 0.2
  252 + script['outfile'] = 'csscs_py4.fits'
253 253 script['nthreads'] = 1
254   - script['chatter'] = 2
  254 + script['chatter'] = 2
255 255  
256 256 # Run csscs script and save results
257 257 script.logFileOpen()
... ... @@ -262,27 +262,27 @@ class Test(test):
262 262  
263 263 # Set up for test with energy dispersion
264 264 script = cscripts.csscs()
265   - script['logfile'] = 'csscs_py5.log'
266   - script['inobs'] = self._cntcube
267   - script['expcube'] = self._expcube
268   - script['psfcube'] = self._psfcube
269   - script['bkgcube'] = self._bkgcube
270   - script['edisp'] = True
  265 + script['logfile'] = 'csscs_py5.log'
  266 + script['inobs'] = self._cntcube
  267 + script['expcube'] = self._expcube
  268 + script['psfcube'] = self._psfcube
  269 + script['bkgcube'] = self._bkgcube
  270 + script['edisp'] = True
271 271 script['edispcube'] = self._edispcube
272   - script['inmodel'] = self._bkgmodel
273   - script['srcnames'] = 'Crab'
274   - script['emin'] = 1.
275   - script['emax'] = 100.
276   - script['nxpix'] = 2
277   - script['nypix'] = 2
278   - script['binsz'] = 0.1
279   - script['coordsys'] = 'CEL'
280   - script['proj'] = 'CAR'
281   - script['xref'] = 83.63
282   - script['yref'] = 22.01
283   - script['rad'] = 0.2
284   - script['outfile'] = 'csscs_py5.fits'
285   - script['chatter'] = 2
  272 + script['inmodel'] = self._bkgmodel
  273 + script['srcnames'] = 'Crab'
  274 + script['emin'] = 1.
  275 + script['emax'] = 100.
  276 + script['nxpix'] = 2
  277 + script['nypix'] = 2
  278 + script['binsz'] = 0.1
  279 + script['coordsys'] = 'CEL'
  280 + script['proj'] = 'CAR'
  281 + script['xref'] = 83.63
  282 + script['yref'] = 22.01
  283 + script['rad'] = 0.2
  284 + script['outfile'] = 'csscs_py5.fits'
  285 + script['chatter'] = 2
286 286  
287 287 # Run csscs script and save results
288 288 script.logFileOpen()
... ... @@ -293,27 +293,27 @@ class Test(test):
293 293  
294 294 # Set up for test in On/Off mode with background model
295 295 script = cscripts.csscs()
296   - script['logfile'] = 'csscs_py6.log'
297   - script['inobs'] = self._evs_offaxis
298   - script['caldb'] = self._caldb
299   - script['irf'] = self._irf
300   - script['inmodel'] = self._model
301   - script['srcnames'] = 'Crab'
302   - script['emin'] = 1.
303   - script['emax'] = 100.
304   - script['nxpix'] = 2
305   - script['nypix'] = 2
306   - script['binsz'] = 0.1
307   - script['coordsys'] = 'CEL'
308   - script['proj'] = 'CAR'
309   - script['xref'] = 83.63
310   - script['yref'] = 22.01
311   - script['rad'] = 0.2
312   - script['method'] = 'ONOFF'
  296 + script['logfile'] = 'csscs_py6.log'
  297 + script['inobs'] = self._evs_offaxis
  298 + script['caldb'] = self._caldb
  299 + script['irf'] = self._irf
  300 + script['inmodel'] = self._model
  301 + script['srcnames'] = 'Crab'
  302 + script['emin'] = 1.
  303 + script['emax'] = 100.
  304 + script['nxpix'] = 2
  305 + script['nypix'] = 2
  306 + script['binsz'] = 0.1
  307 + script['coordsys'] = 'CEL'
  308 + script['proj'] = 'CAR'
  309 + script['xref'] = 83.63
  310 + script['yref'] = 22.01
  311 + script['rad'] = 0.2
  312 + script['method'] = 'ONOFF'
313 313 script['inexclusion'] = self._exclusion
314   - script['enumbins'] = 2
315   - script['outfile'] = 'csscs_py6.fits'
316   - script['chatter'] = 2
  314 + script['enumbins'] = 2
  315 + script['outfile'] = 'csscs_py6.fits'
  316 + script['chatter'] = 2
317 317  
318 318 # Run csscs script and save results
319 319 script.logFileOpen()
... ... @@ -324,26 +324,26 @@ class Test(test):
324 324  
325 325 # Same test with exclusion map piped in memory
326 326 script = cscripts.csscs()
327   - script['logfile'] = 'csscs_py7.log'
328   - script['inobs'] = self._evs_offaxis
329   - script['caldb'] = self._caldb
330   - script['irf'] = self._irf
331   - script['inmodel'] = self._model
  327 + script['logfile'] = 'csscs_py7.log'
  328 + script['inobs'] = self._evs_offaxis
  329 + script['caldb'] = self._caldb
  330 + script['irf'] = self._irf
  331 + script['inmodel'] = self._model
332 332 script['srcnames'] = 'Crab'
333   - script['emin'] = 1.
334   - script['emax'] = 100.
335   - script['nxpix'] = 2
336   - script['nypix'] = 2
337   - script['binsz'] = 0.1
  333 + script['emin'] = 1.
  334 + script['emax'] = 100.
  335 + script['nxpix'] = 2
  336 + script['nypix'] = 2
  337 + script['binsz'] = 0.1
338 338 script['coordsys'] = 'CEL'
339   - script['proj'] = 'CAR'
340   - script['xref'] = 83.63
341   - script['yref'] = 22.01
342   - script['rad'] = 0.2
343   - script['method'] = 'ONOFF'
  339 + script['proj'] = 'CAR'
  340 + script['xref'] = 83.63
  341 + script['yref'] = 22.01
  342 + script['rad'] = 0.2
  343 + script['method'] = 'ONOFF'
344 344 script['enumbins'] = 2
345   - script['outfile'] = 'csscs_py7.fits'
346   - script['chatter'] = 2
  345 + script['outfile'] = 'csscs_py7.fits'
  346 + script['chatter'] = 2
347 347  
348 348 # Set exclusion map
349 349 exclmap = gammalib.GSkyRegionMap(self._exclusion)
... ... @@ -358,28 +358,28 @@ class Test(test):
358 358  
359 359 # Set up for test in On/Off mode without background model
360 360 script = cscripts.csscs()
361   - script['logfile'] = 'csscs_py8.log'
362   - script['inobs'] = self._evs_offaxis
363   - script['caldb'] = self._caldb
364   - script['irf'] = self._irf
365   - script['inmodel'] = self._model
366   - script['srcnames'] = 'Crab'
367   - script['emin'] = 1.
368   - script['emax'] = 100.
369   - script['nxpix'] = 2
370   - script['nypix'] = 2
371   - script['binsz'] = 0.1
372   - script['coordsys'] = 'CEL'
373   - script['proj'] = 'CAR'
374   - script['xref'] = 83.63
375   - script['yref'] = 22.01
376   - script['rad'] = 0.2
377   - script['method'] = 'ONOFF'
  361 + script['logfile'] = 'csscs_py8.log'
  362 + script['inobs'] = self._evs_offaxis
  363 + script['caldb'] = self._caldb
  364 + script['irf'] = self._irf
  365 + script['inmodel'] = self._model
  366 + script['srcnames'] = 'Crab'
  367 + script['emin'] = 1.
  368 + script['emax'] = 100.
  369 + script['nxpix'] = 2
  370 + script['nypix'] = 2
  371 + script['binsz'] = 0.1
  372 + script['coordsys'] = 'CEL'
  373 + script['proj'] = 'CAR'
  374 + script['xref'] = 83.63
  375 + script['yref'] = 22.01
  376 + script['rad'] = 0.2
  377 + script['method'] = 'ONOFF'
378 378 script['use_model_bkg'] = False
379   - script['inexclusion'] = self._exclusion
380   - script['enumbins'] = 2
381   - script['outfile'] = 'csscs_py8.fits'
382   - script['chatter'] = 2
  379 + script['inexclusion'] = self._exclusion
  380 + script['enumbins'] = 2
  381 + script['outfile'] = 'csscs_py8.fits'
  382 + script['chatter'] = 2
383 383  
384 384 # Run csscs script and save results
385 385 script.logFileOpen()
... ... @@ -390,26 +390,26 @@ class Test(test):
390 390  
391 391 # Set up for test in unbinned mode
392 392 script = cscripts.csscs()
393   - script['logfile'] = 'csscs_py9.log'
394   - script['inobs'] = self._evs_offaxis
395   - script['caldb'] = self._caldb
396   - script['irf'] = self._irf
397   - script['inmodel'] = self._model
  393 + script['logfile'] = 'csscs_py9.log'
  394 + script['inobs'] = self._evs_offaxis
  395 + script['caldb'] = self._caldb
  396 + script['irf'] = self._irf
  397 + script['inmodel'] = self._model
398 398 script['srcnames'] = 'Crab'
399   - script['emin'] = 1.
400   - script['emax'] = 100.
401   - script['nxpix'] = 2
402   - script['nypix'] = 2
403   - script['binsz'] = 0.1
  399 + script['emin'] = 1.
  400 + script['emax'] = 100.
  401 + script['nxpix'] = 2
  402 + script['nypix'] = 2
  403 + script['binsz'] = 0.1
404 404 script['coordsys'] = 'CEL'
405   - script['proj'] = 'CAR'
406   - script['xref'] = 83.63
407   - script['yref'] = 22.01
408   - script['rad'] = 0.2
409   - script['method'] = 'UNBINNED'
  405 + script['proj'] = 'CAR'
  406 + script['xref'] = 83.63
  407 + script['yref'] = 22.01
  408 + script['rad'] = 0.2
  409 + script['method'] = 'UNBINNED'
410 410 script['enumbins'] = 2
411   - script['outfile'] = 'csscs_py9.fits'
412   - script['chatter'] = 2
  411 + script['outfile'] = 'csscs_py9.fits'
  412 + script['chatter'] = 2
413 413  
414 414 # Run csscs script and save results
415 415 script.logFileOpen()
... ... @@ -431,25 +431,25 @@ class Test(test):
431 431  
432 432 # Setup script for pickling text
433 433 script = cscripts.csscs()
434   - script['logfile'] = 'csscs_py1_pickle.log'
435   - script['inobs'] = self._cntcube
436   - script['expcube'] = self._expcube
437   - script['psfcube'] = self._psfcube
438   - script['bkgcube'] = self._bkgcube
439   - script['inmodel'] = self._bkgmodel
  434 + script['logfile'] = 'csscs_py1_pickle.log'
  435 + script['inobs'] = self._cntcube
  436 + script['expcube'] = self._expcube
  437 + script['psfcube'] = self._psfcube
  438 + script['bkgcube'] = self._bkgcube
  439 + script['inmodel'] = self._bkgmodel
440 440 script['srcnames'] = 'Crab'
441   - script['emin'] = 1.
442   - script['emax'] = 100.
443   - script['nxpix'] = 2
444   - script['nypix'] = 2
445   - script['binsz'] = 0.1
  441 + script['emin'] = 1.
  442 + script['emax'] = 100.
  443 + script['nxpix'] = 2
  444 + script['nypix'] = 2
  445 + script['binsz'] = 0.1
446 446 script['coordsys'] = 'CEL'
447   - script['proj'] = 'CAR'
448   - script['xref'] = 83.63
449   - script['yref'] = 22.01
450   - script['rad'] = 0.2
451   - script['outfile'] = 'csscs_py1_pickle.fits'
452   - script['chatter'] = 2
  447 + script['proj'] = 'CAR'
  448 + script['xref'] = 83.63
  449 + script['yref'] = 22.01
  450 + script['rad'] = 0.2
  451 + script['outfile'] = 'csscs_py1_pickle.fits'
  452 + script['chatter'] = 2
453 453  
454 454 # Perform pickeling tests of filled class
455 455 obj = self._pickeling(script)
... ... @@ -485,9 +485,9 @@ class Test(test):
485 485 calc_ulim : bool, optional
486 486 Check upper limit HDU
487 487 """
488   -
489 488 # Check that the entire fits container can be extracted
490 489 fits = script.fits()
  490 +
491 491 # Dump to disk and verify
492 492 fits.saveto('csscs_py3_mem.fits', True)
493 493 self._check_result_file('csscs_py3_mem.fits', srcnames=srcnames, nx=nx, ny=ny,
... ... @@ -534,8 +534,6 @@ class Test(test):
534 534 calc_ulim : bool, optional
535 535 Check upper limit HDU
536 536 """
537   -
538   - print('ho', calc_ts)
539 537 # Loop over source names
540 538 for name in srcnames:
541 539 # Check flux map
... ... @@ -546,7 +544,6 @@ class Test(test):
546 544 self._check_map(skymap, nx=nx, ny=ny)
547 545 # If requested check TS map
548 546 if calc_ts:
549   - print('hoho')
550 547 skymap = gammalib.GSkyMap(filename + '[' + name + ' TS]')
551 548 self._check_map(skymap, nx=nx, ny=ny)
552 549 # If requested check upper limit map
... ... @@ -571,7 +568,6 @@ class Test(test):
571 568 ny : int, optional
572 569 Number of Y pixels
573 570 """
574   -
575 571 # Check dimensions
576 572 self.test_value(skymap.nmaps(), 1, 'Check number of maps')
577 573 self.test_value(skymap.nx(), nx, 'Check for number of X pixels')
... ...
test/test_python_cscripts.py
... ... @@ -2,7 +2,7 @@
2 2 # ==========================================================================
3 3 # This scripts performs unit tests for cscripts
4 4 #
5   -# Copyright (C) 2016-2019 Juergen Knoedlseder
  5 +# Copyright (C) 2016-2020 Juergen Knoedlseder
6 6 #
7 7 # This program is free software: you can redistribute it and/or modify
8 8 # it under the terms of the GNU General Public License as published by
... ... @@ -18,14 +18,11 @@
18 18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 19 #
20 20 # ==========================================================================
21   -
22 21 import cscripts
23 22 import gammalib
24 23 import os
25 24 import sys
26   -
27 25 sys.path.append(os.path.dirname(os.path.abspath(__file__)))
28   -
29 26 import test_cscript
30 27 import test_cscaldb
31 28 import test_csbkgmodel
... ... @@ -64,11 +61,8 @@ import test_csiactobs
64 61  
65 62  
66 63 # ================== #
67   -
68 64 # Perform unit tests #
69   -
70 65 # ================== #
71   -
72 66 def test(installed=False, debug=False):
73 67 """
74 68 Perform cscripts unit testing.
... ... @@ -101,13 +95,12 @@ def test(installed=False, debug=False):
101 95 # test environment
102 96 else:
103 97 os.environ['CALDB'] = '%s/caldb' % (os.environ['TEST_SRCDIR'])
104   - # Create a local "pfiles" directory and set PFILES environment variable
105 98  
  99 + # Create a local "pfiles" directory and set PFILES environment variable
106 100 try:
107 101 os.mkdir('pfiles')
108 102 except:
109 103 pass
110   -
111 104 os.environ['PFILES'] = 'pfiles'
112 105  
113 106 # Copy the cscripts parameter files into the "pfiles" directory. For a
... ... @@ -115,7 +108,6 @@ def test(installed=False, debug=False):
115 108 # source directory into the "pfiles" directory, for an installed version
116 109 # we get all parameter files from the "syspfiles" directory. Also make
117 110 # sure that all parameter files are writable.
118   -
119 111 if not installed:
120 112 os.system('cp -r %s/cscripts/*.par pfiles/' % (os.environ['TEST_SRCDIR']))
121 113 os.system('chmod u+w pfiles/*')
... ... @@ -207,12 +199,8 @@ def test(installed=False, debug=False):
207 199  
208 200  
209 201 # ======================== #
210   -
211 202 # Main routine entry point #
212   -
213 203 # ======================== #
214   -
215 204 if __name__ == '__main__':
216 205 # Run tests
217   -
218 206 test()
... ...