41 const double c_theta_max = 5.0;
49#define G_CONSTRUCTOR "GModelSpatialEllipticalGeneralGauss::"\
50 "GModelSpatialEllipticalGeneralGauss(GSkyDir&, double&, double&, "\
51 "double&, double&, std::string&)"
52#define G_READ "GModelSpatialEllipticalGeneralGauss::read(GXmlElement&)"
53#define G_WRITE "GModelSpatialEllipticalGeneralGauss::write(GXmlElement&)"
54#define G_MC "GModelSpatialEllipticalGeneralGauss::mc(GEnergy&, GTime&, "\
60#define G_SMALL_ANGLE_APPROXIMATION
105 const double& semimajor,
106 const double& semiminor,
107 const double& posangle,
109 const std::string& coordsys) :
114 std::string msg =
"Invalid coordinate system \""+
coordsys+
"\" "
115 "specified. Please specify either \"CEL\" or "
215 if (
this != &model) {
333 const double& posangle,
336 const bool& gradients)
const
348 #if defined(G_SMALL_ANGLE_APPROXIMATION)
350 double cosinus = std::cos(rel_posangle);
351 double sinus = std::sin(rel_posangle);
355 std::sqrt(arg1*arg1 + arg2*arg2);
356 double r_relative = theta/r_ellipse;
357 double exponent = std::pow(r_relative,
m_inv_ridx);
364 double term1 =
m_term1 * cosphi * cosphi;
365 double term2 =
m_term2 * sinphi * sinphi;
366 double term3 =
m_term3 * sinphi * cosphi;
369 double exponent = std::pow(theta * std::sqrt(term1 + term2 + term3),
m_inv_ridx) ;
373 value =
m_norm * std::exp(-exponent);
376 #if defined(G_NAN_CHECK)
378 std::cout <<
"*** ERROR: GModelSpatialEllipticalGeneralGauss::eval";
379 std::cout <<
"(theta=" << theta <<
"): NaN/Inf encountered";
380 std::cout <<
"(posangle=" <<
posangle <<
"): NaN/Inf encountered";
381 std::cout <<
" (value=" << value;
382 std::cout <<
", MinorAxis^2=" <<
m_minor2;
383 std::cout <<
", MaxjorAxis^2=" <<
m_major2;
384 std::cout <<
", m_norm=" <<
m_norm;
385 std::cout <<
")" << std::endl;
415 #if defined(G_DEBUG_MC)
426 std::string msg =
"Non positive maximum ellpitical general Gauss model value.";
434 value =
eval(theta, phi, energy, time) * std::sin(theta);
436 #if defined(G_DEBUG_MC)
440 #if defined(G_DEBUG_MC)
441 std::cout <<
"#=" << n_samples <<
" ";
466 const double& margin)
const
608 result.append(
"=== GModelSpatialEllipticalGeneralGauss ===");
613 for (
int i = 0; i <
size(); ++i) {
636 m_type =
"EllipticalGeneralGaussian";
737 bool changed =
false;
770 #if !defined(G_SMALL_ANGLE_APPROXIMATION)
783 double cospos = std::cos(posangle_rad);
784 double sinpos = std::sin(posangle_rad);
789 m_sin2pos = std::sin(2.0 * posangle_rad);
Exception handler interface definition.
Mathematical function definitions.
const GModelSpatialEllipticalGeneralGauss g_elliptical_general_gauss_seed
Generalised elliptical gaussian model class interface definition.
Radial disk model class interface definition.
Spatial model registry class definition.
Class that handles energies in a unit independent way.
void write(GXmlElement &xml) const
Set or update parameter attributes in XML element.
void read(const GXmlElement &xml)
Extract parameter attributes from XML element.
double m_sin2pos
sine of twice the position angle
double m_norm
Normalization.
double ridx(void) const
Return reciprocal of the elliptical profile index.
void free_members(void)
Delete class members.
double m_term2
Help term 2.
double m_major_rad
Major axis in radians.
double m_minor_rad
Minor axis in radians.
virtual ~GModelSpatialEllipticalGeneralGauss(void)
Destructor.
virtual void read(const GXmlElement &xml)
Read model from XML element.
virtual GModelSpatialEllipticalGeneralGauss & operator=(const GModelSpatialEllipticalGeneralGauss &model)
Assignment operator.
double m_major2
square of major axis
virtual double theta_max(void) const
Return maximum model radius (in radians)
double m_last_minor
Last semi-minor axis.
double m_last_ridx
Last reciprocal radial index.
virtual void clear(void)
Clear generalised elliptical Gaussian model.
virtual GModelSpatialEllipticalGeneralGauss * clone(void) const
Clone generalised elliptical Gaussian model.
double m_sinpos2
squared sine of position angle
double m_cospos2
squared cosine of position angle
double m_last_posangle
Last position angle.
virtual void write(GXmlElement &xml) const
Write model into XML element.
double m_term3
Help term 3.
virtual void set_region(void) const
Set boundary sky region.
double m_term1
Help term 1.
GModelSpatialEllipticalGeneralGauss(void)
Void constructor.
void init_members(void)
Initialise class members.
virtual double eval(const double &theta, const double &posangle, const GEnergy &energy, const GTime &time, const bool &gradients=false) const
Evaluate function (in units of sr^-1)
virtual std::string print(const GChatter &chatter=NORMAL) const
Print information.
double m_minor2
square of minor axis
void update(void) const
Update precomputation cache.
void copy_members(const GModelSpatialEllipticalGeneralGauss &model)
Copy class members.
double m_inv_ridx
Spatial profile index.
GModelPar m_ridx
Reciprocal of exponent of the radial profile.
double m_last_major
Last semi-major axis.
virtual bool contains(const GSkyDir &dir, const double &margin=0.0) const
Checks whether model contains specified sky direction.
virtual GSkyDir mc(const GEnergy &energy, const GTime &time, GRan &ran) const
Returns MC sky direction.
Abstract elliptical spatial model base class.
void init_members(void)
Initialise class members.
GModelPar m_semiminor
Semi-minor axis of ellipse (deg)
double semimajor(void) const
Return semi-major axis of ellipse.
virtual void write(GXmlElement &xml) const
Write model into XML element.
GModelPar m_semimajor
Semi-major axis of ellipse (deg)
GModelPar m_lat
Declination or Galactic latitude (deg)
void free_members(void)
Delete class members.
double posangle(void) const
Return Position Angle of model.
virtual GModelSpatialElliptical & operator=(const GModelSpatialElliptical &model)
Assignment operator.
GModelPar m_lon
Right Ascension or Galactic longitude (deg)
const GSkyDir & dir(void) const
Return position of elliptical spatial model.
std::string coordsys(void) const
Return coordinate system.
double semiminor(void) const
Return semi-minor axis of ellipse.
virtual void read(const GXmlElement &xml)
Read model from XML element.
Interface definition for the spatial model registry class.
std::string m_type
Spatial model type.
std::string type(void) const
Return model type.
const GSkyRegion * region(void) const
Return boundary sky region.
std::vector< GModelPar * > m_pars
Parameter pointers.
void init_members(void)
Initialise class members.
int size(void) const
Return number of parameters.
void free_members(void)
Delete class members.
GSkyRegionCircle m_region
Bounding circle.
void free(void)
Free a parameter.
const double & scale(void) const
Return parameter scale.
bool has_grad(void) const
Signal if parameter gradient is computed analytically.
double min(void) const
Return parameter minimum boundary.
double gradient(void) const
Return parameter gradient.
void clear(void)
Clear parameter.
double value(void) const
Return parameter value.
const std::string & name(void) const
Return parameter name.
Random number generator class.
double uniform(void)
Returns random double precision floating value in range 0 to 1.
void rotate_deg(const double &phi, const double &theta)
Rotate sky direction by zenith and azimuth angle.
double dist(const GSkyDir &dir) const
Compute angular distance between sky directions in radians.
Interface for the circular sky region class.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
bool is_infinite(const double &x)
Signal if argument is infinite.
bool is_notanumber(const double &x)
Signal if argument is not a number.
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.
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.
double gammln(const double &arg)
Computes logarithm of gamma function.
GXmlElement * xml_need_par(const std::string &origin, GXmlElement &xml, const std::string &name)
Return pointer to parameter with given name in XML element.
void xml_check_parnum(const std::string &origin, const GXmlElement &xml, const int &number)
Checks number of parameters.
void xml_check_type(const std::string &origin, GXmlElement &xml, const std::string &type)
Checks the model type.