diff --git a/ChangeLog b/ChangeLog
index c8fe995..cf3ec76 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,7 @@
* Version 1.1.0 released
=========================
+ Rename spatial model components (#1818)
Fix consistency problem in GCTABackground3D (#1815)
Models accessing file now support relative file names (#1808)
Add GXmlElement and GXmlDocument filename() methods (#1808)
diff --git a/NEWS b/NEWS
index 5e21137..ee2bf23 100644
--- a/NEWS
+++ b/NEWS
@@ -217,6 +217,22 @@ The GModelSpatialDiffuseMap, GModelSpatialDiffuseCube and GModelSpectralFunc
class now support the specifications of file names that are relative to the
XML file (#1808).
+The spatial model components have been renamed to enhance the readability and
+to make them more homogenous. The Fermi/LAT Science Tools should also evolve
+to support the new names:
+* "PointSource" (alias: "SkyDirFunction")
+* "RadialDisk" (alias: "DiskFunction")
+* "RadialGaussian" (alias: "GaussFunction")
+* "RadialShell" (alias: "ShellFunction")
+* "EllipticalDisk"
+* "EllipticalGaussian" (alias: "EllipticalGauss")
+* "DiffuseIsotropic" (alias: "ConstantValue")
+* "DiffuseMap" (alias: "SpatialMap")
+* "DiffuseMapCube" (alias: "MapCubeFunction")
+By default the old model names are still supported. Support of the old model
+names can be turned off by specifying the --disable-legacy-model-names option
+to the ./configure script (#1818).
+
9. Numerics module
------------------
diff --git a/configure.ac b/configure.ac
index e796c37..609a075 100644
--- a/configure.ac
+++ b/configure.ac
@@ -699,6 +699,23 @@ fi
#############################################################################
+# Checks for Legacy model names option (G_LEGACY_MODEL_NAMES) #
+#############################################################################
+AC_MSG_CHECKING(whether to enable legacy model names option)
+AC_ARG_ENABLE([legacy_model_names],
+ AS_HELP_STRING([--enable-legacy-model-names],
+ [enables legacy model names [default=yes]]),
+ [LEGACY_MODEL_NAMES="$enableval"],
+ [LEGACY_MODEL_NAMES="yes"])
+if test "x$LEGACY_MODEL_NAMES" = "xyes"; then
+ AC_DEFINE([G_LEGACY_MODEL_NAMES], [1], [Legacy model names are enabled])
+ AC_MSG_RESULT(yes)
+else
+ AC_MSG_RESULT(no)
+fi
+
+
+#############################################################################
# Checks for Warning option (G_WARNINGS) #
#############################################################################
AC_MSG_CHECKING(whether to enable console warnings)
@@ -1560,6 +1577,11 @@ if test "x$SMALL_MEMORY" = "xyes"; then
else
echo " - Optimize memory usage (no)"
fi
+if test "x$LEGACY_MODEL_NAMES" = "xyes"; then
+ echo " * Enable legacy model names (yes) (default)"
+else
+ echo " - Enable legacy model names (no)"
+fi
if test "x$enable_openmp" = "xyes"; then
echo " * Enable OpenMP (yes) (default)"
else
diff --git a/doc/source/users/user_manual/modules/model.rst b/doc/source/users/user_manual/modules/model.rst
index 7b8ffe0..ecc4687 100644
--- a/doc/source/users/user_manual/modules/model.rst
+++ b/doc/source/users/user_manual/modules/model.rst
@@ -114,7 +114,7 @@ Point source
.. code-block:: xml
-
+
@@ -129,7 +129,7 @@ Radial disk
.. code-block:: xml
-
+
@@ -145,7 +145,7 @@ Radial Gaussian
.. code-block:: xml
-
+
@@ -161,7 +161,7 @@ Radial shell
.. code-block:: xml
-
+
@@ -196,7 +196,7 @@ Elliptical Gaussian
.. code-block:: xml
-
+
@@ -214,7 +214,7 @@ Isotropic source
.. code-block:: xml
-
+
@@ -228,7 +228,7 @@ Diffuse map
.. code-block:: xml
-
+
@@ -242,7 +242,7 @@ Diffuse map cube
.. code-block:: xml
-
+
diff --git a/examples/cpp/readmodel.cpp b/examples/cpp/readmodel.cpp
index 732e821..3c6182b 100644
--- a/examples/cpp/readmodel.cpp
+++ b/examples/cpp/readmodel.cpp
@@ -56,7 +56,7 @@ void create_xml_file(void)
file << " \n";
file << " \n";
- file << " \n";
+ file << " \n";
file << " \n";
file << "
-
+
diff --git a/inst/cta/test/data/crab.xml b/inst/cta/test/data/crab.xml
index be48302..8b136bf 100644
--- a/inst/cta/test/data/crab.xml
+++ b/inst/cta/test/data/crab.xml
@@ -6,7 +6,7 @@
-
+
diff --git a/inst/cta/test/data/crab_disk.xml b/inst/cta/test/data/crab_disk.xml
index 0d2c05b..bf2d270 100644
--- a/inst/cta/test/data/crab_disk.xml
+++ b/inst/cta/test/data/crab_disk.xml
@@ -6,7 +6,7 @@
-
+
diff --git a/inst/cta/test/data/crab_eplaw.xml b/inst/cta/test/data/crab_eplaw.xml
index 0ec5710..8576983 100644
--- a/inst/cta/test/data/crab_eplaw.xml
+++ b/inst/cta/test/data/crab_eplaw.xml
@@ -7,7 +7,7 @@
-
+
diff --git a/inst/cta/test/data/crab_file_function.xml b/inst/cta/test/data/crab_file_function.xml
index dc05e10..3eaba1a 100644
--- a/inst/cta/test/data/crab_file_function.xml
+++ b/inst/cta/test/data/crab_file_function.xml
@@ -4,7 +4,7 @@
-
+
diff --git a/inst/cta/test/data/crab_file_function_mod.xml b/inst/cta/test/data/crab_file_function_mod.xml
index 5dfc2ba..0dba311 100644
--- a/inst/cta/test/data/crab_file_function_mod.xml
+++ b/inst/cta/test/data/crab_file_function_mod.xml
@@ -4,7 +4,7 @@
-
+
diff --git a/inst/cta/test/data/crab_gauss.xml b/inst/cta/test/data/crab_gauss.xml
index d93f3ed..446327e 100644
--- a/inst/cta/test/data/crab_gauss.xml
+++ b/inst/cta/test/data/crab_gauss.xml
@@ -6,7 +6,7 @@
-
+
diff --git a/inst/cta/test/data/crab_irf.xml b/inst/cta/test/data/crab_irf.xml
index b28e716..238cbaa 100644
--- a/inst/cta/test/data/crab_irf.xml
+++ b/inst/cta/test/data/crab_irf.xml
@@ -6,7 +6,7 @@
-
+
diff --git a/inst/cta/test/data/crab_poly.xml b/inst/cta/test/data/crab_poly.xml
index 81d3ea9..6d1b1f8 100644
--- a/inst/cta/test/data/crab_poly.xml
+++ b/inst/cta/test/data/crab_poly.xml
@@ -6,7 +6,7 @@
-
+
diff --git a/inst/cta/test/data/crab_profile.xml b/inst/cta/test/data/crab_profile.xml
index 38cbb8e..1ffa630 100644
--- a/inst/cta/test/data/crab_profile.xml
+++ b/inst/cta/test/data/crab_profile.xml
@@ -6,7 +6,7 @@
-
+
diff --git a/inst/cta/test/data/crab_ptsrc.xml b/inst/cta/test/data/crab_ptsrc.xml
index dd1014d..066242c 100644
--- a/inst/cta/test/data/crab_ptsrc.xml
+++ b/inst/cta/test/data/crab_ptsrc.xml
@@ -6,7 +6,7 @@
-
+
diff --git a/inst/cta/test/data/crab_shell.xml b/inst/cta/test/data/crab_shell.xml
index bd393b1..83716d0 100644
--- a/inst/cta/test/data/crab_shell.xml
+++ b/inst/cta/test/data/crab_shell.xml
@@ -6,7 +6,7 @@
-
+
diff --git a/inst/cta/test/data/onoff_model.xml b/inst/cta/test/data/onoff_model.xml
index a000e6f..38d32f9 100644
--- a/inst/cta/test/data/onoff_model.xml
+++ b/inst/cta/test/data/onoff_model.xml
@@ -6,7 +6,7 @@
-
+
diff --git a/inst/cta/test/data/radio.xml b/inst/cta/test/data/radio.xml
index de99543..295412f 100644
--- a/inst/cta/test/data/radio.xml
+++ b/inst/cta/test/data/radio.xml
@@ -6,7 +6,7 @@
-
+
diff --git a/inst/cta/test/data/rsp_models.xml b/inst/cta/test/data/rsp_models.xml
index c9e84ea..af3db6c 100644
--- a/inst/cta/test/data/rsp_models.xml
+++ b/inst/cta/test/data/rsp_models.xml
@@ -6,7 +6,7 @@
-
+
diff --git a/inst/cta/test/data/stacked_model.xml b/inst/cta/test/data/stacked_model.xml
index d1c6b9f..2889676 100644
--- a/inst/cta/test/data/stacked_model.xml
+++ b/inst/cta/test/data/stacked_model.xml
@@ -6,7 +6,7 @@
-
+
diff --git a/inst/lat/test/data/p6v3/source_model.xml b/inst/lat/test/data/p6v3/source_model.xml
index cd53cdb..6034cc4 100644
--- a/inst/lat/test/data/p6v3/source_model.xml
+++ b/inst/lat/test/data/p6v3/source_model.xml
@@ -3,7 +3,7 @@
-
+
@@ -11,7 +11,7 @@
-
+
@@ -22,7 +22,7 @@
-
+
diff --git a/inst/lat/test/data/p7v6/crab_model.xml b/inst/lat/test/data/p7v6/crab_model.xml
index 4ef655f..3d8af6b 100644
--- a/inst/lat/test/data/p7v6/crab_model.xml
+++ b/inst/lat/test/data/p7v6/crab_model.xml
@@ -3,7 +3,7 @@
-
+
@@ -11,7 +11,7 @@
-
+
@@ -22,7 +22,7 @@
-
+
diff --git a/inst/lat/test/data/p7v6/source_model.xml b/inst/lat/test/data/p7v6/source_model.xml
index 4ef655f..3d8af6b 100644
--- a/inst/lat/test/data/p7v6/source_model.xml
+++ b/inst/lat/test/data/p7v6/source_model.xml
@@ -3,7 +3,7 @@
-
+
@@ -11,7 +11,7 @@
-
+
@@ -22,7 +22,7 @@
-
+
diff --git a/inst/lat/test/data/p8v2/source_model.xml b/inst/lat/test/data/p8v2/source_model.xml
index 0c702d5..572b396 100644
--- a/inst/lat/test/data/p8v2/source_model.xml
+++ b/inst/lat/test/data/p8v2/source_model.xml
@@ -3,7 +3,7 @@
-
+
@@ -11,7 +11,7 @@
-
+
@@ -22,7 +22,7 @@
-
+
diff --git a/inst/mwl/test/data/crab.xml b/inst/mwl/test/data/crab.xml
index c43fa18..c0b57a7 100644
--- a/inst/mwl/test/data/crab.xml
+++ b/inst/mwl/test/data/crab.xml
@@ -6,7 +6,7 @@
-
+
diff --git a/inst/mwl/test/data/crab_mwl.xml b/inst/mwl/test/data/crab_mwl.xml
index c19c3df..268750d 100644
--- a/inst/mwl/test/data/crab_mwl.xml
+++ b/inst/mwl/test/data/crab_mwl.xml
@@ -6,7 +6,7 @@
-
+
@@ -17,7 +17,7 @@
-
+
diff --git a/inst/mwl/test/data/crab_mwl2.xml b/inst/mwl/test/data/crab_mwl2.xml
index 03c34e9..95c3b71 100644
--- a/inst/mwl/test/data/crab_mwl2.xml
+++ b/inst/mwl/test/data/crab_mwl2.xml
@@ -7,7 +7,7 @@
-
+
@@ -18,7 +18,7 @@
-
+
diff --git a/src/model/GModelSpatialDiffuseConst.cpp b/src/model/GModelSpatialDiffuseConst.cpp
index 0e1e7d3..a0373a0 100644
--- a/src/model/GModelSpatialDiffuseConst.cpp
+++ b/src/model/GModelSpatialDiffuseConst.cpp
@@ -410,7 +410,7 @@ double GModelSpatialDiffuseConst::mc_norm(const GSkyDir& dir,
* Read the isotropic source model information from an XML element. The XML
* element is expected to have the following format:
*
- *
+ *
*
*
*
@@ -442,7 +442,7 @@ void GModelSpatialDiffuseConst::read(const GXmlElement& xml)
* Write the isotropic source model information into an XML element. The XML
* element will have the following format:
*
- *
+ *
*
*
*
@@ -451,13 +451,13 @@ void GModelSpatialDiffuseConst::write(GXmlElement& xml) const
{
// Set model type
if (xml.attribute("type") == "") {
- xml.attribute("type", "ConstantValue");
+ xml.attribute("type", type());
}
// Verify model type
- if (xml.attribute("type") != "ConstantValue") {
+ if (xml.attribute("type") != type()) {
throw GException::model_invalid_spatial(G_WRITE, xml.attribute("type"),
- "Spatial model is not of type \"ConstantValue\".");
+ "Spatial model is not of type \""+type()+"\".");
}
// Get or create Value parameter
diff --git a/src/model/GModelSpatialDiffuseCube.cpp b/src/model/GModelSpatialDiffuseCube.cpp
index 65aeee9..a73abce 100644
--- a/src/model/GModelSpatialDiffuseCube.cpp
+++ b/src/model/GModelSpatialDiffuseCube.cpp
@@ -508,13 +508,13 @@ bool GModelSpatialDiffuseCube::contains(const GSkyDir& dir,
* Read the map cube information from an XML element. The XML element should
* have either the format
*
- *
+ *
*
*
*
* or alternatively
*
- *
+ *
*
*
*
@@ -568,13 +568,13 @@ void GModelSpatialDiffuseCube::read(const GXmlElement& xml)
* Write the map cube information into an XML element. The XML element will
* have either the format
*
- *
+ *
*
*
*
* or alternatively
*
- *
+ *
*
*
*
@@ -584,13 +584,13 @@ void GModelSpatialDiffuseCube::write(GXmlElement& xml) const
{
// Set model type
if (xml.attribute("type") == "") {
- xml.attribute("type", "MapCubeFunction");
+ xml.attribute("type", type());
}
// Verify model type
- if (xml.attribute("type") != "MapCubeFunction") {
+ if (xml.attribute("type") != type()) {
throw GException::model_invalid_spatial(G_WRITE, xml.attribute("type"),
- "Spatial model is not of type \"MapCubeFunction\".");
+ "Spatial model is not of type \""+type()+"\".");
}
// If XML element has 0 nodes then append parameter node. The name
diff --git a/src/model/GModelSpatialDiffuseMap.cpp b/src/model/GModelSpatialDiffuseMap.cpp
index 899d123..43726a1 100644
--- a/src/model/GModelSpatialDiffuseMap.cpp
+++ b/src/model/GModelSpatialDiffuseMap.cpp
@@ -487,13 +487,13 @@ bool GModelSpatialDiffuseMap::contains(const GSkyDir& dir,
* Reads the spatial information for a diffuse map from an XML element. The
* expected format of the XML element is
*
- *
+ *
*
*
*
* or
*
- *
+ *
*
*
*
@@ -563,7 +563,7 @@ void GModelSpatialDiffuseMap::read(const GXmlElement& xml)
* Writes the spatial information for a diffuse map into an XML element. The
* format of the XML element is
*
- *
+ *
*
*
*
@@ -580,19 +580,19 @@ void GModelSpatialDiffuseMap::write(GXmlElement& xml) const
{
// Set model type
if (xml.attribute("type") == "") {
- xml.attribute("type", "SpatialMap");
+ xml.attribute("type", type());
}
- // Set sky map file name
- //xml.attribute("file", m_filename);
- xml.attribute("file", gammalib::xml_file_reduce(xml, m_filename));
-
// Verify model type
- if (xml.attribute("type") != "SpatialMap") {
+ if (xml.attribute("type") != type()) {
throw GException::model_invalid_spatial(G_WRITE, xml.attribute("type"),
- "Spatial model is not of type \"SpatialMap\".");
+ "Spatial model is not of type \""+type()+"\".");
}
+ // Set sky map file name
+ //xml.attribute("file", m_filename);
+ xml.attribute("file", gammalib::xml_file_reduce(xml, m_filename));
+
// If XML element has 0 nodes then append parameter node. The name
// of the node is "Prefactor" as this is the Fermi/LAT standard.
// We thus assure that the XML files will be compatible with
diff --git a/src/model/GModelSpatialEllipticalDisk.cpp b/src/model/GModelSpatialEllipticalDisk.cpp
index e94e344..b009706 100644
--- a/src/model/GModelSpatialEllipticalDisk.cpp
+++ b/src/model/GModelSpatialEllipticalDisk.cpp
@@ -1,7 +1,7 @@
/***************************************************************************
* GModelSpatialEllipticalDisk.cpp - Elliptical disk source model class *
* ----------------------------------------------------------------------- *
- * copyright (C) 2013-2015 by Michael Mayer *
+ * copyright (C) 2013-2016 by Michael Mayer *
* ----------------------------------------------------------------------- *
* *
* This program is free software: you can redistribute it and/or modify *
@@ -455,7 +455,7 @@ double GModelSpatialEllipticalDisk::theta_max(void) const
* Reads the elliptical disk model information from an XML element. The XML
* element shall have either the format
*
- *
+ *
*
*
*
@@ -465,7 +465,7 @@ double GModelSpatialEllipticalDisk::theta_max(void) const
*
* or
*
- *
+ *
*
*
*
@@ -544,7 +544,7 @@ void GModelSpatialEllipticalDisk::read(const GXmlElement& xml)
* Write the elliptical disk model information into an XML element. The XML
* element will have the format
*
- *
+ *
*
*
*
diff --git a/src/model/GModelSpatialEllipticalGauss.cpp b/src/model/GModelSpatialEllipticalGauss.cpp
index f02757d..97096ee 100644
--- a/src/model/GModelSpatialEllipticalGauss.cpp
+++ b/src/model/GModelSpatialEllipticalGauss.cpp
@@ -1,7 +1,7 @@
/***************************************************************************
* GModelSpatialEllipticalGauss.cpp - Elliptical gauss source model class *
* ----------------------------------------------------------------------- *
- * copyright (C) 2015 by Michael Mayer *
+ * copyright (C) 2015-2016 by Michael Mayer *
* ----------------------------------------------------------------------- *
* *
* This program is free software: you can redistribute it and/or modify *
@@ -498,7 +498,7 @@ double GModelSpatialEllipticalGauss::theta_max(void) const
* Reads the elliptical gauss model information from an XML element. The XML
* element shall have either the format
*
- *
+ *
*
*
*
@@ -508,7 +508,7 @@ double GModelSpatialEllipticalGauss::theta_max(void) const
*
* or
*
- *
+ *
*
*
*
@@ -587,7 +587,7 @@ void GModelSpatialEllipticalGauss::read(const GXmlElement& xml)
* Write the elliptical gauss model information into an XML element. The XML
* element will have the format
*
- *
+ *
*
*
*
diff --git a/src/model/GModelSpatialPointSource.cpp b/src/model/GModelSpatialPointSource.cpp
index 212d9a6..8f96981 100644
--- a/src/model/GModelSpatialPointSource.cpp
+++ b/src/model/GModelSpatialPointSource.cpp
@@ -1,7 +1,7 @@
/***************************************************************************
* GModelSpatialPointSource.cpp - Spatial point source model class *
* ----------------------------------------------------------------------- *
- * copyright (C) 2009-2015 by Juergen Knoedlseder *
+ * copyright (C) 2009-2016 by Juergen Knoedlseder *
* ----------------------------------------------------------------------- *
* *
* This program is free software: you can redistribute it and/or modify *
@@ -341,14 +341,14 @@ bool GModelSpatialPointSource::contains(const GSkyDir& dir,
* Read the point source information from an XML element with the following
* format
*
- *
+ *
*
*
*
*
* or
*
- *
+ *
*
*
*
@@ -427,7 +427,7 @@ void GModelSpatialPointSource::read(const GXmlElement& xml)
* Write the point source information into an XML element with the following
* format
*
- *
+ *
*
*
*
diff --git a/src/model/GModelSpatialRadialDisk.cpp b/src/model/GModelSpatialRadialDisk.cpp
index 6caac53..c119ab1 100644
--- a/src/model/GModelSpatialRadialDisk.cpp
+++ b/src/model/GModelSpatialRadialDisk.cpp
@@ -1,7 +1,7 @@
/***************************************************************************
* GModelSpatialRadialDisk.cpp - Radial disk source model class *
* ----------------------------------------------------------------------- *
- * copyright (C) 2011-2015 by Christoph Deil *
+ * copyright (C) 2011-2016 by Christoph Deil *
* ----------------------------------------------------------------------- *
* *
* This program is free software: you can redistribute it and/or modify *
@@ -378,7 +378,7 @@ double GModelSpatialRadialDisk::theta_max(void) const
* Reads the radial disk model information from an XML element. The XML
* element shall have either the format
*
- *
+ *
*
*
*
@@ -386,7 +386,7 @@ double GModelSpatialRadialDisk::theta_max(void) const
*
* or
*
- *
+ *
*
*
*
@@ -454,7 +454,7 @@ void GModelSpatialRadialDisk::read(const GXmlElement& xml)
* Writes the radial disk model information into an XML element. The XML
* element will have the format
*
- *
+ *
*
*
*
diff --git a/src/model/GModelSpatialRadialGauss.cpp b/src/model/GModelSpatialRadialGauss.cpp
index 4188a08..2ee7351 100644
--- a/src/model/GModelSpatialRadialGauss.cpp
+++ b/src/model/GModelSpatialRadialGauss.cpp
@@ -1,7 +1,7 @@
/***************************************************************************
* GModelSpatialRadialGauss.cpp - Radial Gaussian source model class *
* ----------------------------------------------------------------------- *
- * copyright (C) 2011-2015 by Juergen Knoedlseder *
+ * copyright (C) 2011-2016 by Juergen Knoedlseder *
* ----------------------------------------------------------------------- *
* *
* This program is free software: you can redistribute it and/or modify *
@@ -371,7 +371,7 @@ double GModelSpatialRadialGauss::theta_max(void) const
* Reads the radial Gauss model information from an XML element. The XML
* element shall have either the format
*
- *
+ *
*
*
*
@@ -379,7 +379,7 @@ double GModelSpatialRadialGauss::theta_max(void) const
*
* or
*
- *
+ *
*
*
*
@@ -449,7 +449,7 @@ void GModelSpatialRadialGauss::read(const GXmlElement& xml)
* Writes the radial disk model information into an XML element. The XML
* element will have the format
*
- *
+ *
*
*
*
diff --git a/src/model/GModelSpatialRadialShell.cpp b/src/model/GModelSpatialRadialShell.cpp
index e934527..df97f06 100644
--- a/src/model/GModelSpatialRadialShell.cpp
+++ b/src/model/GModelSpatialRadialShell.cpp
@@ -1,7 +1,7 @@
/***************************************************************************
* GModelSpatialRadialShell.cpp - Radial shell source model class *
* ----------------------------------------------------------------------- *
- * copyright (C) 2011-2015 by Christoph Deil *
+ * copyright (C) 2011-2016 by Christoph Deil *
* ----------------------------------------------------------------------- *
* *
* This program is free software: you can redistribute it and/or modify *
@@ -417,7 +417,7 @@ double GModelSpatialRadialShell::theta_max(void) const
* Reads the radial shell model information from an XML element. The XML
* element shall have either the format
*
- *
+ *
*
*
*
@@ -426,7 +426,7 @@ double GModelSpatialRadialShell::theta_max(void) const
*
* or
*
- *
+ *
*
*
*
@@ -513,7 +513,7 @@ void GModelSpatialRadialShell::read(const GXmlElement& xml)
* Writes the radial shell model information into an XML element. The XML
* element will have the format
*
- *
+ *
*
*
*
diff --git a/src/model/GModelSpatialRegistry.cpp b/src/model/GModelSpatialRegistry.cpp
index ec548e8..28d1859 100644
--- a/src/model/GModelSpatialRegistry.cpp
+++ b/src/model/GModelSpatialRegistry.cpp
@@ -1,7 +1,7 @@
/***************************************************************************
* GModelSpatialRegistry.cpp - Spatial model registry class *
* ----------------------------------------------------------------------- *
- * copyright (C) 2011-2013 by Juergen Knoedlseder *
+ * copyright (C) 2011-2016 by Juergen Knoedlseder *
* ----------------------------------------------------------------------- *
* *
* This program is free software: you can redistribute it and/or modify *
@@ -40,7 +40,7 @@
/* __ Coding definitions _________________________________________________ */
/* __ Debug definitions __________________________________________________ */
-#define G_DEBUG_REGISTRY 0
+//#define G_DEBUG_REGISTRY //!< Dump registry
/*==========================================================================
@@ -58,7 +58,7 @@ GModelSpatialRegistry::GModelSpatialRegistry(void)
init_members();
// Debug option: Show actual registry
- #if G_DEBUG_REGISTRY
+ #if defined(G_DEBUG_REGISTRY)
std::cout << "GModelSpatialRegistry(void): ";
for (int i = 0; i < size(); ++i) {
std::cout << "\"" << names()[i] << "\" ";
@@ -85,14 +85,19 @@ GModelSpatialRegistry::GModelSpatialRegistry(const GModelSpatial* model)
init_members();
// Debug option: Notify new registry
- #if G_DEBUG_REGISTRY
+ #if defined(G_DEBUG_REGISTRY)
std::cout << "GModelSpatialRegistry(const GModelSpatial*): ";
std::cout << "add \"" << model->type() << "\" to registry." << std::endl;
#endif
// Allocate new registry
+ #if defined(G_LEGACY_MODEL_NAMES)
+ std::string* new_names = new std::string[size()+2];
+ const GModelSpatial** new_models = new const GModelSpatial*[size()+2];
+ #else
std::string* new_names = new std::string[size()+1];
const GModelSpatial** new_models = new const GModelSpatial*[size()+1];
+ #endif
// Save old registry
for (int i = 0; i < size(); ++i) {
@@ -104,15 +109,24 @@ GModelSpatialRegistry::GModelSpatialRegistry(const GModelSpatial* model)
new_names[size()] = model->type();
new_models[size()] = model;
+ // Add new model with alias to registry for legacy naming convention
+ #if defined(G_LEGACY_MODEL_NAMES)
+ new_names[size()+1] = model->alias();
+ new_models[size()+1] = model;
+ #endif
+
// Set pointers on new registry
names().assign(new_names);
models().assign(new_models);
// Increment number of models in registry
+ #if defined(G_LEGACY_MODEL_NAMES)
+ number()++;
+ #endif
number()++;
// Debug option: Show actual registry
- #if G_DEBUG_REGISTRY
+ #if defined(G_DEBUG_REGISTRY)
std::cout << "GModelSpatialRegistry(const GModelSpatial*): ";
for (int i = 0; i < size(); ++i) {
std::cout << "\"" << names()[i] << "\" ";
diff --git a/test/data/crab.xml b/test/data/crab.xml
index 77953ce..30d79d6 100644
--- a/test/data/crab.xml
+++ b/test/data/crab.xml
@@ -6,7 +6,7 @@
-
+
diff --git a/test/data/model_diffuse_const.xml b/test/data/model_diffuse_const.xml
index e4f4653..e610701 100644
--- a/test/data/model_diffuse_const.xml
+++ b/test/data/model_diffuse_const.xml
@@ -6,7 +6,7 @@
-
+
diff --git a/test/data/model_diffuse_cube.xml b/test/data/model_diffuse_cube.xml
index 81801d7..49edd23 100644
--- a/test/data/model_diffuse_cube.xml
+++ b/test/data/model_diffuse_cube.xml
@@ -4,7 +4,7 @@
-
+
diff --git a/test/data/model_diffuse_map.xml b/test/data/model_diffuse_map.xml
index c9e84ea..af3db6c 100644
--- a/test/data/model_diffuse_map.xml
+++ b/test/data/model_diffuse_map.xml
@@ -6,7 +6,7 @@
-
+
diff --git a/test/data/model_elliptical_gauss.xml b/test/data/model_elliptical_gauss.xml
index bcc0a80..54ecb44 100644
--- a/test/data/model_elliptical_gauss.xml
+++ b/test/data/model_elliptical_gauss.xml
@@ -6,7 +6,7 @@
-
+
diff --git a/test/data/model_point_bplaw.xml b/test/data/model_point_bplaw.xml
index ae87b40..6c9786f 100644
--- a/test/data/model_point_bplaw.xml
+++ b/test/data/model_point_bplaw.xml
@@ -7,7 +7,7 @@
-
+
diff --git a/test/data/model_point_const.xml b/test/data/model_point_const.xml
index ce7b557..4db7305 100644
--- a/test/data/model_point_const.xml
+++ b/test/data/model_point_const.xml
@@ -4,7 +4,7 @@
-
+
diff --git a/test/data/model_point_eplaw.xml b/test/data/model_point_eplaw.xml
index 0a1c237..a087ed1 100644
--- a/test/data/model_point_eplaw.xml
+++ b/test/data/model_point_eplaw.xml
@@ -7,7 +7,7 @@
-
+
diff --git a/test/data/model_point_filefct.xml b/test/data/model_point_filefct.xml
index f96a3d5..dfd69ce 100644
--- a/test/data/model_point_filefct.xml
+++ b/test/data/model_point_filefct.xml
@@ -4,7 +4,7 @@
-
+
diff --git a/test/data/model_point_gauss.xml b/test/data/model_point_gauss.xml
index b93d4d0..7b4ba3e 100644
--- a/test/data/model_point_gauss.xml
+++ b/test/data/model_point_gauss.xml
@@ -6,7 +6,7 @@
-
+
diff --git a/test/data/model_point_logparabola.xml b/test/data/model_point_logparabola.xml
index 877328e..3ffb995 100644
--- a/test/data/model_point_logparabola.xml
+++ b/test/data/model_point_logparabola.xml
@@ -7,7 +7,7 @@
-
+
diff --git a/test/data/model_point_nodes.xml b/test/data/model_point_nodes.xml
index 44588f0..72f5492 100644
--- a/test/data/model_point_nodes.xml
+++ b/test/data/model_point_nodes.xml
@@ -11,7 +11,7 @@
-
+
diff --git a/test/data/model_point_plaw.xml b/test/data/model_point_plaw.xml
index 33cd942..64e227d 100644
--- a/test/data/model_point_plaw.xml
+++ b/test/data/model_point_plaw.xml
@@ -6,7 +6,7 @@
-
+
diff --git a/test/data/model_point_plaw2.xml b/test/data/model_point_plaw2.xml
index b744d4a..5fade16 100644
--- a/test/data/model_point_plaw2.xml
+++ b/test/data/model_point_plaw2.xml
@@ -7,7 +7,7 @@
-
+
diff --git a/test/data/model_point_supeplaw.xml b/test/data/model_point_supeplaw.xml
index f87f610..4fc6d3e 100644
--- a/test/data/model_point_supeplaw.xml
+++ b/test/data/model_point_supeplaw.xml
@@ -8,7 +8,7 @@
-
+
diff --git a/test/data/model_radial_disk.xml b/test/data/model_radial_disk.xml
index 0f8346c..7b622bb 100644
--- a/test/data/model_radial_disk.xml
+++ b/test/data/model_radial_disk.xml
@@ -6,7 +6,7 @@
-
+
diff --git a/test/data/model_radial_gauss.xml b/test/data/model_radial_gauss.xml
index 7de828f..1c6d39d 100644
--- a/test/data/model_radial_gauss.xml
+++ b/test/data/model_radial_gauss.xml
@@ -6,7 +6,7 @@
-
+
diff --git a/test/data/model_radial_shell.xml b/test/data/model_radial_shell.xml
index c842f67..00b7a6c 100644
--- a/test/data/model_radial_shell.xml
+++ b/test/data/model_radial_shell.xml
@@ -6,7 +6,7 @@
-
+
diff --git a/test/data/test.xml b/test/data/test.xml
index 04b6d0f..627d842 100644
--- a/test/data/test.xml
+++ b/test/data/test.xml
@@ -10,7 +10,7 @@
-
+
diff --git a/test/test_GModel.cpp b/test/test_GModel.cpp
index 088178e..00ad6e1 100644
--- a/test/test_GModel.cpp
+++ b/test/test_GModel.cpp
@@ -531,8 +531,8 @@ void TestGModel::test_point_source(void)
test_try("Test void constructor");
try {
GModelSpatialPointSource model;
- test_assert(model.type() == "SkyDirFunction",
- "Model type \"SkyDirFunction\" expected.");
+ test_assert(model.type() == "PointSource",
+ "Model type \"PointSource\" expected.");
test_try_success();
}
catch (std::exception &e) {
@@ -573,7 +573,7 @@ void TestGModel::test_point_source(void)
GXmlElement* element = xml.element(0)->element(0)->element("spatialModel", 0);
GModelSpatialPointSource model(*element);
test_value(model.size(), 2);
- test_assert(model.type() == "SkyDirFunction", "Expected \"SkyDirFunction\"");
+ test_assert(model.type() == "PointSource", "Expected \"PointSource\"");
test_value(model.ra(), 83.6331);
test_value(model.dec(), +22.0145);
@@ -618,8 +618,8 @@ void TestGModel::test_diffuse_const(void)
test_try("Test void constructor");
try {
GModelSpatialDiffuseConst model;
- test_assert(model.type() == "ConstantValue",
- "Model type \"ConstantValue\" expected.");
+ test_assert(model.type() == "DiffuseIsotropic",
+ "Model type \"DiffuseIsotropic\" expected.");
test_try_success();
}
catch (std::exception &e) {
@@ -645,7 +645,8 @@ void TestGModel::test_diffuse_const(void)
GXmlElement* element = xml.element(0)->element(0)->element("spatialModel", 0);
GModelSpatialDiffuseConst model(*element);
test_value(model.size(), 1);
- test_assert(model.type() == "ConstantValue", "Expected \"ConstantValue\"");
+ test_assert(model.type() == "DiffuseIsotropic",
+ "Expected \"DiffuseIsotropic\"");
test_value(model.value(), 1.0);
// Test value method
@@ -684,8 +685,8 @@ void TestGModel::test_diffuse_cube(void)
test_try("Test void constructor");
try {
GModelSpatialDiffuseCube model;
- test_assert(model.type() == "MapCubeFunction",
- "Model type \"MapCubeFunction\" expected.");
+ test_assert(model.type() == "DiffuseMapCube",
+ "Model type \"DiffuseMapCube\" expected.");
test_assert(model.filename().url() == "", "Model filename \"\" expected.");
test_try_success();
}
@@ -732,7 +733,8 @@ void TestGModel::test_diffuse_cube(void)
GXmlElement* element = xml.element(0)->element(0)->element("spatialModel", 0);
GModelSpatialDiffuseCube model(*element);
test_value(model.size(), 1);
- test_assert(model.type() == "MapCubeFunction", "Expected \"MapCubeFunction\"");
+ test_assert(model.type() == "DiffuseMapCube",
+ "Expected \"DiffuseMapCube\"");
test_value(model.value(), 1.0);
test_assert(model.filename().url() == m_cube_file,
"Model filename \""+m_cube_file+"\" expected.");
@@ -780,8 +782,8 @@ void TestGModel::test_diffuse_map(void)
{
// Test void constructor
GModelSpatialDiffuseMap model1;
- test_assert(model1.type() == "SpatialMap",
- "Check that model is of type \"SpatialMap\".");
+ test_assert(model1.type() == "DiffuseMap",
+ "Check that model is of type \"DiffuseMap\".");
test_assert(model1.filename().url() == "",
"Check that model has empty filename.");
@@ -806,9 +808,9 @@ void TestGModel::test_diffuse_map(void)
GModelSpatialDiffuseMap model(*elementp);
test_value(model.size(), 1,
"Check that model build from an XML element has one parameter.");
- test_assert(model.type() == "SpatialMap",
+ test_assert(model.type() == "DiffuseMap",
"Check that model build from an XML element is of type "
- "\"SpatialMap\".");
+ "\"DiffuseMap\".");
test_value(model.value(), 1.0,
"Check that normalisation of model build from an XML element is "
"unity.");
@@ -888,8 +890,8 @@ void TestGModel::test_radial_disk(void)
test_try("Test void constructor");
try {
GModelSpatialRadialDisk model;
- test_assert(model.type() == "DiskFunction",
- "Model type \"DiskFunction\" expected.");
+ test_assert(model.type() == "RadialDisk",
+ "Model type \"RadialDisk\" expected.");
test_try_success();
}
catch (std::exception &e) {
@@ -919,7 +921,7 @@ void TestGModel::test_radial_disk(void)
GXmlElement* element = xml.element(0)->element(0)->element("spatialModel", 0);
GModelSpatialRadialDisk model(*element);
test_value(model.size(), 3);
- test_assert(model.type() == "DiskFunction", "Expected \"DiskFunction\"");
+ test_assert(model.type() == "RadialDisk", "Expected \"RadialDisk\"");
test_value(model.ra(), 83.6331);
test_value(model.dec(), 22.0145);
test_value(model.radius(), 0.45);
@@ -975,8 +977,8 @@ void TestGModel::test_radial_gauss(void)
test_try("Test void constructor");
try {
GModelSpatialRadialGauss model;
- test_assert(model.type() == "GaussFunction",
- "Model type \"GaussFunction\" expected.");
+ test_assert(model.type() == "RadialGaussian",
+ "Model type \"RadialGaussian\" expected.");
test_try_success();
}
catch (std::exception &e) {
@@ -1006,7 +1008,8 @@ void TestGModel::test_radial_gauss(void)
GXmlElement* element = xml.element(0)->element(0)->element("spatialModel", 0);
GModelSpatialRadialGauss model(*element);
test_value(model.size(), 3);
- test_assert(model.type() == "GaussFunction", "Expected \"GaussFunction\"");
+ test_assert(model.type() == "RadialGaussian",
+ "Expected \"RadialGaussian\"");
test_value(model.ra(), 83.6331);
test_value(model.dec(), 22.0145);
test_value(model.sigma(), 0.20);
@@ -1062,8 +1065,8 @@ void TestGModel::test_radial_shell(void)
test_try("Test void constructor");
try {
GModelSpatialRadialShell model;
- test_assert(model.type() == "ShellFunction",
- "Model type \"ShellFunction\" expected.");
+ test_assert(model.type() == "RadialShell",
+ "Model type \"RadialShell\" expected.");
test_try_success();
}
catch (std::exception &e) {
@@ -1094,7 +1097,7 @@ void TestGModel::test_radial_shell(void)
GXmlElement* element = xml.element(0)->element(0)->element("spatialModel", 0);
GModelSpatialRadialShell model(*element);
test_value(model.size(), 4);
- test_assert(model.type() == "ShellFunction", "Expected \"ShellFunction\"");
+ test_assert(model.type() == "RadialShell", "Expected \"RadialShell\"");
test_value(model.ra(), 83.6331);
test_value(model.dec(), 22.0145);
test_value(model.radius(), 0.30);
@@ -1253,8 +1256,8 @@ void TestGModel::test_elliptical_gauss(void)
test_try("Test void constructor");
try {
GModelSpatialEllipticalGauss model;
- test_assert(model.type() == "EllipticalGauss",
- "Model type \"EllipticalGauss\" expected.");
+ test_assert(model.type() == "EllipticalGaussian",
+ "Model type \"EllipticalGaussian\" expected.");
test_try_success();
}
catch (std::exception &e) {
@@ -1286,7 +1289,8 @@ void TestGModel::test_elliptical_gauss(void)
GXmlElement* element = xml.element(0)->element(0)->element("spatialModel", 0);
GModelSpatialEllipticalGauss model(*element);
test_value(model.size(), 5);
- test_assert(model.type() == "EllipticalGauss", "Expected \"EllipticalGauss\"");
+ test_assert(model.type() == "EllipticalGaussian",
+ "Expected \"EllipticalGaussian\"");
test_value(model.ra(), 83.6331);
test_value(model.dec(), 22.0145);
test_value(model.posangle(), 45.0);
@@ -2633,13 +2637,22 @@ void TestGModel::test_model_registry(void)
int num = registry.size();
for (int i = 0; i < num; ++i) {
GModelSpatial* ptr = registry.alloc(registry.name(i));
- test_assert(ptr != NULL, "Model pointer for \""+ registry.name(i)+"\" is NULL");
+ test_assert(ptr != NULL,
+ "Model pointer for \""+ registry.name(i)+"\" is NULL");
if (ptr != NULL) {
// Test model type
- test_assert(ptr->type() == registry.name(i),
+ #if defined(G_LEGACY_MODEL_NAMES)
+ test_assert((ptr->type() == registry.name(i)) ||
+ (ptr->alias() == registry.name(i)),
+ "Expected \""+registry.name(i)+"\" instead"
+ " of \""+ptr->type()+"\" or \""+
+ ptr->alias()+"\".");
+ #else
+ test_assert(ptr->type() == registry.name(i),
"Expected \""+registry.name(i)+"\" instead"
" of \""+ptr->type()+"\".");
+ #endif
// Free model
delete ptr;