mt_metadata.features.weights.channel_weight_spec ================================================ .. py:module:: mt_metadata.features.weights.channel_weight_spec .. autoapi-nested-parse:: Container for weighting strategy to apply to a single tf estimation having a single output channel (usually one of "ex", "ey", "hz"). candidate data structure is stored in test_helpers/channel_weight_specs_example.json Candidate names: processing_weights, feature_weights, channel_weights_spec, channel_weighting Notes, and doc for weights PR. channel_weight_specs is a candidate name for the json block like the following: >>> diff processing_configuration_template.json test_processing_config_with_weights_block.json (Another candidate name could be `processing_weights`, or `weights`, but the final nomenclature can be sorted out after there is a functional prototype with the appropriate structure.) This block is basically a dict that maps an output channel name to a ChannelWeightSpec (CWS) object. There are at least three places we would like to be able to plug in such a dict to the processing flow. 1. At the frequency_band level, so that each band can be associated with a specialty CWS 2. At the decimation_level level, so that all bands in a GIB have a common, default. 3. At a high level, so that all processing uses them. TAI: In future, hopefully we could insert a custom CWS for a specific band, but leave all other bands to use the DecimationLevel default CWS, for example. i.e. the CWS can be defined for different scopes. TODO FIXME: IN mt_metadata/transfer_functions/processing/auaora/processing.py when you output a json, it looks like the `decimations` level should be named: `decimation_levels` instead. The general model I'll try to follow will be to open an itearable of objects with a plural of the object name. For example, the processing block called "bands" follows with an itearble of: { "band": { "center_averaging_type": "geometric", ... "index_min": 25 } } ... { "band": { "center_averaging_type": "geometric", ... "index_min": 25 } } Will start by plugging this into the DecimationLevel. TODO: Determine if this class, which represents a single element of a list of channel weight specs, which will be in the json, should have a wrapper or not. In the same way that a DecimationLevel has Bands, it will also have ChannelWeightSpecs. Classes ------- .. autoapisummary:: mt_metadata.features.weights.channel_weight_spec.CombinationStyleEnum mt_metadata.features.weights.channel_weight_spec.ChannelWeightSpec Module Contents --------------- .. py:class:: CombinationStyleEnum Bases: :py:obj:`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'. .. py:attribute:: multiplication :value: 'multiplication' .. py:attribute:: minimum :value: 'minimum' .. py:attribute:: maximum :value: 'maximum' .. py:attribute:: mean :value: 'mean' .. py:class:: ChannelWeightSpec(**data) Bases: :py:obj:`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. .. attribute:: _skip_equals Private attribute listing fields to skip in equality comparisons :type: list[str] .. attribute:: _fields Private attribute caching field information :type: dict[str, Any] .. rubric:: 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 .. py:attribute:: combination_style :type: Annotated[CombinationStyleEnum, Field(default='multiplication', description='How to combine multiple feature weights.', alias=None, json_schema_extra={'units': None, 'required': True, 'examples': ['multiplication']})] .. py:attribute:: output_channels :type: Annotated[list[str], Field(default_factory=list, description='list of tf ouput channels for which this weighting scheme will be applied', alias=None, json_schema_extra={'units': None, 'required': True, 'examples': ['[ ex ey hz ]']})] .. py:attribute:: feature_weight_specs :type: Annotated[list[mt_metadata.features.weights.feature_weight_spec.FeatureWeightSpec], Field(default_factory=list, description='List of feature weighting schemes to use for TF processing.', alias=None, json_schema_extra={'units': None, 'required': True, 'examples': ['[]']})] .. py:attribute:: weights :type: Annotated[xarray.DataArray | xarray.Dataset | numpy.ndarray | None, Field(default=None, description='Weights computed for this channel weight spec. Should be set after evaluation.', json_schema_extra={'units': None, 'required': False, 'examples': ['null']})] .. py:method:: check_feature_weight_specs(value, info) :classmethod: .. py:method:: check_weights(value) :classmethod: .. py:method:: evaluate(feature_values_dict) Evaluate the channel weight by combining weights from all features. :param feature_values_dict: Dictionary mapping feature names to their computed values. e.g., {"coherence": ndarray, "multiple_coherence": ndarray} :type feature_values_dict: dict[str, np.ndarray | float] :returns: **channel_weight** :rtype: float or np.ndarray .. py:method:: get_weights_for_band(band) Extract weights for the frequency bin closest to the band's center frequency. TODO: Add tests. :param band: Should have a .center_frequency attribute (float, Hz). :type band: Band :returns: **weights** -- Weights for the closest frequency bin. :rtype: np.ndarray or xarray.DataArray