R/aggregate.albedo.platform.R

Defines functions aggregate.albedo.platform

aggregate.albedo.platform <- function(albedo,bands){

  Nbands = (ncol(bands) - 1)

  albedo.band <- rep(NA,Nbands)
  names(albedo.band) <- colnames(bands)[2:(Nbands + 1)]

  WL.albedo <- as.numeric(names(albedo))
  WL.bands <- bands[,1]

  for (iband in seq(1,Nbands)){

    weights <- WL.albedo*0
    weights[WL.albedo %in% WL.bands] <- bands[WL.albedo %in% WL.bands,1 + iband]

    albedo.band[iband] <- weighted.mean(x = albedo,
                                        w = weights)
  }
  return(albedo.band)
}
femeunier/LianaRTM documentation built on Dec. 20, 2021, 7:50 a.m.