diff --git a/dev/.documenter-siteinfo.json b/dev/.documenter-siteinfo.json index 5f7934f..e4c14a6 100644 --- a/dev/.documenter-siteinfo.json +++ b/dev/.documenter-siteinfo.json @@ -1 +1 @@ -{"documenter":{"julia_version":"1.6.7","generation_timestamp":"2024-07-22T15:50:21","documenter_version":"1.5.0"}} \ No newline at end of file +{"documenter":{"julia_version":"1.6.7","generation_timestamp":"2024-07-24T11:44:49","documenter_version":"1.5.0"}} \ No newline at end of file diff --git a/dev/array.html b/dev/array.html index c250ac7..fcbca5f 100644 --- a/dev/array.html +++ b/dev/array.html @@ -1,5 +1,5 @@ -Array signal processing · SignalAnalysis.jl

Array signal processing

SignalAnalysis.beamformMethod
beamform(s, f, n, sd; fs=framerate(s), method=Bartlett())
+Array signal processing · SignalAnalysis.jl

Array signal processing

SignalAnalysis.beamformMethod
beamform(s, f, n, sd; fs=framerate(s), method=Bartlett())
 beamform(s, f, sd; fs=framerate(s), method=Bartlett())

Narrowband frequency-domain beamformer. Takes in passband signals s and produces beamformer output for all directions specified by the steering delays sd. The beamformer output is an energy estimate (or equivalent) for each steering direction. The beamforming only uses a narrowband signal cenetered at frequency f with a bandwidth of about fs/n.

If n is not specified, or is 1, then the input signal is assumed to be narrowband, and centered at frequency f.

The narrowband assumption requires that the bandwidth be no greater than about 5/T, where T is the maximum time taken for a signal to propagate through the array.

Several beamforming methods are available:

Custom beamformers can be implemented by creating a subtype of SignalAnalysis.Beamformer and implementing the SignalAnalysis.beamformer() method dispatched on that type.

Example:

julia> x = cw(100.0, 1.0, 44100.0);
 julia> sd = steering(0.0:1.0:3.0, 1500.0, range(0.0, π; length=181));
 julia> bfo = beamform([x x x x], 100.0, 4096, sd; method=Capon(0.1))
@@ -7,11 +7,11 @@
  0.12406290296318974
  0.1240975045516605
  ⋮
- 0.12406290296318974
source
SignalAnalysis.beamformMethod
beamform(s, sd; fs=framerate(s))

Broadband time-domain delay-and-sum beamformer. Takes in passband or baseband signals s and produces beamformer output for all directions specified by the steering delays sd. The beamformer output is a timeseries signal for each steering direction.

Example:

julia> x = cw(100.0, 1.0, 44100.0);
+ 0.12406290296318974
source
SignalAnalysis.beamformMethod
beamform(s, sd; fs=framerate(s))

Broadband time-domain delay-and-sum beamformer. Takes in passband or baseband signals s and produces beamformer output for all directions specified by the steering delays sd. The beamformer output is a timeseries signal for each steering direction.

Example:

julia> x = cw(100.0, 1.0, 44100.0);
 julia> sd = steering(0.0:1.0:3.0, 1500.0, range(0.0, π; length=181));
 julia> bfo = beamform([x x x x], sd)
 SampledSignal @ 44100.0 Hz, 44100×181 Array{Complex{Float64},2}:
-  ⋮
source
SignalAnalysis.steeringMethod
steering(rxpos, c, θ)
 

Computes steering delays for specified receiver positions rxpos, signal propagation speed c, and angles θ. Array θ can be a 1D array of angles or 2D array with (azimuth, elevation) pair in each row. The delays are computed with a far-field assumption, i.e., for plane incoming waves.

Examples:

julia> steering(0.0:1.0:5.0, 1500.0, range(0.0, π; length=181))
 6×181 Array{Float64,2}:
   0.00166667    0.00166641   …  -0.00166641   -0.00166667
@@ -45,4 +45,4 @@
   9.80987e-5    9.83857e-5    9.86427e-5  …   0.00021154   0.000210989   0.000210373
   0.000210373   0.000210989   0.00021154      9.86427e-5   9.83857e-5    9.80987e-5
  -0.000210373  -0.000210989  -0.00021154     -9.86427e-5  -9.83857e-5   -9.80987e-5
- -9.80987e-5   -9.83857e-5   -9.86427e-5     -0.00021154  -0.000210989  -0.000210373
source
+ -9.80987e-5 -9.83857e-5 -9.86427e-5 -0.00021154 -0.000210989 -0.000210373
source
diff --git a/dev/basic.html b/dev/basic.html index ecbd4ed..69571ee 100644 --- a/dev/basic.html +++ b/dev/basic.html @@ -1,8 +1,8 @@ Basic signal analysis · SignalAnalysis.jl

Basic signal analysis

+

Computes total signal energy.

source
SignalAnalysis.ifrequencyMethod
ifrequency(s; fs)
+

Computes instantaneous frequency of the signal.

source
SignalAnalysis.meanfrequencyMethod
meanfrequency(s; fs, nfft, window)
+

Computes mean frequency of a signal.

source
SignalAnalysis.meantimeMethod
meantime(s)
+

Computes mean time of the signal.

source
SignalAnalysis.rmsbandwidthMethod
rmsbandwidth(s; fs, nfft, window)
+

Computes RMS bandwidth of a signal.

source
SignalAnalysis.rmsdurationMethod
rmsduration(s)
+

Computes RMS duration of the signal.

source
diff --git a/dev/dsp.html b/dev/dsp.html index 17d91e3..dac4a46 100644 --- a/dev/dsp.html +++ b/dev/dsp.html @@ -1,11 +1,11 @@ -Signal processing · SignalAnalysis.jl

Signal processing

DSP.filtMethod
filt(f, x::SampledSignal[, si])
-filt(b, a, x::SampledSignal[, si])

Same as filt, but retains sampling rate information.

source
SignalAnalysis.circconvFunction
circconv(x)
+Signal processing · SignalAnalysis.jl

Signal processing

DSP.filtMethod
filt(f, x::SampledSignal[, si])
+filt(b, a, x::SampledSignal[, si])

Same as filt, but retains sampling rate information.

source
SignalAnalysis.circconvFunction
circconv(x)
 circconv(x, y)
-

Computes the circular convolution of x and y. Both vectors must be the same length.

source
SignalAnalysis.composeMethod
compose(r, t, a; duration, fs)
+

Computes the circular convolution of x and y. Both vectors must be the same length.

source
SignalAnalysis.composeMethod
compose(r, t, a; duration, fs)
 

Compose a signal from a reference signal and a list of arrival times and amplitudes.

Examples:

julia> x = cw(10kHz, 0.01, 44.1kHz)
 julia> y1 = compose(x, [0.01, 0.03, 0.04], [1.0, 0.8, 0.6]; duration=0.05)
-julia> y2 = compose(real(x), [10ms, 30ms, 40ms], [1.0, 0.8, 0.6]; duration=50ms)
source
SignalAnalysis.delay!Method
delay!(x, v)

Delay signal x by v units. The delay may be specified in samples or in time units (e.g. 2.3𝓈). The function supports delays of fractional or negative number of samples. The length of the returned signal is the same as the original, with any part of the signal that is shifted beyond the original length discarded.

Examples:

julia> x = signal([1.0, 2.0, 3.0], 10.0)
+julia> y2 = compose(real(x), [10ms, 30ms, 40ms], [1.0, 0.8, 0.6]; duration=50ms)
source
SignalAnalysis.delay!Method
delay!(x, v)

Delay signal x by v units. The delay may be specified in samples or in time units (e.g. 2.3𝓈). The function supports delays of fractional or negative number of samples. The length of the returned signal is the same as the original, with any part of the signal that is shifted beyond the original length discarded.

Examples:

julia> x = signal([1.0, 2.0, 3.0], 10.0)
 julia> delay!(x, 1)
 SampledSignal @ 10.0 Hz, 3-element Vector{Float64}:
  0.0
@@ -35,16 +35,16 @@
   2.98570052268015
   1.870314441196549
   0.9057002486847239
- -0.06203155191384361
source
SignalAnalysis.demonMethod
demon(x; fs, downsample, method, cutoff)
-

Estimates DEMON spectrum. The output is highpass filtered with a cutoff frequency and downsampled. Supported downsampling methods are :rms (default), :mean and :fir.

source
SignalAnalysis.demonMethod
demon(x; fs, downsample, method, cutoff)
+

Estimates DEMON spectrum. The output is highpass filtered with a cutoff frequency and downsampled. Supported downsampling methods are :rms (default), :mean and :fir.

source
SignalAnalysis.downconvertFunction
downconvert(s, sps, fc)
 downconvert(s, sps, fc, pulseshape; fs)
-

Converts passband signal centered around carrier frequency fc to baseband, and downsamples it by a factor of sps. If the pulseshape is specified to be nothing, downsampling is performed without filtering.

source
SignalAnalysis.dztMethod
dzt(x, L, K)
+

Converts passband signal centered around carrier frequency fc to baseband, and downsamples it by a factor of sps. If the pulseshape is specified to be nothing, downsampling is performed without filtering.

source
SignalAnalysis.dztMethod
dzt(x, L, K)
 dzt(x, L)

Compute the discrete Zak transform (DZT) of signal x with L delay bins and K Doppler bins. The length of signal x must be equal to LK. If K is not specified, it is assumed to be the length of x divided by L. Returns a K × L complex matrix.

If the frame rate of x if fs Sa/s, the delay bins are spaced at 1/fs seconds and the Doppler bins are spaced at fs/LK Hz. The DZT is scaled such that the energy of the signal is preserved, i.e., sum(abs2, x) ≈ sum(abs2, X).

For efficient computation of the DZT, K should product of small primes.

Examples:

julia> x = randn(ComplexF64, 4096)
 4096-element Vector{ComplexF64}:
   :
 julia> X = dzt(x, 64)
 64×64 Matrix{ComplexF64}:
-  :
source
SignalAnalysis.findsignalFunction
findsignal(r, s)
 findsignal(r, s, n; prominence, finetune, mingap, mfo)
 

Finds up to n strongest copies of reference signal r in signal s. The reference signal r should have a delta-like autocorrelation for this function to work well.

If the keyword parameter finetune is set to 0, approximate arrival times are computed based on a matched filter. If it is set to a positive value, an iterative optimization is performed to find more accruate arrival times within roughly finetune samples of the coarse arrival times.

The keyword parameter mingap controls the minimum number of samples between two arrivals.

Returns named tuple (time=t, amplitude=a, mfo=m) where t is a vector of arrival times, a is a vector of complex amplitudes of the arrivals, and m is the complex matched filter output (if keyword parameter mfo is set to true). The arrivals are sorted in ascending order of arrival times.

Examples:

julia> x = chirp(1000, 5000, 0.1, 40960; window=(tukey, 0.05))
 julia> x4 = resample(x, 4)
@@ -57,7 +57,7 @@
 julia> findsignal(x, y, 3)
 (time = [0.000781, 0.001538, 0.003125], amplitude = [...], mfo=[])
 julia> findsignal(x, y, 3; mfo=true)
-(time = [0.000775, 0.001545, 0.003124], amplitude = [...], mfo=[...])
source
SignalAnalysis.firFunction
fir(n, f1)
 fir(n, f1, f2; fs, method)
 

Designs a n-tap FIR filter with a passband from f1 to f2 using the specified method. If frame rate fs is not specified, f1 and f2 are given in normalized units (1.0 being Nyquist). If f1 is 0, the designed filter is a lowpass filter, and if f2 is nothing then it is a highpass filter.

This method is a convenience wrapper around DSP.digitalfilter.

Examples:

julia> lpf = fir(127, 0, 10kHz; fs=44.1kHz)   # design a lowpass filter
 127-element Array{Float64,1}:
@@ -69,7 +69,7 @@
 
 julia> bpf = fir(127, 1kHz, 5kHz; fs=44.1kHz) # design a bandpass filter
 127-element Array{Float64,1}:
-  ⋮
source
SignalAnalysis.gmseqFunction
gmseq(m)
 gmseq(m, θ)
 

Generates an generalized m-sequence of length 2^m-1 or tap specification m.

Generalized m-sequences are related to m-sequences but have an additional parameter θ. When θ = π/2, generalized m-sequences become normal m-sequences. When θ < π/2, generalized m-sequences contain a DC-component that leads to an exalted carrier after modulation. When θ is atan(√(2^m-1)), the m-sequence is considered to be period matched. Period matched m-sequences are complex sequences with perfect discrete periodic auto-correlation properties, i.e., all non-zero lag periodic auto-correlations are zero. The zero-lag autocorrelation is 2^m-1, where m is the shift register length.

This function currently supports shift register lengths between 2 and 30.

Examples:

julia> x = gmseq(3)         # generate period matched m-sequence
 7-element Array{Complex{Float64},1}:
@@ -89,8 +89,8 @@
  0.7071067811865476 - 0.7071067811865475im
  0.7071067811865476 + 0.7071067811865475im
  0.7071067811865476 - 0.7071067811865475im
- 0.7071067811865476 - 0.7071067811865475im
source
SignalAnalysis.goertzelMethod
goertzel(x, f, n; fs)
-

Detects frequency f in input signal using the Goertzel algorithm.

The detection metric returned by this function is the complex output of the Goertzel filter at the end of the input block. Typically, you would want to compare the magnitude of this output with a threshold to detect a frequency.

When a block size n is specified, the Goertzel algorithm in applied to blocks of data from the original time series.

source
SignalAnalysis.hadamardMethod
hadamard(i, k)

Generate a vector with the entries of row i of a Walsh-Hadamard matrix of size 2ᵏ × 2ᵏ. Rows are numbered from 0 to 2ᵏ-1, so that i = 1 is the first non-trivial (not all ones) Hadamard sequence.

source
SignalAnalysis.hadamardMethod
hadamard(k)

Generate a Walsh-Hadamard matrix of size 2ᵏ × 2ᵏ. Each row of the matrix is orthogonal to all other rows.

source
SignalAnalysis.goertzelMethod
goertzel(x, f, n; fs)
+

Detects frequency f in input signal using the Goertzel algorithm.

The detection metric returned by this function is the complex output of the Goertzel filter at the end of the input block. Typically, you would want to compare the magnitude of this output with a threshold to detect a frequency.

When a block size n is specified, the Goertzel algorithm in applied to blocks of data from the original time series.

source
SignalAnalysis.hadamardMethod
hadamard(i, k)

Generate a vector with the entries of row i of a Walsh-Hadamard matrix of size 2ᵏ × 2ᵏ. Rows are numbered from 0 to 2ᵏ-1, so that i = 1 is the first non-trivial (not all ones) Hadamard sequence.

source
SignalAnalysis.hadamardMethod
hadamard(k)

Generate a Walsh-Hadamard matrix of size 2ᵏ × 2ᵏ. Each row of the matrix is orthogonal to all other rows.

source
SignalAnalysis.idztMethod
idzt(X)
 

Compute the inverse discrete Zak transform (DZT) of 2D K × L complex signal X with L delay bins and K Doppler bins. The length of the returned signal is LK.

See dzt for more details.

Examples:

julia> x = randn(ComplexF64, 4096)
 4096-element Vector{ComplexF64}:
   :
@@ -98,7 +98,7 @@
 64×64 Matrix{ComplexF64}:
   :
 julia> idzt(X) ≈ x
-true
source
SignalAnalysis.istftMethod
istft(Real, X; nfft, noverlap, window)

Compute the inverse short time Fourier transform (ISTFT) of one-sided STFT coefficients X which is based on segments with nfft samples with overlap of noverlap samples. Refer to DSP.Periodograms.spectrogram for description of the parameters.

For perfect reconstruction, the parameters nfft, noverlap and window in stft and istft have to be the same, and the windowing must obey the constraint of "nonzero overlap add" (NOLA). Implementation based on Zhivomirov 2019 and istft in scipy.

Examples:

julia> x = randn(1024)
+true
source
SignalAnalysis.istftMethod
istft(Real, X; nfft, noverlap, window)

Compute the inverse short time Fourier transform (ISTFT) of one-sided STFT coefficients X which is based on segments with nfft samples with overlap of noverlap samples. Refer to DSP.Periodograms.spectrogram for description of the parameters.

For perfect reconstruction, the parameters nfft, noverlap and window in stft and istft have to be the same, and the windowing must obey the constraint of "nonzero overlap add" (NOLA). Implementation based on Zhivomirov 2019 and istft in scipy.

Examples:

julia> x = randn(1024)
 1024-element Array{Float64,1}:
  -0.7903319156212055
  -0.564789077302601
@@ -122,7 +122,7 @@
   ⋮
   2.6158861993992537
   1.2980813993011973
- -0.010592954871694371
source
SignalAnalysis.istftMethod
istft(Complex, X; nfft, noverlap, window)

Compute the inverse short time Fourier transform (ISTFT) of two-sided STFT coefficients X which is based on segments with nfft samples with overlap of noverlap samples. Refer to DSP.Periodograms.spectrogram for description of the parameters.

For perfect reconstruction, the parameters nfft, noverlap and window in stft and istft have to be the same, and the windowing must obey the constraint of "nonzero overlap add" (NOLA). Implementation based on Zhivomirov 2019 and istft in scipy.

Examples:

julia> x = randn(Complex{Float64}, 1024)
+ -0.010592954871694371
source
SignalAnalysis.istftMethod
istft(Complex, X; nfft, noverlap, window)

Compute the inverse short time Fourier transform (ISTFT) of two-sided STFT coefficients X which is based on segments with nfft samples with overlap of noverlap samples. Refer to DSP.Periodograms.spectrogram for description of the parameters.

For perfect reconstruction, the parameters nfft, noverlap and window in stft and istft have to be the same, and the windowing must obey the constraint of "nonzero overlap add" (NOLA). Implementation based on Zhivomirov 2019 and istft in scipy.

Examples:

julia> x = randn(Complex{Float64}, 1024)
 1024-element Array{Complex{Float64},1}:
   -0.5540372432417755 - 0.4286434695080883im
   -0.4759024596520576 - 0.5609424987802376im
@@ -140,8 +140,8 @@
  -0.47590245965205774 - 0.5609424987802374im
                       ⋮
   -0.2649395958422591 - 0.28333817822701474im
-  -0.5294529732365809 + 0.7345044619457455im
source
SignalAnalysis.mseqFunction
mseq(m)
 mseq(m, θ)
 

Generates an m-sequence of length 2^m-1 or tap specification m.

m-sequences are sequences of +1/-1 values with near-perfect discrete periodic auto-correlation properties. All non-zero lag periodic auto-correlations are -1. The zero-lag autocorrelation is 2^m-1, where m is the shift register length.

This function currently supports shift register lengths between 2 and 30.

If specification m is provided, it should be a list of taps for the shift register. List of known m-sequence taps can be found in books or online.

Examples:

julia> x = mseq(3)                  # generate regular m-sequence
 7-element Array{Float64,1}:
@@ -161,16 +161,16 @@
  -1.0
   1.0
  -1.0
- -1.0
source
SignalAnalysis.pllFunction
pll(x)
 pll(x, fc)
 pll(x, fc, bandwidth; fs)
-

Phased-lock loop to track carrier frequency (approximately fc) in the input signal. If fc is not specified, the algorithm will attempt to track the dominant frequency.

source
SignalAnalysis.rcosfirFunction
rcosfir(β, sps)
+

Phased-lock loop to track carrier frequency (approximately fc) in the input signal. If fc is not specified, the algorithm will attempt to track the dominant frequency.

source
SignalAnalysis.removedc!Method
removedc!(s; α)
-

DC removal filter. Parameter α controls the cutoff frequency. Implementation based on Lyons 2011 (3rd ed) real-time DC removal filter in Fig. 13-62(d).

See also: removedc

source
SignalAnalysis.removedcMethod
removedc(s; α)
-

DC removal filter. Parameter α controls the cutoff frequency. Implementation based on Lyons 2011 (3rd ed) real-time DC removal filter in Fig. 13-62(d).

See also: removedc!

source
SignalAnalysis.removedc!Method
removedc!(s; α)
+

DC removal filter. Parameter α controls the cutoff frequency. Implementation based on Lyons 2011 (3rd ed) real-time DC removal filter in Fig. 13-62(d).

See also: removedc

source
SignalAnalysis.removedcMethod
removedc(s; α)
+

DC removal filter. Parameter α controls the cutoff frequency. Implementation based on Lyons 2011 (3rd ed) real-time DC removal filter in Fig. 13-62(d).

See also: removedc!

source
SignalAnalysis.upconvertFunction
upconvert(s, sps, fc)
 upconvert(s, sps, fc, pulseshape; fs)
-

Converts baseband signal with sps symbols per passband sample to a real passband signal centered around carrier frequency fc.

source
SignalAnalysis.whitenMethod
whiten(x; nfft, noverlap, window, γ)
-

Spectral whitening of input signal x in the frequency domain. The parameters nfft, noverlap and window are required for the computation of STFT coefficients of x. Refer to DSP.Periodograms.spectrogram for description of the parameters. γ is a scaling or degree-of-flattening factor. The algorithm is based on Lee 1986.

source
+

Converts baseband signal with sps symbols per passband sample to a real passband signal centered around carrier frequency fc.

source
SignalAnalysis.whitenMethod
whiten(x; nfft, noverlap, window, γ)
+

Spectral whitening of input signal x in the frequency domain. The parameters nfft, noverlap and window are required for the computation of STFT coefficients of x. Refer to DSP.Periodograms.spectrogram for description of the parameters. γ is a scaling or degree-of-flattening factor. The algorithm is based on Lee 1986.

source
diff --git a/dev/generate.html b/dev/generate.html index 1c0cb63..9920d44 100644 --- a/dev/generate.html +++ b/dev/generate.html @@ -11,7 +11,7 @@ julia> x = chirp(5kHz, 7kHz, 100ms, 44.1kHz; shape=:hyperbolic, window=(tukey,0.05)) SampledSignal @ 44100.0 Hz, 4410-element Array{Complex{Float64},1}: - ⋮source
SignalAnalysis.cwMethod
cw(freq, duration, fs; phase, window)
+  ⋮
source
SignalAnalysis.cwMethod
cw(freq, duration, fs; phase, window)
 

Generates a sinusoidal signal with specified freq and duration at frame rate fs. The starting phase and window type may be optionally specified.

Examples:

julia> x = cw(5kHz, 200ms, 44.1kHz)
 SampledSignal @ 44100.0 Hz, 8820-element Array{Complex{Float64},1}:
   ⋮
@@ -22,4 +22,4 @@
 
 julia> x = cw(-5kHz, 200ms, 44.1kHz; phase=45°, window=(tukey, 0.05))
 SampledSignal @ 44100.0 Hz, 8820-element Array{Complex{Float64},1}:
-  ⋮
source
+ ⋮source diff --git a/dev/index.html b/dev/index.html index b030258..f0aa08a 100644 --- a/dev/index.html +++ b/dev/index.html @@ -1,2 +1,2 @@ -Home · SignalAnalysis.jl

SignalAnalysis.jl

Signal analysis toolbox for Julia

While a few great signal processing packages (e.g. DSP.jl, SignalOperators.jl) are available, they have limited time-frequency analysis, sonar analysis, and baseband analysis capabilities. This SignalAnalysis.jl package aims to fill that gap. The package has grown out of my research needs, but I hope to expand it over time to provide a wide variety of time-frequency analysis, and baseband signal processing tools.

While this package works with most array-like data types, it uses the SignalBase.jl API to represent multichannel 1D signals (time, frequency or spatial domain). While the package adopts a SampledSignal data type to carry sampling rate information with the sampled signal, the API design allows sampling rate to be provided as a keyword argument in most cases, enabling the user to pass in any array-like data.

APIs

+Home · SignalAnalysis.jl

SignalAnalysis.jl

Signal analysis toolbox for Julia

While a few great signal processing packages (e.g. DSP.jl, SignalOperators.jl) are available, they have limited time-frequency analysis, sonar analysis, and baseband analysis capabilities. This SignalAnalysis.jl package aims to fill that gap. The package has grown out of my research needs, but I hope to expand it over time to provide a wide variety of time-frequency analysis, and baseband signal processing tools.

While this package works with most array-like data types, it uses the SignalBase.jl API to represent multichannel 1D signals (time, frequency or spatial domain). While the package adopts a SampledSignal data type to carry sampling rate information with the sampled signal, the API design allows sampling rate to be provided as a keyword argument in most cases, enabling the user to pass in any array-like data.

APIs

diff --git a/dev/iplot.html b/dev/iplot.html index 0e7d381..01395ce 100644 --- a/dev/iplot.html +++ b/dev/iplot.html @@ -1,2 +1,2 @@ -Interactive plotting · SignalAnalysis.jl
+Interactive plotting · SignalAnalysis.jl
diff --git a/dev/plot.html b/dev/plot.html index 520080f..b7ed637 100644 --- a/dev/plot.html +++ b/dev/plot.html @@ -1,4 +1,4 @@ -Plot recipes · SignalAnalysis.jl

Plot recipes

Plot recipes are enabled by importing Plots:

using Plots

We provide a plot recipe to display signals:

plot(data::SampledSignal; t0=0.0, downsample=:auto, pooling=:auto, kwargs...)

Optional arguments:

  • t0=0.0: start time (for labeling only)
  • downsample=:auto: downsampling factor (integer or :auto)
  • pooling=:auto: pooling mode (:auto, :min, :max, :mean, :minmax, nothing or function)

If the signal is too long, it is automatically downsampled in a perceptually meaningful way. The downsampling can be controlled using the downsample and pooling keywords.

We also provide convenience plot recipes for common signal processing plots:

SignalAnalysis.psdFunction
psd(data; kwargs...)

Plots the power spectral density of data.

Optional keyword arguments

  • fs=1.0: derived from the data if a SampledSignal is provided as input
  • nfft=512: size of FFT window
  • noverlap=nfft÷2: window overlap size
  • window=hamming(nfft): accepts any window from DSP.jl
  • xscale=:auto: one of :auto, :identity or :log10
  • yrange=50: y-scale dB range for automatic scaling
  • other kwargs are passed on to plot
source
SignalAnalysis.specgramFunction
specgram(data; kwargs...)

Plots a spectrogram of the data.

Optional keyword arguments

  • fs=1.0: derived from the data if a SampledSignal is provided as input
  • nfft=256: size of FFT window
  • noverlap=nfft÷2: window overlap size
  • window=hamming(nfft): accepts any window from DSP.jl
  • t0=0.0: start time
  • downsample=:auto: downsampling factor (integer) for time axis
  • pooling=:mean: pooling mode (:min, :max, :mean, nothing or function)
  • crange=50: color scale dB range for automatic scaling
  • other kwargs are passed on to plot
source
SignalAnalysis.plotfreqrespFunction
plotfreqresp(filter; kwargs...)
+Plot recipes · SignalAnalysis.jl

Plot recipes

Plot recipes are enabled by importing Plots:

using Plots

We provide a plot recipe to display signals:

plot(data::SampledSignal; t0=0.0, downsample=:auto, pooling=:auto, kwargs...)

Optional arguments:

  • t0=0.0: start time (for labeling only)
  • downsample=:auto: downsampling factor (integer or :auto)
  • pooling=:auto: pooling mode (:auto, :min, :max, :mean, :minmax, nothing or function)

If the signal is too long, it is automatically downsampled in a perceptually meaningful way. The downsampling can be controlled using the downsample and pooling keywords.

We also provide convenience plot recipes for common signal processing plots:

SignalAnalysis.psdFunction
psd(data; kwargs...)

Plots the power spectral density of data.

Optional keyword arguments

  • fs=1.0: derived from the data if a SampledSignal is provided as input
  • nfft=512: size of FFT window
  • noverlap=nfft÷2: window overlap size
  • window=hamming(nfft): accepts any window from DSP.jl
  • xscale=:auto: one of :auto, :identity or :log10
  • yrange=50: y-scale dB range for automatic scaling
  • other kwargs are passed on to plot
source
SignalAnalysis.specgramFunction
specgram(data; kwargs...)

Plots a spectrogram of the data.

Optional keyword arguments

  • fs=1.0: derived from the data if a SampledSignal is provided as input
  • nfft=256: size of FFT window
  • noverlap=nfft÷2: window overlap size
  • window=hamming(nfft): accepts any window from DSP.jl
  • t0=0.0: start time
  • downsample=:auto: downsampling factor (integer) for time axis
  • pooling=:mean: pooling mode (:min, :max, :mean, nothing or function)
  • crange=50: color scale dB range for automatic scaling
  • other kwargs are passed on to plot
source
SignalAnalysis.plotfreqrespFunction
plotfreqresp(filter; kwargs...)
 plotfreqresp(num; kwargs...)
-plotfreqresp(num, den; kwargs...)

Plots frequency response of a digital filter.

Optional keyword arguments

  • fs=1.0: sampling frequency
  • nfreq=256: number of frequency points to evaluate filter response at
  • xscale=:auto: one of :auto, :identity or :log10
  • other kwargs are passed on to plot
source
+plotfreqresp(num, den; kwargs...)

Plots frequency response of a digital filter.

Optional keyword arguments

  • fs=1.0: sampling frequency
  • nfreq=256: number of frequency points to evaluate filter response at
  • xscale=:auto: one of :auto, :identity or :log10
  • other kwargs are passed on to plot
source
diff --git a/dev/rand.html b/dev/rand.html index e6b12f2..fcb691a 100644 --- a/dev/rand.html +++ b/dev/rand.html @@ -5,10 +5,10 @@ julia> rand(PinkGaussian(1000, 2.0)) 1000-element Array{Float64,1}: - ⋮source
SignalAnalysis.RedGaussianType
struct RedGaussian{T} <: Distributions.Distribution{Distributions.Multivariate, Distributions.Continuous}

Red Gaussian noise distribution for random variate generation.

Example:

julia> rand(RedGaussian(1000))
+   ⋮
source
SignalAnalysis.RedGaussianType
struct RedGaussian{T} <: Distributions.Distribution{Distributions.Multivariate, Distributions.Continuous}

Red Gaussian noise distribution for random variate generation.

Example:

julia> rand(RedGaussian(1000))
 1000-element Array{Float64,1}:
    ⋮
 
 julia> rand(RedGaussian(1000, 2.0))
 1000-element Array{Float64,1}:
-   ⋮
source
+ ⋮source diff --git a/dev/signals.html b/dev/signals.html index c4f63e3..93e51d1 100644 --- a/dev/signals.html +++ b/dev/signals.html @@ -24,7 +24,7 @@ -1.080437097803303 0.8209785486953832 1.3477512734963886 - -0.27722340584395494source
Base.Iterators.partitionMethod
partition(x::SampledSignal, n; step=n, flush=true)

Iterates over the signal x, n samples at a time, with a step size of step. If flush is enabled, the last partition may be smaller than n samples.

When applied to a multichannel signal x, each partition contains samples from all channels.

Examples:

julia> x = signal(collect(1:10), 1.0);
+ -0.27722340584395494
source
Base.Iterators.partitionMethod
partition(x::SampledSignal, n; step=n, flush=true)

Iterates over the signal x, n samples at a time, with a step size of step. If flush is enabled, the last partition may be smaller than n samples.

When applied to a multichannel signal x, each partition contains samples from all channels.

Examples:

julia> x = signal(collect(1:10), 1.0);
 julia> collect(partition(x, 5))
 2-element Array{SubArray{Int64,1,Array{Int64,1},Tuple{UnitRange{Int64}},true},1}:
  [1, 2, 3, 4, 5]
@@ -51,13 +51,13 @@
  2  12
  3  13
  4  14
- 5  15
source
Base.Libc.timeMethod
time(i, x::SampledSignal)

Gets the time of the ith sample in the signal. The index i can be a range or an array of indices.

source
SignalAnalysis.analyticMethod
analytic(s)
-

Converts a signal to analytic representation. The conversion preserves energy, i.e., to convert back to a real signal while conserving energy, multiply by √2.

source
SignalAnalysis.domainMethod
domain(x)
-

Returns the domain of the signal.

source
SignalAnalysis.isanalyticMethod
isanalytic(s)
-

Checks if a signal is analytic.

source
SignalAnalysis.issamerateMethod
issamerate(x, y)
-

Checks if two signals have the same sampling rate. If the sampling rate of a signal is unknown (because it is not a SampledSignal), it is assumed to have the same rate as the other signal.

source
SignalAnalysis.paddedMethod
padded(s::AbstractArray{T, 2}, padding; delay, fill) -> Any
-

Generates a padded view of a signal with optional delay/advance.

source
SignalAnalysis.paddedMethod
padded(s::AbstractArray{T, 1}, padding; delay, fill) -> Any
-

Generates a padded view of a signal with optional delay/advance.

source
SignalAnalysis.samerateasMethod
samerateas(x, y)
+ 5  15
source
Base.Libc.timeMethod
time(i, x::SampledSignal)

Gets the time of the ith sample in the signal. The index i can be a range or an array of indices.

source
SignalAnalysis.analyticMethod
analytic(s)
+

Converts a signal to analytic representation. The conversion preserves energy, i.e., to convert back to a real signal while conserving energy, multiply by √2.

source
SignalAnalysis.domainMethod
domain(x)
+

Returns the domain of the signal.

source
SignalAnalysis.isanalyticMethod
isanalytic(s)
+

Checks if a signal is analytic.

source
SignalAnalysis.issamerateMethod
issamerate(x, y)
+

Checks if two signals have the same sampling rate. If the sampling rate of a signal is unknown (because it is not a SampledSignal), it is assumed to have the same rate as the other signal.

source
SignalAnalysis.paddedMethod
padded(s::AbstractArray{T, 2}, padding; delay, fill) -> Any
+

Generates a padded view of a signal with optional delay/advance.

source
SignalAnalysis.paddedMethod
padded(s::AbstractArray{T, 1}, padding; delay, fill) -> Any
+

Generates a padded view of a signal with optional delay/advance.

source
SignalAnalysis.samerateasMethod
samerateas(x, y)
 

Create a signal with samples y and sampling rate same as signal x.

Examples:

julia> x = signal(randn(100), 8kHz)
 julia> y = samerateas(x, randn(5))
 SampledSignal @ 8000.0 Hz, 5-element Vector{Float64}:
@@ -65,7 +65,7 @@
  -0.5474123820044299
  -0.6916442204609657
  -0.5185296405433826
- -0.4598263144701988
source
SignalAnalysis.samerateasMethod
samerateas(x)
+ -0.4598263144701988
source
SignalAnalysis.samerateasMethod
samerateas(x)
 

Create a signal with the same sampling rate as signal x.

Examples:

julia> x = signal(randn(100), 8kHz)
 julia> y = samerateas(x)(randn(5))
 SampledSignal @ 8000.0 Hz, 5-element Array{Float64,1}:
@@ -73,35 +73,35 @@
  -0.665143340284631
  -0.3955367460364236
  0.8209785486953832
- 1.3477512734963886
source
SignalAnalysis.samplesMethod
samples(s)
-

Gets the underlying samples in the signal.

source
SignalAnalysis.signalMethod
signal(x::AbstractArray, fs) -> Any
-

Creates a signal with frame rate fs.

source
SignalAnalysis.signalMethod
signal(filename::AbstractString; start, nsamples) -> Any
-

Loads a signal from a WAV file.

source
SignalAnalysis.signalMethod
signal(fs) -> Any
-

Creates a curried function that takes in an array and creates a signal with sampling rate fs.

source
SignalAnalysis.signalMethod
signal(
+ 1.3477512734963886
source
SignalAnalysis.samplesMethod
samples(s)
+

Gets the underlying samples in the signal.

source
SignalAnalysis.signalMethod
signal(x::AbstractArray, fs) -> Any
+

Creates a signal with frame rate fs.

source
SignalAnalysis.signalMethod
signal(filename::AbstractString; start, nsamples) -> Any
+

Loads a signal from a WAV file.

source
SignalAnalysis.signalMethod
signal(fs) -> Any
+

Creates a curried function that takes in an array and creates a signal with sampling rate fs.

source
SignalAnalysis.signalMethod
signal(
     n::Int64,
     fs
 ) -> MetaArrays.MetaArray{Vector{Float64}, SignalAnalysis.SamplingInfo, Float64, 1}
-

Creates an empty signal of length n samples, and frame rate fs.

source
SignalAnalysis.signalMethod
signal(
+

Creates an empty signal of length n samples, and frame rate fs.

source
SignalAnalysis.signalMethod
signal(
     n::Int64,
     ch::Int64,
     fs
 ) -> MetaArrays.MetaArray{Matrix{Float64}, SignalAnalysis.SamplingInfo, Float64, 2}
-

Creates an empty signal of length n samples, ch channels, and frame rate fs.

source
SignalAnalysis.signalMethod
signal(
+

Creates an empty signal of length n samples, ch channels, and frame rate fs.

source
SignalAnalysis.signalMethod
signal(
     x::MetaArrays.MetaArray{var"#s2", SignalAnalysis.SamplingInfo, T, N} where {T, var"#s2", N},
     fs
 ) -> Any
-

Creates a signal with frame rate fs. If the original signal's frame rate is the same as fs, this method simply returns the original signal. Otherwise, it creates a new signal with the specified frame rate and data from the original signal. Do note that this method does not resample the signal.

source
SignalAnalysis.signalMethod
signal(
+

Creates a signal with frame rate fs. If the original signal's frame rate is the same as fs, this method simply returns the original signal. Otherwise, it creates a new signal with the specified frame rate and data from the original signal. Do note that this method does not resample the signal.

source
SignalAnalysis.signalMethod
signal(
     T::Type,
     n::Int64,
     fs
 ) -> MetaArrays.MetaArray{_A, SignalAnalysis.SamplingInfo, _B, 1} where {_A, _B}
-

Creates an empty signal of type T, length n samples, and frame rate fs.

source
SignalAnalysis.signalMethod
signal(
+

Creates an empty signal of type T, length n samples, and frame rate fs.

source
SignalAnalysis.signalMethod
signal(
     T::Type,
     n::Int64,
     ch::Int64,
     fs
 ) -> MetaArrays.MetaArray{_A, SignalAnalysis.SamplingInfo, _B, 2} where {_A, _B}
-

Creates an empty signal of type T, length n samples, ch channels, and frame rate fs.

source
SignalAnalysis.toframeMethod
toframe(t, s::SampledSignal)
+

Creates an empty signal of type T, length n samples, ch channels, and frame rate fs.

source
SignalAnalysis.toframeMethod
toframe(t, s::SampledSignal)
 toframe(t, fs)

Converts time to signal frame number.

Examples:

julia> x = signal(randn(2000), 8kHz);
 julia> toframe(0.2𝓈, x)
 1601
@@ -128,4 +128,4 @@
   1601
   1681
   1761
-   ⋮
source
+ ⋮source diff --git a/dev/tfa.html b/dev/tfa.html index 5d2287d..a9cbec4 100644 --- a/dev/tfa.html +++ b/dev/tfa.html @@ -9,7 +9,7 @@ julia> y = tfd(x, Spectrogram()); julia> plot(y) julia> y = tfd(x, Spectrogram(nfft=512, noverlap=256, window=hamming)); -julia> plot(y)source
SignalAnalysis.tfdMethod
tfd(
+julia> plot(y)
source
SignalAnalysis.tfdMethod
tfd(
     s,
     kernel::Wigner;
     onesided,
@@ -19,4 +19,4 @@
 julia> y = tfd(x, Wigner());
 julia> plot(y; clim=(0,20))
 julia> y = tfd(x, Wigner(nfft=512, smooth=10, method=:CM1980, window=hamming));
-julia> plot(y; clim=(0,20))
source
+julia> plot(y; clim=(0,20))source