mt_metadata.processing.window ============================= .. py:module:: mt_metadata.processing.window .. autoapi-nested-parse:: Updated 2025-01-02: kkappler, adding methods to generate taper values. In future this class can replace ApodizationWindow in aurora. Classes ------- .. autoapisummary:: mt_metadata.processing.window.TypeEnum mt_metadata.processing.window.ClockZeroTypeEnum mt_metadata.processing.window.Window Functions --------- .. autoapisummary:: mt_metadata.processing.window.get_fft_harmonics Module Contents --------------- .. py:class:: TypeEnum 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:: boxcar :value: 'boxcar' .. py:attribute:: triang :value: 'triang' .. py:attribute:: blackman :value: 'blackman' .. py:attribute:: hamming :value: 'hamming' .. py:attribute:: hann :value: 'hann' .. py:attribute:: bartlett :value: 'bartlett' .. py:attribute:: flattop :value: 'flattop' .. py:attribute:: parzen :value: 'parzen' .. py:attribute:: bohman :value: 'bohman' .. py:attribute:: blackmanharris :value: 'blackmanharris' .. py:attribute:: nuttall :value: 'nuttall' .. py:attribute:: barthann :value: 'barthann' .. py:attribute:: kaiser :value: 'kaiser' .. py:attribute:: gaussian :value: 'gaussian' .. py:attribute:: general_gaussian :value: 'general_gaussian' .. py:attribute:: slepian :value: 'slepian' .. py:attribute:: chebwin :value: 'chebwin' .. py:attribute:: dpss :value: 'dpss' .. py:class:: ClockZeroTypeEnum 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:: user_specified :value: 'user specified' .. py:attribute:: data_start :value: 'data start' .. py:attribute:: ignore :value: 'ignore' .. py:class:: Window(**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:: num_samples :type: Annotated[int, Field(default=256, description='Number of samples in a single window', alias=None, json_schema_extra={'units': 'samples', 'required': True, 'examples': ['256']})] .. py:attribute:: overlap :type: Annotated[int, Field(default=32, description='Number of samples overlapped by adjacent windows', alias=None, json_schema_extra={'units': 'samples', 'required': True, 'examples': ['32']})] .. py:attribute:: type :type: Annotated[TypeEnum, Field(default=TypeEnum.boxcar, description='name of the window type', alias=None, json_schema_extra={'units': None, 'required': True, 'examples': ['hamming']})] .. py:attribute:: clock_zero_type :type: Annotated[ClockZeroTypeEnum, Field(default=ClockZeroTypeEnum.ignore, description='how the clock-zero is specified', alias=None, json_schema_extra={'units': None, 'required': True, 'examples': ['user specified']})] .. py:attribute:: clock_zero :type: Annotated[mt_metadata.common.mttime.MTime | str | float | int | numpy.datetime64 | pandas.Timestamp | None, Field(default_factory=lambda: MTime(time_stamp=None), description='Start date and time of the first data window', alias=None, json_schema_extra={'units': None, 'required': False, 'examples': ['2020-02-01T09:23:45.453670+00:00']})] .. py:attribute:: normalized :type: Annotated[bool, Field(default=True, description='True if the window shall be normalized so the sum of the coefficients is 1', validation_alias=AliasChoices('normalised', 'normalized'), json_schema_extra={'units': None, 'required': True, 'examples': [False]})] .. py:attribute:: additional_args :type: Annotated[dict, Field(default_factory=dict, description='Additional arguments for the window function', json_schema_extra={'units': None, 'required': False, 'examples': [{'param': 'value'}]})] .. py:method:: validate_clock_zero(field_value) :classmethod: .. py:property:: num_samples_advance :type: int .. py:method:: fft_harmonics(sample_rate) Returns the frequencies for an fft.. :param sample_rate: :return: .. py:method:: taper() Get's the window coeffcients. via wrapper call to scipy.signal Note: see scipy.signal.get_window for a description of what is expected in args[1:]. http://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.get_window.html .. py:function:: get_fft_harmonics(samples_per_window, sample_rate) Works for odd and even number of points. Development notes: - Could be modified with arguments to support one_sided, two_sided, ignore_dc ignore_nyquist, and etc. Consider taking FrequencyBands as an argument. - This function was in decimation_level, but there were circular import issues. The function needs only a window length and sample rate, so putting it here for now. - TODO: switch to using np.fft.rfftfreq :param samples_per_window: Number of samples in a window that will be Fourier transformed. :type samples_per_window: int :param sample_rate: Inverse of time step between samples; Samples per second in Hz. :type sample_rate: float :returns: **harmonic_frequencies** -- The frequencies that the fft will be computed. These are one-sided (positive frequencies only) Does _not_ return Nyquist Does return DC component :rtype: numpy array