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