1b0b5c1d
dmayerich
first commit
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
#include <iostream>
#include <vector>
#include <complex>
#include <fstream>
#include <stdio.h>
#include <string.h>
using namespace std;
//fftw fourier transform library
#ifdef FFTW_AVAILABLE
#include <fftw3.h>
#endif
#include "rts/material.h"
//#include "options.h"
#include <boost/program_options.hpp>
namespace po = boost::program_options;
typedef double ptype;
typedef complex<ptype> pcomplex;
rts::material<ptype> M;
#define PI 3.14159
int main(int argc, char* argv[])
{
po::options_description desc("Allowed options");
desc.add_options()
("help,h", "Display this help message.")
("input-file,i", po::value<string>(), "Input file containing material information.")
("input-format,f", po::value<string>()->default_value("wavenumber,n,k"), "Format string identifying the order of material properties in the input file. Options include: microns, wavenumber, n (real RI), k (imaginary RI), A (absorbance), Xp (real Chi), Xpp (imaginary Chi).\n\nThe default [microns,n,k] will load a material file with columns representing the wavelength in microns, followed by the real and imaginary parts of the refractive index.")
("output-file,o", po::value<string>()->default_value("out.txt"), "Output file containing the processed material information.")
|
7f308ddf
dmayerich
allow reversal of...
|
36
|
("output-format,t", po::value<string>()->default_value("wavenumber,n,k"), "Format string for the output file (similar to --input-format).")
|
1b0b5c1d
dmayerich
first commit
|
37
38
39
|
("scaling,s", po::value<ptype>()->default_value(1.0), "Scaling value for the absorbance parameter. This value gives the thickness (in microns) of the measured material.")
("n0,n", po::value<ptype>()->default_value(1.48), "Average effective refractive index. This is required when computing the real refractive index from the absorption.")
("padding,p", po::value<int>()->default_value(2), "Padding factor used to remove edge artifacts in the Kramers-Kronig computation for computing the real RI from absorption. The default value of p=2 is sufficient in most cases.")
|
7f308ddf
dmayerich
allow reversal of...
|
40
41
|
("resolution,r", po::value<int>(), "Resolution of the spectrum. The default value is based on the number of spectral samples provided in the input file.")
("reverse,v", "reverse the order of the output file");
|
1b0b5c1d
dmayerich
first commit
|
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
po::positional_options_description pos;
pos.add("input-file", 1);
pos.add("output-file", 1);
po::variables_map vm;
po::store(po::command_line_parser(argc, argv).options(desc).positional(pos).run(), vm);
po::notify(vm);
if(vm.count("help"))
{
cout<<desc<<endl;
return 1;
}
|
7f308ddf
dmayerich
allow reversal of...
|
56
|
|
1b0b5c1d
dmayerich
first commit
|
57
58
59
60
61
|
//if the input file is given, load it, otherwise exit
if(vm.count("input-file"))
{
M.fromFile(vm["input-file"].as<string>(),
vm["input-format"].as<string>(),
|
a4e4dd55
dmayerich
fixed error in sc...
|
62
|
1.0 / vm["scaling"].as<ptype>());
|
1b0b5c1d
dmayerich
first commit
|
63
64
65
66
67
68
69
70
71
72
73
74
75
|
}
else
{
cout<<"No input file was provided."<<endl;
exit(1);
}
//the default sample rate of the spectrum is given by the number of samples in the input file
int R = M.nSamples();
if(vm.count("resolution"))
R = vm["resolution"].as<int>();
//compute the real refractive index
|
7f308ddf
dmayerich
allow reversal of...
|
76
|
rts::material<ptype> N = M.computeN(vm["n0"].as<ptype>(),
|
1b0b5c1d
dmayerich
first commit
|
77
78
79
80
|
R,
vm["padding"].as<int>());
//output the file using the standard format
|
7f308ddf
dmayerich
allow reversal of...
|
81
82
83
84
|
bool reverse_order = false;
if(vm.count("reverse"))
reverse_order = true;
N.save(vm["output-file"].as<string>(), vm["output-format"].as<string>(), reverse_order);
|
1b0b5c1d
dmayerich
first commit
|
85
86
87
|
return 0;
}
|