Un po' alla volta. x Mauro: uso "diffract.r" che sono alcune classi in R.
www.visi.com/~mkoehler/optics_tools/Lo script che fa l'ultima animazione è questo:
size <- 101
t <- turb.ft(size*11,size*11)
t <- t/sd(as.vector (t))
t2 <- turb.ft(size*11,size*11)
t2 <- t2/sd(as.vector (t2))
p <- pupil(size)
p$obstruct(0.20)
step <- 4
step2 <- 2
nsteps <- floor((size*10)/step)
def=7
star <- star.test(p,def,size=100,pad=4,draw=FALSE)
zmax <- 2.5*max(star)
gamma <- 2.2
rmsi <- vector(mode="numeric",length=nsteps)
library("Cairo")
p$add.astig(0.07,1)
p$add.roughness(0.03,4)
p$add.micro(0.02)
for (i in 1:nsteps) {
istr=format(100000+i)
Cairo(paste("turbulence",istr,".png",sep=""), type="png", width=400, height=400)
tt <- 0.5*t[((i-1)*step+1) : ((i-1)*step+size),(size*1+1):(size*2)]+0.5*t2[((i-1)*step2+1) : ((i-1)*step2+size),(size*1+1):(size*2)]
rms <- sd(as.vector (tt))*2
rmsi[i] <- sd(as.vector(p$wf()),na.rm=TRUE)
p$set.turb2(tt,rms)
star <- star.test(p,def*(1-2*i/nsteps),size=100,pad=4,draw=FALSE)
zmax = 0.9*zmax + 0.1*max(star)
image ((star/zmax)^(1/gamma), zlim=c(0,1), col=gray256, asp=1, bty='n', axes=FALSE)
dev.off()
}
plot(rmsi,type="l")
mean(rmsi)
Poi bisogna comporre le immagini .png in un filmato (lo faccio con Mathematica).
Serve anche questo (il modello di turbolenza di Kolmogorov/Fried)
turb.ft <- function (size, friedratio=1, pad=2) {
n <- nextn (size*pad)
b <- matrix (rnorm (n^2)+1i*rnorm(n^2), n, n)
rho <- make.rho.fdom (n)
b <- b * sqrt (0.023*rho^(-11/3)/friedratio^(5/3))
b[rho == 0] <- 0
resize (Re (ift (b)), size, size)/ (2*pi)
}
CITAZIONE (Dob45 @ 8/9/2012, 20:02)
Mauro, complimenti per l'ultima animazione , veramente molto realistica !
Intendi la stella del rifrattore vero