def __init__(self, params, chan='bb', jfactor=1E19, tablepath=None, dfactor=1E17):
        """Constructor.

        Parameters
        ----------
        params : list
            Parameter vector.

        chan : str
            Channel string.  Can be one of cc, bb, tt, tautau, ww, zz,
            mumu, gg, ee, ss, uu, dd, or any of the above with _decay appended.

        jfactor : float
            J-factor of this object.  Note that this needs to be given
            in the same units as the mass parameter.

        tablepath : str
            Path to lookup table with pre-computed DM spectra on a
            grid of energy, mass, and channel.

        dfactor : float
            D-factor of this object.  Note that this needs to be given
            in the same units as the mass parameter.

        """

        if tablepath is None:
            tablepath = os.path.join('$FERMIPY_DATA_DIR',
                                     'gammamc_dif.dat')
        data = np.loadtxt(os.path.expandvars(tablepath))

        # Number of decades in x = log10(E/M)
        ndec = 10.0
        xedge = np.linspace(0, 1.0, 251)
        self._x = 0.5 * (xedge[1:] + xedge[:-1]) * ndec - ndec

        chan_code = DMFitFunction.channel_rev_map[chan]
        ichan = DMFitFunction.channel_index_mapping[chan_code]
        self._chan = chan
        self._chan_code = chan_code

        # These are the mass points
        self._mass = np.array([2.0, 4.0, 6.0, 8.0, 10.0,
                               25.0, 50.0, 80.3, 91.2, 100.0,
                               150.0, 176.0, 200.0, 250.0, 350.0, 500.0, 750.0,
                               1000.0, 1500.0, 2000.0, 3000.0, 5000.0, 7000.0, 1E4])
        self._dndx = data.reshape((12, 24, 250))
        self._dndx_interp = RegularGridInterpolator([self._mass, self._x],
                                                    self._dndx[ichan, :, :],
                                                    bounds_error=False,
                                                    fill_value=None)
        extra_params = dict(dndx_interp=self._dndx_interp,
                            chan=chan_code,
                            jfactor=jfactor,
                            dfactor=dfactor)

        super(DMFitFunction, self).__init__(params, 1.0, extra_params)
def __init__ ( self , params , chan = 'bb' , jfactor = 1E19 , tablepath = None , dfactor = 1E17 ) : if tablepath is None : tablepath = os . path . join ( '$FERMIPY_DATA_DIR' , 'gammamc_dif.dat' ) data = np . loadtxt ( os . path . expandvars ( tablepath ) ) ndec = 10.0 xedge = np . linspace ( 0 , 1.0 , 251 ) self . _x = 0.5 * ( xedge [ 1 : ] + xedge [ : - 1 ] ) * ndec - ndec chan_code = DMFitFunction . channel_rev_map [ chan ] ichan = DMFitFunction . channel_index_mapping [ chan_code ] self . _chan = chan self . _chan_code = chan_code self . _mass = np . array ( [ 2.0 , 4.0 , 6.0 , 8.0 , 10.0 , 25.0 , 50.0 , 80.3 , 91.2 , 100.0 , 150.0 , 176.0 , 200.0 , 250.0 , 350.0 , 500.0 , 750.0 , 1000.0 , 1500.0 , 2000.0 , 3000.0 , 5000.0 , 7000.0 , 1E4 ] ) self . _dndx = data . reshape ( ( 12 , 24 , 250 ) ) self . _dndx_interp = RegularGridInterpolator ( [ self . _mass , self . _x ] , self . _dndx [ ichan , : , : ] , bounds_error = False , fill_value = None ) extra_params = dict ( dndx_interp = self . _dndx_interp , chan = chan_code , jfactor = jfactor , dfactor = dfactor ) super ( DMFitFunction , self ) . __init__ ( params , 1.0 , extra_params )
Constructor.

        Parameters
        ----------
        params : list
            Parameter vector.

        chan : str
            Channel string.  Can be one of cc, bb, tt, tautau, ww, zz,
            mumu, gg, ee, ss, uu, dd, or any of the above with _decay appended.

        jfactor : float
            J-factor of this object.  Note that this needs to be given
            in the same units as the mass parameter.

        tablepath : str
            Path to lookup table with pre-computed DM spectra on a
            grid of energy, mass, and channel.

        dfactor : float
            D-factor of this object.  Note that this needs to be given
            in the same units as the mass parameter.