Commit 40451b0949df60870ef31bbef575367091ddb5ef

Authored by Jürgen Knödlseder
1 parent 79735dc9

Add "inmodel" and "srcname" parameters to csphagen and use the spatial part of t…

…he source model to compute the ARF (#2292)
cscripts/csphagen.par
... ... @@ -17,6 +17,8 @@
17 17 # Input and output parameters
18 18 #============================
19 19 inobs, f, a, obs.xml,,, "Input event list or observation definition XML file"
  20 +inmodel, f, a, NONE,,, "Input model definition XML file (if NONE, use point source)"
  21 +srcname, s, a, Crab,,, "Source name"
20 22 caldb, s, a, prod2,,, "Calibration database"
21 23 irf, s, a, South_0.5h,,, "Instrument response function"
22 24 inexclusion, f, h, NONE,,, "Sky map of exclusion regions"
... ...
cscripts/csphagen.py
... ... @@ -45,6 +45,7 @@ class csphagen(ctools.csobservation):
45 45 self._ebounds = gammalib.GEbounds()
46 46 self._src_dir = gammalib.GSkyDir()
47 47 self._src_reg = gammalib.GSkyRegions()
  48 + self._src_model = None
48 49 self._bkg_regs = []
49 50 self._excl_reg = None
50 51 self._has_exclusion = False
... ... @@ -123,7 +124,6 @@ class csphagen(ctools.csobservation):
123 124 # Off region region the parameter 'bkgregfile' for all CTA observations
124 125 # without Off region
125 126 for obs in self.obs():
126   - #if obs.instrument() == 'CTA':
127 127 if obs.classname() == 'GCTAObservation':
128 128 if obs.off_regions().is_empty():
129 129 filename = self['bkgregfile'].filename()
... ... @@ -160,6 +160,13 @@ class csphagen(ctools.csobservation):
160 160 # allow counts cube)
161 161 self._setup_observations(self.obs(), True, True, False)
162 162  
  163 + # Get spatial component of source model if an input model is defined
  164 + inmodel = self['inmodel'].filename()
  165 + if not self['inmodel'].is_undefined():
  166 + models = gammalib.GModels(inmodel)
  167 + name = self['srcname'].string()
  168 + self._src_model = models[name].spatial().clone()
  169 +
163 170 # Set energy bounds
164 171 self._ebounds = self._create_ebounds()
165 172  
... ... @@ -167,8 +174,9 @@ class csphagen(ctools.csobservation):
167 174 self._src_reg = gammalib.GSkyRegions()
168 175  
169 176 # Exclusion map
170   - if self['inexclusion'].filename().is_fits():
171   - self._excl_reg = gammalib.GSkyRegionMap(self['inexclusion'].filename())
  177 + if not self['inexclusion'].is_undefined():
  178 + inexclusion = self['inexclusion'].filename()
  179 + self._excl_reg = gammalib.GSkyRegionMap(inexclusion)
172 180 self._has_exclusion = True
173 181 else:
174 182 self._has_exclusion = False
... ... @@ -400,6 +408,10 @@ class csphagen(ctools.csobservation):
400 408 outobs = gammalib.GObservations()
401 409 self._bkg_regs = []
402 410  
  411 + # Set spatial model
  412 + if self._src_model == None:
  413 + self._src_model = gammalib.GModelSpatialPointSource(self._src_dir)
  414 +
403 415 # Loop through observations and generate pha, arf, rmf files
404 416 for obs in self.obs():
405 417  
... ... @@ -420,7 +432,8 @@ class csphagen(ctools.csobservation):
420 432 # If there are background regions then create On/Off observation
421 433 # and append it to the output container
422 434 if bkg_reg.size() >= self['bkgregmin'].integer():
423   - onoff = gammalib.GCTAOnOffObservation(obs, self._src_dir,
  435 + onoff = gammalib.GCTAOnOffObservation(obs,
  436 + self._src_model,
424 437 etrue_ebounds,
425 438 self._ebounds,
426 439 self._src_reg,
... ...
doc/source/users/reference_manual/csphagen.rst
... ... @@ -64,6 +64,14 @@ General parameters
64 64 ``inobs [file]``
65 65 Input event list or observation definition XML file.
66 66  
  67 +``inmodel [file]``
  68 + Input model XML file (if ``NONE`` a point source at the centre of the
  69 + source region is used).
  70 +
  71 +``srcname [string]``
  72 + Name of the source in the source model XML file which should be used
  73 + for ARF computation. Only the spatial part of the model is used.
  74 +
67 75 ``caldb [string]``
68 76 Calibration database.
69 77  
... ...