Exemplo n.º 1
0
def run_cwt(data):
    cwt = CWT(nscales=2, min_scale=6.0, scale_step=1.3)
    data['background'] = 1. * np.ones_like(data['background'], dtype=float)
    cwt.set_data(data['image'], data['background'])

    # TODO: run one step, try to understand what it does
    # cwt.run_one_iteration(nsigma=100, nsigmap=4.0)

    cwt.run_iteratively(nsigma=100, niter=5)
    return cwt
Exemplo n.º 2
0
    def setup(self):
        filename = "$GAMMAPY_DATA/tests/unbundled/poisson_stats_image/counts.fits.gz"
        image = Map.read(filename)
        background = image.copy(data=np.ones(image.data.shape, dtype=float))

        self.kernels = CWTKernels(n_scale=2,
                                  min_scale=3.0,
                                  step_scale=2.6,
                                  old=False)
        self.data = dict(image=image, background=background)
        self.cwt = CWT(kernels=self.kernels,
                       significance_threshold=2.0,
                       keep_history=True)
Exemplo n.º 3
0
def run_cwt():
    data = make_poisson_data()

    cwt_kernels = CWTKernels(n_scale=2,
                             min_scale=3.0,
                             step_scale=2.6,
                             old=False)
    cwt = CWT(kernels=cwt_kernels,
              significance_threshold=2.,
              keep_history=True)
    cwt_data = CWTData(counts=data['image'],
                       background=data['background'],
                       n_scale=cwt_kernels.n_scale)

    cwt.analyze(data=cwt_data)
    return cwt_data
Exemplo n.º 4
0

# Let's start to analyse input data. Import Logging module to see how the algorithm works during data analysis.

# In[ ]:


from gammapy.detect import CWT
import logging

logger = logging.getLogger()
logger.setLevel(logging.INFO)
cwt = CWT(
    kernels=cwt_kernels,
    tol=TOL,
    significance_threshold=SIGNIFICANCE_THRESHOLD,
    significance_island_threshold=SIGNIFICANCE_ISLAND_THRESHOLD,
    remove_isolated=REMOVE_ISOLATED,
    keep_history=KEEP_HISTORY,
)


# In order to the algorithm was able to analyze source images, you need to convert them to a special format, i.e. create an CWTData object. Do this.

# In[ ]:


from gammapy.detect import CWTKernels, CWTData

cwt_data = CWTData(
    counts=data["counts"], background=data["background"], n_scale=N_SCALE
)