168 Invalid pointing definition file format
174 self._log_header1(gammalib.TERSE,
175 'Creating observation definition XML file')
180 self.
_pntdef = gammalib.GCsv(self[
'inpnt'].filename(),
',')
186 raise RuntimeError(
'No header found in pointing definition file.')
197 for col
in range(ncols):
198 header.append(self.
_pntdef[0,col])
201 for pnt
in range(npnt):
207 obs = gammalib.GCTAObservation()
210 if 'instrument' in header:
211 instrument = self.
_pntdef[row, header.index(
'instrument')]
213 instrument = self[
'instrument'].string()
214 instrument = gammalib.toupper(instrument)
215 obs.instrument(instrument)
220 name = self.
_pntdef[row, header.index(
'name')]
222 name = self[
'name'].string()
228 obsid = self.
_pntdef[row, header.index(
'id')]
230 obsid =
'%6.6d' % identifier
236 if 'ra' in header
and 'dec' in header:
237 ra = float(self.
_pntdef[row, header.index(
'ra')])
238 dec = float(self.
_pntdef[row, header.index(
'dec')])
239 pntdir = gammalib.GSkyDir()
240 pntdir.radec_deg(ra,dec)
241 elif 'lon' in header
and 'lat' in header:
242 lon = float(self.
_pntdef[row, header.index(
'lon')])
243 lat = float(self.
_pntdef[row, header.index(
'lat')])
244 pntdir = gammalib.GSkyDir()
245 pntdir.lb_deg(lon,lat)
247 raise RuntimeError(
'No (ra,dec) or (lon,lat) columns '
248 'found in pointing definition file.')
249 obs.pointing(gammalib.GCTAPointing(pntdir))
253 if 'caldb' in header:
254 caldb = self.
_pntdef[row, header.index(
'caldb')]
256 caldb = self[
'caldb'].string()
258 irf = self.
_pntdef[row, header.index(
'irf')]
260 irf = self[
'irf'].string()
261 if caldb !=
'' and irf !=
'':
262 obs = self.
_set_irf(obs, caldb, irf)
266 if 'deadc' in header:
267 deadc = float(self.
_pntdef[row, header.index(
'deadc')])
269 deadc = self[
'deadc'].real()
275 self.
_tmin = float(self.
_pntdef[row, header.index(
'tmin')])
276 if 'duration' in header:
277 duration = float(self.
_pntdef[row, header.index(
'duration')])
279 duration = self[
'duration'].real()
280 tref = gammalib.GTimeReference(self[
'mjdref'].real(),
's')
282 tmax = self.
_tmin + duration
283 gti = gammalib.GGti(tref)
284 tstart = gammalib.GTime(tmin, tref)
285 tstop = gammalib.GTime(tmax, tref)
287 gti.append(tstart, tstop)
288 obs.ontime(gti.ontime())
289 obs.livetime(gti.ontime()*deadc)
297 emin = float(self.
_pntdef[row, header.index(
'emin')])
300 if self[
'emin'].is_valid():
301 emin = self[
'emin'].real()
304 emax = float(self.
_pntdef[row, header.index(
'emax')])
307 if self[
'emax'].is_valid():
308 emax = self[
'emax'].real()
310 has_ebounds = has_emin
and has_emax
312 ebounds = gammalib.GEbounds(gammalib.GEnergy(emin,
'TeV'),
313 gammalib.GEnergy(emax,
'TeV'))
319 rad = float(self.
_pntdef[row, header.index(
'rad')])
322 if self[
'rad'].is_valid():
323 rad = self[
'rad'].real()
326 roi = gammalib.GCTARoi(gammalib.GCTAInstDir(pntdir), rad)
329 event_list = gammalib.GCTAEventList()
334 event_list.ebounds(ebounds)
339 obs.events(event_list)
342 name = obs.instrument()+
' observation'
343 value =
'Name="%s" ID="%s"' % (obs.name(), obs.id())
344 self._log_value(gammalib.NORMAL, name, value)
345 self._log_string(gammalib.EXPLICIT, str(obs)+
'\n')
348 self.
_obs.append(obs)