GSTAT examples

GSTAT ex03

% ex03 : gstat example ex03.cmd
cmd_file='ex03';
[pred,pred_var,pred_covar,mask,G]=gstat(sprintf('%s.cmd',cmd_file));

[obs,obs_header,obs_title]=read_eas(G.data{1}.file);

figure(3);clf;
imagesc(mask.x,mask.y,pred(:,:,1));

hold on
plot(obs(:,1),obs(:,2),'k.','MarkerSize',10);
scatter(obs(:,1),obs(:,2),10,obs(:,3));
hold off
axis image
cb=colorbar;
set(get(cb,'Ylabel'),'string',obs_header{3})
title(sprintf('GSTAT %s.cmd - %s',cmd_file,obs_title))
xlabel(obs_header{1})
ylabel(obs_header{2})

print('-dpng',sprintf('%s.png',cmd_file))

GSTAT ex04

% ex04 : gstat example ex04.cmd
cmd_file='ex04';
[pred,pred_var,pred_covar,mask,G]=gstat(sprintf('%s.cmd',cmd_file));

[out,out_header,out_title]=read_eas(G.set.output);
[obs,obs_header,obs_title]=read_eas(G.data{1}.file);

figure(4);clf;
scatter(obs(:,1),obs(:,2),10,obs(:,3));
hold on
plot(out(:,1),out(:,2),'k.','MarkerSize',12);
scatter(out(:,1),out(:,2),10,out(:,3));
hold off
axis image
cb=colorbar;
set(get(cb,'Ylabel'),'string',obs_header{3})
title(sprintf('GSTAT %s.cmd - %s',cmd_file,obs_title))
xlabel(obs_header{1})
ylabel(obs_header{2})

print('-dpng',sprintf('%s.png',cmd_file))

GSTAT ex05

% ex05 : gstat example ex05.cmd
cmd_file='ex05';
[pred,pred_var,pred_covar,mask,G]=gstat(sprintf('%s.cmd',cmd_file));

[obs,obs_header,obs_title]=read_eas(G.data{1}.file);

if (isfield(G.data{1},'log')); pred=exp(pred);end

figure(5);clf;
subplot(1,2,1);
imagesc(mask.x,mask.y,pred(:,:,1));
hold on
plot(obs(:,1),obs(:,2),'k.','MarkerSize',12);
scatter(obs(:,1),obs(:,2),10,obs(:,3));
hold off
axis image
cb=colorbar;
set(get(cb,'Ylabel'),'string',obs_header{3})
xlabel(obs_header{1})
ylabel(obs_header{2})
title('Mean')

subplot(1,2,2);
imagesc(mask.x,mask.y,pred_var(:,:,1));
colorbar
hold on
plot(obs(:,1),obs(:,2),'k.','MarkerSize',12);
hold off
axis image
%cb=colorbar;
%set(get(cb,'Ylabel'),'string',obs_header{3})
xlabel(obs_header{1})
ylabel(obs_header{2})
title('Variance')

watermark(sprintf('GSTAT %s.cmd - %s',cmd_file,G.mgstat.comment{2}));

print('-dpng',sprintf('%s.png',cmd_file))

GSTAT ex06

% ex06 : gstat example ex06.cmd
cmd_file='ex06';
[pred,pred_var,pred_covar,mask,G]=gstat(sprintf('%s.cmd',cmd_file));
figure(6),clf;
imagesc(mask.x,mask.y,pred(:,:,1));
cb=colorbar;
axis image
title('Unconditional Gaussian simulation')
watermark(sprintf('GSTAT %s.cmd - %s',cmd_file,G.mgstat.comment{2}));

print('-dpng',sprintf('%s.png',cmd_file))

GSTAT ex07

% ex07 : gstat example ex07.cmd
cmd_file='ex07';
[pred,pred_var,pred_covar,mask,G]=gstat(sprintf('%s.cmd',cmd_file));


[obs,obs_header,obs_title]=read_eas(G.data{1}.file);

if (isfield(G.data{1},'log')); pred=exp(pred);end



figure(7);clf;
imagesc(mask.x,mask.y,pred(:,:,1));

hold on
plot(obs(:,1),obs(:,2),'k.','MarkerSize',12);
scatter(obs(:,1),obs(:,2),10,obs(:,3));
hold off
axis image
cb=colorbar;
set(get(cb,'Ylabel'),'string',obs_header{3})
xlabel(obs_header{1})
ylabel(obs_header{2})


cb=colorbar;
axis image
title('Unconditional Gaussian simulation')
watermark(sprintf('GSTAT %s.cmd - %s',cmd_file,G.mgstat.comment{2}));

print('-dpng',sprintf('%s.png',cmd_file))

GSTAT ex09

% ex09 : gstat example ex09.cmd
cmd_file='ex09';
disp(sprintf('%s : There (seems to be) a bug in GSTAT setting NCOLUMNS = 6, when there is only 5 columes in the output EAS file',mfilename)); 
[pred,pred_var,pred_covar,mask,G]=gstat(sprintf('%s.cmd',cmd_file));

GSTAT ex10

cmd_file='ex10';
[pred,pred_var,pred_covar,mask,G]=gstat(sprintf('%s.cmd',cmd_file));


[obs1,obs_header1,obs_title1]=read_eas(G.data{1}.file);
[obs2,obs_header2,obs_title2]=read_eas(G.data{2}.file);

for i=1:2;
    if (isfield(G.data{i},'log')); pred(:,:,i)=exp(pred(:,:,i));end
end

clf;
subplot(2,2,1);
imagesc(mask.x,mask.y,pred(:,:,1));axis image;title([G.predictions{1}.data,' mean estimate'])
hold on
plot(obs1(:,1),obs1(:,2),'k.','MarkerSize',12);
scatter(obs1(:,1),obs1(:,2),10,obs1(:,G.data{1}.v),'filled');
hold off
axis image
cb=colorbar;
set(get(cb,'Ylabel'),'string',obs_header1{3})
xlabel(obs_header1{1})
ylabel(obs_header1{2})

subplot(2,2,2);
imagesc(mask.x,mask.y,pred(:,:,2));axis image;title([G.predictions{2}.data,' mean estimate'])
hold on
plot(obs2(:,1),obs2(:,2),'k.','MarkerSize',12);
scatter(obs2(:,1),obs2(:,2),10,obs1(:,G.data{2}.v),'filled');
hold off
axis image
cb=colorbar;
set(get(cb,'Ylabel'),'string',obs_header2{3})
xlabel(obs_header2{1})
ylabel(obs_header2{2})

subplot(2,2,3);
imagesc(mask.x,mask.y,pred_var(:,:,1));axis image;
colorbar
title([G.predictions{1}.data,' variance estimate'])

subplot(2,2,4);
imagesc(mask.x,mask.y,pred_var(:,:,2));axis image;
colorbar
title([G.predictions{1}.data,' variance estimate'])


watermark(sprintf('GSTAT %s.cmd - %s',cmd_file,G.mgstat.comment{2}));

print('-dpng',sprintf('%s',cmd_file))