Learn R Programming

kzfs (version 1.0.1.5)

kzp2: Check Images' Motion Scales with 2D KZ Periodogram Signals

Description

Functions used to reveal directional and scale information with 2D KZ periodograms for spatial motions covered by heavy noises.

One can get 2D raw periodogram with function kzp2, and smooth the 2D periodogram with function smooth.kzp2.

Function summary.kzp2 can help to summarize direction and frequency information from smoothed 2D KZ periodogram.

Usage

kzp2(x, m = dim(x), k = 1, ...)

smooth.kzp2(rpg, dpct = 0.01, w = dim(rpg), k = 1)

kzp2.summary(spg, rg.x, rg.y = rg.x)

Arguments

x

Data array of 2D wave field. Missing values are allowed. Limited to 2D arrays for current version.

m

The window size for a regular Fourier transform. Default value is set to data array size.

k

The number of iterations for the KZFT. Default is 1.

...

Arguments to be passed to methods.

  • w : Smoothing window size. Defaults to data array size.

  • k : The number of iteration times of KZFT

  • n : The sampling frequency rate as a multiplication of the Fourier frequencies

  • p : The distance between two successive intervals as a percentage of the total length of the data series

rpg

Array of raw 2D periodogram. Usually it is part of output of kzp2.

dpct

A pre-specified percentage of total variation. Default value is 1%.

w

Smoothing window size. Defaults to data array dimension.

spg

Array of smoothed 2D periodogram. It could be output of summary.kzp2.

rg.x

Frequency range for x direction. Defaults to c(0, 0.5).

rg.y

Frequency range for y direction. Defaults to the same value of the range for x direction.

Value

Returned value of function kzp2 is a data list of periodogram information, including data array kzp2d for 2D periodogram values, and two frequency vectors, freq.x and freq.y for x and y direction, respectively.

smooth.kzp2 only outputs the array of smoothed values. kzp2.summary returns a data list for suggested wave paramenters, including frequecy and direction values.

Details

KZ 2D raw spectrum is calculated based on kz.ft. The smoothing method is an extension of kzft::smooth.kzp. See introduction of DZ method in kzft::smooth.kzp for more information.

See Also

kzpdr, kzpdr.eval, kzpdr.spikes

Examples

Run this code
dx <- 100				# x range
dy <- 120				# y range
b <- expand.grid(x=1:dx, y=1:dy)
q1 <- pi/6; f1 <- 0.2;
b$v1 <- sin(f1*2*pi*(b$x*cos(q1)+b$y*sin(q1))+100*runif(1))
q2 <- pi/4; f2 <- 0.08;
b$v2 <- sin(f2*2*pi*(b$x*cos(q2)+b$y*sin(q2))+100*runif(1))
a <- array(0,c(dx,dy))
a[as.matrix(b[,1:2])] <- b$v1 + 1.5*b$v2
a <- a + 10*matrix(rnorm(dx*dy,0,1),ncol=dy)

rp <- kzp2(a)			# raw 2D spectrum

fy <- rp$freq.y; fx <- rp$freq.x; rp <- rp$kzp2d

# smoothing 2D spectrum 2 times
sp <- smooth.kzp2(rp,0.01,k=2)	

par(mfrow=c(2,1), cex=0.5)
persp(x=fx, y=fy, z=rp, expand =0.5,
	main = "Raw 2D KZ Periodogram", ltheta=40, shade=0.75,
	theta=-30, phi=15, zlab="",xlab="x", ylab="y",
	ticktype="detailed", col="lightblue")

persp(x=fx, y=fy, z=sp, expand =0.5,
	main = "Smoothed 2D KZ Periodogram", ltheta=40, shade=0.75,
	theta=-30, phi=25, zlab="",xlab="x", ylab="y",
	ticktype="detailed", col="lightblue")
par(mfrow=c(1,1), cex=1)

kzp2.summary(sp)		# direction & frequency

Run the code above in your browser using DataLab