gamma-astro-data-formats
gamma-astro-data-formats copied to clipboard
Comparison with astromodels
The format I am designing for astromodels to specify functions is very similar to what you are trying to achieve, so maybe we can try to converge. This is what I have:
powerlaw:
description :
A simple power-law with normalization expressed as
a logarithm
formula :
expression : 10**logK * (x / piv)**index
latex :
\frac{dN}{dx} = 10^{logK}~\frac{x}{piv}^{index}
parameters:
logK :
desc : Logarithm of normalization
initial value : 0
min : -40
max : 40
piv :
desc : Pivot energy
initial value : 1
fix : yes
index :
desc : Photon index
initial value : -2
min : -10
max : 10
powerlaw_flux:
description:
A simple power-law with the integral between two extremes as
normalization parameter
formula:
expression : 10**(logK) * (index + 1) * (x / piv)**index /
( xmin**(index+1) - xmax**(index+1) )
latex :
\frac{dN}{dx} = \frac{index + 1}{xmin^{index+1} - xmax^{index+1}}
10^{logK}~\frac{x}{piv}^{index}
parameters:
logK :
desc : Logarithm of normalization
initial value : 0
min : -40
max : 40
piv :
desc : Pivot energy
initial value : 1
fix : yes
index :
desc : Photon index
initial value : -2
min : -10
max : 10
xmin :
desc : Lower bound of integration
initial value : 1
xmax :
desc : Upper bound of integration
initial value : 10
This can easily be read from python as:
import yaml
with open("astromodels/functions/powerlaw.yaml","r") as f:
d = yaml.load(f)
print(d['powerlaw'])
'A simple power-law with normalization expressed as a logarithm'
print(d['powerlaw']['parameters']['index'])
{'max': 10, 'initial value': -2, 'desc': 'Photon index', 'min': -10}
Maybe we can analyze our respective trials and merge the good things about both in one format.