### ===================================================================================================================
### FUNCTION: Collect the PSSE-NSCE plot for reporting
### ===================================================================================================================
# Copyright ©VIIA 2024
### ===================================================================================================================
### 1. Import modules
### ===================================================================================================================
# General imports
from __future__ import annotations
from pathlib import Path
from typing import TYPE_CHECKING, Dict, List, Union
# References for functions and classes in the viiaPackage
if TYPE_CHECKING:
from viiapackage.viiaStatus import ViiaProject
from viiapackage.pictures import PSSENSCEPlotSettings
### ===================================================================================================================
### 2. Function to collect the image with the PSSE-NSCE plot
### ===================================================================================================================
[docs]def viia_get_psse_nsce_plots(
project: ViiaProject, appendix_pictures_folder: Path) -> Dict[str, List[Dict[str, Union[str, Path]]]]:
"""
Collect the PSSE-NSCE plots to be added to the engineering report.
Input:
- project (obj): VIIA project object containing collections of fem objects and project variables.
- appendix_pictures_folder (Path): Folder with the appendix pictures for the engineering report.
Output:
- Returns a dictionary with jinja tag vs a list of dicts with jinja tags vs layer name and picture path.
"""
# Collect PSSE and NSCE plots
psse_nsce_folder = appendix_pictures_folder / PSSENSCEPlotSettings.subfolder
# Check if folder exists for the PSSE and NSCE plots found
if not psse_nsce_folder.exists():
project.write_log(
f"WARNING: Folder '{psse_nsce_folder.as_posix()}' is not found. PSSE-NSCE plot not added to the report.")
return {}
# Collect the plots in the folder
psse_nsce_pictures = []
unsorted_pics = []
for plot in psse_nsce_folder.iterdir():
if plot.is_file() and plot.suffix == '.png':
unsorted_pics.append(plot)
# Sort the pictures per layer
layers = project.get_all_layers_and_center_of_mass_elevation()
for layer, z in layers.items():
for plot in unsorted_pics:
if layer.name == plot.stem.replace(PSSENSCEPlotSettings.file_base_name, '').strip():
psse_nsce_pictures.append({'psse_nsce_layer': layer.name, 'psse_nsce_picture': plot})
break
# Return the dictionary for the jinja-tag in the report
return {'psse_nsce_pictures': psse_nsce_pictures}
### ===================================================================================================================
### 3. End of script
### ===================================================================================================================