Skip to content
Snippets Groups Projects
Commit 82789ca4 authored by Felix Metzner's avatar Felix Metzner
Browse files

Improving output path for shape sys plots and fixing minor bug in assertion.

parent 10f56920
Branches
No related tags found
No related merge requests found
......@@ -337,13 +337,16 @@ class SystematicsShapePlotter:
self,
sys_shape_info: ShapePlotInfoContainer,
) -> None:
target_dir_path: PathType = os.path.join(self.output_dir_path, sys_shape_info.name)
os.makedirs(target_dir_path, exist_ok=True)
for component_index, comp_info in enumerate(self.fit_components):
# Select by component by index in 2nd dimension
_normed_shape_for_comp: np.ndarray = sys_shape_info.normed_base_shape[:, component_index]
_rel_shape_error_for_comp: np.ndarray = sys_shape_info.relative_shape_error[:, component_index, :]
assert len(_normed_shape_for_comp) == 1, _normed_shape_for_comp
assert len(_rel_shape_error_for_comp) == 2, _rel_shape_error_for_comp
assert len(_normed_shape_for_comp.shape) == 1, _normed_shape_for_comp.shape
assert len(_rel_shape_error_for_comp.shape) == 2, _rel_shape_error_for_comp.shape
# Split 1st dimension by reco channel
_normed_shape_reco_ch_splits: List[np.ndarray] = np.split(
......@@ -378,16 +381,21 @@ class SystematicsShapePlotter:
reco_ch_info=reco_ch_info,
component_info=comp_info,
):
self.plot_systematics_shape_effect_for(spec_sys_shape_info=_this_shape_info)
self.plot_systematics_shape_effect_for(
spec_sys_shape_info=_this_shape_info,
target_dir_path=target_dir_path,
)
def plot_systematics_shape_effect_for(
self,
spec_sys_shape_info: SpecificShapePlotInfoContainer,
target_dir_path: PathType,
) -> None:
set_matplotlibrc_params()
os.makedirs(self.output_dir_path, exist_ok=True)
plot_file_name: str = f"{self.plot_name_prefix}_{spec_sys_shape_info.name}_SubSet{spec_sys_shape_info.subset_index}"
plot_file_name: str = f"{self.plot_name_prefix}"
plot_file_name += f"_comp{spec_sys_shape_info.component_info.name}_ch{spec_sys_shape_info.reco_ch_info.name}"
plot_file_name += f"_{spec_sys_shape_info.name}_SubSet{spec_sys_shape_info.subset_index}"
fig, ax = plt.subplots(figsize=self.fig_size, dpi=300) # type: FigureType, AxesType
......@@ -458,7 +466,7 @@ class SystematicsShapePlotter:
export(
fig=fig,
filename=plot_file_name,
target_dir=self.output_dir_path,
target_dir=target_dir_path,
close_figure=False,
)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment