### ===================================================================================================================
### FUNCTION: Load L2 measure data
### ===================================================================================================================
# Copyright ©VIIA 2024
### ===================================================================================================================
### 1. Import modules
### ===================================================================================================================
# General imports
from __future__ import annotations
from typing import TYPE_CHECKING, List
# References for functions and classes in the viiaPackage
if TYPE_CHECKING:
from viiapackage.viiaStatus import ViiaProject
from viiapackage.reporting.helper_functions.set_folder_location import set_folder_location
### ===================================================================================================================
### 2. Function load_l2_measure_data
### ===================================================================================================================
[docs]def load_l2_measure_data(project: ViiaProject, governing_analysis: str) -> List:
"""
Get the data of L2 measures.
Input:
- project (obj): Project object reference containing collections of fem objects and project variables.
- governing_analysis (str): Name of the governing analysis, for example 'S2'.
Output:
- L2 measure data is loaded if available
"""
image_folders = set_folder_location(project=project, governing_analysis=governing_analysis)
result_folder = image_folders['image_folders']['seismic_result_folder']
if not result_folder or not result_folder.exists():
project.write_log(
f"WARNING: Result folder for {governing_analysis} is not found. L2 measure data cannot be "
f"loaded.")
return
# Check if the json-file could be found
json_file = project.viia_get_file(
path=result_folder, starts_with=project.name, in_name=governing_analysis, suffix='.json')
# If there is no json-file found a warning is thrown
if not json_file:
project.write_log(
f"ERROR: The json-file for {governing_analysis} is not found. It is required to collect the analysis.")
return
# Collect the analysis
if not project.collections.analyses:
project.write_log(
f"WARNING: The analysis object for A12 analysis could not be found.")
return
analyses_a4 = [analysis for analysis in project.collections.analyses if 'A4' in analysis.name]
analyses_a12 = [analysis for analysis in project.collections.analyses if 'A12' in analysis.name]
analyses_a15 = [analysis for analysis in project.collections.analyses if 'A15' in analysis.name]
if analyses_a15:
if len(analyses_a15) > 1:
project.write_log(f"WARNING: Multiple A15 analyses found, workflow is not prepared for this.")
return None
analysis = analyses_a15[0]
elif analyses_a12:
if len(analyses_a12) > 1:
project.write_log(f"WARNING: Multiple A12 analyses found, workflow is not prepared for this.")
return None
analysis = analyses_a12[0]
elif analyses_a4:
if len(analyses_a4) > 1:
project.write_log(f"WARNING: Multiple A4 analyses found, workflow is not prepared for this.")
return None
analysis = analyses_a4[0]
OUTPUT_4A, OUTPUT_4B = None, None
for item in result_folder.iterdir():
if item.is_file() and item.suffix == ".tb":
if not OUTPUT_4A and "OUTPUT_4A" in item.name:
OUTPUT_4A = item
continue
if not OUTPUT_4B and "OUTPUT_4B" in item.name:
OUTPUT_4B = item
if OUTPUT_4A and OUTPUT_4B:
break
for file in [OUTPUT_4A, OUTPUT_4B]:
if file:
project.read_diana_tbfile(file=file, analysis=analysis)
### ===================================================================================================================
### 3. End of script
### ===================================================================================================================