# Create 2D surface data
s <- seq(0, 1, length.out = 20)
t <- seq(0, 1, length.out = 20)
surface <- outer(sin(2*pi*s), cos(2*pi*t))
fd2d <- fdata(array(surface, dim = c(1, 20, 20)))
# Project to tensor product basis
coefs <- fdata2basis_2d(fd2d, nbasis.s = 7, nbasis.t = 7, type = "fourier")
Run the code above in your browser using DataLab