ProjectField <- function(ano, eof, mode = 1) {
  nlon <- dim(ano)[6]
  nlat <- dim(ano)[5]
  nyr <- dim(ano)[3]
  lt <- dim(ano)[4]
  nfc <- dim(ano)[2]
  nmod <- dim(ano)[1]
  
  # Security checks.
  if (dim(eof$EOFs)[2] != nlat) {
    stop("Inconsistent number of latitudes between eof and input field")
  }
  if (dim(eof$EOFs)[3] != nlon) {
    stop("Inconsistent number of longitudes between eof and input field")
  }
  
  # Initialization of pc.ver.
  pc.ver <- array(NA, dim = c(nmod, nfc, nyr, lt))
  
  # Weigths
  e.1 <- eof$EOFs[mode, , ] * eof$wght
  ano <- ano * InsertDim(InsertDim(InsertDim(InsertDim(eof$wght, 
    1, nmod), 2, nfc), 3, nyr), 4, lt)
  
  for (imo in 1:nmod) {
    for (im in 1:nfc) {
      for (iy in 1:nyr) {
        for (il in 1:lt) {
          if (!all(is.na(ano[imo, im, iy, il, , ]))) {
          pc.ver[imo, im, iy, il] <- sum(ano[imo, im, 
            iy, il, , ] * e.1, na.rm = TRUE)
          }
        }
      }
    }
  }
  
  return(list(PC = pc.ver))
}

