Commit b14736b7e0683b6266ae710f202a0723bd10b4e3
1 parent
fba90429
Adapt cslightcrv, csphasecrv and csscs for the usage of rectangular On/Off regions (#3248)
Showing
12 changed files
with
116 additions
and
23 deletions
cscripts/cslightcrv.par
| ... | ... | @@ -45,8 +45,11 @@ yref, r, a, 22.51,-90,90, "Second coordinate of image/source region cen |
| 45 | 45 | nxpix, i, a, 200,,, "Size of the X axis in pixels" |
| 46 | 46 | nypix, i, a, 200,,, "Size of the Y axis in pixels" |
| 47 | 47 | binsz, r, a, 0.02,,, "Pixel size (deg/pixel)" |
| 48 | -srcshape, s, h, CIRCLE,CIRCLE,, "Shape of the source region" | |
| 48 | +srcshape, s, a, CIRCLE,CIRCLE|RECT,, "Shape of the source region" | |
| 49 | 49 | rad, r, a, 0.2,0,180, "Radius of source region circle (deg)" |
| 50 | +width, r, a, 0.2,0,180, "Width of source region rectangle (deg)" | |
| 51 | +height, r, a, 0.2,0,180, "Height of source region rectangle (deg)" | |
| 52 | +posang, r, a, 0.0,-360,360, "Position angle of source region rectangle (deg)" | |
| 50 | 53 | bkgmethod, s, h, REFLECTED,REFLECTED,, "Method for background estimation" |
| 51 | 54 | bkgregmin, i, h, 2,1,1000, "Minimum number of background regions" |
| 52 | 55 | use_model_bkg, b, h, yes,,, "Use background model?" | ... | ... |
cscripts/csphasecrv.par
| ... | ... | @@ -42,8 +42,11 @@ yref, r, a, 22.51,-90,90, "Second coordinate of image/source region center |
| 42 | 42 | nxpix, i, a, 200,,, "Size of the X axis in pixels" |
| 43 | 43 | nypix, i, a, 200,,, "Size of the Y axis in pixels" |
| 44 | 44 | binsz, r, a, 0.02,,, "Pixel size (deg/pixel)" |
| 45 | -srcshape, s, h, CIRCLE,CIRCLE,, "Shape of the source region" | |
| 45 | +srcshape, s, a, CIRCLE,CIRCLE|RECT,, "Shape of the source region" | |
| 46 | 46 | rad, r, a, 0.2,0,180, "Radius of source region circle (deg)" |
| 47 | +width, r, a, 0.2,0,180, "Width of source region rectangle (deg)" | |
| 48 | +height, r, a, 0.2,0,180, "Height of source region rectangle (deg)" | |
| 49 | +posang, r, a, 0.0,-360,360, "Position angle of source region rectangle (deg)" | |
| 47 | 50 | bkgmethod, s, h, REFLECTED,REFLECTED,, "Method for background estimation" |
| 48 | 51 | bkgregmin, i, h, 2,1,1000, "Minimum number of background regions" |
| 49 | 52 | maxoffset, r, h, 4.0,,, "Maximum offset of source from camera center to accept observation" | ... | ... |
cscripts/csscs.par
| ... | ... | @@ -45,7 +45,10 @@ emax, r, a, 100.0,,, "Upper energy limit (TeV)" |
| 45 | 45 | method, s, a, UNBINNED, UNBINNED|ONOFF,, "Analysis method" |
| 46 | 46 | enumbins, i, a, 20,,, "Number of energy bins" |
| 47 | 47 | bkgmethod, s, h, REFLECTED,REFLECTED,, "Method for background estimation" |
| 48 | -srcshape, s, h, CIRCLE,CIRCLE,, "Shape of the source region" | |
| 48 | +srcshape, s, a, CIRCLE,CIRCLE|RECT,, "Shape of the source region" | |
| 49 | +width, r, a, 0.2,0,180, "Width of source region rectangle (deg)" | |
| 50 | +height, r, a, 0.2,0,180, "Height of source region rectangle (deg)" | |
| 51 | +posang, r, a, 0.0,-360,360, "Position angle of source region rectangle (deg)" | |
| 49 | 52 | bkgregmin, i, h, 2,1,1000, "Minimum number of background regions" |
| 50 | 53 | bkgregskip, i, h, 1,0,10, "Number of background regions to skip next to On region" |
| 51 | 54 | use_model_bkg, b, h, yes,,, "Use background model?" | ... | ... |
cscripts/obsutils.py
| ... | ... | @@ -129,6 +129,7 @@ def sim(obs, log=False, debug=False, chatter=2, edisp=False, seed=0, |
| 129 | 129 | phagen['emin'] = emin |
| 130 | 130 | phagen['emax'] = emax |
| 131 | 131 | phagen['enumbins'] = nbins |
| 132 | + phagen['srcshape'] = 'CIRCLE' | |
| 132 | 133 | phagen['coordsys'] = 'CEL' |
| 133 | 134 | phagen['ra'] = ra |
| 134 | 135 | phagen['dec'] = dec |
| ... | ... | @@ -798,8 +799,8 @@ def get_onoff_obs(cls, obs, nthreads=0, ra = None, dec = None, srcname = ''): |
| 798 | 799 | # User has specified custom centre for the source region |
| 799 | 800 | if ra != None and dec != None: |
| 800 | 801 | phagen['coordsys'] = 'CEL' |
| 801 | - phagen['ra'] = ra | |
| 802 | - phagen['dec'] = dec | |
| 802 | + phagen['ra'] = ra | |
| 803 | + phagen['dec'] = dec | |
| 803 | 804 | # Otherwise use default in class |
| 804 | 805 | else: |
| 805 | 806 | phagen['coordsys'] = cls['coordsys'].string() |
| ... | ... | @@ -811,6 +812,10 @@ def get_onoff_obs(cls, obs, nthreads=0, ra = None, dec = None, srcname = ''): |
| 811 | 812 | phagen['glat'] = cls['yref'].real() |
| 812 | 813 | if cls['srcshape'].string() == 'CIRCLE': |
| 813 | 814 | phagen['rad'] = cls['rad'].real() |
| 815 | + elif cls['srcshape'].string() == 'RECT': | |
| 816 | + phagen['width'] = cls['width'].real() | |
| 817 | + phagen['height'] = cls['height'].real() | |
| 818 | + phagen['posang'] = cls['posang'].real() | |
| 814 | 819 | phagen['bkgmethod'] = cls['bkgmethod'].string() |
| 815 | 820 | if cls['bkgmethod'].string() == 'REFLECTED': |
| 816 | 821 | phagen['bkgregmin'] = cls['bkgregmin'].integer() | ... | ... |
doc/source/users/reference_manual/cslightcrv.rst
| ... | ... | @@ -129,13 +129,23 @@ General parameters |
| 129 | 129 | ``binsz [real]`` |
| 130 | 130 | Pixel size for ``3D`` analysis (in degrees/pixel). |
| 131 | 131 | |
| 132 | -``(srcshape = CIRCLE) [string]`` | |
| 133 | - Shape of the source region for On/Off analysis. | |
| 134 | - ``CIRCLE``: circular region around given position. | |
| 132 | +``srcshape <CIRCLE|RECT> [string]`` | |
| 133 | + Shape of the source region. ``CIRCLE`` defines a circular region around given | |
| 134 | + position, ``RECT`` defines a rectangle centred on a given position. | |
| 135 | 135 | |
| 136 | 136 | ``rad [real]`` |
| 137 | 137 | Radius of source region circle for On/Off analysis (deg) |
| 138 | 138 | |
| 139 | +``width [real]`` | |
| 140 | + Width of source region rectangle for On/Off analysis (deg). | |
| 141 | + | |
| 142 | +``height [real]`` | |
| 143 | + Height of source region rectangle for On/Off analysis (deg). | |
| 144 | + | |
| 145 | +``posang [real]`` | |
| 146 | + Position angle of source region rectangle for On/Off analysis, counted | |
| 147 | + counterclockwise from celestial North (deg). | |
| 148 | + | |
| 139 | 149 | ``(bkgmethod = REFLECTED) [string]`` |
| 140 | 150 | Method for background estimation in On/Off analysis. |
| 141 | 151 | ``REFLECTED:`` background evaluated in regions with the same shape as | ... | ... |
doc/source/users/reference_manual/csphasecrv.rst
| ... | ... | @@ -118,13 +118,23 @@ General parameters |
| 118 | 118 | ``binsz [real]`` |
| 119 | 119 | Pixel size for ``3D`` analysis (in degrees/pixel). |
| 120 | 120 | |
| 121 | -``(srcshape = CIRCLE) [string]`` | |
| 122 | - Shape of the source region for On/Off analysis. | |
| 123 | - ``CIRCLE``: circular region around given position. | |
| 121 | +``srcshape <CIRCLE|RECT> [string]`` | |
| 122 | + Shape of the source region. ``CIRCLE`` defines a circular region around given | |
| 123 | + position, ``RECT`` defines a rectangle centred on a given position. | |
| 124 | 124 | |
| 125 | 125 | ``rad [real]`` |
| 126 | 126 | Radius of source region circle for On/Off analysis (deg) |
| 127 | 127 | |
| 128 | +``width [real]`` | |
| 129 | + Width of source region rectangle for On/Off analysis (deg). | |
| 130 | + | |
| 131 | +``height [real]`` | |
| 132 | + Height of source region rectangle for On/Off analysis (deg). | |
| 133 | + | |
| 134 | +``posang [real]`` | |
| 135 | + Position angle of source region rectangle for On/Off analysis, counted | |
| 136 | + counterclockwise from celestial North (deg). | |
| 137 | + | |
| 128 | 138 | ``(bkgmethod = REFLECTED) [string]`` |
| 129 | 139 | Method for background estimation in On/Off analysis. |
| 130 | 140 | ``REFLECTED:`` background evaluated in regions with the same shape as | ... | ... |
doc/source/users/reference_manual/csscs.rst
| ... | ... | @@ -159,9 +159,19 @@ On/Off parameters |
| 159 | 159 | with the same shape as source region reflected w.r.t. pointing direction for |
| 160 | 160 | each observation. |
| 161 | 161 | |
| 162 | -``(srcshape = CIRCLE) [string]`` | |
| 163 | - Shape of the source region. | |
| 164 | - ``CIRCLE``: circular region around given position. | |
| 162 | +``srcshape <CIRCLE|RECT> [string]`` | |
| 163 | + Shape of the source region. ``CIRCLE`` defines a circular region around given | |
| 164 | + position, ``RECT`` defines a rectangle centred on a given position. | |
| 165 | + | |
| 166 | +``width [real]`` | |
| 167 | + Width of source region rectangle for On/Off analysis (deg). | |
| 168 | + | |
| 169 | +``height [real]`` | |
| 170 | + Height of source region rectangle for On/Off analysis (deg). | |
| 171 | + | |
| 172 | +``posang [real]`` | |
| 173 | + Position angle of source region rectangle for On/Off analysis, counted | |
| 174 | + counterclockwise from celestial North (deg). | |
| 165 | 175 | |
| 166 | 176 | ``(bkgregmin = 2) [integer]`` |
| 167 | 177 | Minimum number of background regions that are required for an | ... | ... |
test/test_cslightcrv.py
| ... | ... | @@ -2,7 +2,7 @@ |
| 2 | 2 | # ========================================================================== |
| 3 | 3 | # This scripts performs unit tests for the cslightcrv script. |
| 4 | 4 | # |
| 5 | -# Copyright (C) 2016-2018 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 |
| ... | ... | @@ -251,6 +251,7 @@ class Test(test): |
| 251 | 251 | lcrv['tmax'] = '2020-01-01T00:05:00' |
| 252 | 252 | lcrv['tbins'] = 2 |
| 253 | 253 | lcrv['method'] = 'ONOFF' |
| 254 | + lcrv['srcshape'] = 'CIRCLE' | |
| 254 | 255 | lcrv['use_model_bkg'] = False # Needed even if WSTAT |
| 255 | 256 | lcrv['emin'] = 1.0 |
| 256 | 257 | lcrv['emax'] = 100.0 | ... | ... |
test/test_csphagen.py
| ... | ... | @@ -88,7 +88,7 @@ class Test(test): |
| 88 | 88 | '" ebinalg="LOG" emin=0.1 emax=100. enumbins=' + \ |
| 89 | 89 | str(self._nbins) + \ |
| 90 | 90 | ' etruemin=0.05 etruemax=150 etruebins=5'+ \ |
| 91 | - ' coordsys="CEL" ra=83.633 dec=22.0145' + \ | |
| 91 | + ' srcshape="CIRCLE" coordsys="CEL" ra=83.633 dec=22.0145' + \ | |
| 92 | 92 | ' rad=0.2 stack="no" inexclusion="' + \ |
| 93 | 93 | self._exclusion + \ |
| 94 | 94 | '" bkgmethod="REFLECTED" '+ \ |
| ... | ... | @@ -111,7 +111,7 @@ class Test(test): |
| 111 | 111 | '" ebinalg="LOG" emin=0.1 emax=100. enumbins=' + \ |
| 112 | 112 | str(self._nbins) + \ |
| 113 | 113 | ' etruemin=0.05 etruemax=150 etruebins=5'+ \ |
| 114 | - ' coordsys="CEL" ra=83.633 dec=22.0145' + \ | |
| 114 | + ' srcshape="CIRCLE" coordsys="CEL" ra=83.633 dec=22.0145' + \ | |
| 115 | 115 | ' rad=0.2 stack="no" inexclusion="' + \ |
| 116 | 116 | self._exclusion + \ |
| 117 | 117 | '" bkgmethod="REFLECTED" '+ \ |
| ... | ... | @@ -143,6 +143,7 @@ class Test(test): |
| 143 | 143 | phagen['emin'] = 0.1 |
| 144 | 144 | phagen['emax'] = 100.0 |
| 145 | 145 | phagen['enumbins'] = self._nbins |
| 146 | + phagen['srcshape'] = 'CIRCLE' | |
| 146 | 147 | phagen['coordsys'] = 'CEL' |
| 147 | 148 | phagen['ra'] = 83.633 |
| 148 | 149 | phagen['dec'] = 22.0145 |
| ... | ... | @@ -176,6 +177,7 @@ class Test(test): |
| 176 | 177 | phagen['emin'] = 0.1 |
| 177 | 178 | phagen['emax'] = 100.0 |
| 178 | 179 | phagen['enumbins'] = self._nbins |
| 180 | + phagen['srcshape'] = 'CIRCLE' | |
| 179 | 181 | phagen['coordsys'] = 'CEL' |
| 180 | 182 | phagen['ra'] = 83.633 |
| 181 | 183 | phagen['dec'] = 22.0145 |
| ... | ... | @@ -215,6 +217,7 @@ class Test(test): |
| 215 | 217 | phagen['emax'] = 100.0 |
| 216 | 218 | phagen['enumbins'] = self._nbins |
| 217 | 219 | phagen['ebingamma'] = 1.0 |
| 220 | + phagen['srcshape'] = 'CIRCLE' | |
| 218 | 221 | phagen['coordsys'] = 'CEL' |
| 219 | 222 | phagen['ra'] = 83.633 |
| 220 | 223 | phagen['dec'] = 22.0145 |
| ... | ... | @@ -247,6 +250,7 @@ class Test(test): |
| 247 | 250 | phagen['emin'] = 0.1 |
| 248 | 251 | phagen['emax'] = 100.0 |
| 249 | 252 | phagen['enumbins'] = self._nbins |
| 253 | + phagen['srcshape'] = 'CIRCLE' | |
| 250 | 254 | phagen['coordsys'] = 'CEL' |
| 251 | 255 | phagen['ra'] = 83.633 |
| 252 | 256 | phagen['dec'] = 22.0145 |
| ... | ... | @@ -346,6 +350,7 @@ class Test(test): |
| 346 | 350 | phagen['emin'] = 0.1 |
| 347 | 351 | phagen['emax'] = 100.0 |
| 348 | 352 | phagen['enumbins'] = self._nbins |
| 353 | + phagen['srcshape'] = 'CIRCLE' | |
| 349 | 354 | phagen['coordsys'] = 'CEL' |
| 350 | 355 | phagen['ra'] = 83.633 |
| 351 | 356 | phagen['dec'] = 22.0145 |
| ... | ... | @@ -372,6 +377,43 @@ class Test(test): |
| 372 | 377 | self._check_output('csphagen_py7', self._nbins, self._nreg_with_excl) |
| 373 | 378 | self._check_outobs('csphagen_py7_obs.xml', 1) |
| 374 | 379 | |
| 380 | + # Test with rectangular region | |
| 381 | + phagen = cscripts.csphagen() | |
| 382 | + phagen['inobs'] = self._myevents1 | |
| 383 | + phagen['inmodel'] = 'NONE' | |
| 384 | + phagen['caldb'] = self._caldb | |
| 385 | + phagen['irf'] = self._irf | |
| 386 | + phagen['ebinalg'] = 'LOG' | |
| 387 | + phagen['emin'] = 0.1 | |
| 388 | + phagen['emax'] = 100.0 | |
| 389 | + phagen['enumbins'] = self._nbins | |
| 390 | + phagen['srcshape'] = 'RECT' | |
| 391 | + phagen['width'] = 0.15 | |
| 392 | + phagen['height'] = 0.25 | |
| 393 | + phagen['posang'] = 45.0 | |
| 394 | + phagen['coordsys'] = 'CEL' | |
| 395 | + phagen['ra'] = 83.633 | |
| 396 | + phagen['dec'] = 22.0145 | |
| 397 | + phagen['rad'] = 0.2 | |
| 398 | + phagen['stack'] = False | |
| 399 | + phagen['inexclusion'] = self._exclusion | |
| 400 | + phagen['bkgmethod'] = 'REFLECTED' | |
| 401 | + phagen['etruemin'] = 0.05 | |
| 402 | + phagen['etruemax'] = 150.0 | |
| 403 | + phagen['etruebins'] = 5 | |
| 404 | + phagen['outobs'] = 'csphagen_py8_obs.xml' | |
| 405 | + phagen['outmodel'] = 'csphagen_py8_model.xml' | |
| 406 | + phagen['prefix'] = 'csphagen_py8' | |
| 407 | + phagen['logfile'] = 'csphagen_py8.log' | |
| 408 | + phagen['chatter'] = 2 | |
| 409 | + | |
| 410 | + # Execute script | |
| 411 | + phagen.execute() | |
| 412 | + | |
| 413 | + # Check output | |
| 414 | + self._check_output('csphagen_py8', self._nbins, self._nreg_with_excl) | |
| 415 | + self._check_outobs('csphagen_py8_obs.xml', 1) | |
| 416 | + | |
| 375 | 417 | # Return |
| 376 | 418 | return |
| 377 | 419 | |
| ... | ... | @@ -393,6 +435,7 @@ class Test(test): |
| 393 | 435 | phagen['emin'] = 0.1 |
| 394 | 436 | phagen['emax'] = 100.0 |
| 395 | 437 | phagen['enumbins'] = self._nbins |
| 438 | + phagen['srcshape'] = 'CIRCLE' | |
| 396 | 439 | phagen['coordsys'] = 'CEL' |
| 397 | 440 | phagen['ra'] = 83.633 |
| 398 | 441 | phagen['dec'] = 22.0145 | ... | ... |
test/test_csphasecrv.py
| ... | ... | @@ -2,7 +2,7 @@ |
| 2 | 2 | # ========================================================================== |
| 3 | 3 | # This scripts performs unit tests for the csphasecrv script. |
| 4 | 4 | # |
| 5 | -# Copyright (C) 2017-2018 Juergen Knoedlseder | |
| 5 | +# Copyright (C) 2017-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 |
| ... | ... | @@ -247,6 +247,7 @@ class Test(test): |
| 247 | 247 | pcrv['phbinalg'] = 'LIN' |
| 248 | 248 | pcrv['phbins'] = 2 |
| 249 | 249 | pcrv['method'] = 'ONOFF' |
| 250 | + pcrv['srcshape'] = 'CIRCLE' | |
| 250 | 251 | pcrv['statistic'] = 'WSTAT' |
| 251 | 252 | pcrv['emin'] = 1.0 |
| 252 | 253 | pcrv['emax'] = 100.0 | ... | ... |
test/test_csscs.py
| ... | ... | @@ -299,8 +299,8 @@ class Test(test): |
| 299 | 299 | script['irf'] = self._irf |
| 300 | 300 | script['inmodel'] = self._model |
| 301 | 301 | script['srcnames'] = 'Crab' |
| 302 | - script['emin'] = 1. | |
| 303 | - script['emax'] = 100. | |
| 302 | + script['emin'] = 1.0 | |
| 303 | + script['emax'] = 100.0 | |
| 304 | 304 | script['nxpix'] = 2 |
| 305 | 305 | script['nypix'] = 2 |
| 306 | 306 | script['binsz'] = 0.1 |
| ... | ... | @@ -310,6 +310,7 @@ class Test(test): |
| 310 | 310 | script['yref'] = 22.01 |
| 311 | 311 | script['rad'] = 0.2 |
| 312 | 312 | script['method'] = 'ONOFF' |
| 313 | + script['srcshape'] = 'CIRCLE' | |
| 313 | 314 | script['inexclusion'] = self._exclusion |
| 314 | 315 | script['enumbins'] = 2 |
| 315 | 316 | script['outfile'] = 'csscs_py6.fits' |
| ... | ... | @@ -330,8 +331,8 @@ class Test(test): |
| 330 | 331 | script['irf'] = self._irf |
| 331 | 332 | script['inmodel'] = self._model |
| 332 | 333 | script['srcnames'] = 'Crab' |
| 333 | - script['emin'] = 1. | |
| 334 | - script['emax'] = 100. | |
| 334 | + script['emin'] = 1.0 | |
| 335 | + script['emax'] = 100.0 | |
| 335 | 336 | script['nxpix'] = 2 |
| 336 | 337 | script['nypix'] = 2 |
| 337 | 338 | script['binsz'] = 0.1 |
| ... | ... | @@ -341,6 +342,7 @@ class Test(test): |
| 341 | 342 | script['yref'] = 22.01 |
| 342 | 343 | script['rad'] = 0.2 |
| 343 | 344 | script['method'] = 'ONOFF' |
| 345 | + script['srcshape'] = 'CIRCLE' | |
| 344 | 346 | script['enumbins'] = 2 |
| 345 | 347 | script['outfile'] = 'csscs_py7.fits' |
| 346 | 348 | script['chatter'] = 2 |
| ... | ... | @@ -375,6 +377,7 @@ class Test(test): |
| 375 | 377 | script['yref'] = 22.01 |
| 376 | 378 | script['rad'] = 0.2 |
| 377 | 379 | script['method'] = 'ONOFF' |
| 380 | + script['srcshape'] = 'CIRCLE' | |
| 378 | 381 | script['use_model_bkg'] = False |
| 379 | 382 | script['inexclusion'] = self._exclusion |
| 380 | 383 | script['enumbins'] = 2 | ... | ... |
test/test_obsutils.py
| ... | ... | @@ -2,7 +2,7 @@ |
| 2 | 2 | # ========================================================================== |
| 3 | 3 | # This scripts performs unit tests for the obsutils module |
| 4 | 4 | # |
| 5 | -# Copyright (C) 2017-2018 Juergen Knoedlseder | |
| 5 | +# Copyright (C) 2017-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 |
| ... | ... | @@ -670,6 +670,7 @@ class Test(test): |
| 670 | 670 | lcrv['tmax'] = '2020-01-01T00:05:00' |
| 671 | 671 | lcrv['tbins'] = 2 |
| 672 | 672 | lcrv['method'] = 'ONOFF' |
| 673 | + lcrv['srcshape'] = 'CIRCLE' | |
| 673 | 674 | lcrv['emin'] = 1.0 |
| 674 | 675 | lcrv['emax'] = 100.0 |
| 675 | 676 | lcrv['enumbins'] = 2 | ... | ... |