ogstools.propertylib package#
Define easy-to-access Property classes and PropertyCollection instances.
- class ogstools.propertylib.Property[source]#
Bases:
object
Represent a generic mesh property.
- data_name: str#
The name of the property data in the mesh.
- data_unit: str = ''#
The unit of the property data in the mesh.
- output_unit: str = ''#
The output unit of the property.
- output_name: str = ''#
The output name of the property.
- mask: str = ''#
The name of the mask data in the mesh.
- func()#
The function to be applied on the data. .. seealso::
transform()
- Parameters:
vals (T) –
- Return type:
T
- mesh_dependent: bool = False#
If the function to be applied is dependent on the mesh itself
- process_with_units: bool = False#
If true, apply the function on values with units.
- cmap: Colormap | str = 'coolwarm'#
Colormap to use for plotting.
- bilinear_cmap: bool = False#
Should this property be displayed with a bilinear cmap?
- categoric: bool = False#
Does this property only have categoric values?
- property type_name: str#
- replace(**changes)[source]#
Create a new Property object with modified attributes.
Be aware that there is no type check safety here. So make sure, the new attributes and values are correct.
- __init__(data_name, data_unit='', output_unit='', output_name='', mask='', func=<function identity>, mesh_dependent=False, process_with_units=False, cmap='coolwarm', bilinear_cmap=False, categoric=False)#
- Parameters:
data_name (str) –
data_unit (str) –
output_unit (str) –
output_name (str) –
mask (str) –
func (Callable) –
mesh_dependent (bool) –
process_with_units (bool) –
cmap (Colormap | str) –
bilinear_cmap (bool) –
categoric (bool) –
- Return type:
None
- classmethod from_property(new_property, **changes)[source]#
Create a new Property object with modified attributes.
- Parameters:
new_property (Property) –
changes (Any) –
- 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 property. 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.
- Parameters:
data (int | float | ndarray | UnstructuredGrid | Sequence) –
strip_unit (bool) –
- Return type:
ndarray
- is_mask()[source]#
Check if the property is a mask.
- Returns:
True if the property is a mask, False otherwise.
- Return type:
bool
- class ogstools.propertylib.Scalar[source]#
Bases:
Property
Represent a scalar property.
- __init__(data_name, data_unit='', output_unit='', output_name='', mask='', func=<function identity>, mesh_dependent=False, process_with_units=False, cmap='coolwarm', bilinear_cmap=False, categoric=False)#
- Parameters:
data_name (str) –
data_unit (str) –
output_unit (str) –
output_name (str) –
mask (str) –
func (Callable) –
mesh_dependent (bool) –
process_with_units (bool) –
cmap (Colormap | str) –
bilinear_cmap (bool) –
categoric (bool) –
- Return type:
None
- class ogstools.propertylib.Vector[source]#
Bases:
Property
Represent a vector property.
Vector properties should contain either 2 (2D) or 3 (3D) components. Vector components can be accesses with brackets e.g. displacement[0]
- __getitem__(index)[source]#
Get a scalar property as a specific component of the vector property.
- Parameters:
index (int | Literal['x', 'y', 'z']) – The index of the component.
- Returns:
A scalar property as a vector component.
- Return type:
- __init__(data_name, data_unit='', output_unit='', output_name='', mask='', func=<function identity>, mesh_dependent=False, process_with_units=False, cmap='coolwarm', bilinear_cmap=False, categoric=False)#
- Parameters:
data_name (str) –
data_unit (str) –
output_unit (str) –
output_name (str) –
mask (str) –
func (Callable) –
mesh_dependent (bool) –
process_with_units (bool) –
cmap (Colormap | str) –
bilinear_cmap (bool) –
categoric (bool) –
- Return type:
None
- class ogstools.propertylib.Matrix[source]#
Bases:
Property
Represent a matrix property.
Matrix properties 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 property as a matrix component.
- Parameters:
index (int | Literal['xx', 'yy', 'zz', 'xy', 'yz', 'xz']) –
- Return type:
- property eigenvectors: VectorList#
A vector property as the eigenvectors of the matrix.
- property deviator_invariant_1: Scalar#
A scalar property as the first invariant of the matrix deviator.
- property deviator_invariant_2: Scalar#
A scalar property as the second invariant of the matrix deviator.
- property deviator_invariant_3: Scalar#
A scalar property as the third invariant of the matrix deviator.
- property octahedral_shear: Scalar#
A scalar property as the octahedral shear component of the matrix.
- __init__(data_name, data_unit='', output_unit='', output_name='', mask='', func=<function identity>, mesh_dependent=False, process_with_units=False, cmap='coolwarm', bilinear_cmap=False, categoric=False)#
- Parameters:
data_name (str) –
data_unit (str) –
output_unit (str) –
output_name (str) –
mask (str) –
func (Callable) –
mesh_dependent (bool) –
process_with_units (bool) –
cmap (Colormap | str) –
bilinear_cmap (bool) –
categoric (bool) –
- Return type:
None
Submodules#
- ogstools.propertylib.custom_colormaps module
- ogstools.propertylib.matrix module
Matrix
Matrix.__getitem__()
Matrix.magnitude
Matrix.trace
Matrix.eigenvalues
Matrix.eigenvectors
Matrix.det
Matrix.invariant_1
Matrix.invariant_2
Matrix.invariant_3
Matrix.mean
Matrix.hydrostatic_component
Matrix.deviator
Matrix.deviator_invariant_1
Matrix.deviator_invariant_2
Matrix.deviator_invariant_3
Matrix.octahedral_shear
Matrix.von_Mises
Matrix.qp_ratio
Matrix.__init__()
- ogstools.propertylib.mesh_dependent module
- ogstools.propertylib.presets module
- ogstools.propertylib.property module
Property
Property.data_name
Property.data_unit
Property.output_unit
Property.output_name
Property.mask
Property.func()
Property.mesh_dependent
Property.process_with_units
Property.cmap
Property.bilinear_cmap
Property.categoric
Property.type_name
Property.replace()
Property.__init__()
Property.from_property()
Property.transform()
Property.get_output_unit()
Property.difference
Property.is_mask()
Property.get_mask()
Property.magnitude
Property.mask_used()
Property.get_label()
Scalar
- ogstools.propertylib.tensor_math module
identity()
sym_tensor_to_mat()
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()
- ogstools.propertylib.unit_registry module
- ogstools.propertylib.vector module