Remove geom, psf, map, images attributes
@@ -62,13 +62,9 @@ class Analysis:
self._set_logging()
self.observations = None
- self.geom = None
self.background_estimator = None
self.datasets = None
self.extraction = None
- self.images = None
- self.maps = None
- self.psf_kernel = None
self.model = None
self.fit = None
self.fit_result = None
@@ -100,7 +96,6 @@ class Analysis:
self.fit_result = self.fit.run(optimize_opts=optimize_opts)
log.info(self.fit_result)
-
@classmethod
def from_file(cls, filename, template="basic"):
"""Instantiation of analysis from settings in config file.
@@ -124,7 +119,6 @@ class Analysis:
if self.settings["reduction"]["data_reducer"] == "1d":
self._spectrum_extraction()
elif self.settings["reduction"]["data_reducer"] == "3d":
- self._create_geometry()
self._map_making()
else:
# TODO raise error?
@@ -221,7 +215,7 @@ class Analysis:
del geom_params["offset_max"]
if "psf_max_radius" in geom_params:
del geom_params["psf_max_radius"]
- self.geom = WcsGeom.create(**geom_params)
+ return WcsGeom.create(**geom_params)
def _energy_axes(self):
"""Builds energy axes from settings in geometry."""
@@ -240,25 +234,26 @@ class Analysis:
maker_params = {}
if "offset_max" in self.settings["geometry"]:
maker_params = {"offset_max": self.settings["geometry"]["offset_max"]}
- maker = MapMaker(self.geom, **maker_params)
- self.maps = maker.run(self.observations)
- self.images = maker.run_images()
- table_psf = make_mean_psf(self.observations, self.geom.center_skydir)
+ geom = self._create_geometry()
+ maker = MapMaker(geom, **maker_params)
+ maps = maker.run(self.observations)
+ # self.images = maker.run_images()
+ table_psf = make_mean_psf(self.observations, geom.center_skydir)
psf_params = {}
if "psf_max_radius" in self.settings["geometry"]:
psf_params = {"max_radius": self.settings["geometry"]["psf_max_radius"]}
- self.psf_kernel = PSFKernel.from_table_psf(table_psf, self.geom, **psf_params)
+ psf_kernel = PSFKernel.from_table_psf(table_psf, geom, **psf_params)
self._read_model()
# TODO: background model may come from YAML parameters
- background_model = BackgroundModel(self.maps["background"], norm=1.0)
+ background_model = BackgroundModel(maps["background"], norm=1.0)
background_model.parameters["tilt"].frozen = False
self.datasets = Datasets(
MapDataset(
model=self.model,
- counts=self.maps["counts"],
- exposure=self.maps["exposure"],
+ counts=maps["counts"],
+ exposure=maps["exposure"],
background_model=background_model,
- psf=self.psf_kernel,
+ psf=psf_kernel,
)
)
