Example #1
0
    def stat_sum(self):
        """Total likelihood given the current model parameters."""
        counts, npred = self._counts_data, self.npred().data

        if self.mask is not None:
            return cash_sum_cython(counts[self.mask.data],
                                   npred[self.mask.data])
        else:
            return cash_sum_cython(counts.ravel(), npred.ravel())
Example #2
0
def f_cash(x, counts, background, model):
    """Wrapper for cash statistics, that defines the model function.

    Parameters
    ----------
    x : float
        Model amplitude.
    counts : `~numpy.ndarray`
        Count image slice, where model is defined.
    background : `~numpy.ndarray`
        Background image slice, where model is defined.
    model : `~numpy.ndarray`
        Source template (multiplied with exposure).
    """
    return cash_sum_cython(counts.ravel(),
                           (background + x * FLUX_FACTOR * model).ravel())
Example #3
0
def test_cash_sum_cython(test_data):
    counts = np.array(test_data["n_on"], dtype=float)
    npred = np.array(test_data["mu_sig"], dtype=float)
    stat = stats.cash_sum_cython(counts=counts, npred=npred)
    ref = stats.cash(counts, npred).sum()
    assert_allclose(stat, ref)
Example #4
0
 def stat_sum(self, norm):
     """Stat sum"""
     return cash_sum_cython(self.counts.ravel(), self.npred(norm).ravel())