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.

Parameters:
  • changes (Any) – Attributes to be changed.

  • self (Property)

Returns:

A copy of the Property with changed attributes.

Return type:

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

classmethod from_property(new_property, **changes)[source]#

Create a new Property object with modified attributes.

Parameters:
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

get_output_unit()[source]#

Get the output unit.

returns: The output unit.

Return type:

str

property difference: Property#

returns: A property relating to differences in this quantity.

is_mask()[source]#

Check if the property is a mask.

Returns:

True if the property is a mask, False otherwise.

Return type:

bool

get_mask()[source]#
Returns:

A property representing this properties mask.

Return type:

Property

property magnitude: Property#
mask_used(mesh)[source]#

Check whether the mesh contains the mask of this property.

Parameters:

mesh (UnstructuredGrid)

Return type:

bool

get_label()[source]#

Creates property label in format ‘property_name / property_unit’

Return type:

str

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:

Scalar

property magnitude: Scalar#
Returns:

A scalar property as the magnitude of the vector.

__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:

Scalar

property magnitude: Scalar#

A scalar property as the frobenius norm of the matrix.

property trace: Scalar#

A scalar property as the trace of the matrix.

property eigenvalues: Vector#

A vector property as the eigenvalues of the matrix.

property eigenvectors: VectorList#

A vector property as the eigenvectors of the matrix.

property det: Scalar#

A scalar property as the determinant of the matrix.

property invariant_1: Scalar#

A scalar property as the first invariant of the matrix.

property invariant_2: Scalar#

A scalar property as the second invariant of the matrix.

property invariant_3: Scalar#

A scalar property as the third invariant of the matrix.

property mean: Scalar#

A scalar property as the mean value of the matrix.

property hydrostatic_component: Matrix#

A vector property as the effective pressure of the matrix.

property deviator: Matrix#

A vector property as the deviator 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.

property von_Mises: Scalar#

A scalar property as the von Mises stress.

property qp_ratio: Scalar#

A scalar property as the qp stress ratio.

__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#