ogstools.variables package#
Predefined variables for data and unit transformation.
- class ogstools.variables.Matrix[source]#
Bases:
VariableRepresent a matrix variable.
Matrix variables should contain either 4 (2D) or 6 (3D) components. Matrix components can be accesses with brackets e.g. stress[0]
- __getitem__(index)[source]#
A scalar variable as a matrix component.
The following index values correspond to a polar coordinate system:
rr: radial component tt: angular component in theta (azimuthal) direction pp: angular component in phi (polar) direction rt: shear component in the radial-azimuthal plane tp: shear component in the azimuthal-polar plane rp: shear component in the radial-polar plane
- Return type:
- to_polar(center=(0, 0, 0), normal=(0, 0, 1))[source]#
Return the Matrix converted to a polar coordinate system.
For 3D only spherical coordinate system is implemented for now.
- Return type:
- property eigenvectors: VectorList#
A vector variable as the eigenvectors of the matrix.
- property deviator_invariant_1: Scalar#
A scalar variable as the first invariant of the matrix deviator.
- property deviator_invariant_2: Scalar#
A scalar variable as the second invariant of the matrix deviator.
- property deviator_invariant_3: Scalar#
A scalar variable as the third invariant of the matrix deviator.
- class ogstools.variables.Variable[source]#
Bases:
objectRepresent a generic mesh variable.
- __init__(data_name, data_unit='', output_unit=None, output_name=None, symbol='', mask='', func=identity, mesh_dependent=False, process_with_units=False, cmap='coolwarm', bilinear_cmap=False, categoric=False, color=None)[source]#
- func()#
The function to be applied on the data. .. seealso::
transform()- Return type:
TypeVar(T)
- replace(**changes)[source]#
Create a new Variable object with modified attributes.
Be aware that there is no type check safety here. So make sure, the new attributes and values are correct.
- Parameters:
changes (
Any) – Attributes to be changed.- Return type:
Self- Returns:
A copy of the Variable with changed attributes.
- classmethod from_variable(new_variable, **changes)[source]#
Create a new Variable object with modified attributes.
- Return type:
Self
- classmethod find(variable, mesh)[source]#
Returns a Variable preset or creates one with correct type.
Searches for presets by data_name and output_name and returns if found. If ‘variable’ is given as type Variable this will also look for derived variables (difference, aggregate). Otherwise create Scalar, Vector, or Matrix Variable depending on the shape of data in mesh.
- transform(data, strip_unit=True)[source]#
Return the transformed data values.
Converts the data from data_unit to output_unit and applies the transformation function of this variable. The result is returned by default without units. if strip_unit is False, a quantity is returned.
Note: If self.mesh_dependent is True, self.func is applied directly to the mesh. Otherwise, it is determined by self.process_with_units if the data is passed to the function with units (i.e. as a pint quantity) or without.
- Return type:
- is_mask()[source]#
Check if the variable is a mask.
- Return type:
- Returns:
True if the variable is a mask, False otherwise.
- class ogstools.variables.Vector[source]#
Bases:
VariableRepresent a vector variable.
Vector variables should contain either 2 (2D) or 3 (3D) components. Vector components can be accesses with brackets e.g. displacement[0]
Submodules#
- ogstools.variables.custom_colormaps module
- ogstools.variables.matrix module
MatrixMatrix.__getitem__()Matrix.to_polar()Matrix.magnitudeMatrix.traceMatrix.eigenvaluesMatrix.eigenvectorsMatrix.detMatrix.invariant_1Matrix.invariant_2Matrix.invariant_3Matrix.tensor_meanMatrix.hydrostatic_componentMatrix.deviatorMatrix.deviator_invariant_1Matrix.deviator_invariant_2Matrix.deviator_invariant_3Matrix.octahedral_shearMatrix.von_MisesMatrix.qp_ratio
- ogstools.variables.mesh_dependent module
- ogstools.variables.tensor_math module
identity()sym_tensor_to_mat()mat_to_sym_tensor()trace()matrix_trace()eigenvalues()eigenvectors()det()frobenius_norm()invariant_1()invariant_2()invariant_3()mean()effective_pressure()hydrostatic_component()deviator()deviator_invariant_1()deviator_invariant_2()deviator_invariant_3()octahedral_shear()von_mises()qp_ratio()to_polar()
- ogstools.variables.unit_registry module
- ogstools.variables.variable module
VariableVariable.__init__()Variable.data_nameVariable.data_unitVariable.output_unitVariable.output_nameVariable.symbolVariable.maskVariable.func()Variable.mesh_dependentVariable.process_with_unitsVariable.cmapVariable.bilinear_cmapVariable.categoricVariable.colorVariable.type_nameVariable.replace()Variable.from_variable()Variable.find()Variable.transform()Variable.get_output_unitVariable.minVariable.maxVariable.meanVariable.medianVariable.sumVariable.stdVariable.varVariable.differenceVariable.abs_errorVariable.rel_errorVariable.anasolVariable.is_mask()Variable.get_mask()Variable.magnitudeVariable.mask_used()Variable.get_label()
Scalar
- ogstools.variables.vector module