54 #define G_CONST "GModelSpectralTable(GEbounds&, GModelSpectralTablePars&, "\
56 #define G_FLUX "GModelSpectralTable::flux(GEnergy&, GEnergy&)"
57 #define G_EFLUX "GModelSpectralTable::eflux(GEnergy&, GEnergy&)"
58 #define G_MC "GModelSpectralTable::mc(GEnergy&, GEnergy&, GTime&, GRan&)"
59 #define G_READ "GModelSpectralTable::read(GXmlElement&)"
60 #define G_WRITE "GModelSpectralTable::write(GXmlElement&)"
61 #define G_LOAD "GModelSpectralTable::load(GFilename&)"
62 #define G_TABLE_PAR "GModelSpectralTable::table_par(int&)"
63 #define G_ENERGY_SCALE "GModelSpectralTable::energy_scale(std::string&)"
64 #define G_LOAD_PAR "GModelSpectralTable::load_par(GFits&)"
65 #define G_PAR_INDEX "GModelSpectralTable::par_index(std::string&)"
66 #define G_UPDATE "GModelSpectralTable::update()"
108 const double&
norm) :
148 if (spectra.
dim() != pars.
size()+1) {
150 " dimensions but an array with "+
152 "expected. Please specify a spectra array with the "
153 "correct dimension.";
158 for (
int i = 0; i < pars.
size(); ++i) {
159 int npars = pars[i]->
size();
160 int nspec = spectra.
shape()[i];
161 if (npars != nspec) {
162 std::string msg =
"Parameter \""+pars[i]->par().name()+
"\" has "+
166 "array with the correct number of spectra.";
172 int nebins = ebounds.
size();
173 int nspec = spectra.
shape()[pars.
size()];
174 if (nebins != nspec) {
175 std::string msg =
"Spectra array has "+
gammalib::str(nspec)+
" energy "
177 " energy boundaries. Please specify a spectra "
178 "array with the correct number of energy bins.";
268 if (
this != &model) {
378 const GTime& srcTime,
379 const bool& gradients)
const
387 double log10energy = srcEng.
log10MeV();
390 #if defined(G_DEBUG_ESCALE)
391 std::cout <<
"GModelSpectralTable::eval";
392 std::cout <<
" " << srcEng.
log10MeV();
393 std::cout <<
" " << log10energy << std::endl;
405 double func = wgt_left * val_left + wgt_right * val_right;
421 for (
int i = 0; i < dim; ++i) {
438 (wgt_left * grad_left + wgt_right * grad_right) *
443 grad = (wgt_left * grad_left + wgt_right * grad_right) *
456 #if defined(G_NAN_CHECK)
458 std::cout <<
"*** ERROR: GModelSpectralTable::eval";
459 std::cout <<
"(srcEng=" << srcEng;
460 std::cout <<
", srcTime=" << srcTime <<
"):";
461 std::cout <<
" NaN/Inf encountered";
462 std::cout <<
" (value=" << value;
463 std::cout <<
", norm=" <<
norm();
464 std::cout <<
", func=" << func;
465 std::cout <<
")" << std::endl;
505 double e_min = emin.
MeV();
506 double e_max = emax.
MeV();
519 if (inx_emin == inx_emax) {
534 int i_start = (e_min <
m_lin_nodes[0]) ? inx_emin : inx_emin+1;
544 for (
int i = i_start; i < inx_emax; ++i) {
598 double e_min = emin.
MeV();
599 double e_max = emax.
MeV();
612 if (inx_emin == inx_emax) {
628 int i_start = (e_min <
m_lin_nodes[0]) ? inx_emin : inx_emin+1;
639 for (
int i = i_start; i < inx_emax; ++i) {
695 for (inx =
m_mc_cum.size()-1; inx > 0; --inx) {
707 double eng = (u > 0.0)
716 double eng =
std::exp(u * (e_max - e_min) + e_min);
839 GFits fits(filename);
879 const bool& clobber)
const
896 primary->
card(
"CONTENT",
"MODEL",
"Spectrum file");
897 primary->
card(
"FILENAME", filename.
url(),
"FITS file name");
898 primary->
card(
"ORIGIN", PACKAGE_NAME,
"Origin of FITS file");
899 primary->
card(
"MODLNAME",
"model",
"Model name");
900 primary->
card(
"MODLUNIT",
"photons/cm^2/s/MeV",
"Model units");
901 primary->
card(
"REDSHIFT",
false,
"If true then redshift will be included as a par");
902 primary->
card(
"ADDMODEL",
true,
"If true then this is an additive table model");
903 primary->
card(
"HDUCLASS",
"OGIP",
"Format conforms to OGIP standard");
904 primary->
card(
"HDUCLAS1",
"XSPEC TABLE MODEL",
"Model spectra for XSPEC");
905 primary->
card(
"HDUVERS",
"1.0.0",
"Version of format");
908 fits.
saveto(filename, clobber);
957 if (index < 0 || index >=
size()) {
976 if (index < 0 || index >=
size()) {
1037 if (par.
name() == name) {
1045 std::string msg =
"\"energyscale\" attribute specified but "
1046 "parameter \""+name+
"\" not found in the "
1047 "table model. Please specify one of the "
1048 "table model parameters as energy scale.";
1053 #if defined(G_DEBUG_ESCALE)
1054 std::cout <<
"GModelSpectralTable::energy_scale(): ";
1055 std::cout <<
"energyscale=" <<
m_escale_par << std::endl;
1083 result.append(
"=== GModelSpectralTable ===");
1090 for (
int i = 0; i <
size(); ++i) {
1103 for (
int k = 0; k <
size; ++k) {
1115 result.append(
" (linear)");
1118 result.append(
" (logarithmic)");
1125 result.append(
" [");
1127 result.append(
", ");
1285 #if defined(G_DEBUG_CALLTREE)
1286 std::cout <<
"GModelSpectralTable::set_par_pointers()" << std::endl;
1311 #if defined(G_DEBUG_CALLTREE)
1312 std::cout <<
"GModelSpectralTable::set_energy_nodes()";
1329 for (
int i = 0; i < nebins; ++i) {
1331 double log10_energy_MeV =
std::log10(energy_MeV);
1339 for (
int i = 0; i < nebins; ++i) {
1362 #if defined(G_DEBUG_CALLTREE)
1363 std::cout <<
"GModelSpectralTable::scale_energy()";
1366 #elif defined(G_DEBUG_ESCALE)
1367 std::cout <<
"GModelSpectralTable::scale_energy(): entry" << std::endl;
1372 if (!(m_escale_par.empty()) && (
m_escale == 0.0)) {
1378 if (escales.
size() > 0) {
1393 #if defined(G_DEBUG_ESCALE)
1394 std::cout <<
" Largest energy scale: " << escale0;
1395 std::cout <<
" MeV" << std::endl;
1399 for (
int ispectrum = 0; ispectrum <
nspectra; ++ispectrum) {
1409 #if defined(G_DEBUG_ESCALE)
1410 std::cout <<
" " << ispectrum;
1411 std::cout <<
" " << ispec[ipar];
1412 std::cout <<
" " << escale;
1413 std::cout <<
" MeV" << std::endl;
1417 std::vector<double> spectrum(nebins,0.0);
1420 std::vector<int> index(npars+1,0);
1421 for (
int k = 0; k < npars; ++k) {
1422 index[k] = ispec[k];
1426 for (
int iebin = 0; iebin < nebins; ++iebin) {
1439 spectrum[iebin] = wgt_left * val_left + wgt_right * val_right;
1445 for (
int iebin = 0; iebin < nebins; ++iebin, ++index[npars]) {
1452 for (
int iebin = 0; iebin < nebins; ++iebin) {
1465 #if defined(G_DEBUG_ESCALE)
1466 std::cout <<
"GModelSpectralTable::update(): exit" << std::endl;
1504 for (
int i = 0; i < nrows; ++i) {
1524 for (
int i = 0; i < nrows; ++i) {
1530 col_name(i) = par.
name();
1532 col_initial(i) = (float)par.
value();
1536 col_delta(i) = -1.0;
1546 double min_value = 0.0;
1547 double max_value = 0.0;
1553 if (value < min_value) {
1556 if (value > max_value) {
1559 col_value(i,k) = value;
1565 if (par.
min() < min_value) {
1566 col_minimum(i) = (float)par.
min();
1567 col_bottom(i) = min_value;
1570 col_minimum(i) = (float)par.
min();
1571 col_bottom(i) = (float)par.
min();
1575 col_minimum(i) = min_value;
1576 col_bottom(i) = min_value;
1581 if (par.
max() > max_value) {
1582 col_top(i) = max_value;
1583 col_maximum(i) = (float)par.
max();
1586 col_top(i) = (float)par.
max();
1587 col_maximum(i) = (float)par.
max();
1591 col_top(i) = max_value;
1592 col_maximum(i) = max_value;
1602 table.
append(col_method);
1603 table.
append(col_initial);
1605 table.
append(col_minimum);
1606 table.
append(col_bottom);
1608 table.
append(col_maximum);
1609 table.
append(col_numbvals);
1616 table.
card(
"HDUCLASS",
"OGIP",
"Format conforms to OGIP standard");
1617 table.
card(
"HDUCLAS1",
"XSPEC TABLE MODEL",
"Model spectra for XSPEC");
1618 table.
card(
"HDUCLAS2",
"PARAMETERS",
"Extension containing parameter info");
1619 table.
card(
"HDUVERS",
"1.0.0",
"Version of format");
1620 table.
card(
"NINTPARM", nrows,
"Number of interpolation parameters");
1621 table.
card(
"NADDPARM", 0,
"Number of additional parameters");
1663 table.
card(
"HDUCLASS",
"OGIP",
"Format conforms to OGIP standard");
1664 table.
card(
"HDUCLAS1",
"XSPEC TABLE MODEL",
"Model spectra for XSPEC");
1665 table.
card(
"HDUCLAS2",
"ENERGIES",
"Extension containing energy bin info");
1666 table.
card(
"HDUVERS",
"1.0.0",
"Version of format");
1703 col_spec.
unit(
"ph cm-2 s-1 MeV-1");
1706 std::vector<int> inx(npars+1,0);
1707 for (
int i = 0; i < nrows; ++i) {
1710 for (
int k = 0; k < npars; ++k) {
1715 std::vector<int> index = inx;
1718 for (
int k = 0; k < nebins; ++k, ++index[npars]) {
1733 }
while (ipar >= 0);
1748 table.
card(
"HDUCLASS",
"OGIP",
"Format conforms to OGIP standard");
1749 table.
card(
"HDUCLAS1",
"XSPEC TABLE MODEL",
"Model spectra for XSPEC");
1750 table.
card(
"HDUCLAS2",
"MODEL SPECTRA",
"Extension containing model spectra");
1751 table.
card(
"HDUVERS",
"1.0.0",
"Version of format");
1777 int npars = table.
integer(
"NAXIS2");
1780 for (
int i = 0; i < npars; ++i) {
1783 GModelPar par(table[
"NAME"]->
string(i), table[
"INITIAL"]->real(i));
1800 if (table[
"DELTA"]->real(i) < 0.0) {
1810 std::vector<double> values;
1811 for (
int k = 0; k < table[
"NUMBVALS"]->
integer(i); ++k) {
1814 double value = table[
"VALUE"]->
real(i,k);
1835 values.push_back(value);
1843 table_model_par.
method(table[
"METHOD"]->integer(i));
1873 int nebins = table.
integer(
"NAXIS2");
1879 std::string emin_unit = table[
"ENERG_LO"]->unit();
1880 std::string emax_unit = table[
"ENERG_HI"]->unit();
1881 if (emin_unit.empty()) {
1884 if (emax_unit.empty()) {
1889 for (
int i = 0; i < nebins; ++i) {
1890 GEnergy emin(table[
"ENERG_LO"]->real(i), emin_unit);
1891 GEnergy emax(table[
"ENERG_HI"]->real(i), emax_unit);
1914 int npars = fits.
table(
"PARAMETERS")->
integer(
"NAXIS2");
1915 int nebins = fits.
table(
"ENERGIES")->
integer(
"NAXIS2");
1918 std::vector<int> naxis(npars+1, 0);
1919 for (
int i = 0; i < npars; ++i) {
1920 naxis[i] = (*fits.
table(
"PARAMETERS"))[
"NUMBVALS"]->integer(i);
1922 naxis[npars] = nebins;
1931 int nrows = table.
integer(
"NAXIS2");
1934 for (
int i = 0; i < nrows; ++i) {
1937 std::vector<int> index(npars+1, 0);
1940 std::vector<double> parval(npars, 0.0);
1941 for (
int k = 0; k < npars; ++k) {
1947 nodes.
set_value(table[
"PARAMVAL"]->real(i,k));
1959 #if defined(G_DEBUG_LOAD_SPEC)
1960 std::cout << i <<
": (";
1961 for (
int k = 0; k < index.size(); ++k) {
1965 std::cout << index[k];
1967 std::cout <<
")" << std::endl;
1971 for (
int k = 0; k < nebins; ++k, ++index[npars]) {
1995 for (; index <
size(); ++index) {
2002 if (index >=
size()) {
2003 std::string msg =
"Parameter name \""+name+
"\" not found in spectral "
2004 "table. Please specify one of the following parameter "
2006 for (
int i = 0; i <
size(); ++i) {
2085 bool need_update =
false;
2096 for (
int i = 0; i <
m_npars; ++i) {
2108 #if defined(G_DEBUG_UPDATE)
2109 std::cout <<
"GModelSpectralTable::update() required" << std::endl;
2113 std::vector<double> weights(2*
m_npars, 0.0);
2114 std::vector<double> weight_gradients(2*
m_npars, 0.0);
2115 std::vector<int> indices(2*
m_npars, 0);
2119 for (
int i = 0; i <
m_npars; ++i) {
2126 double value = par->
value();
2162 #if defined(G_DEBUG_UPDATE)
2163 std::cout <<
" wgt_l=" << weights[il];
2164 std::cout <<
" wgt_r=" << weights[ir];
2165 std::cout <<
" wgt_grad_l=" << weight_gradients[il];
2166 std::cout <<
" wgt_grad_r=" << weight_gradients[ir];
2167 std::cout <<
" inx_l=" << indices[il];
2168 std::cout <<
" inx_r=" << indices[ir] << std::endl;
2174 int combinations = 1 <<
m_npars;
2181 #if defined(G_DEBUG_UPDATE)
2182 double weight_sum = 0.0;
2186 for (
int i = 0; i < combinations; ++i) {
2189 #if defined(G_DEBUG_UPDATE)
2190 std::cout <<
" " << i <<
": ";
2194 double weight = 1.0;
2195 std::vector<double> grad_weight(m_npars, 1.0);
2198 std::vector<int> index_shape(m_npars+1,0);
2201 for (
int k = 0, div = 1; k <
m_npars; ++k, div *= 2) {
2204 int index = i/div % 2 + k * 2;
2207 weight *= weights[index];
2210 index_shape[k] = indices[index];
2213 for (
int j = 0; j <
m_npars; ++j) {
2215 grad_weight[j] *= weight_gradients[index];
2218 grad_weight[j] *= weights[index];
2223 #if defined(G_DEBUG_UPDATE)
2225 std::cout <<
" (" << weights[index];
2226 std::cout <<
" @ " << indices[index] <<
") ";
2232 #if defined(G_DEBUG_UPDATE)
2233 std::cout <<
": wgt=" << weight;
2235 for (
int k = 0; k <
m_npars; ++k) {
2239 std::cout << grad_weight[k];
2241 std::cout <<
"]" << std::endl;
2242 weight_sum += weight;
2246 for (
int iebin = 0; iebin <
m_nebins; ++iebin) {
2258 for (
int j = 0; j <
m_npars; ++j) {
2279 #if defined(G_DEBUG_UPDATE)
2280 std::cout <<
" sum(wgt)=" << weight_sum << std::endl;
2318 double prefactor = 0.0;
2321 if ((fmin > 0.0) && (fmax > 0.0)) {
2323 prefactor = fmin /
std::pow(emin/epivot, gamma);
2373 double e_min = emin.
MeV();
2374 double e_max = emax.
MeV();
2377 if (e_max > e_min) {
2392 if (inx_emin == inx_emax) {
2411 int i_start = (e_min <
m_lin_nodes[0]) ? inx_emin : inx_emin+1;
2425 for (
int i = i_start; i < inx_emax; ++i) {
2447 for (
int i = 1; i <
m_mc_cum.size(); ++i) {
2452 for (
int i = 0; i <
m_mc_cum.size(); ++i) {
2458 for (
int i = 0; i <
m_mc_cum.size(); ++i) {
2461 double exponent =
m_mc_exp[i] + 1.0;
2464 if (
std::abs(exponent) > 1.0e-11) {
2468 if (exponent < -50.0) {
2476 else if (exponent > +50.0) {
void unit(const std::string &unit)
Set column unit.
int size(void) const
Return number of nodes in node array.
GModelSpectralTablePar * append(const GModelSpectralTablePar &par)
Append table model parameter to container.
GFitsTable * table(const int &extno)
Get pointer to table HDU.
GModelSpectralTable(void)
Void constructor.
std::vector< double > m_mc_max
Upper boundary for MC.
const double & factor_gradient(void) const
Return parameter factor gradient.
double norm(const GVector &vector)
Computes vector norm.
GFitsBinTable create_spec_table(void) const
Create SPECTRA FITS table.
void energy_scale(const std::string &name)
Set energy scale.
Energy value class definition.
const std::string & name(void) const
Return parameter name.
Random number generator class definition.
std::vector< double > m_mc_exp
Exponent for MC.
void clear(void)
Clear array.
Abstract spectral model base class.
std::string m_escale_par
Energy scaling parameter.
GModelPar m_norm
Normalization factor.
double gradient(void) const
Return parameter gradient.
GModelSpectralTablePars m_table_pars
Table model parameters.
GEnergy m_mc_emax
Maximum energy.
int size(void) const
Return number of parameters.
double m_escale
Energy scale.
const double & wgt_grad_left(void) const
Returns left node weight gradient.
GVector abs(const GVector &vector)
Computes absolute of vector elements.
virtual GModelSpectral & operator=(const GModelSpectral &model)
Assignment operator.
void write(GXmlElement &xml) const
Set or update parameter attributes in XML element.
virtual void read(const GXmlElement &xml)
Read model from XML element.
Abstract FITS extension base class.
int size(void) const
Return number of energy boundaries.
GNdarray m_lin_values
Function values and grad's.
void append(const GEnergy &emin, const GEnergy &emax)
Append energy interval.
virtual GEnergy mc(const GEnergy &emin, const GEnergy &emax, const GTime &time, GRan &ran) const
Returns MC energy between [emin, emax].
std::vector< GModelPar * > m_pars
Parameter pointers.
const GEbounds & ebounds(void) const
Return reference to energy boundaries.
void factor_range(const double &min, const double &max)
Set minimum and maximum parameter boundary factors.
bool is_empty(void) const
Signal if filename is empty.
const double & wgt_left(void) const
Returns left node weight.
virtual double flux(const GEnergy &emin, const GEnergy &emax) const
Returns model photon flux between emin, emax
Spectral model registry class definition.
double max(void) const
Return parameter maximum boundary.
void clear(void)
Clear node array.
virtual double eflux(const GEnergy &emin, const GEnergy &emax) const
Returns model energy flux between emin, emax
Random number generator class.
GFitsTableCol * append(const GFitsTableCol &column)
Append column to the table.
void free_members(void)
Delete class members.
virtual ~GModelSpectralTable(void)
Destructor.
double norm(void) const
Return normalization factor.
double MeV(void) const
Return energy in MeV.
const int & method(void) const
Return reference to table model parameter interpolation method.
void set_energy_nodes(void)
Set energy nodes from energy boundaries.
void update_mc(const GEnergy &emin, const GEnergy &emax) const
Update MC cache.
const std::vector< int > & shape(void) const
Return shape of array.
FITS table float column class interface definition.
GNodeArray m_log_nodes
log10(Energy) nodes of function
std::vector< double > m_epivot
Power-law pivot energies.
FITS file class interface definition.
void set_value(const double &value) const
Set indices and weighting factors for interpolation.
std::vector< double > m_flux
Photon fluxes.
double min(const GVector &vector)
Computes minimum vector element.
GFilename xml_file_reduce(const GXmlElement &xml, const std::string &filename)
Reduce file name provided for writing as XML attribute.
void init_members(void)
Initialise class members.
double min(void) const
Return parameter minimum boundary.
double plaw_energy_flux(const double &emin, const double &emax, const double &epivot, const double &gamma)
Compute energy flux between two energies for a power law.
bool is_free(void) const
Signal if parameter is free.
double m_log10escale
log10 of energy scale
Spectral table model parameter container class.
double log10MeV(void) const
Return log10 of energy in MeV.
std::vector< double > m_prefactor
Power-law normalisations.
void update_flux(void) const
Update flux cache.
void set_par_pointers(void)
Set parameter pointers.
bool is_notanumber(const double &x)
Signal if argument is not a number.
std::vector< double > m_mc_cum
Cumulative distribution.
FITS table string column.
void load(const GFilename &filename)
Load table from file.
const double & scale(void) const
Return parameter scale.
bool is_infinite(const double &x)
Signal if argument is infinite.
void load_eng(const GFits &fits)
Load data from ENERGIES extension.
void saveto(const GFilename &filename, const bool &clobber=false)
Saves to specified FITS file.
double real(const std::string &keyname) const
Return card value as double precision.
GFitsBinTable create_eng_table(void) const
Create ENERGIES FITS table.
void copy_members(const GModelSpectralTable &model)
Copy class members.
GVector sqrt(const GVector &vector)
Computes square root of vector elements.
GNodeArray m_lin_nodes
Energy nodes of function.
bool has_grad(void) const
Signal if parameter gradient is computed analytically.
int nspectra(void) const
Return number of spectra in table model.
const GFilename & filename(void) const
Return file name.
bool has_energy_scale(void) const
Signal that energy scale was set.
const double & wgt_right(void) const
Returns right node weight.
Energy boundaries container class.
const GXmlAttribute * attribute(const int &index) const
Return attribute.
std::string print(const GChatter &chatter=NORMAL) const
Print energy.
std::vector< double > m_last_values
Last parameter values.
void free(void)
Free a parameter.
virtual double eval(const GEnergy &srcEng, const GTime &srcTime=GTime(), const bool &gradients=false) const
Evaluate spectral table model.
const GEnergy & emin(void) const
Return minimum energy of all intervals.
virtual void clear(void)
Clear table model.
void fix(void)
Fix a parameter.
GNdarray m_spectra
Spectra.
bool has_attribute(const std::string &name) const
Check if element has a given attribute.
GXmlElement * xml_need_par(const std::string &origin, GXmlElement &xml, const std::string &name)
Return pointer to parameter with given name in XML element.
GVector log(const GVector &vector)
Computes natural logarithm of vector elements.
Spectral table model parameter class definition.
double uniform(void)
Returns random double precision floating value in range 0 to 1.
void check_energy_interval(const std::string &origin, const GEnergy &emin, const GEnergy &emax)
Checks energy interval.
const GModelSpectralTable g_spectral_table_seed
void clear(void)
Clear parameter.
int m_nebins
Number of energy bins.
GFilename m_filename
Filename of table.
FITS table string column class interface definition.
std::vector< double > m_gamma
Power-law indices.
Abstract interface for FITS table.
bool is_fixed(void) const
Signal if parameter is fixed.
Spectral table model class.
GEbounds m_ebounds
Energy boundaries.
void remove_range(void)
Removes minimum and maximum boundary.
int size(void) const
Return number of table model parameters in container.
GEnergy elogmean(const int &index) const
Returns logarithmic mean energy for a given energy interval.
int integer(const std::string &keyname) const
Return card value as integer.
const int & inx_left(void) const
Returns left node index.
GModelSpectralTablePar & table_par(const int &index)
Return reference to table parameter.
int par_index(const std::string &name) const
Return index for parameter name.
bool has_max(void) const
Signal if parameter has maximum boundary.
std::vector< double > m_mc_min
Lower boundary for MC.
N-dimensional array class.
const std::string & extname(void) const
Return extension name.
void clear(void)
Clear energy boundaries.
double max(const GVector &vector)
Computes maximum vector element.
void load_par(const GFits &fits)
Load data from PARAMETERS extension.
Interface definition for the spectral model registry class.
FITS table long integer column.
bool xml_has_par(const GXmlElement &xml, const std::string &name)
Checks if parameter with given name in XML element exists.
const int & inx_right(void) const
Returns right node index.
virtual GModelSpectralTable * clone(void) const
Clone table model.
virtual std::string type(void) const
Return model type.
Spectral table model parameter container class definition.
std::string url(void) const
Return Uniform Resource Locator (URL)
GNdarray m_log_values
log10(Function) values and grad's
void clear(void)
Clear file name.
void init_members(void)
Initialise class members.
int m_npars
Number of parameters.
double keV(void) const
Return energy in keV.
void range(const double &min, const double &max)
Set minimum and maximum parameter boundaries.
void read(const GXmlElement &xml)
Extract parameter attributes from XML element.
double value(void) const
Return parameter value.
void clear(void)
Clear table model parameters.
bool has_min(void) const
Signal if parameter has minimum boundary.
int index(const std::vector< int > &i) const
Compute array element index.
GVector pow(const GVector &vector, const double &power)
Computes tanh of vector elements.
std::vector< double > m_eflux
Energy fluxes.
Exception handler interface definition.
FITS table long integer column class interface definition.
Spectral table model class definition.
GFitsHDU * append(const GFitsHDU &hdu)
Append HDU to FITS file.
FITS binary table class definition.
GVector exp(const GVector &vector)
Computes exponential of vector elements.
void scale_energy(void)
Scale energy.
const GEnergy & emax(void) const
Return maximum energy of all intervals.
void save(const GFilename &filename, const bool &clobber=false) const
Save table into file.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
void append(const double &node)
Append one node to array.
GEnergy m_mc_emin
Minimum energy.
GFitsBinTable create_par_table(void) const
Create PARAMETERS FITS table.
const GNodeArray & values(void) const
Return reference to table model parameter values as node array.
GFitsHeaderCard & card(const int &cardno)
Return header card.
void close(void)
Close FITS file.
int dim(void) const
Return dimension of array.
void update(void) const
Update cache for spectral table model computation.
virtual GModelSpectralTable & operator=(const GModelSpectralTable &model)
Assignment operator.
const GXmlElement * xml_get_par(const std::string &origin, const GXmlElement &xml, const std::string &name)
Return pointer to parameter with given name in XML element.
Spectral table model parameter class.
void free_members(void)
Delete class members.
const double & wgt_grad_right(void) const
Returns right node weight gradient.
void clear(void)
Clear instance.
virtual void write(GXmlElement &xml) const
Write model into XML element.
void load_spec(const GFits &fits)
Load data from SPECTRA extension.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print table model information.
const double & factor_value(void) const
Return parameter factor value.
Mathematical function definitions.
GVector log10(const GVector &vector)
Computes base10 logarithm of vector elements.
Class that handles energies in a unit independent way.
double plaw_photon_flux(const double &emin, const double &emax, const double &epivot, const double &gamma)
Compute photon flux between two energies for a power law.
GFilename xml_file_expand(const GXmlElement &xml, const std::string &filename)
Expand file name provided as XML attribute for loading.
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.
void xml_check_type(const std::string &origin, GXmlElement &xml, const std::string &type)
Checks the model type.