Beispiel #1
0
    def create(fn,p0):

        # Construct a parameter set from inspection of the input function
        npar = len(inspect.getargspec(fn)[0])
        pset = ParameterSet()
        for i in range(npar): pset.createParameter(p0[i])
        return ParamFn(fn,pset)
Beispiel #2
0
    def create(norm,alpha,ecut,eb):

        pset = ParameterSet()
        pset.createParameter(np.log10(norm),'norm')
        pset.createParameter(alpha,'alpha')
        pset.createParameter(np.log10(ecut),'ecut')
        pset.createParameter(np.log10(eb),'eb')
        return PowerLawExp(pset)
Beispiel #3
0
    def create(norder,coeff=None,offset=0):

        pset = ParameterSet()
        if coeff is None: coeff = np.zeros(norder)
        for i in range(norder):
            pset.addParameter(Parameter(offset+i,coeff[i],'a%i'%i))

        return PolarPolyFn(pset)
Beispiel #4
0
    def create(norm,alpha,beta,eb):

        pset = ParameterSet()
        pset.createParameter(np.log10(norm),'norm')
        pset.createParameter(alpha,'alpha')
        pset.createParameter(beta,'beta')
        pset.createParameter(np.log10(eb),'eb')
        return LogParabola(pset)
Beispiel #5
0
    def create(norder,coeff=None,pset=None,name=None,prefix=''):

        if pset is None: pset = ParameterSet()
        if coeff is None: coeff = np.zeros(norder)

        pars = []
        for i in range(norder):
            p = pset.createParameter(coeff[i],prefix+'a%i'%i)
            pars.append(p)

        return PolyFn(ParameterSet(pars),name)
Beispiel #6
0
    def create(norm,gamma,eb,pset=None,name=None,prefix=''):

        if pset is None: pset = ParameterSet()
        p0 = pset.createParameter(np.log10(norm),prefix+'norm')
        p1 = pset.createParameter(gamma,prefix+'gamma')
        p2 = pset.createParameter(np.log10(eb),prefix+'eb')
        return PowerLaw(ParameterSet([p0,p1,p2]),name)
Beispiel #7
0
 def create(norm,mu,sigma,pset=None):
     
     if pset is None: pset = ParameterSet()
     p0 = pset.createParameter(norm,'norm')
     p1 = pset.createParameter(mu,'mu')
     p2 = pset.createParameter(sigma,'sigma')
     return GaussFn(ParameterSet([p0,p1,p2]))
Beispiel #8
0
 def create(norm,mux,muy,sigma,pset=None):
     
     if pset is None: pset = ParameterSet()
     p0 = pset.createParameter(norm,'norm')
     p1 = pset.createParameter(mux,'mux')
     p2 = pset.createParameter(muy,'muy')
     p3 = pset.createParameter(sigma,'sigma')
     return Gauss2DFn(ParameterSet([p0,p1,p2,p3]))
Beispiel #9
0
class ParamFnBase(object):
    """Base class for a parameterized function."""

    def __init__(self, param = None, name = None):

        if param is None: self._param = ParameterSet()
        else: self._param = param
        self._name = name

    @staticmethod
    def create(npar):

        fn = ParamFn()
        for i in range(npar):
            pass

    def setName(self,name):
        """Set the name of the function."""
        self._name = name

    def name(self):
        """Return the name of the function."""
        return self._name

    def npar(self):
        return self._param.npar()

    def param(self,make_copy=False):
        """Get the parameter set of this function.  If the optional input
        argument set is defined then return a copy of the model
        parameter set with values updated from this set."""

        if make_copy: return copy.deepcopy(self._param)
        else: return self._param

    def update(self,pset):
        """Update the parameters of this function."""
        self._param.update(pset)
Beispiel #10
0
 def create(norm,sigma,pset=None):
     
     if pset is None: pset = ParameterSet()
     p0 = pset.createParameter(norm,'norm')
     p1 = pset.createParameter(sigma,'sigma')
     return Gauss2DProjFn(ParameterSet([p0,p1]))
Beispiel #11
0
    def __init__(self, param = None, name = None):

        if param is None: self._param = ParameterSet()
        else: self._param = param
        self._name = name
Beispiel #12
0
    def create(h,norm=1.0,pset=None,name=None,prefix=''):

        if pset is None: pset = ParameterSet()
        p0 = pset.createParameter(norm,prefix + 'norm')
        return ScaledHistogramModel(h,ParameterSet([p0]),name)