Commit 2d5f1b3070997a9330f499ea0e13af49e212ccad
Merge branch '2118-csresmap-ebinalg-file' into integration
Showing
1 changed file
with
22 additions
and
24 deletions
cscripts/csresmap.py
| ... | ... | @@ -34,7 +34,7 @@ class csresmap(ctools.cscript): |
| 34 | 34 | # Constructor |
| 35 | 35 | def __init__(self, *argv): |
| 36 | 36 | """ |
| 37 | - Constructor. | |
| 37 | + Constructor | |
| 38 | 38 | """ |
| 39 | 39 | # Set name |
| 40 | 40 | self._name = 'csresmap' |
| ... | ... | @@ -107,16 +107,19 @@ class csresmap(ctools.cscript): |
| 107 | 107 | if not self._skip_binning: |
| 108 | 108 | self['xref'].real() |
| 109 | 109 | self['yref'].real() |
| 110 | - self['emin'].real() | |
| 111 | - self['emax'].real() | |
| 112 | - self['enumbins'].integer() | |
| 113 | - self['ebinalg'].string() | |
| 114 | 110 | self['coordsys'].string() |
| 115 | 111 | self['proj'].string() |
| 116 | 112 | self['nxpix'].integer() |
| 117 | 113 | self['nypix'].integer() |
| 118 | 114 | self['binsz'].real() |
| 119 | - | |
| 115 | + self['ebinalg'].string() | |
| 116 | + if self['ebinalg'].string() == 'FILE': | |
| 117 | + self['ebinfile'].filename() | |
| 118 | + else: | |
| 119 | + self['emin'].real() | |
| 120 | + self['emax'].real() | |
| 121 | + self['enumbins'].integer() | |
| 122 | + | |
| 120 | 123 | # Query parameters |
| 121 | 124 | self['edisp'].boolean() |
| 122 | 125 | self['algorithm'].string() |
| ... | ... | @@ -149,11 +152,7 @@ class csresmap(ctools.cscript): |
| 149 | 152 | self._get_parameters() |
| 150 | 153 | |
| 151 | 154 | # Write observation into logger |
| 152 | - if self._logTerse(): | |
| 153 | - self._log('\n') | |
| 154 | - self._log.header1(gammalib.number('Observation',len(self._obs))) | |
| 155 | - self._log(str(self._obs)) | |
| 156 | - self._log('\n') | |
| 155 | + self._log_observations(gammalib.NORMAL, self._obs, 'Observation') | |
| 157 | 156 | |
| 158 | 157 | # If a counts and model cube are specified then load them as sky map |
| 159 | 158 | if self._use_maps: |
| ... | ... | @@ -172,23 +171,24 @@ class csresmap(ctools.cscript): |
| 172 | 171 | else: |
| 173 | 172 | |
| 174 | 173 | # Write header |
| 175 | - if self._logTerse(): | |
| 176 | - self._log('\n') | |
| 177 | - self._log.header1('Generate binned map (ctbin)') | |
| 174 | + self._log_header1(gammalib.TERSE, 'Generate binned map (ctbin)') | |
| 178 | 175 | |
| 179 | 176 | # Create countsmap |
| 180 | 177 | bin = ctools.ctbin(self._obs) |
| 181 | - bin['nxpix'] = self['nxpix'].integer() | |
| 182 | - bin['nypix'] = self['nypix'].integer() | |
| 183 | - bin['proj'] = self['proj'].string() | |
| 184 | - bin['coordsys'] = self['coordsys'].string() | |
| 185 | 178 | bin['xref'] = self['xref'].real() |
| 186 | 179 | bin['yref'] = self['yref'].real() |
| 187 | - bin['enumbins'] = self['enumbins'].integer() | |
| 180 | + bin['proj'] = self['proj'].string() | |
| 181 | + bin['coordsys'] = self['coordsys'].string() | |
| 188 | 182 | bin['ebinalg'] = self['ebinalg'].string() |
| 189 | - bin['emin'] = self['emin'].real() | |
| 190 | - bin['emax'] = self['emax'].real() | |
| 183 | + bin['nxpix'] = self['nxpix'].integer() | |
| 184 | + bin['nypix'] = self['nypix'].integer() | |
| 191 | 185 | bin['binsz'] = self['binsz'].real() |
| 186 | + if self['ebinalg'].string() == "FILE": | |
| 187 | + bin['ebinfile'] = self['ebinfile'].filename().file() | |
| 188 | + else: | |
| 189 | + bin['enumbins'] = self['enumbins'].integer() | |
| 190 | + bin['emin'] = self['emin'].real() | |
| 191 | + bin['emax'] = self['emax'].real() | |
| 192 | 192 | bin['chatter'] = self['chatter'].integer() |
| 193 | 193 | bin['clobber'] = self['clobber'].boolean() |
| 194 | 194 | bin['debug'] = self['debug'].boolean() |
| ... | ... | @@ -201,9 +201,7 @@ class csresmap(ctools.cscript): |
| 201 | 201 | countmap = cta_counts_cube.counts() |
| 202 | 202 | |
| 203 | 203 | # Write header |
| 204 | - if self._logTerse(): | |
| 205 | - self._log('\n') | |
| 206 | - self._log.header1('Generate model map (ctmodel)') | |
| 204 | + self._log_header1(gammalib.TERSE, 'Generate model map (ctmodel)') | |
| 207 | 205 | |
| 208 | 206 | # Create model map |
| 209 | 207 | model = ctools.ctmodel(self._obs) | ... | ... |