Remove ASMoothMapEstimator.parameters
@@ -41,12 +41,10 @@ class ASmoothMapEstimator(Estimator):
tag = "ASmoothMapEstimator"
def __init__(self, scales, kernel=Gaussian2DKernel, method="lima", threshold=5):
- self.parameters = {
- "kernel": kernel,
- "method": method,
- "threshold": threshold,
- "scales": scales,
- }
+ self.scales = scales
+ self.kernel = kernel
+ self.threshold = threshold
+ self.method = method
def kernels(self, pixel_scale):
"""
@@ -62,12 +60,11 @@ class ASmoothMapEstimator(Estimator):
kernels : list
List of `~astropy.convolution.Kernel`
"""
- p = self.parameters
- scales = p["scales"].to_value("deg") / Angle(pixel_scale).deg
+ scales = self.scales.to_value("deg") / Angle(pixel_scale).deg
kernels = []
for scale in scales: # .value:
- kernel = p["kernel"](scale, mode="oversample")
+ kernel = self.kernel(scale, mode="oversample")
# TODO: check if normalizing here makes sense
kernel.normalize("peak")
kernels.append(kernel)
@@ -173,7 +170,7 @@ class ASmoothMapEstimator(Estimator):
cubes["flux"] = scale_cube(flux.data, kernels)
cubes["significance"] = self._significance_cube(
- cubes, method=self.parameters["method"]
+ cubes, method=self.method
)
smoothed = self._reduce_cubes(cubes, kernels)
@@ -208,7 +205,6 @@ class ASmoothMapEstimator(Estimator):
cubes : dict
Data cubes
"""
- p = self.parameters
shape = cubes["counts"].shape[:2]
smoothed = {}
@@ -216,12 +212,12 @@ class ASmoothMapEstimator(Estimator):
for key in ["counts", "background", "scale", "significance", "flux"]:
smoothed[key] = np.tile(np.nan, shape)
- for idx, scale in enumerate(p["scales"]):
+ for idx, scale in enumerate(self.scales):
# slice out 2D image at index idx out of cube
slice_ = np.s_[:, :, idx]
mask = np.isnan(smoothed["counts"])
- mask = (cubes["significance"][slice_] > p["threshold"]) & mask
+ mask = (cubes["significance"][slice_] > self.threshold) & mask
smoothed["scale"][mask] = scale
smoothed["significance"][mask] = cubes["significance"][slice_][mask]
