From 8e1420827d8a6ff95057875010c9ee13bb7529fe Mon Sep 17 00:00:00 2001 From: Jürgen Knödlseder Date: Tue, 11 Jan 2022 00:22:31 +0100 Subject: [PATCH] Rename GPulsarEphemerides class to GPulsarEphemeris --- NEWS | 4 ++-- include/GPulsar.hpp | 22 +++++++++++----------- include/GPulsarEphemerides.hpp | 327 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- include/GPulsarEphemeris.hpp | 327 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ include/GammaLib.hpp | 2 +- include/Makefile.am | 2 +- inst/com/src/GCOMDri.cpp | 10 +++++----- pyext/GPulsar.i | 16 ++++++++-------- pyext/GPulsarEphemerides.i | 78 ------------------------------------------------------------------------------ pyext/GPulsarEphemeris.i | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ pyext/gammalib/obs.i | 2 +- src/obs/GPulsar.cpp | 134 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------- src/obs/GPulsarEphemerides.cpp | 293 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- src/obs/GPulsarEphemeris.cpp | 293 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/obs/Makefile.am | 2 +- 15 files changed, 795 insertions(+), 795 deletions(-) delete mode 100644 include/GPulsarEphemerides.hpp create mode 100644 include/GPulsarEphemeris.hpp delete mode 100644 pyext/GPulsarEphemerides.i create mode 100644 pyext/GPulsarEphemeris.i delete mode 100644 src/obs/GPulsarEphemerides.cpp create mode 100644 src/obs/GPulsarEphemeris.cpp diff --git a/NEWS b/NEWS index f87e658..3c78235 100644 --- a/NEWS +++ b/NEWS @@ -16,7 +16,7 @@ The following classes have been added: - GIntegrals - GResponseVectorCache - GPulsar -- GPulsarEphemerides +- GPulsarEphemeris - GSkyDirs - GSkyRegionRect - GModelAssociation @@ -283,7 +283,7 @@ intervals (#3973). Add GGti::reduce(GGti&) method to reduce Good Time Intervals to the intersection with a specific list of intervals (#3973). -Add GPulsar and GPulsarEphemerides classes to support pulsar analysis (#3973). +Add GPulsar and GPulsarEphemeris classes to support pulsar analysis (#3973). Add likelihood fit event selection hook (#3912). diff --git a/include/GPulsar.hpp b/include/GPulsar.hpp index d1c81fe..7d08558 100644 --- a/include/GPulsar.hpp +++ b/include/GPulsar.hpp @@ -31,7 +31,7 @@ #include #include #include "GBase.hpp" -#include "GPulsarEphemerides.hpp" +#include "GPulsarEphemeris.hpp" /* __ Forward declarations _______________________________________________ */ class GGti; @@ -66,14 +66,14 @@ public: virtual std::string print(const GChatter& chatter = NORMAL) const; // Other methods - int size(void) const; - bool is_empty(void) const; - const std::string& name(void) const; - void name(const std::string& name); - const GPulsarEphemerides& ephemerides(const GTime& time) const; - GGti validity(void) const; - void load(const GFilename& filename, - const std::string& name = ""); + int size(void) const; + bool is_empty(void) const; + const std::string& name(void) const; + void name(const std::string& name); + const GPulsarEphemeris& ephemeris(const GTime& time) const; + GGti validity(void) const; + void load(const GFilename& filename, + const std::string& name = ""); protected: // Protected methods @@ -87,8 +87,8 @@ protected: void load_parfile(const GFilename& filename); // Protected members - std::string m_name; //!< Pulsar name - std::vector m_ephemerides; //!< Pulsar ephemerides + std::string m_name; //!< Pulsar name + std::vector m_ephemerides; //!< Pulsar ephemerides }; diff --git a/include/GPulsarEphemerides.hpp b/include/GPulsarEphemerides.hpp deleted file mode 100644 index 967803e..0000000 --- a/include/GPulsarEphemerides.hpp +++ /dev/null @@ -1,327 +0,0 @@ -/*************************************************************************** - * GPulsarEphemerides.hpp - Pulsar ephemerides class * - * ----------------------------------------------------------------------- * - * copyright (C) 2022 by 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 * - * the Free Software Foundation, either version 3 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program. If not, see . * - * * - ***************************************************************************/ -/** - * @file GPulsarEphemerides.hpp - * @brief Pulsar ephemerides class definition - * @author Juergen Knoedlseder - */ - -#ifndef GPULSAREPHEMERIDES_HPP -#define GPULSAREPHEMERIDES_HPP - -/* __ Includes ___________________________________________________________ */ -#include -#include "GBase.hpp" -#include "GTime.hpp" -#include "GSkyDir.hpp" -#include "GModelTemporalPhaseCurve.hpp" - -/* __ Forward declarations _______________________________________________ */ - -/* __ Constants __________________________________________________________ */ - - -/***********************************************************************//** - * @class GPulsarEphemerides - * - * @brief Pulsar ephemerides class - * - * @todo Add class description. - ***************************************************************************/ -class GPulsarEphemerides : public GBase { - -public: - // Constructors and destructors - GPulsarEphemerides(void); - GPulsarEphemerides(const GPulsarEphemerides& ephemerides); - virtual ~GPulsarEphemerides(void); - - // Operators - GPulsarEphemerides& operator=(const GPulsarEphemerides& ephemerides); - - // Implemented pure virtual base class methods - virtual void clear(void); - virtual GPulsarEphemerides* clone(void) const; - virtual std::string classname(void) const; - virtual std::string print(const GChatter& chatter = NORMAL) const; - - // Other methods - const std::string& name(void) const; - void name(const std::string& name); - const GSkyDir& dir(void) const; - void dir(const GSkyDir& dir); - const GTime& tstart(void) const; - void tstart(const GTime& tstart); - const GTime& tstop(void) const; - void tstop(const GTime& tstop); - GTime t0(void) const; - void t0(const GTime& t0); - double f0(void) const; - void f0(const double& f0); - double f1(void) const; - void f1(const double& f1); - double f2(void) const; - void f2(const double& f2); - double phase(const GTime& time) const; - -protected: - // Protected methods - void init_members(void); - void copy_members(const GPulsarEphemerides& ephemerides); - void free_members(void); - - // Protected members - std::string m_name; //!< Pulsar name - GTime m_tstart; //!< Validity start time - GTime m_tstop; //!< Validity stop time - GSkyDir m_dir; //!< Pulsar sky direction - GModelTemporalPhaseCurve m_phase_curve; //!< Pulsar phase curve -}; - - -/***********************************************************************//** - * @brief Return class name - * - * @return String containing the class name ("GPulsarEphemerides"). - ***************************************************************************/ -inline -std::string GPulsarEphemerides::classname(void) const -{ - return ("GPulsarEphemerides"); -} - - -/***********************************************************************//** - * @brief Returns pulsar name - * - * @return Pulsar name. - ***************************************************************************/ -inline -const std::string& GPulsarEphemerides::name(void) const -{ - // Return - return m_name; -} - - -/***********************************************************************//** - * @brief Set pulsar name - * - * @param[in] name Pulsar name. - ***************************************************************************/ -inline -void GPulsarEphemerides::name(const std::string& name) -{ - m_name = name; - return; -} - - -/***********************************************************************//** - * @brief Returns pulsar sky direction - * - * @return Pulsar sky direction. - ***************************************************************************/ -inline -const GSkyDir& GPulsarEphemerides::dir(void) const -{ - // Return - return m_dir; -} - - -/***********************************************************************//** - * @brief Set pulsar sky direction - * - * @param[in] dir Pulsar sky direction. - ***************************************************************************/ -inline -void GPulsarEphemerides::dir(const GSkyDir& dir) -{ - m_dir = dir; - return; -} - - -/***********************************************************************//** - * @brief Returns validity start time - * - * @return Validity start time. - ***************************************************************************/ -inline -const GTime& GPulsarEphemerides::tstart(void) const -{ - // Return - return m_tstart; -} - - -/***********************************************************************//** - * @brief Set validity start time - * - * @param[in] tstart Validity start time. - ***************************************************************************/ -inline -void GPulsarEphemerides::tstart(const GTime& tstart) -{ - m_tstart = tstart; - return; -} - - -/***********************************************************************//** - * @brief Returns validity stop time - * - * @return Validity stop time. - ***************************************************************************/ -inline -const GTime& GPulsarEphemerides::tstop(void) const -{ - // Return - return m_tstop; -} - - -/***********************************************************************//** - * @brief Set validity stop time - * - * @param[in] tstop Validity stop time. - ***************************************************************************/ -inline -void GPulsarEphemerides::tstop(const GTime& tstop) -{ - m_tstop = tstop; - return; -} - - -/***********************************************************************//** - * @brief Returns time of phase 0 - * - * @return Reference time of phase 0. - ***************************************************************************/ -inline -GTime GPulsarEphemerides::t0(void) const -{ - return (m_phase_curve.mjd()); -} - - -/***********************************************************************//** - * @brief Set time of phase 0 - * - * @param[in] t0 Reference time of phase 0. - ***************************************************************************/ -inline -void GPulsarEphemerides::t0(const GTime& t0) -{ - m_phase_curve.mjd(t0); - return; -} - - -/***********************************************************************//** - * @brief Returns pulsar frequency (Hz) - * - * @return Pulsar frequency (Hz). - ***************************************************************************/ -inline -double GPulsarEphemerides::f0(void) const -{ - return (m_phase_curve.f0()); -} - - -/***********************************************************************//** - * @brief Set pulsar frequency (Hz) - * - * @param[in] f0 Pulsar frequency (Hz). - ***************************************************************************/ -inline -void GPulsarEphemerides::f0(const double& f0) -{ - m_phase_curve.f0(f0); - return; -} - - -/***********************************************************************//** - * @brief Returns pulsar frequency derivative (s^-2) - * - * @return Pulsar frequency derivative (s^-2). - ***************************************************************************/ -inline -double GPulsarEphemerides::f1(void) const -{ - return (m_phase_curve.f1()); -} - - -/***********************************************************************//** - * @brief Set pulsar frequency derivative (s^-2) - * - * @param[in] f1 Pulsar frequency derivative (s^-2). - ***************************************************************************/ -inline -void GPulsarEphemerides::f1(const double& f1) -{ - m_phase_curve.f1(f1); - return; -} - - -/***********************************************************************//** - * @brief Returns pulsar second frequency derivative (s^-3) - * - * @return Pulsar second frequency derivative (s^-3). - ***************************************************************************/ -inline -double GPulsarEphemerides::f2(void) const -{ - return (m_phase_curve.f2()); -} - - -/***********************************************************************//** - * @brief Set pulsar second frequency derivative (s^-3) - * - * @param[in] f2 Pulsar second frequency derivative (s^-3). - ***************************************************************************/ -inline -void GPulsarEphemerides::f2(const double& f2) -{ - m_phase_curve.f2(f2); - return; -} - - -/***********************************************************************//** - * @brief Returns pulsar phase - * - * @return Pulsar phase. - ***************************************************************************/ -inline -double GPulsarEphemerides::phase(const GTime& time) const -{ - return (m_phase_curve.phase(time)); -} - -#endif /* GPULSAREPHEMERIDES_HPP */ diff --git a/include/GPulsarEphemeris.hpp b/include/GPulsarEphemeris.hpp new file mode 100644 index 0000000..8cec42e --- /dev/null +++ b/include/GPulsarEphemeris.hpp @@ -0,0 +1,327 @@ +/*************************************************************************** + * GPulsarEphemeris.hpp - Pulsar ephemeris class * + * ----------------------------------------------------------------------- * + * copyright (C) 2022 by 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 * + * the Free Software Foundation, either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * + * * + ***************************************************************************/ +/** + * @file GPulsarEphemeris.hpp + * @brief Pulsar ephemeris class definition + * @author Juergen Knoedlseder + */ + +#ifndef GPULSAREPHEMERIS_HPP +#define GPULSAREPHEMERIS_HPP + +/* __ Includes ___________________________________________________________ */ +#include +#include "GBase.hpp" +#include "GTime.hpp" +#include "GSkyDir.hpp" +#include "GModelTemporalPhaseCurve.hpp" + +/* __ Forward declarations _______________________________________________ */ + +/* __ Constants __________________________________________________________ */ + + +/***********************************************************************//** + * @class GPulsarEphemeris + * + * @brief Pulsar ephemeris class + * + * This class implements an ephemeris for a pulsar. + ***************************************************************************/ +class GPulsarEphemeris : public GBase { + +public: + // Constructors and destructors + GPulsarEphemeris(void); + GPulsarEphemeris(const GPulsarEphemeris& ephemeris); + virtual ~GPulsarEphemeris(void); + + // Operators + GPulsarEphemeris& operator=(const GPulsarEphemeris& ephemeris); + + // Implemented pure virtual base class methods + virtual void clear(void); + virtual GPulsarEphemeris* clone(void) const; + virtual std::string classname(void) const; + virtual std::string print(const GChatter& chatter = NORMAL) const; + + // Other methods + const std::string& name(void) const; + void name(const std::string& name); + const GSkyDir& dir(void) const; + void dir(const GSkyDir& dir); + const GTime& tstart(void) const; + void tstart(const GTime& tstart); + const GTime& tstop(void) const; + void tstop(const GTime& tstop); + GTime t0(void) const; + void t0(const GTime& t0); + double f0(void) const; + void f0(const double& f0); + double f1(void) const; + void f1(const double& f1); + double f2(void) const; + void f2(const double& f2); + double phase(const GTime& time) const; + +protected: + // Protected methods + void init_members(void); + void copy_members(const GPulsarEphemeris& ephemeris); + void free_members(void); + + // Protected members + std::string m_name; //!< Pulsar name + GTime m_tstart; //!< Validity start time + GTime m_tstop; //!< Validity stop time + GSkyDir m_dir; //!< Pulsar sky direction + GModelTemporalPhaseCurve m_phase_curve; //!< Pulsar phase curve +}; + + +/***********************************************************************//** + * @brief Return class name + * + * @return String containing the class name ("GPulsarEphemeris"). + ***************************************************************************/ +inline +std::string GPulsarEphemeris::classname(void) const +{ + return ("GPulsarEphemeris"); +} + + +/***********************************************************************//** + * @brief Returns pulsar name + * + * @return Pulsar name. + ***************************************************************************/ +inline +const std::string& GPulsarEphemeris::name(void) const +{ + // Return + return m_name; +} + + +/***********************************************************************//** + * @brief Set pulsar name + * + * @param[in] name Pulsar name. + ***************************************************************************/ +inline +void GPulsarEphemeris::name(const std::string& name) +{ + m_name = name; + return; +} + + +/***********************************************************************//** + * @brief Returns pulsar sky direction + * + * @return Pulsar sky direction. + ***************************************************************************/ +inline +const GSkyDir& GPulsarEphemeris::dir(void) const +{ + // Return + return m_dir; +} + + +/***********************************************************************//** + * @brief Set pulsar sky direction + * + * @param[in] dir Pulsar sky direction. + ***************************************************************************/ +inline +void GPulsarEphemeris::dir(const GSkyDir& dir) +{ + m_dir = dir; + return; +} + + +/***********************************************************************//** + * @brief Returns validity start time + * + * @return Validity start time. + ***************************************************************************/ +inline +const GTime& GPulsarEphemeris::tstart(void) const +{ + // Return + return m_tstart; +} + + +/***********************************************************************//** + * @brief Set validity start time + * + * @param[in] tstart Validity start time. + ***************************************************************************/ +inline +void GPulsarEphemeris::tstart(const GTime& tstart) +{ + m_tstart = tstart; + return; +} + + +/***********************************************************************//** + * @brief Returns validity stop time + * + * @return Validity stop time. + ***************************************************************************/ +inline +const GTime& GPulsarEphemeris::tstop(void) const +{ + // Return + return m_tstop; +} + + +/***********************************************************************//** + * @brief Set validity stop time + * + * @param[in] tstop Validity stop time. + ***************************************************************************/ +inline +void GPulsarEphemeris::tstop(const GTime& tstop) +{ + m_tstop = tstop; + return; +} + + +/***********************************************************************//** + * @brief Returns time of phase 0 + * + * @return Reference time of phase 0. + ***************************************************************************/ +inline +GTime GPulsarEphemeris::t0(void) const +{ + return (m_phase_curve.mjd()); +} + + +/***********************************************************************//** + * @brief Set time of phase 0 + * + * @param[in] t0 Reference time of phase 0. + ***************************************************************************/ +inline +void GPulsarEphemeris::t0(const GTime& t0) +{ + m_phase_curve.mjd(t0); + return; +} + + +/***********************************************************************//** + * @brief Returns pulsar frequency (Hz) + * + * @return Pulsar frequency (Hz). + ***************************************************************************/ +inline +double GPulsarEphemeris::f0(void) const +{ + return (m_phase_curve.f0()); +} + + +/***********************************************************************//** + * @brief Set pulsar frequency (Hz) + * + * @param[in] f0 Pulsar frequency (Hz). + ***************************************************************************/ +inline +void GPulsarEphemeris::f0(const double& f0) +{ + m_phase_curve.f0(f0); + return; +} + + +/***********************************************************************//** + * @brief Returns pulsar frequency derivative (s^-2) + * + * @return Pulsar frequency derivative (s^-2). + ***************************************************************************/ +inline +double GPulsarEphemeris::f1(void) const +{ + return (m_phase_curve.f1()); +} + + +/***********************************************************************//** + * @brief Set pulsar frequency derivative (s^-2) + * + * @param[in] f1 Pulsar frequency derivative (s^-2). + ***************************************************************************/ +inline +void GPulsarEphemeris::f1(const double& f1) +{ + m_phase_curve.f1(f1); + return; +} + + +/***********************************************************************//** + * @brief Returns pulsar second frequency derivative (s^-3) + * + * @return Pulsar second frequency derivative (s^-3). + ***************************************************************************/ +inline +double GPulsarEphemeris::f2(void) const +{ + return (m_phase_curve.f2()); +} + + +/***********************************************************************//** + * @brief Set pulsar second frequency derivative (s^-3) + * + * @param[in] f2 Pulsar second frequency derivative (s^-3). + ***************************************************************************/ +inline +void GPulsarEphemeris::f2(const double& f2) +{ + m_phase_curve.f2(f2); + return; +} + + +/***********************************************************************//** + * @brief Returns pulsar phase + * + * @return Pulsar phase. + ***************************************************************************/ +inline +double GPulsarEphemeris::phase(const GTime& time) const +{ + return (m_phase_curve.phase(time)); +} + +#endif /* GPULSAREPHEMERIS_HPP */ diff --git a/include/GammaLib.hpp b/include/GammaLib.hpp index 060f1ac..eaa6c1b 100644 --- a/include/GammaLib.hpp +++ b/include/GammaLib.hpp @@ -198,7 +198,7 @@ #include "GPhoton.hpp" #include "GSource.hpp" #include "GPulsar.hpp" -#include "GPulsarEphemerides.hpp" +#include "GPulsarEphemeris.hpp" /* __ Model handling _____________________________________________________ */ #include "GModelPar.hpp" diff --git a/include/Makefile.am b/include/Makefile.am index 9ab149c..1852bd2 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -158,7 +158,7 @@ pkginclude_HEADERS = GammaLib.hpp \ GPhoton.hpp \ GSource.hpp \ GPulsar.hpp \ - GPulsarEphemerides.hpp \ + GPulsarEphemeris.hpp \ GModelPar.hpp \ GModelAssociation.hpp \ GModelAssociations.hpp \ diff --git a/inst/com/src/GCOMDri.cpp b/inst/com/src/GCOMDri.cpp index 0ad6dd6..99b07a2 100644 --- a/inst/com/src/GCOMDri.cpp +++ b/inst/com/src/GCOMDri.cpp @@ -460,16 +460,16 @@ void GCOMDri::compute_dre(const GCOMObservation& obs, // Optionally apply pulsar phase selection if (has_pulsar) { - // Get pulsar ephemerides - const GPulsarEphemerides& ephemerides = - m_selection.pulsar().ephemerides(event->time()); + // Get pulsar ephemeris + const GPulsarEphemeris& ephemeris = + m_selection.pulsar().ephemeris(event->time()); // Convert time to Solar System Barycentre GTime time = event->time() + - obs.bvcs().tdelta(ephemerides.dir(), event->time()); + obs.bvcs().tdelta(ephemeris.dir(), event->time()); // Compute pulsar phase - double phase = ephemerides.phase(time); + double phase = ephemeris.phase(time); // If phase is not contained in phase interval then skip event if (!m_selection.pulsar_phases().contains(phase)) { diff --git a/pyext/GPulsar.i b/pyext/GPulsar.i index b4658f3..ee407b9 100644 --- a/pyext/GPulsar.i +++ b/pyext/GPulsar.i @@ -49,14 +49,14 @@ public: virtual std::string classname(void) const; // Other methods - int size(void) const; - bool is_empty(void) const; - const std::string& name(void) const; - void name(const std::string& name); - const GPulsarEphemerides& ephemerides(const GTime& time) const; - GGti validity(void) const; - void load(const GFilename& filename, - const std::string& name = ""); + int size(void) const; + bool is_empty(void) const; + const std::string& name(void) const; + void name(const std::string& name); + const GPulsarEphemeris& ephemeris(const GTime& time) const; + GGti validity(void) const; + void load(const GFilename& filename, + const std::string& name = ""); }; diff --git a/pyext/GPulsarEphemerides.i b/pyext/GPulsarEphemerides.i deleted file mode 100644 index e1e3866..0000000 --- a/pyext/GPulsarEphemerides.i +++ /dev/null @@ -1,78 +0,0 @@ -/*************************************************************************** - * GPulsarEphemerides.i - Pulsar ephemerides class * - * ----------------------------------------------------------------------- * - * copyright (C) 2022 by 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 * - * the Free Software Foundation, either version 3 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program. If not, see . * - * * - ***************************************************************************/ -/** - * @file GPulsarEphemerides.i - * @brief Pulsar ephemerides class definition - * @author Juergen Knoedlseder - */ -%{ -/* Put headers and other declarations here that are needed for compilation */ -#include "GPulsarEphemerides.hpp" -%} - - -/***********************************************************************//** - * @class GPulsarEphemerides - * - * @brief Pulsar ephemerides class - ***************************************************************************/ -class GPulsarEphemerides : public GBase { - -public: - // Constructors and destructors - GPulsarEphemerides(void); - GPulsarEphemerides(const GPulsarEphemerides& ephemerides); - virtual ~GPulsarEphemerides(void); - - // Implemented pure virtual base class methods - virtual void clear(void); - virtual GPulsarEphemerides* clone(void) const; - virtual std::string classname(void) const; - - // Other methods - const std::string& name(void) const; - void name(const std::string& name); - const GSkyDir& dir(void) const; - void dir(const GSkyDir& dir); - const GTime& tstart(void) const; - void tstart(const GTime& tstart); - const GTime& tstop(void) const; - void tstop(const GTime& tstop); - GTime t0(void) const; - void t0(const GTime& t0); - double f0(void) const; - void f0(const double& f0); - double f1(void) const; - void f1(const double& f1); - double f2(void) const; - void f2(const double& f2); - double phase(const GTime& time) const; -}; - - -/***********************************************************************//** - * @brief GPulsarEphemerides class extension - ***************************************************************************/ -%extend GPulsarEphemerides { - GPulsarEphemerides copy() { - return (*self); - } -}; diff --git a/pyext/GPulsarEphemeris.i b/pyext/GPulsarEphemeris.i new file mode 100644 index 0000000..4409d12 --- /dev/null +++ b/pyext/GPulsarEphemeris.i @@ -0,0 +1,78 @@ +/*************************************************************************** + * GPulsarEphemeris.i - Pulsar ephemeris class * + * ----------------------------------------------------------------------- * + * copyright (C) 2022 by 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 * + * the Free Software Foundation, either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * + * * + ***************************************************************************/ +/** + * @file GPulsarEphemeris.i + * @brief Pulsar ephemeris class definition + * @author Juergen Knoedlseder + */ +%{ +/* Put headers and other declarations here that are needed for compilation */ +#include "GPulsarEphemeris.hpp" +%} + + +/***********************************************************************//** + * @class GPulsarEphemeris + * + * @brief Pulsar ephemeris class + ***************************************************************************/ +class GPulsarEphemeris : public GBase { + +public: + // Constructors and destructors + GPulsarEphemeris(void); + GPulsarEphemeris(const GPulsarEphemeris& ephemeris); + virtual ~GPulsarEphemeris(void); + + // Implemented pure virtual base class methods + virtual void clear(void); + virtual GPulsarEphemeris* clone(void) const; + virtual std::string classname(void) const; + + // Other methods + const std::string& name(void) const; + void name(const std::string& name); + const GSkyDir& dir(void) const; + void dir(const GSkyDir& dir); + const GTime& tstart(void) const; + void tstart(const GTime& tstart); + const GTime& tstop(void) const; + void tstop(const GTime& tstop); + GTime t0(void) const; + void t0(const GTime& t0); + double f0(void) const; + void f0(const double& f0); + double f1(void) const; + void f1(const double& f1); + double f2(void) const; + void f2(const double& f2); + double phase(const GTime& time) const; +}; + + +/***********************************************************************//** + * @brief GPulsarEphemeris class extension + ***************************************************************************/ +%extend GPulsarEphemeris { + GPulsarEphemeris copy() { + return (*self); + } +}; diff --git a/pyext/gammalib/obs.i b/pyext/gammalib/obs.i index ac8323c..df8cb45 100644 --- a/pyext/gammalib/obs.i +++ b/pyext/gammalib/obs.i @@ -245,4 +245,4 @@ %include "GPhotons.i" %include "GSource.i" %include "GPulsar.i" -%include "GPulsarEphemerides.i" +%include "GPulsarEphemeris.i" diff --git a/src/obs/GPulsar.cpp b/src/obs/GPulsar.cpp index 62f1c97..7b48166 100644 --- a/src/obs/GPulsar.cpp +++ b/src/obs/GPulsar.cpp @@ -189,17 +189,17 @@ GPulsar* GPulsar::clone(void) const /***********************************************************************//** - * @brief Return pulsar ephemerides + * @brief Return pulsar ephemeris * * param[in] time Time. - * @return Pulsar ephemerides. + * @return Pulsar ephemeris. * * @exception GException::invalid_argument - * No valid ephemerides found for specified @p time. + * No valid ephemeris found for specified @p time. * - * Returns the pulsar ephemerides as function of time. + * Returns the pulsar ephemeris as function of time. ***************************************************************************/ -const GPulsarEphemerides& GPulsar::ephemerides(const GTime& time) const +const GPulsarEphemeris& GPulsar::ephemeris(const GTime& time) const { // Find appropriate ephemerides int ifound = -1; @@ -213,7 +213,7 @@ const GPulsarEphemerides& GPulsar::ephemerides(const GTime& time) const // Throw an expection if no valid ephemerides were found if (ifound == -1) { - std::string msg = "No valid ephemerides found for MJD "+ + std::string msg = "No valid ephemeris found for MJD "+ gammalib::str(time.mjd())+". Please specify " "ephemerides that comprise the time."; throw GException::invalid_argument(G_PHASE, msg); @@ -519,21 +519,21 @@ void GPulsar::load_integral(const GFitsTable* table, const std::string& name) t0.mjd(tref0->real(i)); t0 += t2peak->real(i); - // Allocate ephemerides - GPulsarEphemerides ephemerides; + // Allocate ephemeris + GPulsarEphemeris ephemeris; // Set attributes - ephemerides.name(m_name); - ephemerides.dir(dir); - ephemerides.tstart(tstart); - ephemerides.tstop(tstop); - ephemerides.t0(t0); - ephemerides.f0(f0->real(i)); - ephemerides.f1(f1->real(i)); - ephemerides.f2(f2->real(i)); - - // Push back ephemerides - m_ephemerides.push_back(ephemerides); + ephemeris.name(m_name); + ephemeris.dir(dir); + ephemeris.tstart(tstart); + ephemeris.tstop(tstop); + ephemeris.t0(t0); + ephemeris.f0(f0->real(i)); + ephemeris.f1(f1->real(i)); + ephemeris.f2(f2->real(i)); + + // Push back ephemeris + m_ephemerides.push_back(ephemeris); } // endfor: looped over ephemerides @@ -592,21 +592,21 @@ void GPulsar::load_fermi(const GFitsTable* table, const std::string& name) GTime t0; t0.mjd(toabary_int->integer(i)+toabary_frac->real(i)); - // Allocate ephemerides - GPulsarEphemerides ephemerides; + // Allocate ephemeris + GPulsarEphemeris ephemeris; // Set attributes - ephemerides.name(m_name); - ephemerides.dir(dir); - ephemerides.tstart(tstart); - ephemerides.tstop(tstop); - ephemerides.t0(t0); - ephemerides.f0(f0->real(i)); - ephemerides.f1(f1->real(i)); - ephemerides.f2(f2->real(i)); - - // Push back ephemerides - m_ephemerides.push_back(ephemerides); + ephemeris.name(m_name); + ephemeris.dir(dir); + ephemeris.tstart(tstart); + ephemeris.tstop(tstop); + ephemeris.t0(t0); + ephemeris.f0(f0->real(i)); + ephemeris.f1(f1->real(i)); + ephemeris.f2(f2->real(i)); + + // Push back ephemeris + m_ephemerides.push_back(ephemeris); } // endfor: looped over ephemerides @@ -731,21 +731,21 @@ void GPulsar::load_psrtime(const GFilename& filename, const std::string& name) GTime t0; t0.mjd(t0geo); // TODO: conversion to Bary ??? - // Allocate ephemerides - GPulsarEphemerides ephemerides; + // Allocate ephemeris + GPulsarEphemeris ephemeris; // Set attributes - ephemerides.name(m_name); - ephemerides.dir(dir); - ephemerides.tstart(tstart); - ephemerides.tstop(tstop); - ephemerides.t0(t0); - ephemerides.f0(f0); - ephemerides.f1(f1); - ephemerides.f2(f2); - - // Push back ephemerides - m_ephemerides.push_back(ephemerides); + ephemeris.name(m_name); + ephemeris.dir(dir); + ephemeris.tstart(tstart); + ephemeris.tstop(tstop); + ephemeris.t0(t0); + ephemeris.f0(f0); + ephemeris.f1(f1); + ephemeris.f2(f2); + + // Push back ephemeris + m_ephemerides.push_back(ephemeris); } // endwhile: looped over lines @@ -758,17 +758,17 @@ void GPulsar::load_psrtime(const GFilename& filename, const std::string& name) /***********************************************************************//** - * @brief Load Pulsar from ephemerides par file + * @brief Load Pulsar from ephemeris par file * - * @param[in] filename Name of pulsar ephemerides par file + * @param[in] filename Name of pulsar ephemeris par file * @param[in] name Pulsar name * * @exception GException::file_error - * Could not open ephemerides ASCII file + * Could not open ephemeris ASCII file * @exception GException::invalid_argument * No valid Right Ascension and Declination found * - * Load a pulsar from an ephemerides par file. + * Load a pulsar from an ephemeris par file. ***************************************************************************/ void GPulsar::load_parfile(const GFilename& filename) { @@ -779,16 +779,16 @@ void GPulsar::load_parfile(const GFilename& filename) // Open file FILE* fptr = std::fopen(filename.url().c_str(), "r"); if (fptr == NULL) { - std::string msg = "Pulsar ephemerides file \""+filename.url()+ + std::string msg = "Pulsar ephemeris file \""+filename.url()+ "\" not found or readable. Please specify a " - "valid and readable ephemerides file."; + "valid and readable ephemeris file."; throw GException::file_error(G_LOAD_PARFILE, msg); } - // Allocate ephemerides - GPulsarEphemerides ephemerides; - double ra = 9999.0; - double dec = 9999.0; + // Allocate ephemeris + GPulsarEphemeris ephemeris; + double ra = 9999.0; + double dec = 9999.0; // Read lines while (std::fgets(line, n, fptr) != NULL) { @@ -799,7 +799,7 @@ void GPulsar::load_parfile(const GFilename& filename) // Extract keywords if (elements[0] == "PSRJ") { m_name = "PSR " + gammalib::rstrip_chars(elements[1], "\n"); - ephemerides.name(m_name); + ephemeris.name(m_name); } else if (elements[0] == "RAJ") { std::vector ras = gammalib::split(elements[1], ":"); @@ -819,44 +819,44 @@ void GPulsar::load_parfile(const GFilename& filename) else if (elements[0] == "START") { GTime tstart; tstart.mjd(gammalib::todouble(elements[1])); - ephemerides.tstart(tstart); + ephemeris.tstart(tstart); } else if (elements[0] == "FINISH") { GTime tstop; tstop.mjd(gammalib::todouble(elements[1])); - ephemerides.tstop(tstop); + ephemeris.tstop(tstop); } else if (elements[0] == "TZRMJD") { // TODO: Are you sure??? GTime t0; t0.mjd(gammalib::todouble(elements[1])); - ephemerides.t0(t0); + ephemeris.t0(t0); } else if (elements[0] == "F0") { - ephemerides.f0(gammalib::todouble(elements[1])); + ephemeris.f0(gammalib::todouble(elements[1])); } else if (elements[0] == "F1") { - ephemerides.f1(gammalib::todouble(elements[1])); + ephemeris.f1(gammalib::todouble(elements[1])); } else if (elements[0] == "F2") { - ephemerides.f2(gammalib::todouble(elements[1])); + ephemeris.f2(gammalib::todouble(elements[1])); } } // endwhile: looped over lines // If Right Ascension and Declination is valid then set sky direction - // and push back ephemerides + // and push back ephemeris if (ra >= 0.0 && ra <= 360.0 && dec >= -90.0 && dec <= 90.0) { GSkyDir dir; dir.radec_deg(ra, dec); - ephemerides.dir(dir); - m_ephemerides.push_back(ephemerides); + ephemeris.dir(dir); + m_ephemerides.push_back(ephemeris); } // ... otherwise throw an exception else { std::string msg = "No valid Right Ascension or Declination found in " - "pulsar ephemerides file \""+filename.url()+"\". " - "Please verify the ephemerides file."; + "pulsar ephemeris file \""+filename.url()+"\". " + "Please verify the ephemeris file."; throw GException::invalid_argument(G_LOAD_PARFILE, msg); } diff --git a/src/obs/GPulsarEphemerides.cpp b/src/obs/GPulsarEphemerides.cpp deleted file mode 100644 index 4808119..0000000 --- a/src/obs/GPulsarEphemerides.cpp +++ /dev/null @@ -1,293 +0,0 @@ -/*************************************************************************** - * GPulsarEphemerides.cpp - Pulsar ephemerides class * - * ----------------------------------------------------------------------- * - * copyright (C) 2022 by 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 * - * the Free Software Foundation, either version 3 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program. If not, see . * - * * - ***************************************************************************/ -/** - * @file GPulsarEphemerides.cpp - * @brief Pulsar ephemerides class implementation - * @author Juergen Knoedlseder - */ - -/* __ Includes ___________________________________________________________ */ -#ifdef HAVE_CONFIG_H -#include -#endif -#include "GPulsarEphemerides.hpp" - -/* __ Method name definitions ____________________________________________ */ - -/* __ Macros _____________________________________________________________ */ - -/* __ Coding definitions _________________________________________________ */ - -/* __ Debug definitions __________________________________________________ */ - - - -/*========================================================================== - = = - = Constructors/destructors = - = = - ==========================================================================*/ - -/***********************************************************************//** - * @brief Void constructor - ***************************************************************************/ -GPulsarEphemerides::GPulsarEphemerides(void) -{ - // Initialise class members - init_members(); - - // Return - return; -} - - -/***********************************************************************//** - * @brief Copy constructor - * - * @param[in] ephemerides Pulsar ephemerides. - ***************************************************************************/ -GPulsarEphemerides::GPulsarEphemerides(const GPulsarEphemerides& ephemerides) -{ - // Initialise class members - init_members(); - - // Copy members - copy_members(ephemerides); - - // Return - return; -} - - -/***********************************************************************//** - * @brief Destructor - ***************************************************************************/ -GPulsarEphemerides::~GPulsarEphemerides(void) -{ - // Free members - free_members(); - - // Return - return; -} - - -/*========================================================================== - = = - = Operators = - = = - ==========================================================================*/ - -/***********************************************************************//** - * @brief Assignment operator - * - * @param[in] ephemerides Pulsar ephemerides. - * @return Pulsar ephemerides. - ***************************************************************************/ -GPulsarEphemerides& GPulsarEphemerides::operator=(const GPulsarEphemerides& ephemerides) -{ - // Execute only if object is not identical - if (this != &ephemerides) { - - // Free members - free_members(); - - // Initialise private members - init_members(); - - // Copy members - copy_members(ephemerides); - - } // endif: object was not identical - - // Return this object - return *this; -} - - -/*========================================================================== - = = - = Public methods = - = = - ==========================================================================*/ - -/***********************************************************************//** - * @brief Clear Pulsar ephemerides - ***************************************************************************/ -void GPulsarEphemerides::clear(void) -{ - // Free members - free_members(); - - // Initialise private members - init_members(); - - // Return - return; -} - - -/***********************************************************************//** - * @brief Clone Pulsar ephemerides - * - * @return Pointer to deep copy of Pulsar ephemerides. - ***************************************************************************/ -GPulsarEphemerides* GPulsarEphemerides::clone(void) const -{ - return new GPulsarEphemerides(*this); -} - - -/***********************************************************************//** - * @brief Print Pulsar ephemerides - * - * @param[in] chatter Chattiness. - * @return String containing Pulsar ephemerides information. - ***************************************************************************/ -std::string GPulsarEphemerides::print(const GChatter& chatter) const -{ - // Initialise result string - std::string result; - - // Continue only if chatter is not silent - if (chatter != SILENT) { - - // Append header - result.append("=== GPulsarEphemerides ==="); - - // Append pulsar name and direction - result.append("\n"+gammalib::parformat("Pulsar name")); - result.append(m_name); - result.append("\n"+gammalib::parformat("Pulsar Right Ascension")); - result.append(gammalib::str(m_dir.ra_deg())); - result.append(" deg"); - result.append("\n"+gammalib::parformat("Pulsar Declination")); - result.append(gammalib::str(m_dir.dec_deg())); - result.append(" deg"); - - // Get phase information - double f0 = this->f0(); - - // Append phase information - result.append("\n"+gammalib::parformat("Time of phase 0")); - result.append("MJD "); - result.append(gammalib::str(t0().mjd())); - result.append("\n"+gammalib::parformat("Frequency")); - result.append(gammalib::str(f0)); - result.append(" Hz"); - result.append("\n"+gammalib::parformat("Frequency derivative")); - result.append(gammalib::str(f1())); - result.append(" Hz/s"); - result.append("\n"+gammalib::parformat("2nd frequency derivative")); - result.append(gammalib::str(f2())); - result.append(" Hz/s^2"); - result.append("\n"+gammalib::parformat("Period")); - if (f0 != 0.0) { - double p0 = 1.0 / f0; - if (p0 < 1.0) { - result.append(gammalib::str(p0*1000.0)); - result.append(" ms"); - } - else { - result.append(gammalib::str(p0)); - result.append(" s"); - } - } - else { - result.append("infinity"); - } - - // Append validity information - result.append("\n"+gammalib::parformat("Validity MJD range")); - result.append(gammalib::str(tstart().mjd())); - result.append(" - "); - result.append(gammalib::str(tstop().mjd())); - result.append("\n"+gammalib::parformat("Validity UTC range")); - result.append(tstart().utc()); - result.append(" - "); - result.append(tstop().utc()); - - } // endif: chatter was not silent - - // Return result - return result; -} - - -/*========================================================================== - = = - = Private methods = - = = - ==========================================================================*/ - -/***********************************************************************//** - * @brief Initialise class members - ***************************************************************************/ -void GPulsarEphemerides::init_members(void) -{ - // Initialise members - m_name.clear(); - m_tstart.clear(); - m_tstop.clear(); - m_dir.clear(); - m_phase_curve.clear(); - - // Remove range from phase curve parameters - m_phase_curve["MJD"].remove_range(); - m_phase_curve["F0"].remove_range(); - m_phase_curve["F1"].remove_range(); - m_phase_curve["F2"].remove_range(); - - // Make sure that reference phase is zero - m_phase_curve["Phase"].value(0.0); - - // Return - return; -} - - -/***********************************************************************//** - * @brief Copy class members - * - * @param[in] ephemerides Pulsar ephemerides. - ***************************************************************************/ -void GPulsarEphemerides::copy_members(const GPulsarEphemerides& ephemerides) -{ - // Copy members - m_name = ephemerides.m_name; - m_tstart = ephemerides.m_tstart; - m_tstop = ephemerides.m_tstop; - m_dir = ephemerides.m_dir; - m_phase_curve = ephemerides.m_phase_curve; - - // Return - return; -} - - -/***********************************************************************//** - * @brief Delete class members - ***************************************************************************/ -void GPulsarEphemerides::free_members(void) -{ - // Return - return; -} diff --git a/src/obs/GPulsarEphemeris.cpp b/src/obs/GPulsarEphemeris.cpp new file mode 100644 index 0000000..62f3936 --- /dev/null +++ b/src/obs/GPulsarEphemeris.cpp @@ -0,0 +1,293 @@ +/*************************************************************************** + * GPulsarEphemeris.cpp - Pulsar ephemeris class * + * ----------------------------------------------------------------------- * + * copyright (C) 2022 by 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 * + * the Free Software Foundation, either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * + * * + ***************************************************************************/ +/** + * @file GPulsarEphemeris.cpp + * @brief Pulsar ephemeris class implementation + * @author Juergen Knoedlseder + */ + +/* __ Includes ___________________________________________________________ */ +#ifdef HAVE_CONFIG_H +#include +#endif +#include "GPulsarEphemeris.hpp" + +/* __ Method name definitions ____________________________________________ */ + +/* __ Macros _____________________________________________________________ */ + +/* __ Coding definitions _________________________________________________ */ + +/* __ Debug definitions __________________________________________________ */ + + + +/*========================================================================== + = = + = Constructors/destructors = + = = + ==========================================================================*/ + +/***********************************************************************//** + * @brief Void constructor + ***************************************************************************/ +GPulsarEphemeris::GPulsarEphemeris(void) +{ + // Initialise class members + init_members(); + + // Return + return; +} + + +/***********************************************************************//** + * @brief Copy constructor + * + * @param[in] ephemeris Pulsar ephemeris. + ***************************************************************************/ +GPulsarEphemeris::GPulsarEphemeris(const GPulsarEphemeris& ephemeris) +{ + // Initialise class members + init_members(); + + // Copy members + copy_members(ephemeris); + + // Return + return; +} + + +/***********************************************************************//** + * @brief Destructor + ***************************************************************************/ +GPulsarEphemeris::~GPulsarEphemeris(void) +{ + // Free members + free_members(); + + // Return + return; +} + + +/*========================================================================== + = = + = Operators = + = = + ==========================================================================*/ + +/***********************************************************************//** + * @brief Assignment operator + * + * @param[in] ephemeris Pulsar ephemeris. + * @return Pulsar ephemeris. + ***************************************************************************/ +GPulsarEphemeris& GPulsarEphemeris::operator=(const GPulsarEphemeris& ephemeris) +{ + // Execute only if object is not identical + if (this != &ephemeris) { + + // Free members + free_members(); + + // Initialise private members + init_members(); + + // Copy members + copy_members(ephemeris); + + } // endif: object was not identical + + // Return this object + return *this; +} + + +/*========================================================================== + = = + = Public methods = + = = + ==========================================================================*/ + +/***********************************************************************//** + * @brief Clear Pulsar ephemeris + ***************************************************************************/ +void GPulsarEphemeris::clear(void) +{ + // Free members + free_members(); + + // Initialise private members + init_members(); + + // Return + return; +} + + +/***********************************************************************//** + * @brief Clone Pulsar ephemeris + * + * @return Pointer to deep copy of Pulsar ephemeris. + ***************************************************************************/ +GPulsarEphemeris* GPulsarEphemeris::clone(void) const +{ + return new GPulsarEphemeris(*this); +} + + +/***********************************************************************//** + * @brief Print Pulsar ephemeris + * + * @param[in] chatter Chattiness. + * @return String containing Pulsar ephemeris information. + ***************************************************************************/ +std::string GPulsarEphemeris::print(const GChatter& chatter) const +{ + // Initialise result string + std::string result; + + // Continue only if chatter is not silent + if (chatter != SILENT) { + + // Append header + result.append("=== GPulsarEphemeris ==="); + + // Append pulsar name and direction + result.append("\n"+gammalib::parformat("Pulsar name")); + result.append(m_name); + result.append("\n"+gammalib::parformat("Pulsar Right Ascension")); + result.append(gammalib::str(m_dir.ra_deg())); + result.append(" deg"); + result.append("\n"+gammalib::parformat("Pulsar Declination")); + result.append(gammalib::str(m_dir.dec_deg())); + result.append(" deg"); + + // Get phase information + double f0 = this->f0(); + + // Append phase information + result.append("\n"+gammalib::parformat("Time of phase 0")); + result.append("MJD "); + result.append(gammalib::str(t0().mjd())); + result.append("\n"+gammalib::parformat("Frequency")); + result.append(gammalib::str(f0)); + result.append(" Hz"); + result.append("\n"+gammalib::parformat("Frequency derivative")); + result.append(gammalib::str(f1())); + result.append(" Hz/s"); + result.append("\n"+gammalib::parformat("2nd frequency derivative")); + result.append(gammalib::str(f2())); + result.append(" Hz/s^2"); + result.append("\n"+gammalib::parformat("Period")); + if (f0 != 0.0) { + double p0 = 1.0 / f0; + if (p0 < 1.0) { + result.append(gammalib::str(p0*1000.0)); + result.append(" ms"); + } + else { + result.append(gammalib::str(p0)); + result.append(" s"); + } + } + else { + result.append("infinity"); + } + + // Append validity information + result.append("\n"+gammalib::parformat("Validity MJD range")); + result.append(gammalib::str(tstart().mjd())); + result.append(" - "); + result.append(gammalib::str(tstop().mjd())); + result.append("\n"+gammalib::parformat("Validity UTC range")); + result.append(tstart().utc()); + result.append(" - "); + result.append(tstop().utc()); + + } // endif: chatter was not silent + + // Return result + return result; +} + + +/*========================================================================== + = = + = Private methods = + = = + ==========================================================================*/ + +/***********************************************************************//** + * @brief Initialise class members + ***************************************************************************/ +void GPulsarEphemeris::init_members(void) +{ + // Initialise members + m_name.clear(); + m_tstart.clear(); + m_tstop.clear(); + m_dir.clear(); + m_phase_curve.clear(); + + // Remove range from phase curve parameters + m_phase_curve["MJD"].remove_range(); + m_phase_curve["F0"].remove_range(); + m_phase_curve["F1"].remove_range(); + m_phase_curve["F2"].remove_range(); + + // Make sure that reference phase is zero + m_phase_curve["Phase"].value(0.0); + + // Return + return; +} + + +/***********************************************************************//** + * @brief Copy class members + * + * @param[in] ephemeris Pulsar ephemeris. + ***************************************************************************/ +void GPulsarEphemeris::copy_members(const GPulsarEphemeris& ephemeris) +{ + // Copy members + m_name = ephemeris.m_name; + m_tstart = ephemeris.m_tstart; + m_tstop = ephemeris.m_tstop; + m_dir = ephemeris.m_dir; + m_phase_curve = ephemeris.m_phase_curve; + + // Return + return; +} + + +/***********************************************************************//** + * @brief Delete class members + ***************************************************************************/ +void GPulsarEphemeris::free_members(void) +{ + // Return + return; +} diff --git a/src/obs/Makefile.am b/src/obs/Makefile.am index 9ec0548..775b484 100644 --- a/src/obs/Makefile.am +++ b/src/obs/Makefile.am @@ -53,7 +53,7 @@ sources = GEnergies.cpp \ GPhoton.cpp \ GSource.cpp \ GPulsar.cpp \ - GPulsarEphemerides.cpp + GPulsarEphemeris.cpp # Build libtool library noinst_LTLIBRARIES = libobs.la -- libgit2 0.21.4