ogstools.propertylib.property module#

Defines the Scalar, Vector and Matrix Property classes.

They serve as classes to handle common physical properties in a systematic way (e.g. temperature, pressure, displacement, …). Unit conversion is handled via pint.

class ogstools.propertylib.property.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.property.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