50 std::string result_path,
57 std::vector<std::unique_ptr<std::ifstream>> results_h, results_v;
58 results_h.reserve(n_freqs);
59 results_v.reserve(n_freqs);
61 for (
Index i = 0;
i < n_freqs; ++
i) {
62 std::string filename_h = result_path;
63 std::string filename_v = result_path;
64 filename_h +=
"/emisH_IND_MULT" + std::to_string(
i + 1) +
".txt";
65 filename_v +=
"/emisV_IND_MULT" + std::to_string(
i + 1) +
".txt";
67 results_h.push_back(std::unique_ptr<std::ifstream>(
68 new std::ifstream(filename_h, std::ifstream::in)));
69 results_v.push_back(std::unique_ptr<std::ifstream>(
70 new std::ifstream(filename_v, std::ifstream::in)));
73 Index n_lat =
static_cast<Index>(180.0 / resolution);
74 Index n_lon =
static_cast<Index>(360.0 / resolution);
78 for (
Index i = n_lat - 1;
i >= 0; --
i) {
79 for (
Index j = 0; j < n_lon; ++j) {
83 Numeric lat = 0.125 + resolution / 2.0 - 90.0 +
84 static_cast<Numeric>(
i) * resolution;
86 0.125 + resolution / 2.0 +
static_cast<Numeric>(j) * resolution;
90 Vector emis_h(3), emis_h_interp(n_freqs), emis_h_interp_ref(n_freqs),
91 emis_v(3), emis_v_interp(n_freqs), emis_v_interp_ref(n_freqs);
94 for (
Index k = 0; k < n_freqs; ++k) {
95 (*results_h[k]) >> emis_h_interp_ref[k];
96 (*results_v[k]) >> emis_v_interp_ref[k];
110 for (
Index k = 0; k < n_freqs; ++k) {
111 std::tie(emis_v_interp[k], emis_h_interp[k]) = atlas.
emis_interp(
112 theta, frequencies[k], class1, class2, emis_v, emis_h);
116 for (
Index k = 0; k < n_freqs; ++k) {
118 std::max(error, std::fabs(emis_h_interp[k] - emis_h_interp_ref[k]));
120 std::max(error, std::fabs(emis_v_interp[k] - emis_v_interp_ref[k]));
144 std::vector<std::unique_ptr<std::ifstream>> results_h, results_v;
145 results_h.reserve(3);
146 results_v.reserve(3);
149 std::string filename_h = result_path;
150 std::string filename_v = result_path;
151 filename_h +=
"/emisH" + std::to_string(
i + 1) +
".txt";
152 filename_v +=
"/emisV" + std::to_string(
i + 1) +
".txt";
154 results_h.push_back(std::unique_ptr<std::ifstream>(
155 new std::ifstream(filename_h, std::ifstream::in)));
156 results_v.push_back(std::unique_ptr<std::ifstream>(
157 new std::ifstream(filename_v, std::ifstream::in)));
160 Index n_lat =
static_cast<Index>(180.0 / resolution);
161 Index n_lon =
static_cast<Index>(360.0 / resolution);
165 for (
Index i = n_lat - 1;
i >= 0; --
i) {
166 for (
Index j = 0; j < n_lon; ++j) {
170 Numeric lat = 0.125 + resolution / 2.0 - 90.0 +
171 static_cast<Numeric>(
i) * resolution;
173 0.125 + resolution / 2.0 +
static_cast<Numeric>(j) * resolution;
177 Vector emis_h(3), emis_h_ref(3), emis_v(3), emis_v_ref(3);
180 for (
Index k = 0; k < 3; ++k) {
181 (*results_h[k]) >> emis_h_ref[k];
182 (*results_v[k]) >> emis_v_ref[k];
194 for (
Index k = 0; k < 3; ++k) {
195 error =
std::max(error, std::fabs(emis_h[k] - emis_h_ref[k]));
196 error =
std::max(error, std::fabs(emis_v[k] - emis_v_ref[k]));
203 int main(
int argc,
const char** argv) {
206 <<
"\nThis test uses the test results of the TELSEM2 fortran\n" 207 "module to test the ARTS TELSEM interface. \n\n Usage:\n" 208 "./test_telsem <atlas_path> <results_folder> <resolution> \n" 209 "where:\n - atlas_path: Path to the TELSEM2 atlas to load \n" 210 " - results_folder: The folder containing the result files \n" 211 "\t of the TELSEM2 tests.\n - resolution: The resolution used" 212 "to generate the lat/lon map.\n\n Note that for the interpolation" 213 "test the frequencies must match.\n\n";
217 String atlas_file = argv[1];
218 String result_path = argv[2];
219 Numeric resolution = std::stoi(argv[3]);
221 std::cout <<
"Atlas file: " << atlas_file << std::endl;
222 std::cout <<
"Result path: " << result_path << std::endl;
227 std::cout <<
"Maximum error reading emissivities: " << error
232 Vector frequencies = {6.0, 25.0, 31.4, 60.0, 190.0};
235 atlas_file, result_path, resolution, theta, frequencies);
236 std::cout <<
"Maximum error interpolating emissivities: " << error
INDEX Index
The type to use for all integer numbers and indices.
This file contains the definition of the TELSEM atlas format.
Vector get_emis_h(Index cellnum) const
Index calc_cellnum(Numeric lat, Numeric lon) const
bool contains(Index cellnumber) const
Index nelem() const
Returns the number of elements.
Index get_class2(Index cellnumber) const
Numeric test_telsem_read(String atlas_file, String result_path, Numeric resolution)
Test reading of TELSEM emissivities.
Index get_class1(Index cellnumber) const
The global header file for ARTS.
Vector get_emis_v(Index i) const
NUMERIC Numeric
The type to use for all floating point numbers.
std::pair< Numeric, Numeric > emis_interp(Numeric theta, Numeric freq, Index class1, Index class2, const ConstVectorView &ev, const ConstVectorView &eh) const
Numeric test_telsem_interpolate(std::string atlas_file, std::string result_path, Numeric resolution, Numeric theta, Vector frequencies)
Test reading of TELSEM emissivity interpolation.
int main(int argc, const char **argv)