OpenSeesPyAssistant 1.1
OpenSeesPy for everyone
DataManagement.py
Go to the documentation of this file.
1"""
2Module with the parent abstract class DataManagement. \n
3Carmine Schipani, 2021
4"""
5
6from abc import ABC, abstractmethod
8import numpy as np
9
10
11class DataManagement(ABC):
12 """
13 Abstract parent class for data management.
14 Using the associated MATLAB class \n
15 LOAD_CLASS.m \n
16 for the postprocessing in MATLAB, allowing for simpler and more reliable data management because the parameters
17 from the OpenSeesPy analysis are imported automatically.
18 """
19
20 def SaveData(self, f):
21 """
22 Function that lists in the command window and saves in a opened file text "f" the data from the "self" class that calls it.
23 Example: call this function after this line: \n
24 with open(FileName, 'w') as f:
25
26 @param f (io.TextIOWrapper): Opened file to write into
27
28 @exception WrongDimension: The number of lists in the list self.data needs to be 2
29 """
30 if len(self.data[0]) != 2: raise WrongDimension()
31
32 delimiter = "##############################" # 30 times #
33 col_delimiter = "\t" # tab
34 for data_line in self.data:
35 f.write('\n')
36 for col in data_line:
37 if type(col) == np.ndarray:
38 tmp_str = np.array_str(col, max_line_width = np.inf)
39 else:
40 tmp_str = str(col)
41 f.write(tmp_str)
42 f.write(col_delimiter)
43 f.write('\n')
44 f.write('NEW INFO SECTION DELIMITER \t')
45 f.write(delimiter)
46
47 @abstractmethod
48 def ShowInfo(self):
49 """
50 Abstract method that shows the data stored in the class in the command window.
51 In some cases, it's possible to plot some information (for example the curve of the material model).
52 """
53 pass
54
55 @abstractmethod
56 def ReInit(self):
57 """
58 Abstract method that computes the value of the parameters with respect of the arguments. \n
59 Use after changing the value of argument inside the class (to update the values accordingly). \n
60 This function can be very useful in combination with the function "deepcopy()" from the module "copy". \n
61 Be careful that the parameter self.Initialized is also copied, thus it is safer to copy the class before the method that calls the actual OpenSees commands (and initialise the object).
62 """
63 pass
64
65 @abstractmethod
67 """
68 Abstract method used to define and update the self.data member variable. \n
69 This member variable (self.data) is a list of lists with 2 entries (info_name and info_value)
70 and for each list is stored a different member variable of the class. \n
71 Useful to debug the model, export data, copy object.
72 """
73 pass
Abstract parent class for data management.
def SaveData(self, f)
Function that lists in the command window and saves in a opened file text "f" the data from the "self...
def ShowInfo(self)
Abstract method that shows the data stored in the class in the command window.
def UpdateStoredData(self)
Abstract method used to define and update the self.data member variable.
def ReInit(self)
Abstract method that computes the value of the parameters with respect of the arguments.