mt_metadata.common.band

Band class for frequency band definitions.

Development Notes:

To add better overlap and intersection checking, consider using piso https://piso.readthedocs.io/en/latest/getting_started/index.html

Classes

CenterAveragingTypeEnum

str(object='') -> str

ClosedEnum

str(object='') -> str

Band

Base class for all metadata objects with Pydantic validation.

Module Contents

class mt_metadata.common.band.CenterAveragingTypeEnum

Bases: mt_metadata.common.enumerations.StrEnumerationBase

str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to ‘utf-8’. errors defaults to ‘strict’.

arithmetic = 'arithmetic'
geometric = 'geometric'
class mt_metadata.common.band.ClosedEnum

Bases: mt_metadata.common.enumerations.StrEnumerationBase

str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to ‘utf-8’. errors defaults to ‘strict’.

left = 'left'
right = 'right'
both = 'both'
class mt_metadata.common.band.Band(**data)

Bases: mt_metadata.base.MetadataBase

Base 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

decimation_level: Annotated[int, Field(default=None, description='Decimation level for the band', alias=None, json_schema_extra={'units': None, 'required': True, 'examples': ['0']})]
index_max: Annotated[int, Field(default=None, description='maximum band index', alias=None, json_schema_extra={'units': None, 'required': True, 'examples': ['10']})]
index_min: Annotated[int, Field(default=None, description='minimum band index', alias=None, json_schema_extra={'units': None, 'required': True, 'examples': ['10']})]
frequency_max: Annotated[float, Field(default=0.0, description='maximum band frequency', alias=None, json_schema_extra={'units': 'Hertz', 'required': True, 'examples': ['0.04296875']})]
frequency_min: Annotated[float, Field(default=0.0, description='minimum band frequency', alias=None, json_schema_extra={'units': 'Hertz', 'required': True, 'examples': ['0.03515625']})]
center_averaging_type: Annotated[CenterAveragingTypeEnum, Field(default=CenterAveragingTypeEnum.geometric, description='type of average to apply when computing the band center', alias=None, json_schema_extra={'units': None, 'required': True, 'examples': ['geometric']})]
closed: Annotated[ClosedEnum, Field(default=ClosedEnum.left, description='whether interval is open or closed', alias=None, json_schema_extra={'units': None, 'required': True, 'examples': ['left']})]
name: Annotated[Optional[str], Field(default='', description='Name of the band', alias=None, json_schema_extra={'units': None, 'required': False, 'examples': ['0.039062']})]
classmethod validate_name(value, info)
classmethod update_name_on_frequency_change(value, info)
check_name()
property lower_bound: float
property upper_bound: float
property width: float

returns the width of the band (the bandwidth).

property lower_closed: bool
property upper_closed: bool
set_indices_from_frequencies(frequencies)

assumes min/max freqs are defined

to_interval()
property harmonic_indices

Assumes all harmoincs between min and max are present in the band

Return type:

numpy array of integers corresponding to harminic indices

in_band_harmonics(frequencies)
Parameters:
  • frequencies (array-like, floating poirt)

  • Returns (numpy array) – the actual harmonics or frequencies in band, rather than the indices.

  • -------

property center_frequency: float

returns: center_frequency – The frequency associated with the band center. :rtype: float

property center_period: float

Returns the inverse of center frequency.

overlaps(other)

Check if this band overlaps with another

contains(other)

Check if this band contains nother

property fractional_bandwidth: float

See - https://en.wikipedia.org/wiki/Bandwidth_(signal_processing)#Fractional_bandwidth - https://en.wikipedia.org/wiki/Q_factor

property Q: float

Quality factor (Q) of the band.

Returns:

Q factor. Returns infinity for zero-width bands.

Return type:

float