cloudy-agn/src/generate_spline_sed.cpp
2017-08-08 05:15:14 -04:00

77 lines
2.0 KiB
C++

#include "agn.hpp"
int main(int argc, char const *argv[])
{
if (agn::verbose) std::cout
<< "Setting up environment.\n";
// Create 2d table using n bins, linear values of SED. The
// agn sed_spline class has a function for this. A
// std::map<double,double> represents the table.
int n = 1000;
agn::sed_table SED;
agn::sed_table samples;
agn::sed_spline agnsource;
const char* sample_filename = argv[1];
const char* output_filename = argv[2];
const char* debug_filename = "spline_sed_debug";
std::ifstream sample_table(
sample_filename,
std::ofstream::out
);
std::ofstream output_table(
output_filename,
std::ofstream::out
);
std::ofstream debug_file(
debug_filename,
std::ofstream::out
);
if (agn::verbose) std::cout
<< "Creating agn sed object.\n";
// Read in sampling table and construct a spline model.
samples = agn::read_sed_table(sample_table);
agnsource = agn::sed_spline(samples);
if(agn::debug) debug_file {
std::cout
<< "Read samples:\n"
<< format_sed_table(samples);
}
if(agn::verbose) std::cout
<< "Evaluating relative spectral intensity for "
<< n
<< " photon energy bins.\n";
SED = agnsource.histogram_table(n);
if(agn::verbose) std::cout
<< "Printing SED table to file "
<< output_filename
<< "\n";
output_table << agn::format_sed_table(SED);
if(agn::verbose) std::cout
<< "Printing CLOUDY interpolate command syntax to file "
<< cloudyscript_filename
<< "\n";
if(agn::verbose) std::cout
<< "Closing files. Goodbye.\n";
debug_file.close();
output_table.close();
return 0;
}