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    _cmdline.parse(argc, argv);
 
  145    _database = database.getValue();
 
  147    if (table.getValue() == 
"Theory") {
 
  149      _table = PAHdb::Database::Theory;
 
  150    } 
else if (table.getValue() == 
"Experiment") {
 
  152      _table = PAHdb::Database::Experiment;
 
  153    } 
else if (table.getValue() == 
"Anharmonic") {
 
  155      _table = PAHdb::Database::Anharmonic;
 
  158    _host = host.getValue();
 
  160    _username = username.getValue();
 
  162    _password = password.getValue();
 
  164    _port = port.getValue();
 
  166    _compress = compress.getValue();
 
  168    _timeout = timeout.getValue();
 
  170    _socket = socket.getValue();
 
  172    _databaseversion = databaseversion.getValue();
 
  174    _output = output.getValue();
 
  176    _input = input.getValue();
 
  178    std::string_view tmp = ids.getValue();
 
  180    std::string strvalue;
 
  182    auto it = tmp.begin();
 
  190      if (*it == 
',' || it == tmp.end()) {
 
  192        ivalue = strtol(strvalue.c_str(), &endp, 10);
 
  194        if (strvalue.size() == 0 || *endp != 
'\0') {
 
  197              "PARSE ERROR: Argument (--ids)\n             Value '" + strvalue +
 
  198              "' does not meet constraint: integer")));
 
  201        _ids.push_back(ivalue);
 
  209      if (it == tmp.end()) {
 
  216    tmp = plotsize.getValue();
 
  224      if (*it == 
',' || it == tmp.end()) {
 
  226        ivalue = strtol(strvalue.c_str(), &endp, 10);
 
  228        if (strvalue.size() == 0 || *endp != 
'\0') {
 
  231              "PARSE ERROR: Argument (--plotsize)\n             Value '" +
 
  232              strvalue + 
"' does not meet constraint: int")));
 
  235        _plotsize[i++] = ivalue;
 
  243      if (it == tmp.end()) {
 
  250    if (_plotsize.size() != 2) {
 
  254               "PARSE ERROR: Argument (--plotsize)\n             Value '") +
 
  255           tmp.data() + 
"' does not meet constraint: two integers")));
 
  258    if (model.getValue() == 
"ZeroKelvin") {
 
  260      _model = Parameters::Arg::ZeroKelvin;
 
  261    } 
else if (model.getValue() == 
"FixedTemperature") {
 
  263      _model = Parameters::Arg::FixedTemperature;
 
  264    } 
else if (model.getValue() == 
"Temperature") {
 
  266      _model = Parameters::Arg::Temperature;
 
  269    else if (model.getValue() == 
"Cascade") {
 
  271      _model = Parameters::Arg::Cascade;
 
  274    if (tool.getValue() == 
"CoAdd") {
 
  276      _tool = Parameters::Arg::CoAdd;
 
  277    } 
else if (tool.getValue() == 
"Stack") {
 
  279      _tool = Parameters::Arg::Stack;
 
  280    } 
else if (tool.getValue() == 
"TemperatureStack") {
 
  282      _tool = Parameters::Arg::TemperatureStack;
 
  285    else if (tool.getValue() == 
"CompareExperimentWithTheory") {
 
  287      _tool = Parameters::Arg::CompareExperimentWithTheory;
 
  288    } 
else if (tool.getValue() == 
"SpectralFit") {
 
  289      _tool = Parameters::Arg::SpectralFit;
 
  292    if (profile.getValue() == 
"Lorentzian") {
 
  294      _profile = Parameters::Arg::Lorentzian;
 
  295    } 
else if (profile.getValue() == 
"Gaussian") {
 
  297      _profile = Parameters::Arg::Gaussian;
 
  298    } 
else if (profile.getValue() == 
"Drude") {
 
  300      _profile = Parameters::Arg::Drude;
 
  303    _fwhm = fwhm.getValue();
 
  305    _shift = shift.getValue();
 
  307    _energy = energy.getValue();
 
  309    _temperature = temperature.getValue();
 
  313    tmp = temperatures.getValue();
 
  315    if (tmp.size() > 0) {
 
  321        if (*it == 
',' || it == tmp.end()) {
 
  323          dvalue = strtod(strvalue.c_str(), &endp);
 
  325          if (strvalue.size() == 0 || *endp != 
'\0') {
 
  328                std::string(
"PARSE ERROR: Argument (--temperatures)\n          " 
  330                            strvalue + 
"' does not meet constraint: double")));
 
  333          _temperatures.push_back(dvalue);
 
  341        if (it == tmp.end()) {
 
  349    tmp = weights.getValue();
 
  351    if (tmp.size() > 0) {
 
  357        if (*it == 
',' || it == tmp.end()) {
 
  359          dvalue = strtod(strvalue.c_str(), &endp);
 
  361          if (strvalue.size() == 0 || *endp != 
'\0') {
 
  364                "PARSE ERROR: Argument (--weights)\n             Value '" +
 
  365                strvalue + 
"' does not meet constraint: double")));
 
  368          _weights.push_back(dvalue);
 
  376        if (it == tmp.end()) {
 
  384      _weights = std::vector<double>(_ids.size(), 1.0);
 
  387    tmp = plotlimits.getValue();
 
  395      if (*it == 
',' || it == tmp.end()) {
 
  397        dvalue = strtod(strvalue.c_str(), &endp);
 
  399        if (strvalue.size() == 0 || *endp != 
'\0') {
 
  402              "PARSE ERROR: Argument (--plotlimits)\n             Value '" +
 
  403              strvalue + 
"' does not meet constraint: double")));
 
  406        _plotlimits[i++] = dvalue;
 
  414      if (it == tmp.end()) {
 
  421    if (_plotlimits.size() != 2) {
 
  425              "PARSE ERROR: Argument (--plotlimits)\n             Value '") +
 
  426          tmp.data() + 
"' does not meet constraint: two doubles"));
 
  429    if (units.getValue() == 
"Frequency")
 
  430      _units = Parameters::Arg::Frequency;
 
  431    else if (units.getValue() == 
"Wavelength")
 
  432      _units = Parameters::Arg::Wavelength;
 
  434    _invplotlimits = _plotlimits;
 
  436    _invplotlimits.at(0) = 1e4 / _plotlimits.at(0);
 
  438    _invplotlimits.at(1) = 1e4 / _plotlimits.at(1);
 
  440    _x11 = x11.getValue();
 
  442    _png = !nopng.getValue();
 
  444    _jpeg = jpeg.getValue();
 
  446    _postscript = postscript.getValue();
 
  447  } 
catch (
const TCLAP::ArgException &e) {