-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLyaPowerxQmlExposure.cpp
More file actions
159 lines (122 loc) · 3.65 KB
/
LyaPowerxQmlExposure.cpp
File metadata and controls
159 lines (122 loc) · 3.65 KB
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <gsl/gsl_errno.h>
#include "core/global_numbers.hpp"
#include "core/mpi_manager.hpp"
#include "core/sq_table.hpp"
#include "core/fiducial_cosmology.hpp"
#include "cross/cross_exposure.hpp"
#include "mathtools/smoother.hpp"
#include "io/logger.hpp"
#include "io/io_helper_functions.hpp"
#include "io/config_file.hpp"
#include "io/bootstrap_file.hpp"
int main(int argc, char *argv[])
{
mympi::init(argc, argv);
if (argc<2)
{
fprintf(stderr, "Missing config file!\n");
mympi::finalize();
return 1;
}
const char *FNAME_CONFIG = argv[1];
gsl_set_error_handler_off();
ConfigFile config = ConfigFile();
std::unique_ptr<OneDCrossExposureQMLE> qps;
// Let all PEs to read config at the same time.
try
{
config.readFile(FNAME_CONFIG);
LOG::LOGGER.open(config.get("OutputDir", "."), mympi::this_pe);
specifics::printBuildSpecifics();
mytime::writeTimeLogHeader();
}
catch (std::exception& e)
{
fprintf(stderr, "Error while reading config file: %s\n", e.what());
mympi::abort();
return 1;
}
try
{
process::readProcess(config);
bins::readBins(config);
specifics::readSpecifics(config);
conv::readConversion(config);
fidcosmo::readFiducialCosmo(config);
}
catch (std::exception& e)
{
LOG::LOGGER.ERR("Error while parsing config file: %s\n",
e.what());
mympi::abort();
return 1;
}
if (process::SAVE_EACH_PE_RESULT) {
try {
ioh::boot_saver = std::make_unique<ioh::BootstrapFile>(
process::FNAME_BASE, bins::NUMBER_OF_K_BANDS,
bins::NUMBER_OF_Z_BINS, mympi::this_pe);
mympi::barrier();
}
catch (std::exception& e) {
LOG::LOGGER.ERR("Error while openning BootstrapFile: %s\n",
e.what());
mympi::abort();
return 1;
}
}
try
{
// Allocate and read look up tables
process::sq_private_table = std::make_unique<SQLookupTable>(config);
// Readjust allocated memory wrt save tables
if (process::SAVE_ALL_SQ_FILES || specifics::USE_RESOLUTION_MATRIX)
{
process::sq_private_table->readTables();
process::updateMemory(-process::sq_private_table->getMaxMemUsage());
}
else
process::updateMemory(-process::sq_private_table->getOneSetMemUsage());
}
catch (std::exception& e)
{
LOG::LOGGER.ERR("Error while SQ Table contructed: %s\n", e.what());
mympi::abort();
return 1;
}
process::smoother = std::make_unique<Smoother>(config);
try
{
qps = std::make_unique<OneDCrossExposureQMLE>(config);
config.checkUnusedKeys();
}
catch (std::exception& e)
{
LOG::LOGGER.ERR("Error while OneDCrossExposureQMLE contructed: %s\n", e.what());
mympi::abort();
return 1;
}
try
{
qps->xQmlEstimate();
}
catch (std::exception& e)
{
LOG::LOGGER.ERR("Error while xQmlEstimate: %s\n", e.what());
qps->printfSpectra();
std::string buf = process::FNAME_BASE + "_error_dump_quadratic_power_estimate_detailed.dat";
qps->writeDetailedSpectrumEstimates(buf.c_str());
buf = process::FNAME_BASE + "_error_dump_fisher_matrix.dat";
qps->writeFisherMatrix(buf.c_str());
mympi::abort();
return 1;
}
qps.reset();
ioh::boot_saver.reset();
mympi::finalize();
return 0;
}