Cheetah - SKA - PSS - Prototype Time Domain Search Pipeline
GeneratorAppConfig.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/GeneratorAppConfig.h"
25 #include "cheetah/data/Units.h"
26 #include "cheetah/version.h"
27 
28 
29 namespace ska {
30 namespace cheetah {
31 namespace generators {
32 
33 
34 GeneratorAppConfig::GeneratorAppConfig(std::string const& app_name, std::string const& description)
35  : BasicAppConfig(app_name, description)
36  , _number_of_chunks(1)
37  , _number_of_channels(1024)
38  , _number_of_time_samples(4096)
39  , _frequency(1200.0 * boost::units::si::mega * data::hz)
40  , _channel_width(-300.0 * boost::units::si::kilo * data::hz)
41  , _sample_interval(1.0 * boost::units::si::milli * boost::units::si::seconds)
42 {
43  add(_generator_config);
44  add(_sigproc_config);
45 }
46 
47 GeneratorAppConfig::~GeneratorAppConfig()
48 {
49 }
50 
52 {
53  return _generator_config;
54 }
55 
57 {
58  return _sigproc_config;
59 }
60 
61 std::string GeneratorAppConfig::version() const
62 {
63  return std::string(cheetah::version) + "\n" + BasicAppConfig::version();
64 }
65 
66 void GeneratorAppConfig::add_options(OptionsDescriptionEasyInit& add_options)
67 {
68  add_options
69  ("list-generators", boost::program_options::bool_switch()->notifier([this](bool b)
70  {
71  if(b) {
72  for(auto const& gen : _generator_keys) {
73  std::cout << "\t" << gen << "\n";
74  }
75  }
76  return false;
77  }), "display a list of generators available")
78  ("generator,g", boost::program_options::value<std::vector<std::string>>(&_generator_selected)
79  , "the name of the generator to use as a data model (see --list-generators)")
80  ("channels", boost::program_options::value<std::size_t>(&_number_of_channels)->default_value(_number_of_channels)
81  , "the number of channels in each block of data")
82  ("samples", boost::program_options::value<std::size_t>(&_number_of_time_samples)->default_value(_number_of_time_samples)
83  , "the number of time samples in each block of data")
84  ("chunks", boost::program_options::value<std::size_t>(&_number_of_chunks)->default_value(_number_of_chunks)
85  , "the number of block of data to generate")
86  ("start_freq", boost::program_options::value<typename FrequencyType::value_type>()->default_value(_frequency.value())
87  ->notifier([this](typename FrequencyType::value_type const& val)
88  {
89  _frequency = val * boost::units::si::mega * data::hertz;
90  })
91  , "the frequency of the first channel (MHz)")
92  ("channel_width", boost::program_options::value<typename FrequencyType::value_type>()->default_value(_channel_width.value())
93  ->notifier([this](typename FrequencyType::value_type const& val)
94  {
95  _channel_width = val * boost::units::si::mega * data::hertz;
96  })
97  , "the width of each channel (MHz)")
98  ("sample_interval", boost::program_options::value<typename IntervalType::value_type>()->default_value(_sample_interval.value())
99  ->notifier([this](typename IntervalType::value_type const& val)
100  {
101  _sample_interval= val * boost::units::si::seconds;
102  })
103  , "the width of each channel (MHz)");
104 }
105 
106 void GeneratorAppConfig::set_generator_list(std::vector<std::string> const& generator_names)
107 {
108  _generator_keys = generator_names;
109 }
110 
111 std::vector<std::string> const& GeneratorAppConfig::generator_list() const
112 {
113  return _generator_keys;
114 }
115 
116 std::vector<std::string> const& GeneratorAppConfig::data_generator() const
117 {
118  return _generator_selected;
119 }
120 
122 {
123  return _number_of_chunks;
124 }
125 
127 {
128  return _number_of_time_samples;
129 }
130 
132 {
133  return _number_of_channels;
134 }
135 
136 typename GeneratorAppConfig::FrequencyType GeneratorAppConfig::start_frequency() const
137 {
138  return _frequency;
139 }
140 
141 typename GeneratorAppConfig::FrequencyType GeneratorAppConfig::channel_width() const
142 {
143  return _channel_width;
144 }
145 
146 typename GeneratorAppConfig::IntervalType GeneratorAppConfig::sample_interval() const
147 {
148  return _sample_interval;
149 }
150 
151 } // namespace generators
152 } // namespace cheetah
153 } // namespace ska
std::vector< std::string > const & generator_list() const
list the known generators
Definition: Units.h:112
void set_generator_list(std::vector< std::string > const &generator_names)
set the known generators
ska::cheetah::generators::Config & generator_config()
return the generator configuration object
Generator Configuration file.
Definition: Config.h:46
FrequencyType channel_width() const
return the channel width (homgenous cwidth channels)
Configuration options for a SigProcWriter.
Definition: WriterConfig.h:41
std::vector< std::string > const & data_generator() const
return the chosen data model
Some limits and constants for FLDO.
Definition: Brdz.h:35
sigproc::WriterConfig const & sigproc_config() const
return the configuration object for directing sigproc writer
std::size_t number_of_time_samples() const
return the number of time smaples per data chunk
IntervalType sample_interval() const
sample interval (in seconds)
FrequencyType start_frequency() const
return the start frequency
std::size_t number_of_chunks() const
return the number of data chunks to produce for the data file
std::size_t number_of_channels() const
return the number of channels for each data chunk