This is a program that reads datasets from an hdf5 file. It takes the desired datasets and writes them into the specified text file or directory.
17 using namespace icedb;
18 namespace po = boost::program_options;
20 po::options_description desc(
"Allowed options"), cmdline(
"Command-line options"),
21 config(
"Config options"), hidden(
"Hidden options"), oall(
"all options");
24 (
"help,h",
"produce help message")
25 (
"list-all",
"List all refractive index providers")
26 (
"list-subst", po::value<string>(),
"List all refractive index providers for a given substance")
27 (
"list-substs",
"List all substances for which refractive indices can be determined")
28 (
"list-provider", po::value<string>(),
"List information about a refractive index provider (e.g. source paper, domain of validity)")
29 (
"subst", po::value<string>(),
"Substance of interest (ice, water)")
30 (
"freq,f", po::value<double>(),
"Frequency")
31 (
"freq-units", po::value<string>()->default_value(
"GHz"),
"Frequency units")
32 (
"temp,T", po::value<double>(),
"Temperature")
33 (
"temp-units", po::value<string>()->default_value(
"K"),
"Temperature units")
36 po::positional_options_description p;
39 p.add(
"freq-units", 1);
41 p.add(
"temp-units", 1);
43 desc.add(cmdline).add(config);
44 oall.add(cmdline).add(config).add(hidden);
47 po::store(po::command_line_parser(argc, argv).
48 options(oall).positional(p).run(), vm);
51 auto doHelp = [&](
const std::string &m) { cerr << desc <<
"\n" << m << endl; exit(1); };
52 if (vm.count(
"help") || argc < 2) doHelp(
"");
54 if (vm.count(
"list-all")) {
59 if (vm.count(
"list-substs")) {
63 if (vm.count(
"list-subst")) {
64 string lsubst = vm[
"list-subst"].as<
string>();
66 if (!ps)
ICEDB_throw(error::error_types::xNullPointer)
67 .add<std::string>(
"Reason",
"Cannot find any refractive index formulas for this substance")
68 .add<std::string>(
"Substance", lsubst);
72 if (vm.count(
"list-provider")) {
73 string lprov = vm[
"list-provider"].as<
string>();
75 if (!ps)
ICEDB_throw(error::error_types::xNullPointer)
76 .add<std::string>(
"Reason",
"Cannot find this refractive index provider")
77 .add<std::string>(
"Provider", lprov);
81 if (!vm.count(
"subst")) doHelp(
"Must specify a substance.");
82 string subst = vm[
"subst"].as<
string>();
83 string freqUnits = vm[
"freq-units"].as<
string>();
84 string tempUnits = vm[
"temp-units"].as<
string>();
85 bool hasFreq =
false, hasTemp =
false;
86 double inFreq = 0, inTemp = 0;
87 if (vm.count(
"freq")) { hasFreq =
true; inFreq = vm[
"freq"].as<
double>(); }
88 if (vm.count(
"temp")) { hasTemp =
true; inTemp = vm[
"temp"].as<
double>(); }
89 complex<double> m(0, 0);
97 for (
const auto &p : *(provAll.get())) {
98 prov = p.second->name;
104 f(inFreq, inTemp, m);
105 cout << m <<
"\twas found using provider " << prov <<
"." << endl;
109 catch (std::exception &e) {
if (prov == subst) cerr << e.what(); }
118 cout << m <<
"\twas found using provider " << prov <<
"." << endl;
122 catch (std::exception &e) {
if (prov == subst) cerr << e.what(); }
133 cerr <<
"A refractive index provider that could handle the input cannot be found." << endl;
139 catch (std::exception &e) {
140 cerr <<
"An exception has occurred: " << e.what() << endl;
void enumSubstances(std::ostream &out)
void enumProviders(all_providers_p p, std::ostream &out)
void enumProvider(provider_p p, std::ostream &out)
all_providers_p listAllProviders()
std::function< void(double, double, std::complex< double > &)> refractFunction_freq_temp_t
void prepRefract(provider_p prov, const std::string &inFreqUnits, refractFunction_freqonly_t &res)
all_providers_p findProviders(const std::string &subst, bool haveFreq, bool haveTemp)
provider_p findProviderByName(const std::string &providerName)
std::function< void(double, std::complex< double > &)> refractFunction_freqonly_t