17、土壤光谱转移与转换方法详解

土壤光谱转移与转换方法详解

1. 土壤光谱测量面临的问题

在土壤光谱测量领域,不同实验室对于同一材料的测量协议往往存在差异。即便使用相同的光谱仪或传感器,不同的制造商也可能导致记录的光谱出现额外的变化。随着土壤光谱从业者数量的增加以及可用光谱仪的增多,这些问题变得愈发突出。尽管已经建立了一些土壤光谱库,但库的共享并不普遍,这使得协作工作难以协调。而且,在一个实验室校准的土壤光谱推断模型,很可能不适用于另一个实验室收集的光谱。

为了解决这些问题,需要遵循一定的最低要求和测量协议,以确保在实验室中对光谱进行一致的测量。然而,由于扫描协议、光照条件、仪器设置、传感器或白色参考等因素,不同光谱仪对同一土壤样品可能会产生不同的反射光谱。此外,土壤湿度等外部因素也会影响光谱,在建模时需要考虑这些因素。

1.1 所需包的安装

在进行后续操作之前,需要安装一些必要的包,代码如下:

# specify all the packages used in the chapter and install them if they are not already
myPackages <- c("Cubist", "lattice", "prospectr", "RcppArmadillo",
"pls", "MASS")
# define which packages are not installed in the current computer
notInstalled <- myPackages[!(myPackages %in% installed.packages()[ , "Package"])]
# install the missing packages
if(length(notInstalled)) install.packages(notInstalled)

2. 使用标准样品进行仪器间的光谱转移

2.1 标准样品的选择与特性

测量标准化方法在数据整理项目中较为常见。内部土壤标准(ISS)方法源于湿化学学科,被用于土壤光谱研究。理想的 ISS 应具备价格低廉、使用简单、易于海外运输、均匀性好、时空稳定性强等特点,并且在整个光谱区域具有稳定的光谱性能,其粒度应尽可能与土壤相似。Ben Dor 等人(2015)提出了一些符合这些标准的 ISS 样品,如位于澳大利亚西南部 Wylie 湾(WB)和 Lucky 湾(LB)海岸线的明亮、均匀的沙丘样品。

2.2 光谱收集与对齐步骤

以下是使用标准样品进行光谱标准化的关键步骤:
1. 数据加载

require(soilspec)
# load the package data
data("datStand")
# show the content of the data
names(datStand)
  1. 基准光谱展示
# take data for this section
CSIROs <- datStand$CSIRO.s
# take the wavelength
wavelength <- as.numeric(colnames(CSIROs))
#Make plot
matplot(wavelength, t(CSIROs),
type= "l",
ylab = "Reflectance",
xlab = "Wavelength /nm",
ylim = c(0.2, 1.2),
lty = 1)
# add a legend
legend("topleft",
legend = c("Lucky Bay", "Wilie Bay"),
lty = c(1, 1),
col = c("black", "red"))
  1. 不同仪器光谱收集 :使用 Analytical Spectral Devices (ASD) AgricSpecTM 光谱辐射计和 Spectral Evolution PSR + 3500 便携式光谱辐射计对 Lucky 湾的 ISS 材料进行测量,光谱数据保存于 datStand$ISS_subordinates
# take the data
ISSsubordinates <- datStand$ISS_subordinates
# plot the benchmark spectra
plot(wavelength, CSIROs[1,],
type= "l",
ylab="Reflectance",
ylim = c(0.5, 1.2),
xlab = "Wavelength /nm")
# add line for ASD instrument
lines(wavelength, ISSsubordinates[1,2:ncol(ISSsubordinates)],
col="red")
# add line for Spectral Evolution instrument
lines(wavelength, ISSsubordinates[2,2:ncol(ISSsubordinates)],
col="blue")
# add a legend
legend("topleft",
legend = c("Lucky Bay", "ASD", "Spectral Evolution"),
lty = c(1, 1),
col = c("black", "red", "blue"))
  1. 光谱对齐
    • 计算校正因子:
# correction factors for ASD instrument
xSub1 <- ISSsubordinates[1,2:ncol(ISSsubordinates)]
ASDcf <- 1- ((xSub1 - CSIROs[1,])/xSub1)
# correction factors for Spectral Evolution instrument
xSub2 <- ISSsubordinates[2,2:ncol(ISSsubordinates)]
seCf <- 1- ((xSub2 - CSIROs[1,])/xSub2)
# plot correction factors for ASD instrument
plot(wavelength, ASDcf,
type = "l",
ylab = "Correction factor",
xlab = "Wavelength /nm",
col = "red",
ylim = c(0.9,1.3))
# plot correction factors for Spectral Evolution instrument
lines(wavelength, seCf,
col = "blue")
# add a legend
legend("topleft",
legend = c("ASD", "Spectral Evolution"),
lty = c(1, 1),
col = c("red", "blue"))
- 使用校正因子对齐光谱:
# align ASD spectra
asd.a <- xSub1 * ASDcf
# align Spectral Evolution spectra
se.a <- xSub2 * seCf
# difference between benchmark and ASD spectra
sum(abs(CSIROs[1,] - asd.a))
# difference between benchmark and Spectra Evolution spectra
sum(abs(CSIROs[1,] - se.a))
  1. 土壤样品光谱处理 :两个土壤样品 HVb21 和 HVd13 分别由两种仪器扫描,使用之前计算的校正因子对光谱进行对齐。
# rename the datasets
asdSoil <- datStand$asd.soil
seSoil <- datStand$se.soil
# plot spectrum of first sample scanned by ASD
plot(wavelength, asdSoil[1,2:ncol(asdSoil)],
type = "l",
ylim = c(0, 0.5),
col = "red",
ylab ="Reflectance",
xlab = "Wavelength /nm")
# spectral Evolution measured
lines(wavelength, seSoil[1,2:ncol(seSoil)],
col = "blue")
# add a legend
legend("topleft",
legend = c("ASD", "Spectral Evolution"),
lty = c(1, 1),
col = c("red", "blue"))
# plot spectrum of first sample scanned by ASD
plot(wavelength, asdSoil[2,2:ncol(asdSoil)],
type = "l",
ylim = c(0, 0.6),
col = "red",
ylab = "Reflectance",
xlab = "Wavelength /nm")
# spectral Evolution measured
lines(wavelength, seSoil[2,2:ncol(seSoil)],
col="blue")
# add a legend
legend("topleft",
legend = c("ASD", "Spectral Evolution"),
lty = c(1, 1),
col = c("red", "blue"))
# alignment sample 1 (HVb21)
alignSam1Asd <- asdSoil[1,2:ncol(asdSoil)] * ASDcf
alignSam1Se <- seSoil[1,2:ncol(seSoil)] * seCf
# plotting the aligned ASD spectrum
plot(wavelength, alignSam1Asd,
type = "l",
col = "red",
ylim = c(0, 0.5),
ylab = "Reflectance",
xlab = "Wavelength /nm")
# adding line for the aligned Spectra Evolution spectrum
lines(wavelength, alignSam1Se,
col = "blue")
# add a legend
legend("topleft",
legend = c("ASD", "Spectral Evolution"),
lty = c(1, 1),
col = c("red", "blue"))
# alignment sample 2 (HVd13)
alignSam2Asd <- asdSoil[2,2:ncol(asdSoil)] * ASDcf
alignSam2Se <- seSoil[2,2:ncol(seSoil)] * seCf
# plotting the aligned ASD spectrum
plot(wavelength, alignSam2Asd,
type = "l",
ylim = c(0, 0.6),
col = "red",
ylab = "Reflectance",
xlab = "Wavelength /nm")
# adding line for the aligned Spectra Evolution spectrum
lines(wavelength, alignSam2Se,
col = "blue")
# add a legend
legend("topleft",
legend = c("ASD", "Spectral Evolution"),
lty = c(1, 1),
col = c("red", "blue"))

1.2 操作流程总结

步骤 操作内容
1 安装所需包
2 加载数据
3 展示基准光谱
4 收集不同仪器光谱
5 计算校正因子
6 使用校正因子对齐光谱
7 处理土壤样品光谱

1.3 操作流程 mermaid 流程图

graph LR
    A[安装所需包] --> B[加载数据]
    B --> C[展示基准光谱]
    C --> D[收集不同仪器光谱]
    D --> E[计算校正因子]
    E --> F[使用校正因子对齐光谱]
    F --> G[处理土壤样品光谱]

3. 直接标准化方法

3.1 直接标准化的原理与应用场景

前面介绍的使用标准样品的方法主要校正反射率的偏移,无法处理不同仪器中光谱的变窄或变宽问题。直接标准化(DS)方法是一种更通用的光谱标准化方法,由 Wang 等人(1991)提出,可用于校正影响光谱的其他外部因素。

3.2 直接标准化的操作步骤

在这个例子中,假设 spectra1snv spectra0snv 来自两个不同的仪器,其中 spectra0Snv 是参考仪器的光谱, spectra1Snv 是需要标准化的从属仪器的光谱。这两组光谱是 soilspec 包中 datEPO 数据集的预处理光谱。
1. 数据加载与预处理

# load the required packages
require(soilspec)
require(prospectr)
# load the EPO dataset from the soilspec package
data("datEPO")
# take the data from EPO, as an example between subordinate and reference spectra
spectra0 <- datEPO$spectra0
spectra1 <- datEPO$spectra1
# apply Savitzky - Golay filter
spectra0_sg <- savitzkyGolay(spectra0, w = 11, p = 2, m = 0)
spectra1_sg <- savitzkyGolay(spectra1, w = 11, p = 2, m = 0)
# resample the spectra
new.wavs <- seq(500, 2450, by = 1)
spectra0_rs <- prospectr::resample(spectra0_sg,
wav = as.numeric(colnames(spectra0_sg)),
new.wav = new.wavs,
interpol = "linear")
spectra1_rs <- prospectr::resample(spectra1_sg,
wav = as.numeric(colnames(spectra1_sg)),
new.wav = new.wavs,
interpol = "linear")
# apply a standard normal variate transformation for baseline correction
spectra0Snv <- standardNormalVariate(spectra0_rs)
spectra1Snv <- standardNormalVariate(spectra1_rs)
# define the samples scanned in both instruments
referenceSpecSub <- spectra0Snv[1:20,]
subordinateSpecSub <- spectra1Snv[1:20,]
# the unstandardized spectra are called subordinateSpec
referenceSpec <- spectra0Snv
subordinateSpec <- spectra1Snv
# plot the reference and subordinate spectra used to build the transfer function
matplot(colnames(referenceSpecSub), t(referenceSpecSub),
main = " ",
xlab = "Wavelength /nm",
ylab = "Absorbance",
type = "l",
col = "blue",
lty = 1)
# add the subordinate spectra to the plot
matlines(colnames(subordinateSpecSub), t(subordinateSpecSub),
col="pink")
# add a legend
legend("topright",
legend = c("reference", "subordinate"),
lty = c(1, 1),
col = c("blue", "pink"))
  1. 计算转换矩阵
# define the DS function
DS <- function(reference, subordinate){
# load the required package
library(MASS)
# subordinateI is the generalized inverse of spectra Xs
subordinateI = ginv(subordinate)
# T is the transformation matrix from Xs to Xm
P = subordinateI%*%reference
return(P)
}
P <- DS(reference = referenceSpecSub, subordinate = subordinateSpecSub)
  1. 应用转换矩阵进行光谱转移
Dspec <- as.matrix(subordinateSpec) %*% P
# plot the reference and standardized subordinate spectra via DS
matplot(colnames(referenceSpec), t(referenceSpec),
xlab = "Wavelength /nm",
ylab = "Absorbance",
type = "l",
col = "blue",
lty = 1)
# add the corrected subordinate spectra to the plot
matlines(colnames(Dspec), t(Dspec), col = "red")
# add a legend
legend("topright",
legend = c("reference", "corrected subordinate"),
lty = c(1, 1),
col = c("blue", "red"))

3.3 直接标准化的优缺点

DS 方法是一种简单的仪器间光谱转移方法,但转换矩阵 P 通常是一个超定系统,即参数数量大于观测数量。在这个例子中,矩阵 P 的大小为 1951,而只有 20 个观测值,这意味着在转换特定波长的光谱时,会使用整个光谱的信息。

3.4 操作流程总结

步骤 操作内容
1 加载所需包
2 加载 EPO 数据集
3 对光谱进行预处理
4 定义参考和从属光谱
5 绘制参考和从属光谱
6 定义 DS 函数并计算转换矩阵
7 应用转换矩阵进行光谱转移
8 绘制参考和标准化后的从属光谱

3.5 操作流程 mermaid 流程图

graph LR
    A[加载所需包] --> B[加载 EPO 数据集]
    B --> C[对光谱进行预处理]
    C --> D[定义参考和从属光谱]
    D --> E[绘制参考和从属光谱]
    E --> F[定义 DS 函数并计算转换矩阵]
    F --> G[应用转换矩阵进行光谱转移]
    G --> H[绘制参考和标准化后的从属光谱]

4. 分段直接标准化方法

4.1 分段直接标准化的原理

分段直接标准化(PDS)方法解决了直接标准化转换中的超定系统问题。直接标准化使用整个光谱来标准化特定波长,而 PDS 仅使用光谱上移动窗口定义的相邻值来转换特定波长的值,将转换矩阵 P 限制为带状矩阵。

4.2 分段直接标准化的操作步骤

PDS 仅计算矩阵 P 对角线上的转换系数。对于波长 i,通过线性回归确定转移函数,使用相邻值作为模型中的自变量。
1. 定义 PDS 函数

# define the PDS function
PDS <- function(reference, subordinate, ws, ncomp){
# load the required package
require(pls)
# define the variables
nc <- ncol(reference)
windowSize <- (ws -1)/2
k <- windowSize-1
# create an empty Transformation matrix P and Intercep matrix
P <- matrix(0, nrow = nc, ncol = nc-(2*windowSize)+2)
Intercep <- matrix(0, nrow = nc, ncol = 1)
np <- windowSize*2 # no parameters of PLSR
loop <- windowSize:(nc-k)
for(i in loop){
#PLS regression:
pls.mod <- plsr(reference[,i] ~ as.matrix(subordinate[,(i-k):(i+k)]), ncomp)
#extract PLSR coefficients
coefPLS <- as.numeric(coef(pls.mod, ncomp, intercept = TRUE))
# Save intercept
Intercep[i] <- coefPLS[1]
# Save coefficients to matrix P
P[(i-k):(i+k), i-k] <- t(coefPLS[2:np])
}
# account for the edges by adding 0 values
P <- data.frame(matrix(0,nrow = ncol(reference), ncol = k), P,
matrix(0, nrow = ncol(reference), ncol = k))
colnames(P) <- colnames(reference)
PDSpar <-list(P = P, Intercep = Intercep)
return(PDSpar)
}
  1. 应用 PDS 函数
# define the window size (must be odd number)
## note that here the spectra is resampled at every 5 nm
## so that a window size of 3 is equal to 15 nm
ws = 3
# apply the PDS function
PDSpar <- PDS(reference = referenceSpecSub,
subordinate = subordinateSpecSub,
ws,
ncomp = 1)
  1. 应用转换矩阵和截距进行光谱转换
# multiply spectra with transformation matrix
tSpec <- subordinateSpec %*% as.matrix(PDSpar$P)
# add to each row the intercept values
for (i in 1:nrow(tSpec)){
tSpec[i,] <- tSpec[i,] + as.numeric(t(PDSpar$Intercep))
}
  1. 绘制校正后的从属光谱
# plot the reference and subordinate spectra
matplot(as.numeric(colnames(referenceSpec)), t(referenceSpec),
col = "blue",
lty = 1,
xlab = "Wavelength /nm",
ylab = "Absorbance",
type = "l")
# add the corrected subordinate to the plot
matlines(as.numeric(colnames(tSpec)), t(tSpec),
col = "red")
# add a legend
legend("topright",
legend = c("reference", "corrected subordinate"),
lty = c(1, 1),
col = c("blue", "red"))

4.3 分段直接标准化的优势

PDS 方法通过局部转换,避免了使用整个光谱的信息,更适合处理超定系统问题,能够更准确地对光谱进行标准化。

4.4 操作流程总结

步骤 操作内容
1 定义 PDS 函数
2 定义窗口大小
3 应用 PDS 函数计算转换矩阵和截距
4 应用转换矩阵和截距进行光谱转换
5 绘制参考和校正后的从属光谱

4.5 操作流程 mermaid 流程图

graph LR
    A[定义 PDS 函数] --> B[定义窗口大小]
    B --> C[应用 PDS 函数计算转换矩阵和截距]
    C --> D[应用转换矩阵和截距进行光谱转换]
    D --> E[绘制参考和校正后的从属光谱]

综上所述,土壤光谱转移与转换方法在解决不同实验室光谱测量差异方面具有重要作用。使用标准样品、直接标准化和分段直接标准化等方法可以有效地对光谱进行标准化,提高光谱数据的可比性和模型的适用性。在实际应用中,需要根据具体情况选择合适的方法。

5. 三种方法的对比分析

5.1 方法对比表格

方法 原理 适用场景 优点 缺点
使用标准样品进行仪器间的光谱转移 使用已知的标准样品,通过计算校正因子来对齐不同仪器的光谱 适用于校正不同仪器反射率的偏移 操作相对简单,能有效校正反射率偏移 无法处理光谱的变窄或变宽问题
直接标准化(DS) 通过矩阵运算,将从属仪器的光谱转换为参考仪器的光谱 可用于校正影响光谱的其他外部因素 是一种通用的光谱标准化方法 转换矩阵通常是超定系统,参数数量大于观测数量
分段直接标准化(PDS) 仅使用光谱上移动窗口定义的相邻值来转换特定波长的值,将转换矩阵限制为带状矩阵 解决直接标准化转换中的超定系统问题 避免使用整个光谱信息,更适合处理超定系统问题 计算相对复杂

5.2 方法选择建议

  • 当主要关注反射率偏移校正时 :可以优先考虑使用标准样品进行仪器间的光谱转移方法。该方法操作简单,能快速有效地解决反射率不一致的问题。
  • 当需要校正光谱的其他外部因素,且不介意超定系统带来的问题时 :直接标准化方法是一个不错的选择。它具有更广泛的适用性,可以处理多种影响光谱的因素。
  • 当遇到直接标准化中的超定系统问题,需要更精确的光谱标准化时 :分段直接标准化方法更为合适。它通过局部转换,能更准确地对光谱进行标准化。

5.3 方法对比 mermaid 流程图

graph LR
    A[存在反射率偏移问题] --> B{是否需要处理光谱宽窄变化}
    B -- 否 --> C[使用标准样品进行仪器间的光谱转移]
    B -- 是 --> D{是否能接受超定系统问题}
    D -- 是 --> E[直接标准化(DS)]
    D -- 否 --> F[分段直接标准化(PDS)]

6. 实际应用案例分析

6.1 案例背景

假设一个研究团队需要对不同地区收集的土壤样品进行光谱分析,由于使用了不同的光谱仪,导致光谱数据存在差异。为了确保数据的可比性和模型的准确性,需要对光谱数据进行标准化处理。

6.2 应用步骤

  1. 数据收集 :团队使用了 ASD 和 Spectral Evolution 两种光谱仪对土壤样品进行扫描,同时收集了 Lucky 湾的标准样品光谱数据。
  2. 方法选择 :根据实际情况,团队首先尝试使用标准样品进行仪器间的光谱转移方法,发现该方法能有效校正反射率偏移,但对于光谱的宽窄变化处理效果不佳。于是,团队决定采用分段直接标准化方法进行进一步处理。
  3. 具体操作
    • 使用标准样品进行初步校正 :按照前面介绍的步骤,计算校正因子并对土壤样品光谱进行初步对齐。
    • 应用分段直接标准化方法
      • 定义 PDS 函数。
      • 根据光谱数据特点,定义合适的窗口大小(如 ws = 3)。
      • 应用 PDS 函数计算转换矩阵和截距。
      • 使用转换矩阵和截距对光谱进行转换。
      • 绘制参考和校正后的从属光谱,检查标准化效果。
  4. 结果评估 :通过对比标准化前后的光谱数据,发现分段直接标准化方法能够显著提高光谱数据的可比性。团队使用标准化后的光谱数据建立的土壤性质推断模型,其准确性和稳定性也得到了明显提升。

6.3 案例总结

在实际应用中,单一的方法可能无法完全满足需求,需要根据具体情况灵活选择和组合使用不同的方法。通过本案例可以看出,结合标准样品校正和分段直接标准化方法,能够有效解决不同仪器光谱测量差异问题,提高光谱数据的质量和模型的性能。

7. 未来发展趋势

7.1 技术融合趋势

未来,土壤光谱转移与转换技术可能会与其他先进技术(如机器学习、深度学习等)进行更深入的融合。例如,利用深度学习算法自动学习光谱数据的特征,进一步提高光谱标准化的准确性和效率。

7.2 多模态数据融合

随着传感器技术的发展,除了光谱数据,还可以获取土壤的其他多模态数据(如图像、雷达等)。未来的研究可能会将这些多模态数据进行融合,以更全面地了解土壤的性质和特征。

7.3 标准化体系的完善

为了促进土壤光谱数据的共享和协作,未来可能会建立更加完善的标准化体系。这包括统一的测量协议、标准样品库的建立和共享等,以确保不同实验室和研究团队之间的数据具有更高的可比性。

7.4 发展趋势 mermaid 流程图

graph LR
    A[土壤光谱转移与转换技术] --> B[与机器学习、深度学习融合]
    A --> C[多模态数据融合]
    A --> D[完善标准化体系]

8. 结论

土壤光谱转移与转换方法在解决不同实验室光谱测量差异方面具有重要意义。通过使用标准样品、直接标准化和分段直接标准化等方法,可以有效地对光谱进行标准化,提高光谱数据的可比性和模型的适用性。在实际应用中,需要根据具体情况选择合适的方法,并结合多种方法进行综合处理。未来,随着技术的不断发展,土壤光谱转移与转换技术将朝着更加智能化、多模态和标准化的方向发展。

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值