Commit e6b2bde1cd11cae7470166b34fc20b562bf7c755
1 parent
c350f32b
Avoid /= operator (is problematic in Python 3.x; no clue whether this is a SWIG …
…problem or a Python problem).
Showing
1 changed file
with
14 additions
and
7 deletions
scripts/csresmap.py
| @@ -23,6 +23,7 @@ import gammalib | @@ -23,6 +23,7 @@ import gammalib | ||
| 23 | import sys | 23 | import sys |
| 24 | import tempfile | 24 | import tempfile |
| 25 | import os | 25 | import os |
| 26 | +import math | ||
| 26 | 27 | ||
| 27 | 28 | ||
| 28 | # ============== # | 29 | # ============== # |
| @@ -163,11 +164,9 @@ class csresmap(gammalib.GApplication): | @@ -163,11 +164,9 @@ class csresmap(gammalib.GApplication): | ||
| 163 | # meaningful residual map | 164 | # meaningful residual map |
| 164 | if self.obs.models().size() == 0: | 165 | if self.obs.models().size() == 0: |
| 165 | self.obs.models(self["srcmdl"].filename()) | 166 | self.obs.models(self["srcmdl"].filename()) |
| 166 | - self.m_outfile = self["outfile"].filename() | ||
| 167 | - | ||
| 168 | - self.m_modfile = self["modfile"].filename() | ||
| 169 | - self.m_binfile = self["binfile"].filename() | ||
| 170 | - | 167 | + self.m_outfile = self["outfile"].filename() |
| 168 | + self.m_modfile = self["modfile"].filename() | ||
| 169 | + self.m_binfile = self["binfile"].filename() | ||
| 171 | self.m_xref = self["xref"].real() | 170 | self.m_xref = self["xref"].real() |
| 172 | self.m_yref = self["yref"].real() | 171 | self.m_yref = self["yref"].real() |
| 173 | self.m_emin = self["emin"].real() | 172 | self.m_emin = self["emin"].real() |
| @@ -292,13 +291,21 @@ class csresmap(gammalib.GApplication): | @@ -292,13 +291,21 @@ class csresmap(gammalib.GApplication): | ||
| 292 | 291 | ||
| 293 | # Subtract and divide by model map | 292 | # Subtract and divide by model map |
| 294 | self.resmap -= modelmap | 293 | self.resmap -= modelmap |
| 295 | - self.resmap /= modelmap | 294 | + #self.resmap /= modelmap # Python 3.x does not like this !!! |
| 295 | + for pixel in modelmap: | ||
| 296 | + if pixel != 0.0: | ||
| 297 | + pixel = 1.0/pixel | ||
| 298 | + self.resmap *= modelmap | ||
| 296 | 299 | ||
| 297 | elif self.m_algorithm == "SUBDIVSQRT": | 300 | elif self.m_algorithm == "SUBDIVSQRT": |
| 298 | 301 | ||
| 299 | # subtract and divide by sqrt of model map | 302 | # subtract and divide by sqrt of model map |
| 300 | self.resmap -= modelmap | 303 | self.resmap -= modelmap |
| 301 | - self.resmap /= modelmap.sqrt() | 304 | + #self.resmap /= modelmap.sqrt() # Python 3.x does not like this !!! |
| 305 | + for pixel in modelmap: | ||
| 306 | + if pixel != 0.0: | ||
| 307 | + pixel = 1.0/math.sqrt(pixel) | ||
| 308 | + self.resmap *= modelmap | ||
| 302 | 309 | ||
| 303 | else: | 310 | else: |
| 304 | 311 |