mirror of
https://asciireactor.com/otho/industry-website.git
synced 2024-11-22 14:55:05 +00:00
89 lines
2.4 KiB
C++
89 lines
2.4 KiB
C++
|
#include "agn.hpp"
|
||
|
#include "sed.hpp"
|
||
|
|
||
|
|
||
|
// Syntax: table_powerlaw_spline <samples table> <powerlaw coordinates> <output table>
|
||
|
namespace agn {
|
||
|
bool sed_debug =true;
|
||
|
}
|
||
|
|
||
|
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(
|
||
|
powerlaw_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);
|
||
|
|
||
|
if(agn::sed_debug) debug_file
|
||
|
<< "Read "
|
||
|
<< samples.table.size()
|
||
|
<< " samples:\n"
|
||
|
<< format_sed_table(samples);
|
||
|
powerlaw_coords = agn::read_sed_table(powerlaw_table);
|
||
|
|
||
|
if(agn::sed_debug) debug_file
|
||
|
<< "Read power coords:\n"
|
||
|
<< format_sed_table(powerlaw_coords);
|
||
|
|
||
|
agn::sed_powerlaw_spline agnsource(samples,powerlaw_coords);
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
if(agn::verbose) std::cout
|
||
|
<< "Evaluating 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;
|
||
|
}
|
||
|
|