gammapy/estimators/excess_map.py
def convolved_map_dataset_counts_statistics(dataset, kernel, mask, correlate_off):
    """Return CountsDataset objects containing smoothed maps from the MapDataset"""
    # Kernel is modified later make a copy here
    kernel = copy.deepcopy(kernel)
    kernel.normalize("peak")

    # fft convolution adds numerical noise, to ensure integer results we call
    # np.rint
    n_on = dataset.counts * mask
    n_on_conv = np.rint(n_on.convolve(kernel.array).data)

    if isinstance(dataset, MapDatasetOnOff):
        n_off = dataset.counts_off * mask
        npred_sig = dataset.npred_signal() * mask
        acceptance_on = dataset.acceptance * mask
        acceptance_off = dataset.acceptance_off * mask

        npred_sig_convolve = npred_sig.convolve(kernel.array)
        acceptance_on_convolve = acceptance_on.convolve(kernel.array)
        if correlate_off:
            n_off = n_off.convolve(kernel.array)
            acceptance_off = acceptance_off.convolve(kernel.array)

        with np.errstate(invalid="ignore", divide="ignore"):
            alpha = acceptance_on_convolve / acceptance_off

        return WStatCountsStatistic(
            n_on_conv.data, n_off.data, alpha.data, npred_sig_convolve.data
        )
    else:

        npred = dataset.npred() * mask
        background_conv = npred.convolve(kernel.array)
        return CashCountsStatistic(n_on_conv.data, background_conv.data)
Return CountsDataset objects containing smoothed maps from the MapDataset
Return CountsDataset objects containing smoothed maps from the MapDataset
Return CountsDataset objects containing smoothed maps from the MapDataset
def convolved_map_dataset_counts_statistics(dataset, kernel, mask, correlate_off):
    kernel = copy.deepcopy(kernel)
    kernel.normalize("peak")
    n_on = dataset.counts * mask
    n_on_conv = np.rint(n_on.convolve(kernel.array).data)
    if isinstance(dataset, MapDatasetOnOff):
        n_off = dataset.counts_off * mask
        npred_sig = dataset.npred_signal() * mask
        acceptance_on = dataset.acceptance * mask
        acceptance_off = dataset.acceptance_off * mask
        npred_sig_convolve = npred_sig.convolve(kernel.array)
        acceptance_on_convolve = acceptance_on.convolve(kernel.array)
        if correlate_off:
            n_off = n_off.convolve(kernel.array)
            acceptance_off = acceptance_off.convolve(kernel.array)
        with np.errstate(invalid="ignore", divide="ignore"):
            alpha = acceptance_on_convolve / acceptance_off
        return WStatCountsStatistic(
            n_on_conv.data, n_off.data, alpha.data, npred_sig_convolve.data
        )
    else:
        npred = dataset.npred() * mask
        background_conv = npred.convolve(kernel.array)
        return CashCountsStatistic(n_on_conv.data, background_conv.data)
def convolved_map_dataset_counts_statistics ( dataset , kernel , mask , correlate_off ) : kernel = copy . deepcopy ( kernel ) kernel . normalize ( "peak" ) n_on = dataset . counts * mask n_on_conv = np . rint ( n_on . convolve ( kernel . array ) . data ) if isinstance ( dataset , MapDatasetOnOff ) : n_off = dataset . counts_off * mask npred_sig = dataset . npred_signal ( ) * mask acceptance_on = dataset . acceptance * mask acceptance_off = dataset . acceptance_off * mask npred_sig_convolve = npred_sig . convolve ( kernel . array ) acceptance_on_convolve = acceptance_on . convolve ( kernel . array ) if correlate_off : n_off = n_off . convolve ( kernel . array ) acceptance_off = acceptance_off . convolve ( kernel . array ) with np . errstate ( invalid = "ignore" , divide = "ignore" ) : alpha = acceptance_on_convolve / acceptance_off return WStatCountsStatistic ( n_on_conv . data , n_off . data , alpha . data , npred_sig_convolve . data ) else : npred = dataset . npred ( ) * mask background_conv = npred . convolve ( kernel . array ) return CashCountsStatistic ( n_on_conv . data , background_conv . data )
Return CountsDataset objects containing smoothed maps from the MapDataset
Return CountsDataset objects containing smoothed maps from the MapDataset
"""Return CountsDataset objects containing smoothed maps from the MapDataset""" # Kernel is modified later make a copy here # fft convolution adds numerical noise, to ensure integer results we call # np.rint
dataset
kernel
mask
correlate_off