data
- class czmtestkit.py_modules.data
Bases:
object
Read and store a matrix written to Abaqus/CAE
.msg
files.- Attributes
data.type (str): Keyword in the first line to be excluded when reading the data between specified line numbers. Ideally, this should indicate the vairable name of the matrix/array printed to the .msg file.
data.start (int): Line number corresponding to the first line contating the matrix data in the .msg file.
data.stop (int): Line number corresponding to the last line contating the matrix data in the .msg file. self.start = self.stop if the matrix/array is printed on a single line.
data.shape (tuple): Shape of the matrix [optional].
shape[0] (int): number of rows.
shape[1] (int): number of columns.
data.value (list): Elements of the matrix read from the .msg file.
Example
If a variable Var
\[\begin{split}Var = \left[ \begin{matrix} 1.000000 & 3.000000 & 5.000000 \\ 2.000000 & 4.000000 & 6.000000 \end{matrix} \right]\end{split}\]is printed to the .msg file with the keyword VarKey as follows:
107 VarKey = 1.000000 2.000000 3.000000 108 4.000000 5.000000 6.000000
To fetch this data from
fileName.msg
file, create an instance of data class.dataInst = data()
The keyword to be excluded when reading the matrix is the data.type.
dataInst.type = 'VarKey'
Since the matrix extends between line 107 and 108:
dataInst.start = 107 dataInst.stop = 108
Further, the Var matrix has two rows and three columns, therefore:
dataInst.shape = (2, 3)
With these attributes assigned to an instance of the
data
class, executing thedata.findValue()
method fetches and assigns the elements of Var matrix to data.value as a list[ 1.000000 2.000000 3.000000 4.000000 5.000000 6.000000 ]
.dataInst.findValue("fileName.msg") print(dataInst.value)
Output:
[1.000000, 2.000000, 3.000000, 4.000000, 5.000000, 6.000000]
Methods Summary
findValue
(fileName)Method to find the matrix/array between specified line numbers in the
filename.msg
file. (Seedata
class for an example.)Methods Documentation
- findValue(fileName)
Method to find the matrix/array between specified line numbers in the
filename.msg
file. (Seedata
class for an example.)- Parameters
fileName (str): path to the .msg file including the file name and extension.
Note
Output from the function is unstructured and has to be reshaped based on the requirements or the data.shape attribute.
Warning
data
attributes data.type, data.start, and data.stop must be defined to execute thedata.findValue()
method.