Cheetah - SKA - PSS - Prototype Time Domain Search Pipeline
PulsarInjectionConfig.cpp
1 /*
2  * The MIT License (MIT)
3  *
4  * Copyright (c) 2016 The SKA organisation
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in all
14  * copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * SOFTWARE.
23  */
24 #include "cheetah/generators/PulsarInjectionConfig.h"
25 #include <panda/Error.h>
26 #include <numeric>
27 
28 
29 namespace ska {
30 namespace cheetah {
31 namespace generators {
32 
33 
34 PulsarInjectionConfig::PulsarInjectionConfig(std::string const& tag_name)
35  : utils::Config(tag_name)
36  , _signal_to_noise(10)
37  , _spectral_index(0)
38  , _profile_name("B0011+47")
39  , _phase_model_factory(*this)
40  , _dm(0.0*data::parsecs_per_cube_cm)
41 {
42  add(_simple_phase_model_config);
43  add(_tempo2_phase_model_config);
44 }
45 
46 PulsarInjectionConfig::~PulsarInjectionConfig()
47 {
48 }
49 
50 void PulsarInjectionConfig::add_options(OptionsDescriptionEasyInit& add_options)
51 {
52  std::vector<std::string> const& phase_model_types = _phase_model_factory.types();
53  std::string const phase_model_type_help = "phase model type to use (valid types: " + std::accumulate( std::next(phase_model_types.begin())
54  , phase_model_types.end()
55  , *phase_model_types.begin()
56  , [](const std::string& a, const std::string& b) {
57  return a + ", " + b;
58  }
59  ) + ")";
60  add_options
61  ("profile", boost::program_options::value<std::string>()->notifier([&](std::string const& p) { _profile_name=static_cast<PulsarProfileId>(p); }), "The name of the pulsar profile to emulate")
62  ("snr", boost::program_options::value<float>(&_signal_to_noise)->default_value(_signal_to_noise), "Target signal-to-noise ratio (phase average S/N)")
63  ("spectral_index", boost::program_options::value<float>(&_spectral_index)->default_value(_spectral_index), "Target spectral index")
64  ("dm", boost::program_options::value<double>()->default_value(_dm.value())->notifier(
65  [&](double dm) {
66  _dm = dm * data::parsecs_per_cube_cm;
67  }
68  )
69  ,"dedispersion measure (pc/cm^3)")
70  ("phase_model", boost::program_options::value<std::string>()->default_value("simple")->notifier(
71  [&](std::string const type) {
72  phase_model(type);
73  }
74  )
75  , phase_model_type_help.c_str() )
76  ;
77 }
78 
80 {
81  return _signal_to_noise;
82 }
83 
85 {
86  _signal_to_noise = snr;
87 }
88 
90 {
91  return _profile_name;
92 }
93 
94 void PulsarInjectionConfig::profile(std::string const& profile_name)
95 {
96  _profile_name = PulsarProfileId(profile_name);
97 }
98 
100 {
101  _spectral_index = si;
102 }
103 
105 {
106  return _spectral_index;
107 }
108 
109 PulsarInjectionConfig::PhaseModelType const& PulsarInjectionConfig::phase_model() const
110 {
111  if(!_phase_model) throw panda::Error("phase model not specified");
112  return _phase_model;
113 }
114 
115 void PulsarInjectionConfig::phase_model(std::string const& type)
116 {
117  _phase_model=_phase_model_factory.create(type);
118 }
119 
121 {
122  _simple_phase_model_config = config;
123  phase_model("simple");
124 }
125 
127 {
128  _tempo2_phase_model_config = config;
129  phase_model("tempo2");
130 }
131 
132 data::DedispersionMeasureType<double> PulsarInjectionConfig::dm() const
133 {
134  return _dm;
135 }
136 
137 void PulsarInjectionConfig::dm(data::DedispersionMeasureType<double> dm)
138 {
139  _dm = dm;
140 }
141 
142 } // namespace generators
143 } // namespace cheetah
144 } // namespace ska
Configuration parameters for the SimplePhase Model.
PulsarProfileId const & profile() const
the name of the pulse profile to emulate
data::DedispersionMeasureType< double > dm() const
the dedisperion measure to emulate
configuration parameters for a tempo2 predictor model
Some limits and constants for FLDO.
Definition: Brdz.h:35
placeholder for specifying pulsar profile database URI
float spectral_index() const
get the spectral index to emulate
void set_phase_model(SimplePhaseModelConfig const &)
set the phase model to single type with the speocife settings
PhaseModelType const & phase_model() const
return the phase model that has benn specified
float signal_to_noise() const
signal to nosie ratio to emulate