GSTAT-related m-files

gstat

gstat is used to call gstat from within Matlab. It can be called using either a GSTAT command file as :

[pred_mean,pred_var]=gstat('ex06.cmd');

or using a Matlab mGstat structure as

G=read_gstat_par('ex06.cmd');       % read parameter file
G.G.variogram{1}.V(1).type='Sph';   % change variogram type to Spherical
[pred_mean,pred_var]=gstat(G);

More info at : the section called “gstat”

output precision

By default the output precision of GSTAT is set to format '%16.8f'. This can be specified manually as :

G.set.format='%4.2f'

gstat_read_par

More info at : the section called “read_gstat_par”

gstat_write_par

More info at : the section called “write_gstat_par”

gstat_krig

gstat_krig is the equivalent of the native Matlab command krig. It is called in similar fashion to krig, but calls GSTAT for kriging as opposed to the Matlab kriging routines.

More info at : the section called “gstat_krig”

gstat_convert

Converts binary formatted data formats to ascii.

More info at : the section called “gstat_convert” and the section called “Making GSTAT available for mGstat”

gstat_binary

More info at : the section called “gstat_binary”

semivar_exp_gstat

NB: In the forthcoming releases this m-file will be rename gstat_semivar_exp

This m-file computes the experimental semivariogram using the same conventions as the section called “semivar_exp”, but using GSTAT as backend instead of the native Matlab implemention.

the section called “semivar_exp_gstat” is much more CPU efficient that the section called “semivar_exp”.

An example (from MGSTAT_INSTALL/example/test_gstat_semivar_exp.m)

% GENERATE A REFERENCE DATA SET USING UNCONDITIONAL GAUSSIAN SIMULATION
x=[0:.05:10];
y=[0:.05:10];
V=visim_init(x,y);
V.rseed=1;
V.Va.a_hmax=4; % maximum correlation length
V.Va.a_hmin=.5;  % minumum correlation length
V.Va.ang1=90-22.5;   % Rotation angle of dip(clockwise from north)
V.Va.it=1;     % Gaussian semivariogram
V=visim(V);    % run visim;

[x_obs,y_obs]=meshgrid(x,y);
d_obs=V.D(:,:,1);
n_obs=prod(size(d_obs));


% CHOOSE SOME DATA FOR SEMIVARIOGRAM ANALYSIS
n_use=1000;
i_use=round(rand(1,n_use)*(n_obs-1))+1;
i_use=unique(i_use);

x_use=x_obs(i_use);
y_use=y_obs(i_use);
d_use=d_obs(i_use);

% PLOT DATA
figure(1);
imagesc(V.x,V.y,V.D(:,:,1));
title(visim_format_variogram(V))
axis image;
hold on
plot(x_use,y_use,'w.','MarkerSize',22)
scatter(x_use,y_use,20,d_use,'filled')
hold off
drawnow;

% SEMIVARIOGRAM ANALYSIS ISOTROPIC
[gamma_iso,hc,np,av_dist]=semivar_exp_gstat([x_use(:) y_use(:)],[d_use(:)]);
figure(2);
plot(hc,gamma_iso);
title('isotropic');xlabel('Distance');ylabel('\gamma')

% SEMIVARIOGRAM ANALYSIS ANISOTROPIC
ang_array=[0,22.5,45,67.5,90];
ang_tolerance=10;
for i_ang=1:length(ang_array);   
    [gamma_an(:,i_ang),hc,np,av_dist]=semivar_exp_gstat([x_use(:) y_use(:)],[d_use(:)],ang_array(i_ang),ang_tolerance);
end
figure(3);
plot(hc,gamma_an);xlabel('Distance');ylabel('\gamma')
title('ANisotropic'); 
legend(num2str(ang_array'))
 
% SYNTHETICAL SEMIVARIOGRAM
gamma_synth=semivar_synth('0.0001 Nug(0) + 1 Sph(1)',hc);
figure(4)
plot(hc,gamma_an,'b-')
hold on
plot(hc,gamma_iso,'r-','linewidth',2)
plot(hc,gamma_synth,'k-','linewidth',2)
hold off
;xlabel('Distance');ylabel('\gamma')
legend(num2str(ang_array'))

More info at : the section called “semivar_exp_gstat”