ogstools.materiallib.core.material module#

class ogstools.materiallib.core.material.Material[source]#

Bases: Mapping[str, MaterialProperty]

Represents a single material.

  • Can be constructed directly from YAML raw data.

  • Provides access to all properties.

  • Supports filtering by process schemas or property names.

__init__(name, raw_data)[source]#
classmethod from_file(file_path)[source]#

Create a Material from a YAML file or return None if invalid.

Return type:

Material | None

to_file(file_path)[source]#

Write this Material to a YAML file.

Return type:

None

__getitem__(key)[source]#
Return type:

MaterialProperty

property property_names: list[str]#

Returns a list of all property names of this material.

get_property(key)[source]#
Return type:

MaterialProperty

filter_process(process_schema)[source]#

Return a new Material containing only properties required by a given process schema.

Return type:

Material

filter_properties(allowed, key='name')[source]#

Return a new Material containing only the properties in ‘allowed’, preserving all extra fields (e.g. scope, unit).

Parameters:
  • allowed (set[str] | str) – values to filter for

  • key (str) – attribute to filter for (e.g. ‘name’ or ‘type’)

Return type:

Material

copy()[source]#

Return a deep copy

Return type:

Material