-
Notifications
You must be signed in to change notification settings - Fork 0
/
gen3-fftw-fit-2-init.cpp
86 lines (72 loc) · 2.23 KB
/
gen3-fftw-fit-2-init.cpp
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include <valarray>
#include <string>
#include <gen3pp/bodata.h>
#include <gen3pp/boutil.h>
#include <gen3pp/ccfitsfile.h>
#include <gen3pp/fftw2fit.h>
#include "paramlist.h"
using namespace std;
// Define number of significant figures for writing gim files.
const int sigfig = 12;
int main(int argc, char* argv[]) {
if (argc != 2) {
cerr << "Usage: " << argv[0] << " <filename.cfg>" << endl;
return 0;
}
ParamList pl;
cerr << "Reading configuration...";
pl.parse(argv[1]);
cerr << " done." << endl;
// Get the mean dark count along the third axis.
BOData<double> darkmean;
cerr << "Processing Dark frame...";
string filename;
pl.getValue("DARK_FILE", filename);
CCFITSfile fitsfile;
BOData<double> dat;
fitsfile.read(filename, dat);
print(dat);
getMean(dat, 3, darkmean);
filename = "darkmean3.gim";
write2gim(filename, darkmean, sigfig);
cerr << " done." << endl;
// Calculate sigma.
BOData<double> sigma;
double preset_sigma;
unsigned int err = pl.getValue("PRESET_SIGMA", preset_sigma);
if (err == 0)
{
cerr << "Processing Preset Sigma ...";
sigma.data = darkmean.data;
sigma.axes = darkmean.axes;
string filename = "sigmasigma3.gim";
write2gim(filename, sigma, sigfig);
cerr << " done." << endl;
}
else
{
cerr << "Processing Sigma frame...";
string filename;
pl.getValue("SIGMA_FILE", filename);
CCFITSfile fitsfile;
BOData<double> sigmaData;
fitsfile.read(filename, sigmaData);
print(sigmaData);
getSD(sigmaData, 3, sigma);
filename = "sigmasigma3.txt";
write2gim(filename, sigma, sigfig);
cerr << " done." << endl;
}
// Create FFTW wisdom for use in subsequent processing steps.
double freq;
double del_t;
double nOfData;
const char *wisdom_filename = "wisdom.txt";
pl.getValue("SAMPLING_INTERVAL", del_t);
pl.getValue("XCORR_FREQUENCY", freq);
pl.getValue("NUM_DATA_POINTS", nOfData);
cerr << "Creating FFTW Plan..." << endl;
plan_fftw(nOfData, wisdom_filename);
cerr << "FFTW Plan creation done." << endl;
return 0;
}