cloudy-agn/src/table_powerlaw_spline_sed.cpp

81 lines
2.1 KiB
C++
Raw Normal View History

2017-08-08 09:15:14 +00:00
#include "agn.hpp"
2017-08-08 09:20:20 +00:00
#include "sed.hpp"
2017-08-08 09:15:14 +00:00
2017-08-09 06:57:14 +00:00
// Syntax: table_powerlaw_spline <samples table> <powerlaw coordinates> <output table>
2017-08-08 09:15:14 +00:00
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
2017-08-09 06:57:14 +00:00
// agn sed_powerlaw_spline class has a function for this.
2017-08-08 09:15:14 +00:00
int n = 1000;
agn::sed_table SED;
agn::sed_table samples;
2017-08-08 13:07:34 +00:00
agn::sed_table powerlaw_coords;
2017-08-08 09:15:14 +00:00
const char* sample_filename = argv[1];
2017-08-08 13:07:34 +00:00
const char* powerlaw_filename = argv[2];
const char* output_filename = argv[3];
2017-08-08 09:15:14 +00:00
const char* debug_filename = "spline_sed_debug";
std::ifstream sample_table(
sample_filename,
std::ofstream::out
);
2017-08-08 13:07:34 +00:00
std::ifstream powerlaw_table(
sample_filename,
std::ofstream::out
);
2017-08-08 09:15:14 +00:00
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);
2017-08-08 13:07:34 +00:00
powerlaw_coords = agn::read_sed_table(powerlaw_table);
2017-08-08 09:15:14 +00:00
2017-08-08 10:36:00 +00:00
if(agn::debug) debug_file
2017-08-08 09:15:14 +00:00
<< "Read samples:\n"
<< format_sed_table(samples);
2017-08-08 13:07:34 +00:00
agn::sed_powerlaw_spline agnsource(samples,powerlaw_coords);
2017-08-08 11:21:30 +00:00
2017-08-08 09:15:14 +00:00
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;
}