### ===================================================================================================================
### FUNTION: Collect the latest/relevant folder locations for the engineering data
### ===================================================================================================================
# Copyright ©VIIA 2024
### ===================================================================================================================
### 1. Import modules
### ===================================================================================================================
# General imports
from __future__ import annotations
from typing import TYPE_CHECKING
from pathlib import Path
# References for functions and classes in the viiaPackage
if TYPE_CHECKING:
from viiapackage.viiaStatus import ViiaProject
from viiapackage.reporting.helper_functions.find_latest_folder import find_latest_folder
from viiapackage.general.file_handling.viia_get_latest_model_folder import viia_get_latest_folder
### ===================================================================================================================
### 2. Helper function
### ===================================================================================================================
[docs]def set_folder_location(project: ViiaProject, governing_analysis: str) -> dict:
"""
This function sets up the folder locations for the model/result pictures.
Input:
- project (obj): VIIA project object containing collections of fem objects and project variables.
- governing_analysis (str): Name of the governing analysis, for example 'S2'.
Output:
- Folder locations for the required model/result pictures are set up and returned in a dictionary.
- User is notified about the folder locations in project log file.
"""
model_picture_folder = None
nls_result_folder = None
eigen_result_folder = None
seismic_result_folder = None
# Location of eigenvalue analysis results pictures
latest_folder = \
find_latest_folder(project, Path(project.diana_settings.analysis_settings['A7']['folder_name']))
if latest_folder:
eigen_result_folder = \
Path(project.diana_settings.analysis_settings['A7']['folder_name']) / latest_folder
if eigen_result_folder:
project.write_log(
f"Eigenvalue analysis result pictures will be taken from '{eigen_result_folder}'.")
else:
project.write_log(
f"WARNING: No path of eigenvalue analysis result pictures is set up, please check your "
f"workfolder. Reports will be missing these figures.")
# Collecting NLS and eigenvalue analysis result folders for compliant TVA
if project.version == 1:
# Location of nonlinear static analysis results pictures
latest_folder = \
find_latest_folder(project, Path(project.diana_settings.analysis_settings['A10']['folder_name']))
if latest_folder:
nls_result_folder = Path(project.diana_settings.analysis_settings['A10']['folder_name']) / latest_folder
if nls_result_folder:
project.write_log(
f"Nonlinear static result pictures will be taken from '{nls_result_folder}'.")
else:
project.write_log(
f"WARNING: No path of nonlinear static result pictures is set up, please check your "
f"workfolder. Reports will be missing these figures.")
else:
# Location of nonlinear static analysis results pictures with strengthening measures
latest_folder = \
find_latest_folder(project, Path(project.diana_settings.analysis_settings['A13']['folder_name']))
if latest_folder:
nls_result_folder = Path(project.diana_settings.analysis_settings['A13']['folder_name']) / latest_folder
if nls_result_folder:
project.write_log(
f"Nonlinear static result pictures will be taken from '{nls_result_folder}'.")
else:
# Use the A10 instead
latest_folder = \
find_latest_folder(project, Path(project.diana_settings.analysis_settings['A10']['folder_name']))
if latest_folder:
nls_result_folder = Path(project.diana_settings.analysis_settings['A10']['folder_name']) / latest_folder
if nls_result_folder:
project.write_log(
f"Nonlinear static result pictures will be taken from '{nls_result_folder}'.")
else:
project.write_log(
f"WARNING: No path of nonlinear static result pictures is set up, please check your "
f"workfolder. Reports will be missing these figures.")
# Location of model pictures
latest_folder = \
find_latest_folder(project, Path(project.diana_settings.analysis_settings['MODEL']['folder_name']))
if latest_folder:
model_picture_folder = \
Path(project.diana_settings.analysis_settings['MODEL']['folder_name']) / latest_folder
project.write_log(
f"Model pictures will be taken from '{model_picture_folder}'.")
else:
project.write_log(
f"WARNING: No path of model pictures is set up, please check your work folder. "
f"Reports will be missing these figures.")
# Location of NLTH governing signal results pictures
if project.version == 1:
path = project.workfolder_location / 'A12 - NLTH flex base'
analysis_nr = 'A12'
else:
path = project.workfolder_location / 'A15 - NLTH flex base strengthening'
analysis_nr = 'A15'
if not path.exists():
project.write_log(
f"WARNING: {analysis_nr} analysis folder cannot be found. Reports will be missing NLTH figures.")
else:
timestamp_folders = viia_get_latest_folder(version=project.version, folder=path)
for _key in reversed(sorted(timestamp_folders)):
seismic_result_folder = Path(timestamp_folders[_key] / governing_analysis)
if seismic_result_folder.exists() and seismic_result_folder.is_dir():
break
seismic_result_folder = None
if not seismic_result_folder:
project.write_log(
f"WARNING: Signal {governing_analysis} in {analysis_nr} analysis folder cannot be found. Reports will "
f"be missing NLTH figures.")
else:
project.write_log(
f"NLTH result pictures for {analysis_nr} analysis will be taken from {seismic_result_folder}.")
return {
'image_folders': {
'model_picture_folder': model_picture_folder,
'nls_result_folder': nls_result_folder,
'eigen_result_folder': eigen_result_folder,
'seismic_result_folder': seismic_result_folder}}
### ===================================================================================================================
### 3. End of script
### ===================================================================================================================