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(struct('s',[z.nx z.ny]), covar);
z.true = z.true{1};
Z.dx=5; Z.dy=5;
Z.x = mean(z.x(1:Z.dx)):Z.dx:mean(z.x(end-Z.dx+1:end));
Z.y = mean(z.y(1:Z.dy)):Z.dy:mean(z.y(end-Z.dy+1:end));
[Z.X,Z.Y] = meshgrid(Z.x, Z.y);
G = zeros(numel(Z.X),z.nxy);
[~,id] = min(bsxfun(@minus,Z.X(:), z.X(:)').^2 + bsxfun(@minus, Z.Y(:), z.Y(:)').^2);
G(sub2ind(size(G), id, 1:z.nxy)) = 1/(Z.dx*Z.dy);
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 = (CZZ \ CzZ')';
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(struct('s',[z.nx z.ny]), 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