3Parameters::Parameters()
4 : _cmdline(PROGRAM_DESCRIPTION,
' ', PROGRAM_VERSION) {}
6Parameters::Parameters(
const int argc,
const char *argv[])
7 : _cmdline(PROGRAM_DESCRIPTION,
' ', PROGRAM_VERSION) {
12void Parameters::parse(
const int argc,
const char *argv[]) {
16 TCLAP::ValueArg<std::string> database(
"",
"database",
"MySQL database",
17 false,
"pahdb",
"string", _cmdline);
19 std::vector<std::string> constraint{
"Theory",
"Experiment",
"Anharmonic"};
21 TCLAP::ValuesConstraint<std::string> tableconstraint(constraint);
23 TCLAP::ValueArg<std::string> table(
"",
"table",
"MySQL table",
false,
24 "Theory", &tableconstraint, _cmdline);
26 TCLAP::ValueArg<std::string> host(
"",
"host",
"MySQL host",
false,
27 "localhost",
"string", _cmdline);
29 TCLAP::ValueArg<std::string> username(
"",
"username",
"MySQL username",
30 false,
"root",
"string", _cmdline);
32 TCLAP::ValueArg<std::string> password(
"",
"password",
"MySQL password",
33 false,
"root",
"string", _cmdline);
35 TCLAP::ValueArg<int> port(
"",
"port",
"MySQL port",
false, 3306,
"integer",
38 TCLAP::SwitchArg compress(
"",
"compress",
"MySQL compression", _cmdline);
40 TCLAP::ValueArg<int> timeout(
"",
"timeout",
"MySQL timeout",
false, 60,
43 TCLAP::ValueArg<std::string> socket(
"",
"socket",
"MySQL socket",
false,
44 "/var/run/mysqld/mysqld.sock",
"string",
47 TCLAP::ValueArg<int> databaseversion(
"",
"databaseversion",
48 "Database version",
false, 99,
51 TCLAP::ValueArg<std::string> output(
"",
"output",
"Output file",
false,
52 "default",
"string", _cmdline);
54 TCLAP::ValueArg<std::string> input(
"",
"input",
"Input file",
false,
"",
57 TCLAP::ValueArg<std::string> ids(
"",
"ids",
"Species identifier(s)",
true,
58 "",
"comma separeted list of integers",
61 TCLAP::ValueArg<std::string> plotsize(
62 "",
"plotsize",
"Plot size",
false,
"650,325",
63 "comma separeted list of 2 integers", _cmdline);
68 constraint.insert(constraint.begin(), {
"ZeroKelvin",
"FixedTemperature",
69 "Temperature",
"Cascade"});
71 TCLAP::ValuesConstraint<std::string> modelconstraint(constraint);
73 TCLAP::ValueArg<std::string> model(
"",
"model",
"Emission model",
false,
74 "ZeroKelvin", &modelconstraint,
79 constraint.insert(constraint.begin(),
80 {
"CoAdd",
"Stack",
"TemperatureStack",
81 "CompareExperimentWithTheory",
"SpectralFit"});
83 TCLAP::ValuesConstraint<std::string> toolconstraint(constraint);
85 TCLAP::ValueArg<std::string> tool(
"",
"tool",
"Tool",
false,
"CoAdd",
86 &toolconstraint, _cmdline);
90 constraint.insert(constraint.begin(), {
"Lorentzian",
"Gaussian",
"Drude"});
92 TCLAP::ValuesConstraint<std::string> profileconstraint(constraint);
94 TCLAP::ValueArg<std::string> profile(
"",
"profile",
"Emission profile",
96 &profileconstraint, _cmdline);
98 TCLAP::ValueArg<double> fwhm(
99 "",
"fwhm",
"Full-width-half-maximum for applied emission profile",
100 false, 15.0,
"double", _cmdline);
102 TCLAP::ValueArg<double> shift(
"",
"shift",
"Spectral shift",
false, 0.0,
105 TCLAP::ValueArg<double> energy(
"",
"energy",
"Energy for model [eV]",
false,
106 5,
"double", _cmdline);
108 TCLAP::ValueArg<double> temperature(
"",
"temperature",
109 "Temperature for Blackbody [Kelvin]",
110 false, 550,
"double", _cmdline);
112 TCLAP::ValueArg<std::string> temperatures(
113 "",
"temperatures",
"Temperatures for Blackbodies [Kelvin]",
false,
114 "10,100,1000",
"comma separeted list of doubles", _cmdline);
116 TCLAP::ValueArg<std::string> weights(
117 "",
"weights",
"Weights to apply for co-add",
false,
"",
118 "comma separated list of doubles", _cmdline);
120 TCLAP::ValueArg<std::string> plotlimits(
121 "",
"plotlimits",
"Plot limits",
false,
"7000,0",
122 "Comma separated list of two doubles", _cmdline);
126 constraint.insert(constraint.begin(), {
"Frequency",
"Wavelength"});
128 TCLAP::ValuesConstraint<std::string> unitsconstraint(constraint);
130 TCLAP::ValueArg<std::string> units(
"",
"units",
"Plot units",
false,
131 "Frequency", &unitsconstraint, _cmdline);
133 TCLAP::SwitchArg x11(
"",
"x11",
"Output to screen", _cmdline,
false);
135 TCLAP::SwitchArg nopng(
"",
"nopng",
"Disable output to PNG file", _cmdline,
138 TCLAP::SwitchArg jpeg(
"",
"jpeg",
"Output to a JPEG file", _cmdline,
false);
140 TCLAP::SwitchArg postscript(
"",
"postscript",
"Output to a Postscript file",
143 TCLAP::SwitchArg pdf(
"",
"pdf",
"Output to a PDF file", _cmdline,
false);
145 _cmdline.parse(argc, argv);
147 _database = database.getValue();
149 if (table.getValue() ==
"Theory") {
151 _table = PAHdb::Database::Theory;
152 }
else if (table.getValue() ==
"Experiment") {
154 _table = PAHdb::Database::Experiment;
155 }
else if (table.getValue() ==
"Anharmonic") {
157 _table = PAHdb::Database::Anharmonic;
160 _host = host.getValue();
162 _username = username.getValue();
164 _password = password.getValue();
166 _port = port.getValue();
168 _compress = compress.getValue();
170 _timeout = timeout.getValue();
172 _socket = socket.getValue();
174 _databaseversion = databaseversion.getValue();
176 _output = output.getValue();
178 _input = input.getValue();
180 std::string_view tmp = ids.getValue();
182 std::string strvalue;
184 auto it = tmp.begin();
192 if (*it ==
',' || it == tmp.end()) {
194 ivalue = strtol(strvalue.c_str(), &endp, 10);
196 if (strvalue.size() == 0 || *endp !=
'\0') {
199 "PARSE ERROR: Argument (--ids)\n Value '" + strvalue +
200 "' does not meet constraint: integer")));
203 _ids.push_back(ivalue);
211 if (it == tmp.end()) {
218 tmp = plotsize.getValue();
226 if (*it ==
',' || it == tmp.end()) {
228 ivalue = strtol(strvalue.c_str(), &endp, 10);
230 if (strvalue.size() == 0 || *endp !=
'\0') {
233 "PARSE ERROR: Argument (--plotsize)\n Value '" +
234 strvalue +
"' does not meet constraint: int")));
237 _plotsize[i++] = ivalue;
245 if (it == tmp.end()) {
252 if (_plotsize.size() != 2) {
256 "PARSE ERROR: Argument (--plotsize)\n Value '") +
257 tmp.data() +
"' does not meet constraint: two integers")));
260 if (model.getValue() ==
"ZeroKelvin") {
262 _model = Parameters::Arg::ZeroKelvin;
263 }
else if (model.getValue() ==
"FixedTemperature") {
265 _model = Parameters::Arg::FixedTemperature;
266 }
else if (model.getValue() ==
"Temperature") {
268 _model = Parameters::Arg::Temperature;
271 else if (model.getValue() ==
"Cascade") {
273 _model = Parameters::Arg::Cascade;
276 if (tool.getValue() ==
"CoAdd") {
278 _tool = Parameters::Arg::CoAdd;
279 }
else if (tool.getValue() ==
"Stack") {
281 _tool = Parameters::Arg::Stack;
282 }
else if (tool.getValue() ==
"TemperatureStack") {
284 _tool = Parameters::Arg::TemperatureStack;
287 else if (tool.getValue() ==
"CompareExperimentWithTheory") {
289 _tool = Parameters::Arg::CompareExperimentWithTheory;
290 }
else if (tool.getValue() ==
"SpectralFit") {
291 _tool = Parameters::Arg::SpectralFit;
294 if (profile.getValue() ==
"Lorentzian") {
296 _profile = Parameters::Arg::Lorentzian;
297 }
else if (profile.getValue() ==
"Gaussian") {
299 _profile = Parameters::Arg::Gaussian;
300 }
else if (profile.getValue() ==
"Drude") {
302 _profile = Parameters::Arg::Drude;
305 _fwhm = fwhm.getValue();
307 _shift = shift.getValue();
309 _energy = energy.getValue();
311 _temperature = temperature.getValue();
315 tmp = temperatures.getValue();
317 if (tmp.size() > 0) {
323 if (*it ==
',' || it == tmp.end()) {
325 dvalue = strtod(strvalue.c_str(), &endp);
327 if (strvalue.size() == 0 || *endp !=
'\0') {
330 std::string(
"PARSE ERROR: Argument (--temperatures)\n "
332 strvalue +
"' does not meet constraint: double")));
335 _temperatures.push_back(dvalue);
343 if (it == tmp.end()) {
351 tmp = weights.getValue();
353 if (tmp.size() > 0) {
359 if (*it ==
',' || it == tmp.end()) {
361 dvalue = strtod(strvalue.c_str(), &endp);
363 if (strvalue.size() == 0 || *endp !=
'\0') {
366 "PARSE ERROR: Argument (--weights)\n Value '" +
367 strvalue +
"' does not meet constraint: double")));
370 _weights.push_back(dvalue);
378 if (it == tmp.end()) {
386 _weights = std::vector<double>(_ids.size(), 1.0);
389 tmp = plotlimits.getValue();
397 if (*it ==
',' || it == tmp.end()) {
399 dvalue = strtod(strvalue.c_str(), &endp);
401 if (strvalue.size() == 0 || *endp !=
'\0') {
404 "PARSE ERROR: Argument (--plotlimits)\n Value '" +
405 strvalue +
"' does not meet constraint: double")));
408 _plotlimits[i++] = dvalue;
416 if (it == tmp.end()) {
423 if (_plotlimits.size() != 2) {
427 "PARSE ERROR: Argument (--plotlimits)\n Value '") +
428 tmp.data() +
"' does not meet constraint: two doubles"));
431 if (units.getValue() ==
"Frequency")
432 _units = Parameters::Arg::Frequency;
433 else if (units.getValue() ==
"Wavelength")
434 _units = Parameters::Arg::Wavelength;
436 _invplotlimits = _plotlimits;
438 _invplotlimits.at(0) = 1e4 / _plotlimits.at(0);
440 _invplotlimits.at(1) = 1e4 / _plotlimits.at(1);
442 _x11 = x11.getValue();
444 _png = !nopng.getValue();
446 _jpeg = jpeg.getValue();
448 _postscript = postscript.getValue();
450 _pdf = pdf.getValue();
451 }
catch (
const TCLAP::ArgException &e) {