2. GSTAT-related m-files

2.1. 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 : Section 1.31, “gstat”

2.1.1. output precision

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

G.set.precision='%4.2f'

2.2. gstat_read_par

More info at : Section 1.86, “read_gstat_par”

2.3. gstat_write_par

More info at : Section 1.113, “write_gstat_par”

2.4. 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 : Section 1.35, “gstat_krig”

2.5. gstat_convert

Converts binary formatted data formats to ascii.

More info at : Section 1.33, “gstat_convert” and Section 2.1.1, “Making GSTAT available for mGstat”

2.6. gstat_plot

More info at : Section 1.37, “gstat_plot”

2.7. gstat_demo

More info at : Section 1.34, “gstat_demo”

2.8. gstat_binary

More info at : Section 1.32, “gstat_binary”

2.9. 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 Section 1.95, “semivar_exp”, but using GSTAT as backend instead of the native Matlab implemention.

Section 1.96, “semivar_exp_gstat” is much more CPU efficient that Section 1.95, “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 : Section 1.96, “semivar_exp_gstat”