Commit 4380d4e282f19b053e03254bf8bac0d8059c333c

Authored by Jürgen Knödlseder
1 parent 3f095bf7

Adapt to revised GTime operators.

ChangeLog
1   -2016-02-24 Juergen Knoedlseder <jurgen.knodlseder@irap.omp.eu>
  1 +2016-02-25 Juergen Knoedlseder <jurgen.knodlseder@irap.omp.eu>
2 2  
3 3 * Version 1.1.0 released
4 4 ========================
5 5  
  6 + Adapt to revise GTime operators (#1714)
6 7 Add publish() methods to tools producing images (#1710)
7 8 Read ahead output filename in cterror (#1700)
8 9 Subdivide simulation energy range in ctobssim (#1673)
... ...
... ... @@ -2,7 +2,7 @@ New Features and Important Changes in ctools 1.1.0
2 2  
3 3 Author(s) : Juergen Knoedlseder
4 4  
5   -24 February 2016
  5 +25 February 2016
6 6  
7 7  
8 8 1. Introduction
... ...
cscripts/cslightcrv.py
... ... @@ -2,7 +2,7 @@
2 2 # ==========================================================================
3 3 # Light curve generation script.
4 4 #
5   -# Copyright (C) 2014-2015 Michael Mayer
  5 +# Copyright (C) 2014-2016 Michael Mayer
6 6 #
7 7 # This program is free software: you can redistribute it and/or modify
8 8 # it under the terms of the GNU General Public License as published by
... ... @@ -22,6 +22,7 @@ import gammalib
22 22 import ctools
23 23 import sys
24 24  
  25 +
25 26 # ============ #
26 27 # csspec class #
27 28 # ============ #
... ... @@ -358,14 +359,12 @@ class cslightcrv(ctools.cscript):
358 359 tmax = self.m_tbins.tstop(i)
359 360  
360 361 # Compute time bin center and time width
361   - tmean = (tmin + tmax)
362   - tmean *= 0.5
363   - twidth = (tmax - tmin)
364   - twidth *= 0.5
  362 + twidth = 0.5 * (tmax - tmin) # in seconds
  363 + tmean = tmin + twidth
365 364  
366 365 # Store time as MJD
367   - MJD[i] = tmean.mjd()
368   - e_MJD[i] = twidth.days()
  366 + MJD[i] = tmean.mjd()
  367 + e_MJD[i] = twidth / gammalib.sec_in_day # in days
369 368  
370 369 # Log information
371 370 if self.logExplicit():
... ...
cscripts/csobsinfo.py
... ... @@ -186,9 +186,7 @@ class csobsinfo(ctools.cscript):
186 186 obs_gti = obs.events().gti()
187 187  
188 188 # Compute mean time and dead time fraction in percent
189   - tmean = (obs_gti.tstart() + obs_gti.tstop())
190   - tmean *= 0.5
191   - deadfrac = (1.0-obs.deadc(tmean))*100.0
  189 + deadfrac = (1.0-obs.deadc())*100.0
192 190  
193 191 # Retrieve pointing and store Ra,Dec
194 192 pnt_dir = obs.pointing().dir()
... ... @@ -202,8 +200,8 @@ class csobsinfo(ctools.cscript):
202 200 # Append time interval
203 201 self.gti.merge(obs_gti.tstart(), obs_gti.tstop())
204 202  
205   - # increment global livetime and ontime
206   - ontime += obs.ontime()
  203 + # Increment global livetime and ontime
  204 + ontime += obs.ontime()
207 205 livetime += obs.livetime()
208 206  
209 207 # Log the event type (binned or unbinned)
... ...
src/ctobssim/ctobssim.cpp
... ... @@ -947,17 +947,16 @@ void ctobssim::simulate_interval(GCTAObservation* obs,
947 947 double flux = get_model_flux(model, emin, emax, dir, rad,
948 948 indent, wrklog);
949 949 double rate = flux * area;
950   - double duration = 1800.0; // default: 1800 sec
  950 + double duration = 1800.0; // default: 1800 sec
951 951 if (rate > 0.0) {
952 952 duration = m_max_photons / rate;
953   - if (duration < 1.0) { // not <1 sec
  953 + if (duration < 1.0) { // not <1 sec
954 954 duration = 1.0;
955 955 }
956 956 else if (duration > 180000.0) { // not >50 hr
957 957 duration = 180000.0;
958 958 }
959 959 }
960   - GTime tslice(duration, "sec");
961 960  
962 961 // Skip model if photon rate is 0
963 962 if (rate <= 0.0) {
... ... @@ -983,16 +982,16 @@ void ctobssim::simulate_interval(GCTAObservation* obs,
983 982 " photons/s for model \""+mod+"\" exceeds "
984 983 "maximum allowed photon rate of "+
985 984 gammalib::str(m_max_rate)+" photons/s. "
986   - "Please check the model parameters for "
987   - "model \""+mod+"\" or increase the value "
988   - "of the \"maxrate\" parameter.";
  985 + "Please check the parameters of model "
  986 + "\""+mod+"\" or increase the value of the "
  987 + "\"maxrate\" parameter.";
989 988 throw GException::invalid_value(G_SIMULATE_INTERVAL, msg);
990 989 }
991 990  
992 991 // To reduce memory requirements we split long time intervals into
993 992 // several time slices
994 993 GTime tstart = tmin;
995   - GTime tstop = tstart + tslice;
  994 + GTime tstop = tstart + duration;
996 995  
997 996 // Save state of photon and event counters before doing the
998 997 // simulation
... ... @@ -1009,7 +1008,7 @@ void ctobssim::simulate_interval(GCTAObservation* obs,
1009 1008  
1010 1009 // Log time slice
1011 1010 if (logExplicit()) {
1012   - if (tmax - tmin > tslice) {
  1011 + if (tmax - tmin > duration) {
1013 1012 indent++;
1014 1013 wrklog->indent(indent);
1015 1014 }
... ... @@ -1030,11 +1029,11 @@ void ctobssim::simulate_interval(GCTAObservation* obs,
1030 1029  
1031 1030 // Go to next time slice
1032 1031 tstart = tstop;
1033   - tstop = tstart + tslice;
  1032 + tstop = tstart + duration;
1034 1033  
1035 1034 // Reset indentation
1036 1035 if (logExplicit()) {
1037   - if (tmax - tmin > tslice) {
  1036 + if (tmax - tmin > duration) {
1038 1037 indent--;
1039 1038 wrklog->indent(indent);
1040 1039 }
... ...
src/ctselect/ctselect.cpp
... ... @@ -954,9 +954,8 @@ void ctselect::select_events(GCTAObservation* obs,
954 954 }
955 955  
956 956 // Recompute ontime and livetime.
957   - GTime meantime = 0.5 * (list->gti().tstart() + list->gti().tstop());
958 957 obs->ontime(list->gti().ontime());
959   - obs->livetime(list->gti().ontime() * obs->deadc(meantime));
  958 + obs->livetime(list->gti().ontime() * obs->deadc());
960 959  
961 960 // Return
962 961 return;
... ...