Commit 4d08028c20bab892937a1ef11ce509a86f7d47ad
1 parent
1aa8b709
Integrate code
Showing
4 changed files
with
14 additions
and
16 deletions
cscripts/csresmap.par
| ... | ... | @@ -43,7 +43,7 @@ yref, r, a, 22.01,-90,90, "Second coordinate of image center in degrees (DE |
| 43 | 43 | nxpix, i, a, 200,,, "Size of the X axis in pixels" |
| 44 | 44 | nypix, i, a, 200,,, "Size of the Y axis in pixels" |
| 45 | 45 | binsz, r, a, 0.02,,, "Pixel size (deg/pixel)" |
| 46 | -algorithm, s, a, SUBDIV,SUB|SUBDIV|SUBDIVSQRT|SIGNIF,, "Residual map computation algorithm" | |
| 46 | +algorithm, s, a, SUBDIV,SUB|SUBDIV|SUBDIVSQRT|SIGNIFICANCE,, "Residual map computation algorithm" | |
| 47 | 47 | |
| 48 | 48 | # |
| 49 | 49 | # Standard parameters | ... | ... |
cscripts/csresmap.py
| ... | ... | @@ -2,7 +2,7 @@ |
| 2 | 2 | # ========================================================================== |
| 3 | 3 | # Generates a residual map. |
| 4 | 4 | # |
| 5 | -# Copyright (C) 2014-2016 Michael Mayer | |
| 5 | +# Copyright (C) 2014-2017 Michael Mayer | |
| 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 |
| ... | ... | @@ -242,11 +242,11 @@ class csresmap(ctools.cscript): |
| 242 | 242 | self._resmap /= modelmap.sqrt() |
| 243 | 243 | |
| 244 | 244 | # Calculate significance from Li&Ma derivation |
| 245 | - elif algorithm == 'SIGNIF': | |
| 245 | + elif algorithm == 'SIGNIFICANCE': | |
| 246 | 246 | signmap = (self._resmap - modelmap).sign() |
| 247 | - logmap = self._resmap/modelmap | |
| 248 | - # Masking pixels with 0 counts. Put a small value >0 for log calculation | |
| 249 | - # and restore the 0. value afterwards | |
| 247 | + logmap = self._resmap/modelmap | |
| 248 | + # Masking pixels with zero counts. Put a small value >0 for log | |
| 249 | + # calculation and restore the zero value afterwards | |
| 250 | 250 | mask = [] |
| 251 | 251 | for i in range(logmap.npix()): |
| 252 | 252 | # Testing pixel i and map 0 (there is one map only after stacking) |
| ... | ... | @@ -256,11 +256,10 @@ class csresmap(ctools.cscript): |
| 256 | 256 | logmap = logmap.log() |
| 257 | 257 | for i in mask: |
| 258 | 258 | logmap[i,0] = 0. |
| 259 | - | |
| 260 | - signif_squared_map = (self._resmap*logmap) + modelmap - self._resmap | |
| 259 | + signif_squared_map = (self._resmap*logmap) + modelmap - self._resmap | |
| 261 | 260 | signif_squared_map *= 2. |
| 262 | - unsigned_resmap = signif_squared_map.sqrt() | |
| 263 | - self._resmap = unsigned_resmap * signmap | |
| 261 | + unsigned_resmap = signif_squared_map.sqrt() | |
| 262 | + self._resmap = unsigned_resmap * signmap | |
| 264 | 263 | |
| 265 | 264 | # Raise exception if algorithm is unknown |
| 266 | 265 | else: | ... | ... |
test/test_csresmap.py
| ... | ... | @@ -2,7 +2,7 @@ |
| 2 | 2 | # ========================================================================== |
| 3 | 3 | # This scripts performs unit tests for the csresmap script. |
| 4 | 4 | # |
| 5 | -# Copyright (C) 2016 Juergen Knoedlseder | |
| 5 | +# Copyright (C) 2016-2017 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 |
| ... | ... | @@ -33,7 +33,7 @@ class Test(test): |
| 33 | 33 | This test class makes unit tests for the csresmap script by using it |
| 34 | 34 | from the command line and from Python. |
| 35 | 35 | """ |
| 36 | - | |
| 36 | + | |
| 37 | 37 | # Constructor |
| 38 | 38 | def __init__(self): |
| 39 | 39 | """ |
| ... | ... | @@ -165,7 +165,6 @@ class Test(test): |
| 165 | 165 | # Check pull distribution file |
| 166 | 166 | self._check_result_file('csresmap_py2.fits', nx=200, ny=200) |
| 167 | 167 | |
| 168 | - | |
| 169 | 168 | # Run csresmap with SUBDIVSQRT algorithm |
| 170 | 169 | resmap = cscripts.csresmap() |
| 171 | 170 | resmap['inobs'] = self._cntcube |
| ... | ... | @@ -189,7 +188,7 @@ class Test(test): |
| 189 | 188 | # Check pull distribution file |
| 190 | 189 | self._check_result_file('csresmap_py3.fits', nx=200, ny=200) |
| 191 | 190 | |
| 192 | - # Run csresmap with SIGNIF algorithm | |
| 191 | + # Run csresmap with SIGNIFICANCE algorithm | |
| 193 | 192 | resmap = cscripts.csresmap() |
| 194 | 193 | resmap['inobs'] = self._cntcube |
| 195 | 194 | resmap['modcube'] = 'NONE' |
| ... | ... | @@ -201,7 +200,7 @@ class Test(test): |
| 201 | 200 | resmap['irf'] = self._irf |
| 202 | 201 | resmap['inmodel'] = self._model |
| 203 | 202 | resmap['outmap'] = 'csresmap_py4.fits' |
| 204 | - resmap['algorithm'] = 'SIGNIF' | |
| 203 | + resmap['algorithm'] = 'SIGNIFICANCE' | |
| 205 | 204 | resmap['logfile'] = 'csresmap_py4.log' |
| 206 | 205 | resmap['chatter'] = 3 |
| 207 | 206 | resmap['publish'] = True | ... | ... |
test/test_python_ctools.py