Commit d50752972686875ea4dca06db805af8de1fd2c9f
1 parent
c32709b1
Add maps for parameter uncertainties and prefix extension with source names
Showing
2 changed files
with
17 additions
and
7 deletions
modules/comscripts/comlixmap.par
... | ... | @@ -18,6 +18,7 @@ |
18 | 18 | #============================ |
19 | 19 | inobs, f, a, obs.xml,,, "Input observation definition file" |
20 | 20 | inmodel, f, a, models.xml,,, "Input model definition file" |
21 | +inmap, f, h, NONE,,, "Input Test Statistic map file" | |
21 | 22 | srcname, s, a, Crab,,, "Test source name" |
22 | 23 | outmap, f, a, tsmap.fits,,, "Output Test Statistic map file" |
23 | 24 | ... | ... |
modules/comscripts/comlixmap.py
... | ... | @@ -39,6 +39,7 @@ class comlixmap(ctools.cslikelihood): |
39 | 39 | self._init_cslikelihood(self.__class__.__name__, ctools.__version__, argv) |
40 | 40 | |
41 | 41 | # Initialise members |
42 | + self._inmap = None | |
42 | 43 | self._maps = [] |
43 | 44 | self._map_names = [] |
44 | 45 | self._srcnames = [] |
... | ... | @@ -66,6 +67,10 @@ class comlixmap(ctools.cslikelihood): |
66 | 67 | msg = 'Source "%s" not found in models.' % srcname |
67 | 68 | raise RuntimeError(msg) |
68 | 69 | |
70 | + # Get optional input TS map filename | |
71 | + if self['inmap'].is_valid(): | |
72 | + self._inmap = self['inmap'].filename() | |
73 | + | |
69 | 74 | # Query parameters |
70 | 75 | self['like_accuracy'].real() |
71 | 76 | self['max_iter'].integer() |
... | ... | @@ -177,18 +182,21 @@ class comlixmap(ctools.cslikelihood): |
177 | 182 | nfree = 0 |
178 | 183 | |
179 | 184 | # Compute number of free model parameters for all test sources, |
180 | - # excluding 'RA', 'DEC', 'GLON' and 'GLAT' | |
185 | + # excluding 'RA', 'DEC', 'GLON' and 'GLAT' and add map names | |
186 | + # composed of 'srcname_parname_val' and 'srcname_parname_unc' | |
187 | + # for values and uncertainties | |
181 | 188 | for srcname in self._srcnames: |
182 | 189 | source = self.obs().models()[srcname] |
183 | 190 | for par in source: |
184 | 191 | if par.name() != 'RA' and par.name() != 'DEC' and \ |
185 | 192 | par.name() != 'GLON' and par.name() != 'GLAT' and \ |
186 | 193 | par.is_free(): |
187 | - self._map_names.append(par.name()) | |
194 | + self._map_names.append('%s_%s_val' % (srcname, par.name())) | |
195 | + self._map_names.append('%s_%s_unc' % (srcname, par.name())) | |
188 | 196 | nfree += 1 |
189 | 197 | |
190 | 198 | # Initialise sky maps |
191 | - for i in range(nfree+len(self._srcnames)): | |
199 | + for i in range(2*nfree+len(self._srcnames)): | |
192 | 200 | self._maps.append(gammalib.GSkyMap(proj, coordsys, xref, yref, |
193 | 201 | -binsz, binsz, nxpix, nypix)) |
194 | 202 | |
... | ... | @@ -416,16 +424,17 @@ class comlixmap(ctools.cslikelihood): |
416 | 424 | for i, value in enumerate(ts): |
417 | 425 | self._maps[i][ipix] = value |
418 | 426 | |
419 | - # Store fitted model parameters in sky maps | |
420 | - ipar = len(ts) | |
427 | + # Store fitted model parameters and uncertainties in sky maps | |
428 | + ipar = len(ts) | |
421 | 429 | for srcname in self._srcnames: |
422 | 430 | source = self.obs().models()[srcname] |
423 | 431 | for par in source: |
424 | 432 | if par.name() != 'RA' and par.name() != 'DEC' and \ |
425 | 433 | par.name() != 'GLON' and par.name() != 'GLAT' and \ |
426 | 434 | par.is_free(): |
427 | - self._maps[ipar][ipix] = par.value() | |
428 | - ipar += 1 | |
435 | + self._maps[ipar][ipix] = par.value() | |
436 | + self._maps[ipar+1][ipix] = par.error() | |
437 | + ipar += 2 | |
429 | 438 | |
430 | 439 | # Return |
431 | 440 | return | ... | ... |