# load FieldSim library
library(FieldSim)
d<-function(x){ #Distance on the sphere
u <- x[1]*x[4]+x[2]*x[5]+x[3]*x[6]
if (u<(-1))
u<--1
if (u>1)
u<-1
acos(u)
}
# Example 1 : Fractional spherical field with RS1 covariance function
RS1<-function(x){
H<-0.45 # H can vary from 0 to 0.5
1/2*(d(c(1,0,0,x[1:3]))^{2*H}+d(c(1,0,0,x[4:6]))^{2*H}-d(x)^{2*H})
}
res1<- spheresim(RS1,Ne=100,Nr=1000,Ng=25,nbNeighbor=4)
library(rgl)
library(RColorBrewer)
printsphere(res1)
# Example 2 : Fractional spherical field with RS2 covariance function
RS2<-function(x){
H<-0.45 # H can vary from 0 to 0.5
exp(-d(x)^{2*H})
}
res2<- spheresim(RS2,Ne=100,Nr=1000,Ng=25,nbNeighbor=4)
printsphere(res2)
Run the code above in your browser using DataLab