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) :
113 if ((coordsys !=
"CEL") && (coordsys !=
"GAL")) {
114 std::string msg =
"Invalid coordinate system \""+coordsys+
"\" "
115 "specified. Please specify either \"CEL\" or "
124 if (coordsys ==
"CEL") {
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);
356 double r_relative = theta/r_ellipse;
364 double term1 =
m_term1 * cosphi * cosphi;
365 double term2 =
m_term2 * sinphi * sinphi;
366 double term3 =
m_term3 * sinphi * cosphi;
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
469 double distance = dir.
dist(this->
dir());
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);
GModelPar m_semimajor
Semi-major axis of ellipse (deg)
virtual void write(GXmlElement &xml) const
Write model into XML element.
void free_members(void)
Delete class members.
Abstract elliptical spatial model base class.
const std::string & name(void) const
Return parameter name.
virtual void clear(void)
Clear generalised elliptical Gaussian model.
GModelPar m_lon
Right Ascension or Galactic longitude (deg)
double gradient(void) const
Return parameter gradient.
int size(void) const
Return number of parameters.
double m_major2
square of major axis
void write(GXmlElement &xml) const
Set or update parameter attributes in XML element.
GVector cos(const GVector &vector)
Computes cosine of vector elements.
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 void read(const GXmlElement &xml)
Read model from XML element.
double m_major_rad
Major axis in radians.
virtual GModelSpatialElliptical & operator=(const GModelSpatialElliptical &model)
Assignment operator.
virtual GSkyDir mc(const GEnergy &energy, const GTime &time, GRan &ran) const
Returns MC sky direction.
double m_term1
Help term 1.
const GSkyDir & dir(void) const
Return position of elliptical spatial model.
double m_inv_ridx
Spatial profile index.
Random number generator class.
double m_norm
Normalization.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print information.
Interface for the circular sky region class.
double m_term3
Help term 3.
GModelSpatialEllipticalGeneralGauss(void)
Void constructor.
double m_last_posangle
Last position angle.
Interface definition for the spatial model registry class.
double min(void) const
Return parameter minimum boundary.
void init_members(void)
Initialise class members.
virtual void set_region(void) const
Set boundary sky region.
GSkyRegionCircle m_region
Bounding circle.
double m_last_major
Last semi-major axis.
double m_term2
Help term 2.
bool is_notanumber(const double &x)
Signal if argument is not a number.
const double & scale(void) const
Return parameter scale.
bool is_infinite(const double &x)
Signal if argument is infinite.
double semiminor(void) const
Return semi-minor axis of ellipse.
const GModelSpatialEllipticalGeneralGauss g_elliptical_general_gauss_seed
GVector sqrt(const GVector &vector)
Computes square root of vector elements.
bool has_grad(void) const
Signal if parameter gradient is computed analytically.
void free(void)
Free a parameter.
Radial disk model class interface definition.
std::vector< GModelPar * > m_pars
Parameter pointers.
void rotate_deg(const double &phi, const double &theta)
Rotate sky direction by zenith and azimuth angle.
GModelPar m_ridx
Reciprocal of exponent of the radial profile.
GXmlElement * xml_need_par(const std::string &origin, GXmlElement &xml, const std::string &name)
Return pointer to parameter with given name in XML element.
double uniform(void)
Returns random double precision floating value in range 0 to 1.
void init_members(void)
Initialise class members.
void clear(void)
Clear parameter.
Spatial model registry class definition.
double m_minor2
square of minor axis
virtual double theta_max(void) const
Return maximum model radius (in radians)
virtual ~GModelSpatialEllipticalGeneralGauss(void)
Destructor.
virtual GModelSpatialEllipticalGeneralGauss & operator=(const GModelSpatialEllipticalGeneralGauss &model)
Assignment operator.
virtual void read(const GXmlElement &xml)
Read model from XML element.
GModelPar m_semiminor
Semi-minor axis of ellipse (deg)
std::string type(void) const
Return model type.
void xml_check_parnum(const std::string &origin, const GXmlElement &xml, const int &number)
Checks number of parameters.
double m_minor_rad
Minor axis in radians.
double m_last_ridx
Last reciprocal radial index.
double gammln(const double &arg)
Computes logarithm of gamma function.
void update(void) const
Update precomputation cache.
const GSkyRegion * region(void) const
Return boundary sky region.
void free_members(void)
Delete class members.
void copy_members(const GModelSpatialEllipticalGeneralGauss &model)
Copy class members.
double ridx(void) const
Return reciprocal of the elliptical profile index.
std::string m_type
Spatial model type.
double posangle(void) const
Return Position Angle of model.
Generalised elliptical gaussian model class interface definition.
void read(const GXmlElement &xml)
Extract parameter attributes from XML element.
double value(void) const
Return parameter value.
GModelPar m_lat
Declination or Galactic latitude (deg)
GVector pow(const GVector &vector, const double &power)
Computes tanh of vector elements.
GVector sin(const GVector &vector)
Computes sine of vector elements.
double m_sin2pos
sine of twice the position angle
Exception handler interface definition.
double dist(const GSkyDir &dir) const
Compute angular distance between sky directions in radians.
double m_cospos2
squared cosine of position angle
GVector exp(const GVector &vector)
Computes exponential of vector elements.
void init_members(void)
Initialise class members.
double m_last_minor
Last semi-minor axis.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
virtual bool contains(const GSkyDir &dir, const double &margin=0.0) const
Checks whether model contains specified sky direction.
void free_members(void)
Delete class members.
double m_sinpos2
squared sine of position angle
virtual GModelSpatialEllipticalGeneralGauss * clone(void) const
Clone generalised elliptical Gaussian model.
double semimajor(void) const
Return semi-major axis of ellipse.
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.
virtual void write(GXmlElement &xml) const
Write model into XML element.
Mathematical function definitions.
Class that handles energies in a unit independent way.
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.