mt_metadata.transfer_functions.io.emtfxml.metadata.electrode
Classes
Base class for all metadata objects with Pydantic validation. |
Module Contents
- class mt_metadata.transfer_functions.io.emtfxml.metadata.electrode.Electrode(**data)
Bases:
mt_metadata.base.MetadataBaseBase class for all metadata objects with Pydantic validation.
MetadataBase extends DotNotationBaseModel (which inherits from Pydantic’s BaseModel) to provide automatic validation according to metadata standards. It adds functionality beyond dictionaries, supporting JSON, XML, pandas Series, and other formats for metadata interchange.
- _skip_equals
Private attribute listing fields to skip in equality comparisons
- Type:
list[str]
- _fields
Private attribute caching field information
- Type:
dict[str, Any]
Notes
All field assignments are validated automatically via Pydantic
None values are converted to appropriate defaults (empty string or 0.0)
Supports nested attribute access via dot notation
Thread-safe for read operations after initialization
- location: Annotated[mt_metadata.common.enumerations.ElectrodeLocationEnum, Field(default='', description='Direction of electrode', alias=None, json_schema_extra={'units': None, 'required': True, 'examples': ['N', 'S', 'E', 'W']})]
- number: Annotated[str, Field(default='0', description='Electrode ID number', alias=None, json_schema_extra={'units': None, 'required': True, 'examples': ['1a']})]
- value: Annotated[str, Field(default='', description='Electrode value', alias=None, json_schema_extra={'units': None, 'required': False, 'examples': ['Ag-AgCl']})]
- comments: Annotated[mt_metadata.common.Comment, Field(default_factory=lambda: Comment(), description='comments on the electrode', alias=None, json_schema_extra={'units': None, 'required': True, 'examples': ['Ag-AgCl porous pot']})]
- classmethod validate_comments(value, info)
- to_xml(string=False, required=False)
Convert metadata to an XML representation.
Creates an XML element with type and unit information for each attribute.
- Parameters:
string (bool, optional) – If True, return XML as a string. If False, return an XML Element. Default is False.
required (bool, optional) – If True, include only required elements and elements with non-None values. If False, include all elements. Default is True.
- Returns:
XML Element object if string=False, otherwise XML string
- Return type:
str | et.Element
Examples
>>> xml_elem = metadata.to_xml() >>> xml_str = metadata.to_xml(string=True)