spectral

package
v0.0.0-...-11479a3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 8, 2018 License: ISC Imports: 5 Imported by: 13

Documentation

Overview

Package spectral provides spectral analysis functions for digital signal processing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Pwelch

func Pwelch(x []float64, Fs float64, o *PwelchOptions) (Pxx, freqs []float64)

Pwelch estimates the power spectral density of x using Welch's method. Fs is the sampling frequency (samples per time unit) of x. Fs is used to calculate freqs. Returns the power spectral density Pxx and corresponding frequencies freqs. Designed to be similar to the matplotlib implementation below. Reference: http://matplotlib.org/api/mlab_api.html#matplotlib.mlab.psd See also: http://www.mathworks.com/help/signal/ref/pwelch.html

func Segment

func Segment(x []float64, size, noverlap int) [][]float64

Segment x segmented into segments of length size with specified noverlap. Number of segments returned is (len(x) - size) / (size - noverlap) + 1.

Types

type PwelchOptions

type PwelchOptions struct {
	// NFFT is the number of data points used in each block for the FFT. Must be
	// even; a power 2 is most efficient. This should *NOT* be used to get zero
	// padding, or the scaling of the result will be incorrect. Use Pad for
	// this instead.
	//
	// The default value is 256.
	NFFT int

	// Window is a function that returns an array of window values the length
	// of its input parameter. Each segment is scaled by these values.
	//
	// The default (nil) is window.Hann, from the go-dsp/window package.
	Window func(int) []float64

	// Pad is the number of points to which the data segment is padded when
	// performing the FFT. This can be different from NFFT, which specifies the
	// number of data points used. While not increasing the actual resolution of
	// the psd (the minimum distance between resolvable peaks), this can give
	// more points in the plot, allowing for more detail.
	//
	// The value default is 0, which sets Pad equal to NFFT.
	Pad int

	// Noverlap is the number of points of overlap between blocks.
	//
	// The default value is 0 (no overlap).
	Noverlap int

	// Specifies whether the resulting density values should be scaled by the
	// scaling frequency, which gives density in units of Hz^-1. This allows for
	// integration over the returned frequency values. The default is set for
	// MATLAB compatibility. Note that this is the opposite of matplotlib style,
	// but with equivalent defaults.
	//
	// The default value is false (enable scaling).
	Scale_off bool
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL