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