Gaussian stocastic simulation with area-to-point kriging (A2PK)

This script show you how to generate stocastic fine-scale realization conditioned to a coarse-scale image using area-to-point kriging and conditioning kriging.
addpath('./FastGaussianSimulation');

Generation of the synthetic data

covar.model='exponential'; covar.range=[20 20]; covar.var=1;covar.azimuth=0;
covar= covarIni(covar);
z.x=1:100;
z.y=1:100;
[z.X,z.Y] = meshgrid(z.x, z.y);
z.nxy =numel(z.X);
z.nx=numel(z.x);
z.ny=numel(z.y);
z.true = FGS(z, covar);
z.true = z.true{1};
Z.dx=5; Z.dy=5;
Z.x = Z.dx/2:Z.dx:z.x(end);
Z.y = Z.dy/2:Z.dy:z.y(end);
[Z.X,Z.Y] = meshgrid(Z.x, Z.y);
G = zeros(numel(Z.X),z.nxy);
for ij=1:z.nxy
[~,id_z]=min((z.X(ij)-Z.X(:)).^2 + (z.Y(ij)-Z.Y(:)).^2);
G(id_z,ij)=1;
%G(id_z,ij)=1/(Z.dx*Z.dy); % make it proportional to the cell size if not regular grid.
end
for ij = 1:numel(Z.X)
G(ij,G(ij,:)==1) = 1 ./ sum(G(ij,:)==1);
end
Z.true = reshape(G * z.true(:), numel(Z.y), numel(Z.x));

Plot

c_axis=[ min(z.true(:)) max(z.true(:))];
figure('pos',[0 0 800 330])
subplot(1,2,1);imagesc(z.x, z.y, z.true); caxis(c_axis); title('True fine-scale field'); axis equal;
subplot(1,2,2);imagesc(Z.x, Z.y, Z.true); caxis(c_axis); title('True coarse-scale field'); axis equal;

Kriging prediction

Czz = covar.g(squareform(pdist([z.X(:) z.Y(:)]*covar.cx)));
CzZ = Czz * G';
CZZ = G * CzZ;
W=zeros(z.nxy,numel(Z.X));
CZZinv = inv(CZZ);
for ij=1:z.nxy
W(ij,:) = CZZinv * CzZ(ij,:)';
end
z.krig = reshape( W * Z.true(:), z.ny,z.nx);

Plot

imagesc(z.x, z.y, z.krig); caxis(c_axis); title('Kriging estimation map based on the coarse scale value'); axis equal;

Generate conditional realization

z.uncondSim = FGS(z, covar);
z.uncondSim = z.uncondSim{1};
Z.uncondSim = reshape(G * z.uncondSim(:), numel(Z.y), numel(Z.x));
z.krigSim = reshape( W * Z.uncondSim(:), z.ny,z.nx);
z.condSim = z.krig + (z.uncondSim - z.krigSim);
Z.condSim = reshape(G * z.condSim(:), numel(Z.y), numel(Z.x));

Plot

figure('pos',[0 0 800 330])
subplot(1,2,1); imagesc(z.x, z.y, z.uncondSim); caxis(c_axis); title('Unconditional fine-scale realization');
subplot(1,2,2); imagesc(Z.x, Z.y, Z.uncondSim); caxis(c_axis); title('Unconditional coarse-scale realization');
figure('pos',[0 0 800 330])
subplot(1,2,1); imagesc(z.x, z.y, z.true); caxis(c_axis); title('True fine-scale');
subplot(1,2,2);imagesc(z.x, z.y, z.condSim); caxis(c_axis); title('Conditional realization');
figure('pos',[0 0 800 330])
subplot(1,2,1); imagesc(Z.x, Z.y, Z.true); caxis(c_axis); title('True fine-scale');
subplot(1,2,2);imagesc(Z.x, Z.y, Z.condSim); caxis(c_axis); title('Conditional realization');

Analysis of the realization

TO BE DONE