Learn R Programming

AFM (version 1.2.0)

PSD1DAgainstFrequency: Calculate the 1D Power Spectral Density; returns a data table of PSD 1D and PSD 2D values against spatial frequencies. As mentionned in Sidick2009, this function calculates the PSD against spatial frequencies in 1D from PSD2DAgainstFrequency by using breaks in the log space to sum PSD 2D and frequency values.

Description

Calculate the 1D Power Spectral Density; returns a data table of PSD 1D and PSD 2D values against spatial frequencies. As mentionned in Sidick2009, this function calculates the PSD against spatial frequencies in 1D from PSD2DAgainstFrequency by using breaks in the log space to sum PSD 2D and frequency values.

Usage

PSD1DAgainstFrequency(AFMImage, AFMImagePSDAnalysis)

## S3 method for class 'AFMImage':
PSD1DAgainstFrequency(AFMImage, AFMImagePSDAnalysis)

Arguments

AFMImage
an AFMImage to be analysed
AFMImagePSDAnalysis
n AFMImagePSDAnalysis to store the setup and results of PSD analysis

Value

  • PSD1DAgainstFrequency returns a data table of frequencies and PSD values
    • freq: the considered frequency
    • PSD: the considered PSD value
    • type: PSD-1D
    • fullfilename: directory and filename on the disk

Examples

Run this code
library(AFM)
library(ggplot2)
library(plyr)
library(scales)

# Calculate the Power Spectral Density in one dimension
data("AFMImageOfNormallyDistributedHeights")
oneAFMImage<-AFMImageOfNormallyDistributedHeights
# using 32 breaks in the log space to calculate PSD 1D from PSD 2D
psd1d<-PSD1DAgainstFrequency(oneAFMImage, 32)
p <- ggplot(data=psd1d)
p <- p + geom_point(aes(freq, PSD, color=type),subset = .(type %in% c("PSD-2D")))
p <- p + geom_line(aes(freq, PSD, color=type),subset = .(type %in% c("PSD-1D")),size=1.1)
p <- p + scale_x_log10()
p <- p + scale_y_log10(  breaks = trans_breaks("log10", function(x) 10^x), 
                        labels = trans_format("log10", math_format(10^.x)))
p <- p + ylab("PSD (nm^4)")
p <- p + xlab("Frequency (nm^-1)")
p <- p + ggtitle(basename(oneAFMImage@fullfilename))
p

Run the code above in your browser using DataLab