Commit d32a48de686a3005245dc19948c2eed8c6ff2289
1 parent
10e2ae51
Add coordsys, proj and binsz parameters to comobsres script
Showing
4 changed files
with
39 additions
and
7 deletions
doc/source/users/reference_manual/comobsres.rst
| ... | ... | @@ -36,10 +36,19 @@ General parameters |
| 36 | 36 | ``(armmax = 3.0) [real]`` |
| 37 | 37 | Maximum ARM (deg). |
| 38 | 38 | |
| 39 | +``coordsys <CEL|GAL> [string]`` | |
| 40 | + Coordinate system (CEL - celestial, GAL - galactic). | |
| 41 | + | |
| 42 | +``proj <AIT|AZP|CAR|GLS|MOL|SFL|SIN|STG|TAN> [string]`` | |
| 43 | + Projection method. | |
| 44 | + | |
| 39 | 45 | ``(margin = 30.0) [real]`` |
| 40 | 46 | Sky map margin (deg). This margin is added to the data cube size so that |
| 41 | 47 | also source positions outside the range spanned by the data cube are considered. |
| 42 | 48 | |
| 49 | +``(binsz = 1.0) [real]`` | |
| 50 | + Sky map bin size (deg). | |
| 51 | + | |
| 43 | 52 | ``(grouping = 1) [integer]`` |
| 44 | 53 | Number of Chi/Psi bins to group for residual computation. |
| 45 | 54 | ... | ... |
modules/comscripts/comobsres.par
| ... | ... | @@ -27,7 +27,10 @@ outmap, f, a, resmap.fits,,,"Output residual map" |
| 27 | 27 | algorithm, s, a, SIGNIFICANCE,SUB|SUBDIV|SUBDIVSQRT|SIGNIFICANCE,, "Residual map computation algorithm" |
| 28 | 28 | armmin, r, h, -3.0,,, "Minimum ARM (deg)" |
| 29 | 29 | armmax, r, h, 3.0,,, "Maximum ARM (deg)" |
| 30 | +coordsys, s, a, GAL,CEL|GAL,,"Coordinate system (CEL - celestial, GAL - galactic)" | |
| 31 | +proj, s, a, TAN,AIT|AZP|CAR|GLS|MOL|SFL|SIN|STG|TAN,, "Projection method" | |
| 30 | 32 | margin, r, h, 30.0,,, "Sky map margin (deg)" |
| 33 | +binsz, r, h, 1.0,0.1,10.0, "Bin size (deg)" | |
| 31 | 34 | grouping, i, h, 1,1,80, "Number of Chi/Psi bins to group for residual computation" |
| 32 | 35 | dri, b, h, no,,, "Compute DRI residuals?" |
| 33 | 36 | png, b, h, no,,, "Generate residual histogram png files?" | ... | ... |
modules/comscripts/comobsres.py
| ... | ... | @@ -145,7 +145,10 @@ class comobsres(ctools.csobservation): |
| 145 | 145 | self['algorithm'].string() |
| 146 | 146 | self['armmin'].real() |
| 147 | 147 | self['armmax'].real() |
| 148 | + self['coordsys'].string() | |
| 149 | + self['proj'].string() | |
| 148 | 150 | self['margin'].real() |
| 151 | + self['binsz'].real() | |
| 149 | 152 | |
| 150 | 153 | # Query PNG parameters |
| 151 | 154 | if self['png'].boolean(): |
| ... | ... | @@ -187,6 +190,11 @@ class comobsres(ctools.csobservation): |
| 187 | 190 | glat_min = None |
| 188 | 191 | glat_max = None |
| 189 | 192 | |
| 193 | + # Get parameters | |
| 194 | + proj = self['proj'].string() | |
| 195 | + coordsys = self['coordsys'].string() | |
| 196 | + binsz = self['binsz'].real() | |
| 197 | + | |
| 190 | 198 | # Loop over all input observations |
| 191 | 199 | for obs in inobs: |
| 192 | 200 | |
| ... | ... | @@ -243,15 +251,22 @@ class comobsres(ctools.csobservation): |
| 243 | 251 | # Compute width and number of pixels |
| 244 | 252 | glon_width = glon_max - glon_min |
| 245 | 253 | glat_width = glat_max - glat_min |
| 246 | - nx = int(glon_width+0.5) | |
| 247 | - ny = int(glat_width+0.5) | |
| 254 | + nx = int(glon_width/binsz+0.5) | |
| 255 | + ny = int(glat_width/binsz+0.5) | |
| 248 | 256 | if nx > 360: |
| 249 | 257 | nx = 360 |
| 250 | 258 | if ny > 180: |
| 251 | 259 | ny = 180 |
| 252 | 260 | |
| 261 | + # Translate to celestial coordinates if requested | |
| 262 | + if coordsys == 'CEL': | |
| 263 | + centre = gammalib.GSkyDir() | |
| 264 | + centre.lb_deg(glon, glat) | |
| 265 | + glon = centre.ra_deg() | |
| 266 | + glat = centre.dec_deg() | |
| 267 | + | |
| 253 | 268 | # Allocate map |
| 254 | - map = gammalib.GSkyMap('TAN', 'GAL', glon, glat, -1.0, 1.0, nx, ny) | |
| 269 | + map = gammalib.GSkyMap(proj, coordsys, glon, glat, -binsz, binsz, nx, ny) | |
| 255 | 270 | |
| 256 | 271 | # Return map |
| 257 | 272 | return map | ... | ... |
test/test_comobsres.py
| ... | ... | @@ -2,7 +2,7 @@ |
| 2 | 2 | # ========================================================================== |
| 3 | 3 | # This scripts performs unit tests for the comobsres script. |
| 4 | 4 | # |
| 5 | -# Copyright (C) 2021 Juergen Knoedlseder | |
| 5 | +# Copyright (C) 2021-2022 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 |
| ... | ... | @@ -75,7 +75,8 @@ class Test(test): |
| 75 | 75 | |
| 76 | 76 | # Setup command |
| 77 | 77 | cmd = comobsres+' inobs="'+self._obs+'" inmodel="'+self._model+'" '+ \ |
| 78 | - 'algorithm="SIGNIFICANCE" margin="0.0" '+ \ | |
| 78 | + 'algorithm="SIGNIFICANCE" margin="0.0" binsz="5.0" '+ \ | |
| 79 | + 'coordsys="GAL" proj="TAN" '+ \ | |
| 79 | 80 | 'outfolder="comobsres_cmd1" outmap="comobsres_cmd1.fits" '+ \ |
| 80 | 81 | 'logfile="comobsres_cmd1.log" chatter=1' |
| 81 | 82 | |
| ... | ... | @@ -88,7 +89,8 @@ class Test(test): |
| 88 | 89 | |
| 89 | 90 | # Setup command |
| 90 | 91 | cmd = comobsres+' inobs="file_that_does_not_exist.xml" inmodel="'+self._model+'" '+ \ |
| 91 | - 'algorithm="SIGNIFICANCE" margin="0.0" '+ \ | |
| 92 | + 'algorithm="SIGNIFICANCE" margin="0.0" binsz="5.0" '+ \ | |
| 93 | + 'coordsys="GAL" proj="TAN" '+ \ | |
| 92 | 94 | 'outfolder="comobsres_cmd2" outmap="comobsres_cmd2.fits" '+ \ |
| 93 | 95 | 'logfile="comobsres_cmd2.log" chatter=1' |
| 94 | 96 | |
| ... | ... | @@ -112,7 +114,10 @@ class Test(test): |
| 112 | 114 | add['inobs'] = self._obs |
| 113 | 115 | add['inmodel'] = self._model |
| 114 | 116 | add['algorithm'] = 'SIGNIFICANCE' |
| 117 | + add['coordsys'] = 'GAL' | |
| 118 | + add['proj'] = 'TAN' | |
| 115 | 119 | add['margin'] = 0.0 |
| 120 | + add['binsz'] = 5.0 | |
| 116 | 121 | add['outfolder'] = 'comobsres_py1' |
| 117 | 122 | add['outmap'] = 'comobsres_py1.fits' |
| 118 | 123 | add['logfile'] = 'comobsres_py1.log' |
| ... | ... | @@ -138,7 +143,7 @@ class Test(test): |
| 138 | 143 | map = gammalib.GSkyMap(filename) |
| 139 | 144 | |
| 140 | 145 | # Check that there is one observation |
| 141 | - self.test_value(map.npix(), 3025, 'Check for number of pixels in sky map') | |
| 146 | + self.test_value(map.npix(), 121, 'Check for number of pixels in sky map') | |
| 142 | 147 | |
| 143 | 148 | # Return |
| 144 | 149 | return | ... | ... |