Open jknodlseder opened 8 years ago
@jknodlseder - Thank you for taking the initiative on this!
This doesn't just affect Gammalib and the Fermi ST as mentioned in the title and description, but also Gammapy and pointlike and 3ML and maybe Naima and Gamera as astro modeling codes and other science tool codes that have a use for model specification or serialisation.
So @woodmd @zblz @joleroi @adonath @registerrier @giacomov @tburnett -- please comment here!
@taldcroft - With the Astropy / Sherpa bridge, is there interest on a shared model specification / serialisation spec like this one or are there even plans to develop a more general one?
Here's some first thoughts from me:
My guess is that we'll end up adopting almost exactly what is proposed now, because it's a small refinement / cleanup of something that's already proven and widely used.
Does anyone think we should try to extend the format in a significant way (e.g. multiplicative models or linked parameters)?
Or should we just put this in basically as proposed now?
While I agree that it would be good to adhere to the same XML format between the Fermi ST and other software, in the long run I'd rather move to something more user-friendly and up to date than XML.
As far as XML is concerned, the proposed extension looks good, but I don't think it is possible at this stage to change anything which would break backward compatibility with the already existing XML files for the Fermi ST.
For the future, my preference would be for YAML or JSON, which are the formats we were already talking about here:
https://github.com/open-gamma-ray-astro/gamma-astro-data-formats/issues/1
For 3ML/astromodels I adopted YAML (but moving to JSON would be immediate. Everything is a dictionary so it just a matter of changing the library to call to serialize and de-serialize).
The reason I am implementing a new format is that I need something that goes well beyond what is currently possible with the XML defined for the Fermi ST: links among parameters, physical units, time-varying parameters and so on.
An example of the YAML format I'm using (which is still in development, and it is inspired by what came out from the workshop in Heidelberg) can be found here:
https://gist.github.com/giacomov/4484a43e290520cf5020e64c91eec9ab
A more elaborated example, using a Naima model with parameters depending on time, can be found here:
https://gist.github.com/giacomov/a068c4521cb72d922a6919ab87bb118f
Everything is of "pure types" (int, float, strings) so the same file can be read by a software which has a different class structure than astromodels. Also, the format is very much inspired by the python mantra "explicit is better than implicit", so that it should be easy to interpret just by reading it.
I know that there are other discussions on these things, so please tell me if I should post these details in other places instead of this one. I confess that I am a bit lost with all these repositories...
For complementary information:
GammaLib uses in fact an extension of the Fermi/LAT format that is covering some of the use cases you just described @giacomov. For time variable models, a third block is added to a source
block in the XML format
<temporalModel type="Constant">
<parameter name="Normalization" scale="1.0" value="1.0" min="0.1" max="10.0" free="0"/>
</temporalModel>
(see http://cta.irap.omp.eu/gammalib/user_manual/modules/model.html#sky-models for a complete description of the model types). I have not checked though whether the Fermi/LAT Science Tools simply ignore these extensions, or whether they stop with an error. If the temporal extension is not given in GammaLib, a constant model will be assumed by the software.
Another functionality is the addition of instrument
and id
attributes that allow linking of model components to specific observations, see http://cta.irap.omp.eu/ctools/user_manual/getting_started/beyond_combine.html, http://cta.irap.omp.eu/ctools/user_manual/getting_started/beyond_irf.html and http://cta.irap.omp.eu/ctools/user_manual/getting_started/beyond_model.html.
Linking of parameters is foreseen in a similar logic, but not yet implemented. I also had though a couple of years ago about how to implement parameter functions in the XML format (see https://cta-redmine.irap.omp.eu/projects/gammalib/wiki/GModel) but have this not pushed forward either.
Just some quick comments related to the discussion so far:
a * (b + c * (d - a))
with linked parameters. This could be done by defining a list of model components and then separately a model expression, or it can be done like Sherpa does internally by using a nested tree structure with binary operator model components.source_1 (point source):
. I would recommend against encapsulating multiple pieces of information (source identifier and spatial model) into a string expression that needs to be parsed. Just use additional keys within the source
structure.OK, so there's concerns about this XML model spec format and ideas to make better model spec formats. Personally I agree that YAML would be nicer both as a serialisation and end-user format and I would have more comments e.g. on model parametrisation before this goes in. But others will have gripes with YAML and whatever scheme someone comes up with ("too complex", "doesn't support my use case", "doesn't use the model parametrisation I want").
How should we proceed?
A) Continue discussing and prototyping for another year? B) Allow this XML model spec to go in with some review, with a statement at the top that it's only one proposed solution and it's not agreed on yet by the community as the one way true model spec format.
I prefer B, and encourage others to propose alternative specs. Sure, multiple specs for roughly the same thing are bad. But progress requires someone writing down the proposals in detail and then an analysis of pros and cons, and I don't think A will yield good progress.
@jknodlseder - I have some questions for you:
There's a thread on this on the ctools mailing list today.
@jknodlseder Is it possible to make the ctools mailing list archives public so that we can link to this?
The GammaLib software implements so far the XML format that has been defined for the Fermi/LAT Science Tools (ST) for model definition. GammaLib has several additional spatial model components, and the XML format has been extended to cover also these cases. More spatial models are now also added to the Fermi/LAT Science Tools, hence to keep compatibility between GammaLib and Fermi/LAT Science Tools it would be important to agree now on a common naming convention. This could also be the moment to change some of the initial naming conventions so that model components have a more coherent set of names. It is proposed that the Fermi/LAT Science Tools and GammaLib softwares will implement some proxies to ease the transition from the old to the new format, but ultimately, only the new format should be used in the future for model definition.
The discussion on this has started on Fermi/LAT confluence and in an e-mail thread, here just the summary of what is proposed so far.
The proposal is to change the
type
attributes of thespatialModel
elements in the XML file (see an example XML file below). The following types are proposed:PointSource
as replacement ofSkyDirFunction
in ST and GammaLibRadialDisk
as replacement forSpatialDisk
in ST andDiskFunction
in GammaLibRadialGaussian
as replacement forSpatialGaussian
in ST andGaussFunction
in GammaLibRadialShell
as replacement forShellFunction
in GammaLibEllipticalDisk
stays as is in GammaLibEllipticalGaussian
as replacement forEllipticalGauss
in GammaLibEllipticalShell
if needed in the futureDiffuseIsotropic
as replacement forConstantValue
in ST and GammaLibDiffuseMap
as replacement forSpatialMap
in ST and GammaLibDiffuseMapCube
as replacement forMapCubeFunction
in ST and GammaLibIn addition, the
type
attributes of thesource
elements in the XML file are proposed to be defined as follows:PointSource
for point sources (as is)ExtendedSource
for all radial and elliptical models (isDiffuseSource
in ST)DiffuseSource
for all diffuse models (as is)Below for illustration of the
type
attributes and thesource
andspatialModel
elements an XML of the current XML file format: