43 #if defined(G_LEGACY_XML_FORMAT)
49 #define G_MC "GModelSpatialDiffuseMap::mc(GEnergy&, GTime&, GRan&)"
50 #define G_READ "GModelSpatialDiffuseMap::read(GXmlElement&)"
51 #define G_WRITE "GModelSpatialDiffuseMap::write(GXmlElement&)"
93 const std::string& type) :
143 const bool& normalize) :
175 const bool& normalize) :
249 if (
this != &model) {
323 const bool& gradients)
const
326 double intensity =
m_map(photon.
dir());
371 std::string msg =
"Simulation cone has not been defined or does not "
372 "overlap with the sky map. Please specify a valid "
382 std::string msg =
"No sky map defined. Please specify a valid sky map.";
390 #if defined(G_DEBUG_MC)
391 int num_iterations = 0;
398 #if defined(G_DEBUG_MC)
405 double phi = 360.0 * ran.
uniform();
420 if (uniform <= value) {
427 #if defined(G_DEBUG_MC)
428 std::cout << num_iterations <<
" ";
448 const double& radius)
const
472 const double& margin)
const
534 #if defined(G_LEGACY_XML_FORMAT)
543 #if defined(G_LEGACY_XML_FORMAT)
544 std::string msg =
"Diffuse map model requires either "
545 "\"Normalization\" or \"Prefactor\" parameter.";
547 std::string msg =
"Diffuse map model requires \"Normalization\" "
558 std::string arg = xml.
attribute(
"normalize");
662 double sum_map = 0.0;
663 for (
int i = 0; i < npix; ++i) {
667 double intensity =
m_map(i);
680 if (intensity > m_mc_max) {
681 m_mc_max = intensity;
702 #if defined(G_DEBUG_MC_CACHE)
703 std::cout <<
"GModelSpatialDiffuseMap::mc_cone:" << std::endl;
704 std::cout <<
" Maximum map intensity:";
705 std::cout << m_mc_max <<
" ph/cm2/s/sr" << std::endl;
706 std::cout <<
" Spatially integrated flux:" << std::endl;
707 std::cout << sum <<
" ph/cm2/s" << std::endl;
708 std::cout <<
" Map normalisation:" << std::endl;
709 std::cout <<
m_mc_norm <<
" ph/cm2/s" << std::endl;
735 const GTime& srcTime)
const
760 result.append(
"=== GModelSpatialDiffuseMap ===");
768 result.append(
" [normalized]");
776 for (
int i = 0; i <
size(); ++i) {
937 for (
int i = 0; i < npix; ++i) {
951 for (
int i = 0; i < npix; ++i) {
virtual double eval(const GPhoton &photon, const bool &gradients=false) const
Return intensity of sky map.
bool m_normalize
Normalize map (default: true)
double dist_deg(const GSkyDir &dir) const
Compute angular distance between sky directions in degrees.
double flux(const int &index, const int &map=0) const
Returns flux in pixel.
bool normalize(void) const
Return normalization flag.
double m_mc_one_minus_cosrad
1-cosine of radius
virtual double mc_norm(const GSkyDir &dir, const double &radius) const
Return normalization of diffuse map for Monte Carlo simulations.
const double & factor_gradient(void) const
Return parameter factor gradient.
virtual void set_region(void) const
Set boundary sky region.
double norm(const GVector &vector)
Computes vector norm.
const std::string & name(void) const
Return parameter name.
void load(const GFilename &filename)
Load skymap into the model class.
double value(void) const
Get model value.
double gradient(void) const
Return parameter gradient.
int size(void) const
Return number of parameters.
void write(GXmlElement &xml) const
Set or update parameter attributes in XML element.
GVector cos(const GVector &vector)
Computes cosine of vector elements.
const GSkyMap & map(void) const
Get map.
virtual GModelSpatialDiffuseMap * clone(void) const
Clone spatial map model.
void prepare_map(void)
Prepare sky map after loading.
bool is_empty(void) const
Signal if filename is empty.
virtual void clear(void)
Clear spatial map model.
double sum(const GVector &vector)
Computes vector sum.
double acos(const double &arg)
Computes acos by avoiding NaN due to rounding errors.
Random number generator class.
double m_mc_max
Map maximum for MC.
Interface for the circular sky region class.
std::string print(const GChatter &chatter=NORMAL) const
Print sky direction information.
GFilename xml_file_reduce(const GXmlElement &xml, const std::string &filename)
Reduce file name provided for writing as XML attribute.
Interface definition for the spatial model registry class.
HealPix projection class definition.
bool is_free(void) const
Signal if parameter is free.
GSkyRegionCircle m_region
Bounding circle.
virtual void write(GXmlElement &xml) const
Write model into XML element.
GModelSpatialDiffuseMap(void)
Void constructor.
bool is_notanumber(const double &x)
Signal if argument is not a number.
const double & radius(void) const
Return circular region radius (in degrees)
Class that handles photons.
const double & scale(void) const
Return parameter scale.
bool is_infinite(const double &x)
Signal if argument is infinite.
double m_mc_norm
Map normalization.
void init_members(void)
Initialise class members.
const GModelSpatialDiffuseMap g_spatial_map_seed
GSkyDir pix2dir(const GSkyPixel &pixel) const
Returns sky direction of pixel.
bool has_grad(void) const
Signal if parameter gradient is computed analytically.
void init_members(void)
Initialise class members.
Abstract interface for the sky region class.
const GXmlAttribute * attribute(const int &index) const
Return attribute.
std::vector< GModelPar * > m_pars
Parameter pointers.
void rotate_deg(const double &phi, const double &theta)
Rotate sky direction by zenith and azimuth angle.
void fix(void)
Fix a parameter.
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.
virtual GSkyDir mc(const GEnergy &energy, const GTime &time, GRan &ran) const
Returns MC sky direction.
double uniform(void)
Returns random double precision floating value in range 0 to 1.
void clear(void)
Clear parameter.
Spatial model registry class definition.
const GFilename & filename(void) const
Get file name.
void clear(void)
Clear instance.
virtual GModelSpatialDiffuse & operator=(const GModelSpatialDiffuse &model)
Assignment operator.
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.
const GSkyRegionCircle & mc_cone(void) const
Get Monte Carlo simulation cone.
bool xml_has_par(const GXmlElement &xml, const std::string &name)
Checks if parameter with given name in XML element exists.
virtual ~GModelSpatialDiffuseMap(void)
Destructor.
GSkyRegionCircle region_circle(void) const
Return sky region circle that encloses the sky map.
void free_members(void)
Delete class members.
void free_members(void)
Delete class members.
const GSkyDir & centre(void) const
Return circular region centre.
void free_members(void)
Delete class members.
void clear(void)
Clear file name.
bool m_has_normalize
XML has normalize attribute.
std::string m_type
Spatial model type.
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.
Exception handler interface definition.
virtual double flux(const GSkyRegion ®ion, const GEnergy &srcEng=GEnergy(), const GTime &srcTime=GTime()) const
Returns diffuse map flux integrated in sky region.
std::string tolower(const std::string &s)
Convert string to lower case.
void init_members(void)
Initialise class members.
Abstract diffuse spatial model base class.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
void load(const GFilename &filename)
Load skymap from FITS file.
const int & npix(void) const
Returns number of pixels.
void copy_members(const GModelSpatialDiffuseMap &model)
Copy class members.
GFilename m_filename
Name of skymap.
virtual GModelSpatialDiffuseMap & operator=(const GModelSpatialDiffuseMap &model)
Assignment operator.
const GSkyDir & dir(void) const
Return photon sky direction.
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 read(const GXmlElement &xml)
Read model from XML element.
Spatial map model class interface definition.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print map information.
Mathematical function definitions.
void clear(void)
Clear instance.
Class that handles energies in a unit independent way.
virtual bool contains(const GSkyDir &dir, const double &margin=0.0) const
Signals whether model contains sky direction.
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.
GSkyRegionCircle m_mc_cone
MC cone.
void xml_check_type(const std::string &origin, GXmlElement &xml, const std::string &type)
Checks the model type.