cloudy-agn/src/table_powerlaw_spline_sed.cpp
2017-08-09 02:57:14 -04:00

81 lines
2.1 KiB
C++

#include "agn.hpp"
#include "sed.hpp"
// Syntax: table_powerlaw_spline <samples table> <powerlaw coordinates> <output table>
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_powerlaw_spline class has a function for this.
int n = 1000;
agn::sed_table SED;
agn::sed_table samples;
agn::sed_table powerlaw_coords;
const char* sample_filename = argv[1];
const char* powerlaw_filename = argv[2];
const char* output_filename = argv[3];
const char* debug_filename = "spline_sed_debug";
std::ifstream sample_table(
sample_filename,
std::ofstream::out
);
std::ifstream powerlaw_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);
powerlaw_coords = agn::read_sed_table(powerlaw_table);
if(agn::debug) debug_file
<< "Read samples:\n"
<< format_sed_table(samples);
agn::sed_powerlaw_spline agnsource(samples,powerlaw_coords);
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
<< "Closing files. Goodbye.\n";
debug_file.close();
output_table.close();
return 0;
}