tth_transform: Transform a two theta axis between wavelengths

Description Usage Arguments Value Examples

View source: R/tth_transform.R

Description

tth_transform converts the two theta axis from one wavelength to another via Bragg's law. Use this function with caution if intending the apply fps() or afps() to wavelength transformed samples or libraries because background signals can vary with wavelength which may therefore affect the quality of the fit.

Usage

1
tth_transform(tth, from, to)

Arguments

tth

the 2theta vector to be transformed

from

numeric value defining the wavelength (Angstroms) to transform from

to

numeric value defining the wavelength (Angstroms) to transform to

Value

a transformed 2theta vector

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
data(soils)
sandstone2 <- soils$sandstone

#Convert from Cu (1.54056 Angstroms) to Co (1.78897 Angstroms)
sandstone2$tth <- tth_transform(sandstone2$tth,
                                from = 1.54056,
                                to = 1.78897)

sandstone_list <- as_multi_xy(list("sandstone" = soils$sandstone,
                                   "sandstone2" = sandstone2))
#plot the change
plot(sandstone_list, wavelength = "Cu")

#Alternatively convert the 2theta axis of a library
data(minerals)

minerals2 <- minerals
minerals2$tth <- tth_transform(minerals2$tth,
                                from = 1.54056,
                                to = 1.78897)

#Plot the difference
plot(x = minerals$tth, y = minerals$xrd$QUA.1,
     type = "l", xlim = c(0, 85))
lines(x = minerals2$tth, y = minerals2$xrd$QUA.1,
      col = "red")

benmbutler/powdR documentation built on Nov. 29, 2021, 1:05 p.m.