From 19dd9c214fc798626fd50156a4ca296dabfae5d1 Mon Sep 17 00:00:00 2001 From: Jürgen Knödlseder Date: Tue, 8 Aug 2017 17:16:55 +0200 Subject: [PATCH] Use t-type parameters for all "tmin" and "tmax" parameters (#1864) --- ChangeLog | 4 +++- NEWS | 14 +++++++++----- cscripts/csebins.py | 3 +-- cscripts/cslightcrv.par | 4 ++-- cscripts/cslightcrv.py | 12 +++++------- cscripts/cspull.par | 14 +++++++------- cscripts/cspull.py | 4 +++- cscripts/cstsdist.par | 14 +++++++------- cscripts/cstsdist.py | 4 +++- cscripts/csviscube.par | 4 ++-- cscripts/csviscube.py | 26 +++++++++++++------------- doc/source/users/reference_manual/cslightcrv.rst | 8 ++++---- doc/source/users/reference_manual/cspull.rst | 8 ++++---- doc/source/users/reference_manual/cstsdist.rst | 8 ++++---- doc/source/users/reference_manual/csviscube.rst | 8 ++++---- doc/source/users/reference_manual/ctmodel.rst | 8 ++++---- doc/source/users/reference_manual/ctobssim.rst | 10 +++++----- doc/source/users/reference_manual/ctselect.rst | 8 ++++---- pyext/ctool.i | 24 +++++++++++++++++------- src/ctcubemask/ctcubemask.cpp | 26 +++++++++----------------- src/ctcubemask/ctcubemask.hpp | 5 +---- src/ctmodel/ctmodel.par | 4 ++-- src/ctobssim/ctobssim.par | 4 ++-- src/ctselect/ctselect.cpp | 81 +++++++++++++++++++++++++-------------------------------------------------------- src/ctselect/ctselect.hpp | 7 +------ src/ctselect/ctselect.par | 4 ++-- src/support/ctool.cpp | 249 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------- src/support/ctool.hpp | 36 ++++++++++++++++++++---------------- test/test_cscript.py | 13 ++++++++----- test/test_cslightcrv.py | 12 ++++++------ test/test_cspull.py | 6 ++++-- test/test_cstsdist.py | 8 +++++--- test/test_ctobssim.py | 12 ++++++++---- 33 files changed, 376 insertions(+), 276 deletions(-) diff --git a/ChangeLog b/ChangeLog index aaef867..65bf1cd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,10 @@ -2017-08-01 +2017-08-08 * Version 1.5.0 released ======================== + Use t-type parameters for all "tmin" and "tmax" parameters (#1864) + 2017-07-28 diff --git a/NEWS b/NEWS index e4c9563..2940dcf 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,6 @@ New Features and Important Changes in ctools 1.5.0 -1 August 2017 +8 August 2017 Introduction @@ -26,12 +26,14 @@ None ctobssim - CTA observation simulation ------------------------------------- -None +Use t-type parameters for "tmin" and "tmax" to all specifying times in various +formats (#1864). ctselect - CTA event selection ------------------------------ -None +Use t-type parameters for "tmin" and "tmax" to all specifying times in various +formats (#1864). ctbin - CTA event binning @@ -56,7 +58,8 @@ None ctmodel - CTA counts cube modelling ----------------------------------- -None +Use t-type parameters for "tmin" and "tmax" to all specifying times in various +formats (#1864). ctexpcube - CTA exposure cube generation @@ -116,7 +119,8 @@ None cscripts -------- -None +Use t-type parameters for "tmin" and "tmax" to all specifying times in various +formats (#1864). Examples diff --git a/cscripts/csebins.py b/cscripts/csebins.py index a0580c3..2cbb828 100755 --- a/cscripts/csebins.py +++ b/cscripts/csebins.py @@ -22,7 +22,6 @@ import sys import math import gammalib import ctools -#from cscripts import obsutils # ============= # @@ -175,7 +174,7 @@ class csebins(ctools.cscript): # Build list of response dictionaries responses = [] - + # Loop over all observations for run in obs: diff --git a/cscripts/cslightcrv.par b/cscripts/cslightcrv.par index 825fcb9..3e7d03d 100644 --- a/cscripts/cslightcrv.par +++ b/cscripts/cslightcrv.par @@ -28,8 +28,8 @@ outfile, f, a, lightcurve.fits,,, "Output light curve file" # Script parameters #================== tbinalg, s, a, GTI,FILE|LIN|GTI,, "Algorithm for defining time bins" -tmin, r, a, 51544.5,,,"Lightcurve start time (MJD)" -tmax, r, a, 51544.6,,,"Lightcurve stop time (MJD)" +tmin, t, a, MJD 51544.5,,,"Lightcurve start time (UTC string, JD, MJD or time in seconds)" +tmax, t, a, MJD 51544.6,,,"Lightcurve stop time (UTC string, JD, MJD or time in seconds)" tbins, i, a, 5,1,10000, "Number of time bins" tbinfile, f, a, NONE,,, "File defining the time binning" emin, r, a, 0.1,,, "Lower energy limit of events (TeV)" diff --git a/cscripts/cslightcrv.py b/cscripts/cslightcrv.py index 401dfe2..13cb324 100755 --- a/cscripts/cslightcrv.py +++ b/cscripts/cslightcrv.py @@ -191,17 +191,15 @@ class cslightcrv(ctools.cscript): elif algorithm == 'LIN': # Get start and stop time and number of time bins - time_min = self['tmin'].real() - time_max = self['tmax'].real() + time_min = self['tmin'].time(self._time_reference()) + time_max = self['tmax'].time(self._time_reference()) nbins = self['tbins'].integer() - # Compute time step and setup the GTIs + # Compute time step in seconds and setup the GTIs time_step = (time_max - time_min) / float(nbins) for i in range(nbins): - tmin = gammalib.GTime() - tmax = gammalib.GTime() - tmin.mjd(time_min + i *time_step) - tmax.mjd(time_min + (i+1)*time_step) + tmin = time_min + i *time_step + tmax = time_min + (i+1)*time_step gti.append(tmin,tmax) # If the algorithm is "GTI" then extract the GTIs from the observations diff --git a/cscripts/cspull.par b/cscripts/cspull.par index 2f78313..3d0bd3c 100644 --- a/cscripts/cspull.par +++ b/cscripts/cspull.par @@ -28,20 +28,20 @@ outfile, f, a, pull.dat,,, "Output pull distribution file" # Script parameters #================== ntrials, i, a, 10,,, "Number of trials" -ra, r, a, 83.6331,0,360, "RA of pointing (deg)" -dec, r, a, 22.0145,-90,90, "Dec of pointing (deg)" +ra, r, a, 83.6331,0,360, "RA of pointing (degrees)" +dec, r, a, 22.0145,-90,90, "Dec of pointing (degrees)" coordsys, s, a, CEL,CEL|GAL,, "Coordinate system (CEL - celestial, GAL - galactic)" proj, s, a, TAN,AIT|AZP|CAR|GLS|MER|MOL|SFL|SIN|STG|TAN,, "Projection method" emin, r, a, 0.1,,, "Lower energy limit (TeV)" emax, r, a, 100.0,,, "Upper energy limit (TeV)" enumbins, i, a, 0,,, "Number of energy bins (0=unbinned)" -tmin, r, h, 0.0,,, "Start time (MET in s)" -tmax, r, a, 1800.0,,, "Duration (s)" +tmin, t, a, 2020-01-01T00:00:00,,, "Start time (UTC string, JD, MJD or time in seconds)" +tmax, t, a, 2020-01-01T00:30:00,,, "Stop time (UTC string, JD, MJD or time in seconds)" npix, i, a, 200,,, "Number of pixels for binned" -binsz, r, a, 0.05,,, "Pixel size for binned (deg/pixel)" -rad, r, h, 5.0,0,180, "Radius of ROI (deg)" +binsz, r, a, 0.05,,, "Pixel size for binned (degrees/pixel)" +rad, r, h, 5.0,0,180, "Radius of ROI (degrees)" pattern, s, h, single,single|four,, "Observation pattern" -offset, r, h, 1.5,,, "Observation pattern offset (deg)" +offset, r, h, 1.5,,, "Observation pattern offset (degrees)" profile, b, h, no,,, "Use likelihood profile method for errors?" seed, i, h, 1,,, "Initial random number generator seed" diff --git a/cscripts/cspull.py b/cscripts/cspull.py index 5669185..331cf15 100755 --- a/cscripts/cspull.py +++ b/cscripts/cspull.py @@ -76,8 +76,10 @@ class cspull(ctools.cscript): # Check for requested pattern and set wobble pattern if self['pattern'].string() == 'four': + tmin = self['tmin'].time(self._time_reference()).secs() + duration = self['tmax'].time(self._time_reference()).secs() - tmin self._obs = obsutils.set_observations(self['ra'].real(), self['dec'].real(), self['rad'].real(), - self['tmin'].real(), self['tmax'].real(), + tmin, duration, self['emin'].real(), self['emax'].real(), self['irf'].string(), self['caldb'].string(), deadc=self['deadc'].real(), diff --git a/cscripts/cstsdist.par b/cscripts/cstsdist.par index 515742d..3347c72 100644 --- a/cscripts/cstsdist.par +++ b/cscripts/cstsdist.par @@ -33,20 +33,20 @@ outfile, f, a, ts.dat,,, "Output Test Statistic distribution file" # Script parameters #================== ntrials, i, a, 10,,, "Number of trials" -ra, r, a, 83.63,0,360, "RA of pointing (deg)" -dec, r, a, 22.01,-90,90, "Dec of pointing (deg)" +ra, r, a, 83.63,0,360, "RA of pointing (degrees)" +dec, r, a, 22.01,-90,90, "Dec of pointing (degrees)" coordsys, s, a, CEL,CEL|GAL,, "Coordinate system (CEL - celestial, GAL - galactic)" proj, s, a, TAN,AIT|AZP|CAR|GLS|MER|MOL|SFL|SIN|STG|TAN,, "Projection method" emin, r, a, 0.1,,, "Lower energy limit (TeV)" emax, r, a, 100.0,,, "Upper energy limit (TeV)" enumbins, i, a, 0,,, "Number of energy bins (0=unbinned)" -tmin, r, h, 0.0,,, "Start time (MET in s)" -tmax, r, a, 1800.0,,, "Duration (s)" +tmin, t, a, 2020-01-01T00:00:00,,, "Start time (UTC string, JD, MJD or time in seconds)" +tmax, t, a, 2020-01-01T00:30:00,,, "Stop time (UTC string, JD, MJD or time in seconds)" npix, i, a, 200,,, "Number of pixels for binned" -binsz, r, a, 0.05,,, "Pixel size for binned (deg/pixel)" -rad, r, h, 5.0,0,180, "Radius of ROI (deg)" +binsz, r, a, 0.05,,, "Pixel size for binned (degrees/pixel)" +rad, r, h, 5.0,0,180, "Radius of ROI (degrees)" pattern, s, h, single,single|four,, "Observation pattern" -offset, r, h, 1.5,,, "Observation pattern offset (deg)" +offset, r, h, 1.5,,, "Observation pattern offset (degrees)" # # Standard parameters diff --git a/cscripts/cstsdist.py b/cscripts/cstsdist.py index 2ccd0f4..c1c4dde 100755 --- a/cscripts/cstsdist.py +++ b/cscripts/cstsdist.py @@ -68,8 +68,10 @@ class cstsdist(ctools.cscript): # Check for requested pattern and set wobble pattern if self['pattern'].string() == 'four': + tmin = self['tmin'].time(self._time_reference()).secs() + duration = self['tmax'].time(self._time_reference()).secs() - tmin self._obs = obsutils.set_observations(self['ra'].real(), self['dec'].real(), self['rad'].real(), - self['tmin'].real(), self['tmax'].real(), + tmin, duration, self['emin'].real(), self['emax'].real(), self['irf'].string(), self['caldb'].string(), deadc=self['deadc'].real(), diff --git a/cscripts/csviscube.par b/cscripts/csviscube.par index c5aa3db..1202799 100644 --- a/cscripts/csviscube.par +++ b/cscripts/csviscube.par @@ -16,8 +16,8 @@ # # General parameters #=================== -tmin, r, a, 0.0,,, "Start time (CTA MET in seconds)" -tmax, r, a, 31557600.0,,, "End time (CTA MET in seconds)" +tmin, t, a, 2020-01-01T00:00:00,,, "Start time of observation (UTC string, JD, MJD or time in seconds)" +tmax, t, a, 2021-01-01T00:00:00,,, "Stop time of observation (UTC string, JD, MJD or time in seconds)" geolon, r, a, 79.4041,,, "Geographic longitude of array (deg)" geolat, r, a, -24.6272,,, "Geographic latitude of array (deg)" sunzenith, r, h, 105.0,,, "Minimum Sun zenith angle for observations (deg)" diff --git a/cscripts/csviscube.py b/cscripts/csviscube.py index 8cd55b0..f1a0f77 100755 --- a/cscripts/csviscube.py +++ b/cscripts/csviscube.py @@ -36,7 +36,7 @@ class csviscube(ctools.cscript): def __init__(self, *argv): """ Constructor - + Parameters ---------- argv : list of str @@ -68,8 +68,8 @@ class csviscube(ctools.cscript): Get all parameters """ # Query parameters - self['tmin'].real() - self['tmax'].real() + self['tmin'].time() + self['tmax'].time() self['geolon'].real() self['geolat'].real() self['outfile'].filename() @@ -107,7 +107,7 @@ class csviscube(ctools.cscript): The hour angle h (or local hour angle, LHA) is defined as the difference between local siderial time (LST) and the Right Ascension - + h = LST - ra The map is computed for h=-ra which is equivalent to GST=lon (or LST=0). @@ -234,7 +234,7 @@ class csviscube(ctools.cscript): cos_geolat = math.cos(geolat) sin_sundec = math.sin(sundec) cos_sundec = math.cos(sundec) - + # Compute Right Ascension difference when Sun is below the mimimum # zenith angle in degrees dra = math.acos((cos_sunzenith - sin_geolat * sin_sundec) / @@ -264,17 +264,17 @@ class csviscube(ctools.cscript): #geolon = self['geolon'].real() # Get time interval - tmin = gammalib.GTime(self['tmin'].real(), 's') - tmax = gammalib.GTime(self['tmax'].real(), 's') + tmin = self['tmin'].time(self._time_reference()) + tmax = self['tmax'].time(self._time_reference()) # Initialise hour angle list hour_angles = [] - + # Set number of hour angle bins and compute conversion factor and weight nsteps = 1000 ra2inx = float(nsteps)/360.0 # Conversion from RA (deg) to index weight = 24.0/float(nsteps) # Weight per hour angle step - + # Initialise hour angle array and weight hours = [0.0 for i in range(nsteps)] @@ -298,11 +298,11 @@ class csviscube(ctools.cscript): # Compute the time from now when the Sun will culminate. The time # is here expressed in degrees dra_sun = self._sun_ra_exclusion(time) - + # Set [0,ra_start] and [ra_stop,360.0] ra_start = sunra - dra_sun ra_stop = sunra + dra_sun - + # Case 1: The RA interval during which the Sun is above the zenith # angle constraint is fully comprised within the [0,360] interval. # In that case the dark time is comprised of two intervals: @@ -378,7 +378,7 @@ class csviscube(ctools.cscript): def _visibility_cube(self): """ Compute visibility cube - + Compute visibility cube by displacing the zenith angle map for all hour angles. The visibility cube contains the number of hours a given celestial position is visible under a given zenith angle interval. @@ -475,7 +475,7 @@ class csviscube(ctools.cscript): # Get outfile parameter outfile = self['outfile'].filename() - + # Log file name self._log_value(gammalib.NORMAL, 'Visibility cube file', outfile.url()) diff --git a/doc/source/users/reference_manual/cslightcrv.rst b/doc/source/users/reference_manual/cslightcrv.rst index 4031e81..bdae218 100644 --- a/doc/source/users/reference_manual/cslightcrv.rst +++ b/doc/source/users/reference_manual/cslightcrv.rst @@ -51,11 +51,11 @@ General parameters ``(tbinalg = GTI) [string]`` Algorithm for defining time bins. -``tmin [real]`` - Lightcurve start time (in MJD). +``tmin [time]`` + Lightcurve start time (UTC string, JD, MJD or time in seconds). -``tmax [real]`` - Lightcurve stop time (in MJD). +``tmax [time]`` + Lightcurve stop time (UTC string, JD, MJD or time in seconds). ``tbins [integer]`` Number of time bins. diff --git a/doc/source/users/reference_manual/cspull.rst b/doc/source/users/reference_manual/cspull.rst index 19853d1..b8ee1de 100644 --- a/doc/source/users/reference_manual/cspull.rst +++ b/doc/source/users/reference_manual/cspull.rst @@ -83,11 +83,11 @@ General parameters ``enumbins [integer]`` Number of energy bins (0=unbinned). -``(tmin = 0.0) [real]`` - Start time (in seconds). +``tmin [time]`` + Start time (UTC string, JD, MJD or time in seconds). -``tmax [real]`` - Stop time (in seconds). +``tmax [time]`` + Stop time (UTC string, JD, MJD or time in seconds). ``npix [integer]`` Number of pixels for binned analysis. diff --git a/doc/source/users/reference_manual/cstsdist.rst b/doc/source/users/reference_manual/cstsdist.rst index c3b7db8..e4bc95f 100644 --- a/doc/source/users/reference_manual/cstsdist.rst +++ b/doc/source/users/reference_manual/cstsdist.rst @@ -90,11 +90,11 @@ General parameters ``enumbins [integer]`` Number of energy bins (0=unbinned). -``(tmin = 0.0) [real]`` - Start time (in seconds). +``tmin [time]`` + Start time (UTC string, JD, MJD or time in seconds). -``tmax [real]`` - Stop time (in seconds). +``tmax [time]`` + Stop time (UTC string, JD, MJD or time in seconds). ``npix [integer]`` Number of pixels for binned analysis. diff --git a/doc/source/users/reference_manual/csviscube.rst b/doc/source/users/reference_manual/csviscube.rst index 7febc74..addc886 100644 --- a/doc/source/users/reference_manual/csviscube.rst +++ b/doc/source/users/reference_manual/csviscube.rst @@ -24,11 +24,11 @@ On output, the script will provide a FITS file containing the visibility cube. General parameters ------------------ -``tmin [real]`` - Start time of the observation. +``tmin [time]`` + Start time of observation (UTC string, JD, MJD or time in seconds). -``tmax [real]`` - Stop time of the observation. +``tmax [time]`` + Stop time of observation (UTC string, JD, MJD or time in seconds). ``geolon [real]`` Geographic longitude of the IACT array in degrees. diff --git a/doc/source/users/reference_manual/ctmodel.rst b/doc/source/users/reference_manual/ctmodel.rst index 3301746..f9d076e 100644 --- a/doc/source/users/reference_manual/ctmodel.rst +++ b/doc/source/users/reference_manual/ctmodel.rst @@ -86,11 +86,11 @@ General parameters ``rad [real]`` Radius of field of view (in degrees). -``tmin [real]`` - CTA mission elapsed start time (in seconds). +``tmin [time]`` + Start time (UTC string, JD, MJD or time in seconds). -``tmax [real]`` - CTA mission elapsed stop time (in seconds). +``tmax [time]`` + Stop time (UTC string, JD, MJD or time in seconds). ``(deadc = 0.95) [real]`` Average deadtime correction factor. diff --git a/doc/source/users/reference_manual/ctobssim.rst b/doc/source/users/reference_manual/ctobssim.rst index 5135dca..286ae4c 100644 --- a/doc/source/users/reference_manual/ctobssim.rst +++ b/doc/source/users/reference_manual/ctobssim.rst @@ -83,12 +83,12 @@ General parameters ``rad [real]`` Radius of CTA field of view (simulation cone radius) (in degrees). -``tmin [real]`` - Mission elapsed start time of observation (in seconds). - -``tmax [real]`` - Mission elapsed stop time of observation (in seconds). +``tmin [time]`` + Start time (UTC string, JD, MJD or time in seconds). +``tmax [time]`` + Stop time (UTC string, JD, MJD or time in seconds). + ``emin [real]`` Lower energy limit of simulated events (in TeV). diff --git a/doc/source/users/reference_manual/ctselect.rst b/doc/source/users/reference_manual/ctselect.rst index 82e0334..33dc41b 100644 --- a/doc/source/users/reference_manual/ctselect.rst +++ b/doc/source/users/reference_manual/ctselect.rst @@ -65,13 +65,13 @@ General parameters If INDEF, NONE, UNDEF or UNDEFINED is passed as value, no ROI selection will be performed. -``tmin [real]`` - CTA mission elapsed start time defining the earliest event (in seconds). +``tmin [time]`` + Start time (UTC string, JD, MJD or time in seconds). If INDEF, NONE, UNDEF or UNDEFINED is passed as value, no time selection will be performed. -``tmax [real]`` - CTA mission elapsed stop time defining the latest event (in seconds). +``tmax [time]`` + Stop time (UTC string, JD, MJD or time in seconds). If INDEF, NONE, UNDEF or UNDEFINED is passed as value, no time selection will be performed. diff --git a/pyext/ctool.i b/pyext/ctool.i index e99778f..3f2e45f 100644 --- a/pyext/ctool.i +++ b/pyext/ctool.i @@ -94,6 +94,11 @@ public: %rename(_require_inobs) require_inobs; %rename(_require_inobs_nocube) require_inobs_nocube; %rename(_get_roi) get_roi; + %rename(_get_ebounds) get_ebounds; + %rename(_get_gti) get_gti; + %rename(_get_pointing) get_pointing; + %rename(_get_skydir) get_skydir; + %rename(_set_outfile_name) set_outfile_name; %rename(_set_response) set_response; %rename(_set_edisp) set_edisp; %rename(_restore_edisp) restore_edisp; @@ -121,17 +126,22 @@ public: void setup_models(GObservations& obs, const std::string& name = ""); // Protected methods that create objects from user parameters - GEbounds create_ebounds(void); - GSkyMap create_map(const GObservations& obs); - GCTAEventCube create_cube(const GObservations& obs); - GCTAObservation create_cta_obs(void); + GEbounds create_ebounds(void); + GSkyMap create_map(const GObservations& obs); + GCTAEventCube create_cube(const GObservations& obs); + GCTAObservation create_cta_obs(void); // Protected methods that check user parameters - void require_inobs(const std::string& method); - void require_inobs_nocube(const std::string& method); + void require_inobs(const std::string& method); + void require_inobs_nocube(const std::string& method); // Protected methods that extract user parameters - GCTARoi get_roi(void); + GCTARoi get_roi(const GCTAPointing& pnt = GCTAPointing()); + GEbounds get_ebounds(void); + GGti get_gti(void); + GCTAPointing get_pointing(void); + GSkyDir get_skydir(void); + std::string set_outfile_name(const std::string& filename); // Protected support methods void set_response(GObservations& obs); diff --git a/src/ctcubemask/ctcubemask.cpp b/src/ctcubemask/ctcubemask.cpp index 900f5dd..b30caa1 100644 --- a/src/ctcubemask/ctcubemask.cpp +++ b/src/ctcubemask/ctcubemask.cpp @@ -375,8 +375,6 @@ void ctcubemask::init_members(void) m_regfile.clear(); m_outcube.clear(); m_prefix.clear(); - m_usepnt = false; - m_roi.clear(); m_emin = 0.0; m_emax = 0.0; m_publish = false; @@ -384,7 +382,6 @@ void ctcubemask::init_members(void) // Initialise protected members m_infiles.clear(); m_select_energy = true; - m_select_roi = true; // Return return; @@ -402,8 +399,6 @@ void ctcubemask::copy_members(const ctcubemask& app) m_regfile = app.m_regfile; m_outcube = app.m_outcube; m_prefix = app.m_prefix; - m_usepnt = app.m_usepnt; - m_roi = app.m_roi; m_emin = app.m_emin; m_emax = app.m_emax; m_publish = app.m_publish; @@ -411,7 +406,6 @@ void ctcubemask::copy_members(const ctcubemask& app) // Copy protected members m_infiles = app.m_infiles; m_select_energy = app.m_select_energy; - m_select_roi = app.m_select_roi; // Return return; @@ -442,7 +436,6 @@ void ctcubemask::get_parameters(void) { // Initialise selection flags m_select_energy = true; - m_select_roi = true; // Setup observations from "inobs" parameter. Do not request response // information and do not accept event lists. @@ -450,11 +443,9 @@ void ctcubemask::get_parameters(void) // Get parameters m_regfile = (*this)["regfile"].filename(); - m_usepnt = (*this)["usepnt"].boolean(); - // Get the RoI and enable RoI selection if the RoI is valid - m_roi = get_roi(); - m_select_roi = m_roi.is_valid(); + // Query the RoI + GCTARoi roi = get_roi(); // Check for sanity of energy selection parameters if ((*this)["emin"].is_valid() && (*this)["emax"].is_valid()) { @@ -563,12 +554,13 @@ void ctcubemask::apply_mask(GCTAObservation* obs) // Set all pixels inside selected energy bands but outside RoI // to -1.0 if requested - if (m_select_roi) { - GSkyRegionCircle roi(m_roi.centre().dir(), m_roi.radius()); + GCTARoi roi = get_roi(obs->pointing()); + if (roi.is_valid()) { + GSkyRegionCircle circle(roi.centre().dir(), roi.radius()); for (int i = e_idx1; i <= e_idx2; ++i) { for (int pixel = 0; pixel < npix; ++pixel) { GSkyDir dir = map.inx2dir(pixel); - if (!roi.contains(dir)) { + if (!circle.contains(dir)) { map(pixel,i) = -1.0; } } @@ -576,9 +568,9 @@ void ctcubemask::apply_mask(GCTAObservation* obs) // Log selected RoI log_value(NORMAL, "Selected RoI", - "RA="+gammalib::str(roi.centre().ra_deg())+" deg, "+ - "DEC="+gammalib::str(roi.centre().dec_deg())+" deg, "+ - "Radius="+gammalib::str(roi.radius())+" deg"); + "RA="+gammalib::str(circle.centre().ra_deg())+" deg, "+ + "DEC="+gammalib::str(circle.centre().dec_deg())+" deg, "+ + "Radius="+gammalib::str(circle.radius())+" deg"); } // endif: applied RoI selection diff --git a/src/ctcubemask/ctcubemask.hpp b/src/ctcubemask/ctcubemask.hpp index bea60b8..48ebbd0 100644 --- a/src/ctcubemask/ctcubemask.hpp +++ b/src/ctcubemask/ctcubemask.hpp @@ -1,7 +1,7 @@ /*************************************************************************** * ctcubemask - Cube filter tool * * ----------------------------------------------------------------------- * - * copyright (C) 2014-2016 by Chia-Chun Lu * + * copyright (C) 2014-2017 by Chia-Chun Lu * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -78,8 +78,6 @@ protected: GFilename m_regfile; //!< ds9 region file GFilename m_outcube; //!< Output event list or XML file std::string m_prefix; //!< Prefix for multiple counts maps - bool m_usepnt; //!< Use pointing instead of RA/DEC parameters - GCTARoi m_roi; //!< RoI selection double m_emin; //!< Lower energy double m_emax; //!< Upper energy bool m_publish; //!< Publish counts cube? @@ -87,7 +85,6 @@ protected: // Protected members std::vector m_infiles; //!< Input event filenames bool m_select_energy; //!< Perform energy selection - bool m_select_roi; //!< Perform ROI selection }; diff --git a/src/ctmodel/ctmodel.par b/src/ctmodel/ctmodel.par index 03a3795..f667362 100644 --- a/src/ctmodel/ctmodel.par +++ b/src/ctmodel/ctmodel.par @@ -34,8 +34,8 @@ outcube, f, a, "modcube.fits",,, "Output model cube file" ra, r, a, 83.63,0,360, "RA of pointing (degrees)" dec, r, a, 22.01,-90,90, "Dec of pointing (degrees)" rad, r, a, 5.0,0,180, "Radius of FOV (degrees)" -tmin, r, a, 0.0,,, "Start time (MET in s)" -tmax, r, a, 1800.0,,, "End time (MET in s)" +tmin, t, a, 2020-01-01T00:00:00,,, "Start time (UTC string, JD, MJD or time in seconds)" +tmax, t, a, 2020-01-01T00:30:00,,, "Stop time (UTC string, JD, MJD or time in seconds)" deadc, r, h, 0.98,0,1, "Average deadtime correction factor" # diff --git a/src/ctobssim/ctobssim.par b/src/ctobssim/ctobssim.par index 8786b11..832aaa8 100644 --- a/src/ctobssim/ctobssim.par +++ b/src/ctobssim/ctobssim.par @@ -32,8 +32,8 @@ seed, i, h, 1,,, "Random number generator seed" ra, r, a, 83.63,0,360, "RA of pointing (degrees)" dec, r, a, 22.01,-90,90, "Dec of pointing (degrees)" rad, r, a, 5.0,0,180, "Radius of FOV (degrees)" -tmin, r, a, 0.0,,, "Start time (MET in s)" -tmax, r, a, 1800.0,,, "End time (MET in s)" +tmin, t, a, 2020-01-01T00:00:00,,, "Start time (UTC string, JD, MJD or time in seconds)" +tmax, t, a, 2020-01-01T00:30:00,,, "Stop time (UTC string, JD, MJD or time in seconds)" emin, r, a, 0.1,,, "Lower energy limit (TeV)" emax, r, a, 100.0,,, "Upper energy limit (TeV)" deadc, r, h, 0.98,0,1, "Average deadtime correction factor" diff --git a/src/ctselect/ctselect.cpp b/src/ctselect/ctselect.cpp index 81d904c..02640e9 100644 --- a/src/ctselect/ctselect.cpp +++ b/src/ctselect/ctselect.cpp @@ -466,10 +466,7 @@ void ctselect::init_members(void) // Initialise parameters m_outobs.clear(); m_prefix.clear(); - m_usepnt = false; - m_roi.clear(); - m_tmin = 0.0; - m_tmax = 0.0; + m_gti.clear(); m_emin = 0.0; m_emax = 0.0; m_expr.clear(); @@ -484,8 +481,6 @@ void ctselect::init_members(void) m_timemax.clear(); m_phases.clear(); m_select_energy = false; - m_select_roi = false; - m_select_time = false; m_select_phase = false; // Return @@ -503,10 +498,7 @@ void ctselect::copy_members(const ctselect& app) // Copy parameters m_outobs = app.m_outobs; m_prefix = app.m_prefix; - m_usepnt = app.m_usepnt; - m_roi = app.m_roi; - m_tmin = app.m_tmin; - m_tmax = app.m_tmax; + m_gti = app.m_gti; m_emin = app.m_emin; m_emax = app.m_emax; m_expr = app.m_expr; @@ -521,8 +513,6 @@ void ctselect::copy_members(const ctselect& app) m_timemax = app.m_timemax; m_phases = app.m_phases; m_select_energy = app.m_select_energy; - m_select_roi = app.m_select_roi; - m_select_time = app.m_select_time; m_select_phase = app.m_select_phase; // Return @@ -557,36 +547,18 @@ void ctselect::get_parameters(void) // Initialise selection flags m_select_energy = false; - m_select_roi = false; - m_select_time = false; m_select_phase = false; // Setup observations from "inobs" parameter. Do not request response // information and do not accept counts cubes. setup_observations(m_obs, false, true, false); - // Get some parameters - m_usepnt = (*this)["usepnt"].boolean(); + // Query the RoI + GCTAPointing pnt; + GCTARoi roi = get_roi(pnt); - // Get the RoI and enable RoI selection if the RoI is valid - m_roi = get_roi(); - m_select_roi = m_roi.is_valid(); - - // Get time selection parameters - if ((*this)["tmin"].is_valid() && (*this)["tmax"].is_valid()) { - - // Get User parameters - m_tmin = (*this)["tmin"].real(); - m_tmax = (*this)["tmax"].real(); - - // Additional check for time values - if (m_tmin >= m_tmax) { - m_select_time = false; - } - else { - m_select_time = true; - } - } + // Get Good Time Intervals (empty if no selection is done) + m_gti = get_gti(); // Get energy selection parameters if ((*this)["emin"].is_valid() && (*this)["emax"].is_valid()) { @@ -686,8 +658,8 @@ void ctselect::get_parameters(void) // Set time interval with input times given in CTA reference // time (in seconds) - m_timemin.set(m_tmin, m_cta_ref); - m_timemax.set(m_tmax, m_cta_ref); + m_timemin = m_gti.tstart(); + m_timemax = m_gti.tstop(); // Write parameters into logger log_parameters(TERSE); @@ -716,8 +688,7 @@ void ctselect::get_parameters(void) * observation is replaced by selected event list read from the FITS file. * * Good Time Intervals of the observation will be limited to the time - * interval [m_tmin, m_tmax]. If m_tmin=m_tmax=0, no time selection is - * performed. + * interval [m_timemin, m_timemax]. ***************************************************************************/ void ctselect::select_events(GCTAObservation* obs, const std::string& filename, @@ -756,21 +727,19 @@ void ctselect::select_events(GCTAObservation* obs, // Analyse expression to see if a selection is required bool select_expr = (gammalib::strip_whitespace(m_expr).length() > 0); - // Set RoI selection. If the "usepnt" parameter is set to true then - // use the pointing direction as the RoI centre. - double ra = m_roi.centre().dir().ra_deg(); - double dec = m_roi.centre().dir().dec_deg(); - double rad = m_roi.radius(); - if (m_usepnt) { - const GCTAPointing &pnt = obs->pointing(); - ra = pnt.dir().ra_deg(); - dec = pnt.dir().dec_deg(); - } - + // Set RoI selection + GCTARoi roi = get_roi(obs->pointing()); + double ra = roi.centre().dir().ra_deg(); + double dec = roi.centre().dir().dec_deg(); + double rad = roi.radius(); + + // Signal that RoI selection should be performed + bool select_roi = roi.is_valid(); + // Set time selection interval. We make sure here that the time selection // interval cannot be wider than the GTIs covering the data. This is done // using GGti's reduce() method. - if (m_select_time) { + if (!m_gti.is_empty()) { // Reduce GTIs to specified time interval. The complicated cast is // necessary here because the gti() method is declared const, so @@ -783,8 +752,8 @@ void ctselect::select_events(GCTAObservation* obs, GGti gti = list->gti(); // Make time selection - if (m_select_time) { - + if (!m_gti.is_empty()) { + // Extract effective time interval in the reference time of the // event list. We get this reference time from gti.reference(). double tmin = gti.tstart().convert(gti.reference()); @@ -910,7 +879,7 @@ void ctselect::select_events(GCTAObservation* obs, } // endif: made energy selection // Make RoI selection - if (m_select_roi) { + if (select_roi) { // Store the original radius double original_rad = rad; @@ -1032,7 +1001,7 @@ void ctselect::select_events(GCTAObservation* obs, list->fetch(); // If RoI selection has been applied then set the event list RoI - if (m_select_roi) { + if (select_roi) { GCTAInstDir instdir; instdir.dir().radec_deg(ra, dec); list->roi(GCTARoi(instdir, rad)); @@ -1326,7 +1295,7 @@ void ctselect::save_fits(void) // Save only if it's a CTA observation if (obs != NULL) { - + // Save only if file name is non-empty if (m_infiles[0].length() > 0) { diff --git a/src/ctselect/ctselect.hpp b/src/ctselect/ctselect.hpp index d3554b2..de3a264 100644 --- a/src/ctselect/ctselect.hpp +++ b/src/ctselect/ctselect.hpp @@ -83,10 +83,7 @@ protected: // User parameters std::string m_outobs; //!< Output event list or XML file std::string m_prefix; //!< Prefix for multiple event lists - bool m_usepnt; //!< Use pointing instead of RA/DEC parameters - GCTARoi m_roi; //!< RoI selection - double m_tmin; //!< Start time - double m_tmax; //!< Stop time + GGti m_gti; //!< Time selection double m_emin; //!< Lower energy double m_emax; //!< Upper energy std::string m_expr; //!< Selection expression @@ -101,8 +98,6 @@ protected: GTime m_timemax; //!< Latest time GPhases m_phases; //!< Phase intervals bool m_select_energy; //!< Perform energy selection - bool m_select_roi; //!< Perform RoI selection - bool m_select_time; //!< Perform time selection bool m_select_phase; //!< Perform phase selection }; diff --git a/src/ctselect/ctselect.par b/src/ctselect/ctselect.par index 1b13c02..802bb0b 100644 --- a/src/ctselect/ctselect.par +++ b/src/ctselect/ctselect.par @@ -27,8 +27,8 @@ usepnt, b, h, no,,, "Use pointing instead of RA/DEC parameters?" ra, r, a, 83.63,0,360, "RA for ROI centre (degrees)" dec, r, a, 22.01,-90,90, "Dec for ROI centre (degrees)" rad, r, a, 3.0,0,180, "Radius of ROI (degrees)" -tmin, r, a, 0.0,,, "Start time (CTA MET in seconds)" -tmax, r, a, 0.0,,, "End time (CTA MET in seconds)" +tmin, t, a, NONE,,, "Start time (UTC string, JD, MJD or time in seconds)" +tmax, t, a, NONE,,, "End time (UTC string, JD, MJD or time in seconds)" emin, r, a, 0.1,,, "Lower energy limit (TeV)" emax, r, a, 100.0,,, "Upper energy limit (TeV)" phase, s, h, NONE,,, "Phase expression in the format phasemin0:phasemax0,phasemin1:phasemax1,..." diff --git a/src/support/ctool.cpp b/src/support/ctool.cpp index a8b5488..ecad537 100644 --- a/src/support/ctool.cpp +++ b/src/support/ctool.cpp @@ -737,9 +737,9 @@ GCTAEventCube ctool::create_cube(const GObservations& obs) /***********************************************************************//** - * @brief Create a CTA observation from user parameters + * @brief Create a CTA observation from User parameters * - * Creates an empty CTA observation from user parameters. An empty event list + * Creates an empty CTA observation from User parameters. An empty event list * including RoI, GTI and energy boundary information is attached to the * observation. The method also sets the pointing direction using the ra and * dec parameter, the ROI based on ra, dec and rad, a single GTI based on @@ -760,45 +760,24 @@ GCTAEventCube ctool::create_cube(const GObservations& obs) ***************************************************************************/ GCTAObservation ctool::create_cta_obs(void) { - // Get CTA observation parameters - double ra = (*this)["ra"].real(); - double dec = (*this)["dec"].real(); - double rad = (*this)["rad"].real(); + // Get deadtime correction User parameter double deadc = (*this)["deadc"].real(); - double t_min = (*this)["tmin"].real(); - double t_max = (*this)["tmax"].real(); - double e_min = (*this)["emin"].real(); - double e_max = (*this)["emax"].real(); // Allocate CTA observation and empty event list GCTAObservation obs; GCTAEventList list; // Set pointing direction - GCTAPointing pnt; - GSkyDir skydir; - skydir.radec_deg(ra, dec); - pnt.dir(skydir); + GCTAPointing pnt = get_pointing(); - // Set ROI - GCTAInstDir instdir(skydir); - GCTARoi roi(instdir, rad); + // Set RoI + GCTARoi roi = get_roi(pnt); // Set GTI - GGti gti(m_cta_ref); - GTime tstart; - GTime tstop; - tstart.set(t_min, m_cta_ref); - tstop.set(t_max, m_cta_ref); - gti.append(tstart, tstop); + GGti gti = get_gti(); // Set energy boundaries - GEbounds ebounds; - GEnergy emin; - GEnergy emax; - emin.TeV(e_min); - emax.TeV(e_max); - ebounds.append(emin, emax); + GEbounds ebounds = get_ebounds(); // Set CTA event list attributes list.roi(roi); @@ -870,7 +849,7 @@ void ctool::require_inobs_nocube(const std::string& method) // Signal no cube bool is_cube = false; - + // Try loading file as counts cube. If this is successful then // throw an exception try { @@ -897,9 +876,9 @@ void ctool::require_inobs_nocube(const std::string& method) "observation definition file."; throw GException::invalid_value(method, msg); } - + } // endif: we had a FITS file - + // Return return; } @@ -974,17 +953,21 @@ void ctool::log_models(const GChatter& chatter, /***********************************************************************//** - * @brief Return RoI from user parameters + * @brief Return RoI from User parameters * - * @param[in] obs Observation container. - * @return Region of interest. + * @param[in] pnt Pointing direction. + * @return Region of Interest. * - * Returns region of interest from the user parameters "ra", "dec" and "rad". - * If the "usepnt" parameter exists and is "yes" then postpone then assume - * that the Right Ascension and Declination of the RoI centre will be set - * from the pointing direction somewhere else. + * Returns Region of Interest (RoI) from the User parameters "ra", "dec" and + * "rad". If any of the parameters "ra", "dec" or "rad" is not valid an + * invalid RoI is returned. + * + * If the "usepnt" parameter exists and is set to "yes", the RoI centre will + * be taken from the specified pointing direction instead of the "ra" and + * "dec" parameters. Make sure to provide a valid pointing direction in case + * that you want to use the "usepnt" User parameter. ***************************************************************************/ -GCTARoi ctool::get_roi(void) +GCTARoi ctool::get_roi(const GCTAPointing& pnt) { // Initialise an empty RoI GCTARoi roi; @@ -993,31 +976,32 @@ GCTARoi ctool::get_roi(void) // use for the RoI centre bool usepnt = (has_par("usepnt") && (*this)["usepnt"].boolean()); - // If pointing should not bet used the extract the RoI centre from the - // "ra" and "dec" parameters - if (!usepnt) { + // If the pointing direction should be used then extract the RoI centre + // from the pointing direction + if (usepnt) { + roi.centre(GCTAInstDir(pnt.dir())); + } - // Read "ra" and "dec" parameters only if both are valid - if ((*this)["ra"].is_valid() && (*this)["dec"].is_valid()) { + // ... otherwise extract the RoI centre from "ra" and "dec" User + // parameters if they are valid + else if ((*this)["ra"].is_valid() && (*this)["dec"].is_valid()) { - // Read parameters - double ra = (*this)["ra"].real(); - double dec = (*this)["dec"].real(); + // Get Sky direction + GSkyDir skydir = get_skydir(); - // Set RoI - GCTAInstDir instdir; - instdir.dir().radec_deg(ra, dec); - roi.centre(instdir); + // Convert into CTA instrument direction + GCTAInstDir instdir(skydir); - // Signal that we have a pointing direction - usepnt = true; + // Set RoI centre + roi.centre(instdir); - } // endif: "ra" and "dec" were valid + // Signal that we have a centre + usepnt = true; - } // endif: pointing was not used for RoI centre + } // endelse: set RoI centre from User parameters - // If we have a RoI centre and if the "rad" parameter is valid then - // extract the RoI radius from the parameter + // Extract the RoI radius from the "rad" parameter if we have a centre + // and the "rad" parameter is valid if (usepnt && (*this)["rad"].is_valid()) { roi.radius((*this)["rad"].real()); } @@ -1028,6 +1012,137 @@ GCTARoi ctool::get_roi(void) /***********************************************************************//** + * @brief Return energy boundaries from User parameters + * + * @return Energy boundaries. + * + * Returns energy boundaries from the User parameters "emin" and "emax". If + * one of "emin" or "emax" is not valid, an empty energy boundaries object + * is returned. If "emin" is not valid, "emax" is not queried. + ***************************************************************************/ +GEbounds ctool::get_ebounds(void) +{ + // Initialise energy boundaries + GEbounds ebounds; + + // Get minimum energy from "emin" User parameter + GApplicationPar parmin = (*this)["emin"]; + + // Continue only if "emin" has a valid energy value + if (parmin.is_valid()) { + + // Get maximum energy from "emax" User parameter + GApplicationPar parmax = (*this)["emax"]; + + // Continue only if "emax" has a valid energy value + if (parmax.is_valid()) { + + // Read minimum and maximum energy parameters in TeV + double e_min = parmin.real(); + double e_max = parmax.real(); + + // Set energy boundaries + GEnergy emin; + GEnergy emax; + emin.TeV(e_min); + emax.TeV(e_max); + ebounds.append(emin, emax); + + } // endif: "emax" parameter was valid + + } // endif: "emin" parameter was valid + + // Return energy boundaries + return ebounds; +} + + +/***********************************************************************//** + * @brief Return Good Time Intervals from User parameter + * + * @return Good Time Intervals. + * + * Returns Good Time Intervals from the User parameters "tmin" and "tmax", + * taking into account the transformation into the CTA reference time system. + * If one of "tmin" or "tmax" is not valid, an empty Good Time Interval + * object is returned. If "tmin" is not valid, "tmax" is not queried. + ***************************************************************************/ +GGti ctool::get_gti(void) +{ + // Initialise Good Time Intervals with CTA reference time + GGti gti(m_cta_ref); + + // Get minimum time from "tmin" User parameter + GApplicationPar parmin = (*this)["tmin"]; + + // Continue only if "tmin" has a valid time value + if (parmin.is_valid()) { + + // Get maximum time from "tmax" User parameter + GApplicationPar parmax = (*this)["tmax"]; + + // Continue only if "tmax" has a valid time value + if (parmax.is_valid()) { + + // Get minimum and maximum time for CTA time reference + GTime tmin = parmin.time(m_cta_ref); + GTime tmax = parmax.time(m_cta_ref); + + // Append GTI + gti.append(tmin, tmax); + + } // endif: "tmax" parameter was valid + + } // endif: "tmin" parameter was valid + + // Return GTI + return gti; +} + + +/***********************************************************************//** + * @brief Return CTA pointing from User parameters + * + * @return CTA pointing. + * + * Returns CTA pointing from the User parameters "ra" and "dec". + ***************************************************************************/ +GCTAPointing ctool::get_pointing(void) +{ + // Get sky direction + GSkyDir skydir = get_skydir(); + + // Set CTA pointing + GCTAPointing pnt(skydir); + + // Return pointing + return pnt; +} + + +/***********************************************************************//** + * @brief Return sky direction from User parameters + * + * @return Sky direction. + * + * Returns sky direction from the User parameters "ra" and "dec". + ***************************************************************************/ +GSkyDir ctool::get_skydir(void) +{ + // Read Right Ascension and Declination parameters + double ra = (*this)["ra"].real(); + double dec = (*this)["dec"].real(); + + // Set sky direction + GSkyDir skydir; + skydir.radec_deg(ra, dec); + + // Return sky direction + return skydir; +} + + +/***********************************************************************//** * @brief Set output file name. * * @param[in] filename Input file name. @@ -1056,7 +1171,7 @@ std::string ctool::set_outfile_name(const std::string& filename) // Strip any ".gz" outname = gammalib::strip_chars(outname, ".gz"); - + // Return output filename return outname; } @@ -1120,7 +1235,7 @@ std::vector ctool::set_edisp(GObservations& obs, const bool& edisp) const // Yes, then set the energy dispersion flag if (cta != NULL) { - + // Save old energy dispersion flag old_edisp[i] = cta->response()->apply_edisp(); @@ -1280,7 +1395,7 @@ void ctool::set_obs_response(GCTAObservation* obs) // Set response without energy dispersion obs->response(exposure, psf, background); - + } // endelse: no energy dispersion was available } // endif: energy dispersion needed @@ -1322,7 +1437,7 @@ void ctool::set_obs_response(GCTAObservation* obs) // Attach response to observation obs->response(response); - + // Signal response availability has_response = true; @@ -1398,7 +1513,7 @@ void ctool::set_obs_bounds(GObservations& obs) list->roi(roi); } } - + } // endfor: looped over observations // Return @@ -1682,14 +1797,14 @@ GEnergies ctool::insert_energy_boundaries(const GEnergies& energies, bool insert = true; int index = -1; for (int k = 0; k < engs.size(); ++k) { - + // If energy exists already then skip the boundary and examine the // next one. We consider here 1 MeV as being sufficiently close. if (std::abs(engs[k].MeV()-energy.MeV()) < 1.0) { insert = false; break; } - + // If energy is above the boundary energy we found the index if (engs[k] > energy) { index = k; @@ -1927,7 +2042,7 @@ std::string ctool::warn_too_few_energies(const GEnergies& energies) const double logEmin = std::log10(energies[0].TeV()); double logEmax = std::log10(energies[n-1].TeV()); int nrequired = int((logEmax - logEmin) * 25.0); - + // Warn if there are not enough energy bins if (n < nrequired) { warning.append("\nWARNING: Only "+gammalib::str(n-1)+" energy bins " @@ -1961,7 +2076,7 @@ std::string ctool::warn_xml_suffix(const GFilename& filename) const // Get filename suffix std::string fname = std::string(filename); std::string suffix = gammalib::tolower(fname.substr(fname.length()-4,4)); - + // Warn if there are not enough energy bins if (suffix != ".xml") { warning.append("WARNING: Name of observation definition output file " diff --git a/src/support/ctool.hpp b/src/support/ctool.hpp index 43876e8..bf9cc5e 100644 --- a/src/support/ctool.hpp +++ b/src/support/ctool.hpp @@ -84,28 +84,32 @@ protected: void setup_models(GObservations& obs, const std::string& name = ""); // Protected methods that create objects from user parameters - GEbounds create_ebounds(void); - GSkyMap create_map(const GObservations& obs); - GCTAEventCube create_cube(const GObservations& obs); - GCTAObservation create_cta_obs(void); + GEbounds create_ebounds(void); + GSkyMap create_map(const GObservations& obs); + GCTAEventCube create_cube(const GObservations& obs); + GCTAObservation create_cta_obs(void); // Protected methods that check user parameters - void require_inobs(const std::string& method); - void require_inobs_nolist(const std::string& method); - void require_inobs_nocube(const std::string& method); - - // Protected methods for logging - void log_observations(const GChatter& chatter, - const GObservations& obs, - const std::string& what = "Observation"); - void log_models(const GChatter& chatter, - const GModels& models, - const std::string& what = "Model"); + void require_inobs(const std::string& method); + void require_inobs_nolist(const std::string& method); + void require_inobs_nocube(const std::string& method); // Protected methods that extract user parameters - GCTARoi get_roi(void); + GCTARoi get_roi(const GCTAPointing& pnt = GCTAPointing()); + GEbounds get_ebounds(void); + GGti get_gti(void); + GCTAPointing get_pointing(void); + GSkyDir get_skydir(void); std::string set_outfile_name(const std::string& filename); + // Protected methods for logging + void log_observations(const GChatter& chatter, + const GObservations& obs, + const std::string& what = "Observation"); + void log_models(const GChatter& chatter, + const GModels& models, + const std::string& what = "Model"); + // Protected support methods void set_response(GObservations& obs); std::vector set_edisp(GObservations& obs, const bool& edisp) const; diff --git a/test/test_cscript.py b/test/test_cscript.py index 8e498c3..97c4848 100755 --- a/test/test_cscript.py +++ b/test/test_cscript.py @@ -2,7 +2,7 @@ # ========================================================================== # This scripts performs unit tests for the cspull script. # -# Copyright (C) 2016 Juergen Knoedlseder +# Copyright (C) 2016-2017 Juergen Knoedlseder # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -37,7 +37,7 @@ class cscript_test(ctools.cscript): """ # Set name self._name = 'cscript_test' - self._version = '1.2.0' + self._version = ctools.__version__ # Initialise observation container from constructor arguments self._obs, argv = self._set_input_obs(argv) @@ -84,7 +84,8 @@ class cscript_test(ctools.cscript): # Check get_roi() method def check_get_roi(self): - return self._get_roi() + pnt = gammalib.GCTAPointing() + return self._get_roi(pnt) # Check restore_edisp() method def check_restore_edisp(self): @@ -140,7 +141,7 @@ class ctobservation_test(ctools.csobservation): """ # Set name self._name = 'ctobservation_test' - self._version = '1.2.0' + self._version = ctools.__version__ # Initialise application by calling the appropriate class constructor self._init_csobservation(argv) @@ -171,7 +172,7 @@ class ctlikelihood_test(ctools.cslikelihood): """ # Set name self._name = 'ctlikelihood_test' - self._version = '1.2.0' + self._version = ctools.__version__ # Initialise application by calling the appropriate class constructor self._init_cslikelihood(argv) @@ -213,6 +214,8 @@ class Test(test): pars.append(gammalib.GApplicationPar('rad','r','h','1.0','','','')) pars.append(gammalib.GApplicationPar('emin','r','h','1.0','','','')) pars.append(gammalib.GApplicationPar('emax','r','h','10.0','','','')) + pars.append(gammalib.GApplicationPar('tmin','t','h','2005-10-08T14:30:25','','','')) + pars.append(gammalib.GApplicationPar('tmax','t','h','2005-10-08T14:58:26','','','')) pars.append(gammalib.GApplicationPar('expcube','f','h','NONE','','','')) pars.append(gammalib.GApplicationPar('psfcube','f','h','NONE','','','')) pars.append(gammalib.GApplicationPar('bkgcube','f','h','NONE','','','')) diff --git a/test/test_cslightcrv.py b/test/test_cslightcrv.py index 2eaf4c9..6e93d25 100755 --- a/test/test_cslightcrv.py +++ b/test/test_cslightcrv.py @@ -72,7 +72,7 @@ class Test(test): cmd = cslightcrv+' inobs="'+self._events+'"'+ \ ' inmodel="'+self._model+'" srcname="Crab"'+ \ ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \ - ' tbinalg="LIN" tmin=51544.50 tmax=51544.53'+ \ + ' tbinalg="LIN" tmin="MJD 51544.50" tmax="MJD 51544.53"'+ \ ' tbins=3 enumbins=0 emin=0.1 emax=100.0'+ \ ' outfile="lightcurve_cmd1.fits"'+ \ ' logfile="cslightcrv_cmd1.log" chatter=1' @@ -92,7 +92,7 @@ class Test(test): cmd = cslightcrv+' inobs="events_that_do_not_exist.fits"'+ \ ' inmodel="'+self._model+'" srcname="Crab"'+ \ ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \ - ' tbinalg="LIN" tmin=51544.50 tmax=51544.53'+ \ + ' tbinalg="LIN" tmin="MJD 51544.50" tmax="MJD 51544.53"'+ \ ' tbins=3 enumbins=0 emin=0.1 emax=100.0'+ \ ' outfile="lightcurve_cmd1.fits"'+ \ ' logfile="cslightcrv_cmd2.log"' @@ -117,8 +117,8 @@ class Test(test): lcrv['caldb'] = self._caldb lcrv['irf'] = self._irf lcrv['tbinalg'] = 'LIN' - lcrv['tmin'] = 51544.50 - lcrv['tmax'] = 51544.53 + lcrv['tmin'] = 'MJD 51544.50' + lcrv['tmax'] = 'MJD 51544.53' lcrv['tbins'] = 3 lcrv['enumbins'] = 0 lcrv['emin'] = 0.1 @@ -206,8 +206,8 @@ class Test(test): lcrv['caldb'] = self._caldb lcrv['irf'] = self._irf lcrv['tbinalg'] = 'LIN' - lcrv['tmin'] = 51544.50 - lcrv['tmax'] = 51544.53 + lcrv['tmin'] = 'MJD 51544.50' + lcrv['tmax'] = 'MJD 51544.53' lcrv['tbins'] = 2 lcrv['emin'] = 0.1 lcrv['emax'] = 100.0 diff --git a/test/test_cspull.py b/test/test_cspull.py index 7b9143e..14c91cf 100755 --- a/test/test_cspull.py +++ b/test/test_cspull.py @@ -79,7 +79,7 @@ class Test(test): ' ntrials=2'+ \ ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \ ' ra=83.6331 dec=22.0145 emin=0.1 emax=100.0'+ \ - ' enumbins=0 tmax=100.0 deadc=0.98 rad=5.0'+ \ + ' enumbins=0 tmin=0.0 tmax=100.0 deadc=0.98 rad=5.0'+ \ ' npix=200 binsz=0.05'+ \ ' logfile="cspull_cmd1.log" chatter=1' @@ -100,7 +100,7 @@ class Test(test): ' ntrials=2'+ \ ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \ ' ra=83.6331 dec=22.0145 emin=0.1 emax=100.0'+ \ - ' enumbins=0 tmax=100.0 deadc=0.98 rad=5.0'+ \ + ' enumbins=0 tmin=0.0 tmax=100.0 deadc=0.98 rad=5.0'+ \ ' npix=200 binsz=0.05'+ \ ' logfile="cspull_cmd2.log"' @@ -128,6 +128,7 @@ class Test(test): pull['emin'] = 0.1 pull['emax'] = 100.0 pull['enumbins'] = 0 + pull['tmin'] = 0.0 pull['tmax'] = 100.0 pull['deadc'] = 0.98 pull['rad'] = 5.0 @@ -154,6 +155,7 @@ class Test(test): pull['emin'] = 0.1 pull['emax'] = 100.0 pull['enumbins'] = 10 + pull['tmin'] = 0.0 pull['tmax'] = 100.0 pull['deadc'] = 0.98 pull['rad'] = 5.0 diff --git a/test/test_cstsdist.py b/test/test_cstsdist.py index a8a47cd..a564cc6 100755 --- a/test/test_cstsdist.py +++ b/test/test_cstsdist.py @@ -2,7 +2,7 @@ # ========================================================================== # This scripts performs unit tests for the cstsdist script. # -# Copyright (C) 2016 Juergen Knoedlseder +# Copyright (C) 2016-2017 Juergen Knoedlseder # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -73,7 +73,7 @@ class Test(test): ' srcname="Crab"'+ \ ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \ ' ntrials=1 ra=83.63 dec=22.01 emin=0.1 emax=100.0'+ \ - ' enumbins=0 tmax=1800.0 rad=5.0 npix=200 npix=200'+ \ + ' enumbins=0 tmin=0.0 tmax=1800.0 rad=5.0 npix=200 npix=200'+ \ ' binsz=0.05'+ \ ' outfile="cstsdist_cmd1.dat"'+ \ ' logfile="cstsdist_cmd1.log" chatter=2' @@ -94,7 +94,7 @@ class Test(test): ' srcname="Crab"'+ \ ' caldb="'+self._caldb+'" irf="'+self._irf+'"'+ \ ' ntrials=1 ra=83.63 dec=22.01 emin=0.1 emax=100.0'+ \ - ' enumbins=0 tmax=1800.0 rad=5.0 npix=200 npix=200'+ \ + ' enumbins=0 tmin=0.0 tmax=1800.0 rad=5.0 npix=200 npix=200'+ \ ' binsz=0.05'+ \ ' outfile="cstsdist_cmd2.dat"'+ \ ' logfile="cstsdist_cmd2.log" chatter=2' @@ -123,6 +123,7 @@ class Test(test): tsdist['emin'] = 0.1 tsdist['emax'] = 100.0 tsdist['enumbins'] = 0 + tsdist['tmin'] = 0.0 tsdist['tmax'] = 1800.0 tsdist['rad'] = 5.0 tsdist['outfile'] = 'cstsdist_py1.dat' @@ -151,6 +152,7 @@ class Test(test): tsdist['emin'] = 0.1 tsdist['emax'] = 100.0 tsdist['enumbins'] = 10 + tsdist['tmin'] = 0.0 tsdist['tmax'] = 1800.0 tsdist['rad'] = 5.0 tsdist['npix'] = 50 diff --git a/test/test_ctobssim.py b/test/test_ctobssim.py index eae71cf..0c5d3be 100755 --- a/test/test_ctobssim.py +++ b/test/test_ctobssim.py @@ -75,7 +75,9 @@ class Test(test): ' outevents="ctobssim_cmd1.fits"'+ \ ' caldb="'+self._caldb+'" irf="'+self._irf+'" '+ \ ' ra=83.63 dec=22.01 rad=10.0'+ \ - ' tmin=0.0 tmax=1800.0 emin=0.1 emax=100.0'+ \ + ' tmin="2020-01-01T00:00:00"'+ \ + ' tmax="2020-01-01T00:30:00"'+ \ + ' emin=0.1 emax=100.0'+ \ ' logfile="ctobssim_cmd1.log" chatter=1' # Check if execution of wrong command fails @@ -95,7 +97,9 @@ class Test(test): ' outevents="ctobssim_cmd2.fits"'+ \ ' caldb="'+self._caldb+'" irf="'+self._irf+'" '+ \ ' ra=83.63 dec=22.01 rad=10.0'+ \ - ' tmin=0.0 tmax=1800.0 emin=0.1 emax=100.0'+ \ + ' tmin="2020-01-01T00:00:00"'+ \ + ' tmax="2020-01-01T00:30:00"'+ \ + ' emin=0.1 emax=100.0'+ \ ' logfile="ctobssim_cmd2.log" chatter=1' # Check if execution failed @@ -147,8 +151,8 @@ class Test(test): sim['ra'] = 83.63 sim['dec'] = 22.01 sim['rad'] = 10.0 - sim['tmin'] = 0.0 - sim['tmax'] = 1800.0 + sim['tmin'] = '2020-01-01T00:00:00' + sim['tmax'] = '2020-01-01T00:30:00' sim['emin'] = 0.1 sim['emax'] = 100.0 sim['outevents'] = 'ctobssim_py1.fits' -- libgit2 0.21.4