31 Shows the content of an observation container
40 self._init_csobservation(self.__class__.__name__, ctools.__version__, argv)
51 self.
_gti = gammalib.GGti()
60 Get parameters from parfile and setup the observation
63 if self.obs().size() == 0:
64 self._require_inobs(
'csobsinfo::get_parameters')
65 self.obs(self._get_observations(
False))
73 ra = self[
'ra'].real()
74 dec = self[
'dec'].real()
75 self._obj_dir.radec_deg(ra,dec)
78 if self._read_ahead():
79 self[
'outds9file'].query()
82 self._log_parameters(gammalib.TERSE)
104 self.
_gti = gammalib.GGti()
118 self._log.header1(gammalib.number(
'Observation', self.obs().size()))
121 for obs
in self.obs():
124 if not obs.classname() ==
'GCTAObservation':
125 self._log(
'Skipping '+obs.instrument()+
' observation\n')
129 obs_name = obs.name()
131 obs_name = obs.object()
134 if self._logExplicit():
137 log_name = obs_name +
' (ID='+obs_id+
')'
140 self._log.header2(log_name)
143 obs_names.append(obs_name)
146 obs_bounds = obs.events().
ebounds()
149 obs_gti = obs.events().
gti()
152 deadfrac = (1.0-obs.deadc())*100.0
155 pnt_dir = obs.pointing().dir()
156 self._pnt_ra.append(pnt_dir.ra_deg())
157 self._pnt_dec.append(pnt_dir.dec_deg())
160 if obs_bounds.size() > 0 :
161 self._ebounds.append(obs_bounds.emin(),obs_bounds.emax())
164 self._gti.append(obs_gti.tstart(), obs_gti.tstop())
167 ontime += obs.ontime()
168 livetime += obs.livetime()
171 if obs.eventtype() ==
'CountsCube':
172 n_eventbins += obs.events().size()
175 is_what =
'Number of bins'
177 n_events += obs.events().size()
180 is_what =
'Number of events'
181 self._log_value(gammalib.EXPLICIT,
'Binned', is_binned)
182 self._log_value(gammalib.EXPLICIT, is_what, obs.events().size())
185 zenith = obs.pointing().zenith()
186 azimuth = obs.pointing().azimuth()
187 self._zeniths.append(zenith)
188 self._azimuths.append(azimuth)
192 offset = pnt_dir.dist_deg(self.
_obj_dir)
193 self._offsets.append(offset)
196 if self._logExplicit():
199 self._log.parformat(
'Energy range')
200 if obs_bounds.size() == 0:
201 self._log(
'undefined')
203 self._log(str(obs_bounds.emin()))
205 self._log(str(obs_bounds.emax()))
209 self._log.parformat(
'Time range (MJD)')
210 if obs_gti.size() == 0:
211 self._log(
'undefined')
213 self._log(str(obs_gti.tstart().mjd()))
215 self._log(str(obs_gti.tstop().mjd()))
219 self._log_value(gammalib.EXPLICIT,
'Ontime',
'%.3f s' %
221 self._log_value(gammalib.EXPLICIT,
'Livetime',
'%.3f s' %
223 self._log_value(gammalib.EXPLICIT,
'Deadtime fraction',
'%.3f %%' %
225 self._log_value(gammalib.EXPLICIT,
'Pointing', pnt_dir)
229 self._log_value(gammalib.EXPLICIT,
230 'Offset from target',
'%.2f deg' % offset)
233 self._log_value(gammalib.EXPLICIT,
'Zenith angle',
'%.2f deg' %
235 self._log_value(gammalib.EXPLICIT,
'Azimuth angle',
'%.2f deg' %
239 self._log_header1(gammalib.NORMAL,
'Summary')
242 self._log_header3(gammalib.NORMAL,
'Observations')
243 self._log_value(gammalib.NORMAL,
'Unbinned observations', n_obs_unbinned)
244 self._log_value(gammalib.NORMAL,
'Binned observations', n_obs_binned)
245 self._log_header3(gammalib.NORMAL,
'Events')
246 self._log_value(gammalib.NORMAL,
'Number of events', n_events)
247 self._log_value(gammalib.NORMAL,
'Number of bins', n_eventbins)
253 mean_offset =
'Unknown'
257 mean_zenith =
'Unknown'
261 mean_azimuth =
'Unknown'
264 self._log_header3(gammalib.NORMAL,
'Pointings')
265 self._log_value(gammalib.NORMAL,
'Mean offset angle', mean_offset)
266 self._log_value(gammalib.NORMAL,
'Mean zenith angle', mean_zenith)
267 self._log_value(gammalib.NORMAL,
'Mean azimuth angle', mean_azimuth)
273 if sys.version_info >= (2,4):
274 obs_set = set(obs_names)
276 self._log_value(gammalib.EXPLICIT,
'"'+name+
'"',
277 obs_names.count(name))
280 if self._ebounds.size() == 0:
281 min_value =
'undefined'
282 max_value =
'undefined'
284 min_value = str(self._ebounds.emin())
285 max_value = str(self._ebounds.emax())
288 self._log_header3(gammalib.NORMAL,
'Energy range')
289 self._log_value(gammalib.NORMAL,
'Minimum energy', min_value)
290 self._log_value(gammalib.NORMAL,
'Maximum energy', max_value)
293 mjd =
'%.3f - %.3f' % (self._gti.tstart().mjd(), self._gti.tstop().mjd())
294 utc =
'%s - %s' % (self._gti.tstart().utc(), self._gti.tstop().utc())
295 self._log_header3(gammalib.NORMAL,
'Time range')
296 self._log_value(gammalib.NORMAL,
'MJD (days)', mjd)
297 self._log_value(gammalib.NORMAL,
'UTC', utc)
300 on_time =
'%.2f s = %.2f min = %.2f h' % \
301 (ontime, ontime/60., ontime/3600.)
302 live_time =
'%.2f s = %.2f min = %.2f h' % \
303 (livetime, livetime/60., livetime/3600.)
304 self._log_value(gammalib.NORMAL,
'Total ontime', on_time)
305 self._log_value(gammalib.NORMAL,
'Total livetime', live_time)
312 Save pointings into DS9 region file
314 This method saves all pointing directions that are found in the
315 observation container into a DS9 region file. If "NONE" is
316 specified for the "outds9file" parameter the method does nothing.
319 if self[
'outds9file'].is_valid():
322 ds9file = self[
'outds9file'].filename()
325 self._log_header1(gammalib.TERSE,
'Save pointings in DS9 file')
328 self._log_value(gammalib.NORMAL,
'DS9 filename', ds9file.url())
331 f = open(ds9file.url(),
'w')
337 for i
in range(len(self.
_pnt_ra)):
342 line +=
' # point=cross 20 width=3\n'
361 Return azimuth angles
367 Return pointings right ascension
373 Return pointings declination
385 Return energy boundaries
391 Return good time intervals
399 if __name__ ==
'__main__':