Chapter 5. SNESIM - Single Normal Equation SIMulation

Table of Contents

Working with SNESIM and mGstat
Working with SNESIM and mGstat

This chapter discuss how to run SNESIM from within Matlab. SNESIM is original Fortran code developed for Single Normal Equation SIMulation method developed by Sebastian Strebelle.

This fortran based implementation has been superceeded by an implementaion is available through S-GeMS. See the chapter S-GeMS - The Stanford Geostatistical Modeling Software.

Working with SNESIM and mGstat

mGstat implements 4 m-files that allow interactions with SNESIM Here we make no effort to explain the meaning of all the options for the snesim parameter file, but refer to the documenation for SNESIM

Working with SNESIM and mGstat

Get a copy of a snesim parameter file, as well as the associated training image and data templates using “snesim_init”:

S = snesim_init;
S = 

             fconddata: [1x1 struct]
                  ncat: 2
              cat_code: [0 1]
            pdf_target: [0.7000 0.3000]
         use_vert_prop: 0
             fvertprob: [1x1 struct]
      pdf_target_repro: 1
        pdf_target_par: 0.5000
           debug_level: -2
                fdebug: [1x1 struct]
                   out: [1x1 struct]
                  nsim: 1
                    nx: 80
                   xmn: 0.2500
                  xsiz: 0.5000
                    ny: 120
                   ymn: 0.2500
                  ysiz: 0.5000
                    nz: 1
                   zmn: 0.2500
                  zsiz: 0.5000
                 rseed: 500
             ftemplate: [1x1 struct]
              max_cond: 16
      max_data_per_oct: 0
       max_data_events: 20
            n_mulgrids: 2
    n_mulgrids_w_stree: 1
                   fti: [1x1 struct]
                  nxtr: 250
                  nytr: 250
                  nztr: 1
                  hmax: 10
                  hmin: 10
                 hvert: 5
                  amax: 7
                  amin: 3
                 avert: 0
               parfile: 'snesim.par'

This will read the snesim parameter file into a Matlab structure that can be easily altered.

This SNESIM S structure can be written to a SNESIM parameter files using : “write_snesim”:

write_snesim(S,'snesim.par');

A SNESIM parameter file can be read into a Matlab structure S, using: “read_snesim”:

S=read_snesim('snesim.par');

SNESIM can be from Matlab using: “snesim”:

S = snesim_init;
S.nsim = 10;
S = snesim(S);

The output from running snesim is located in the data structure as S.D. In the present case:

size(S.D)
80 120 10

Thus to plot the realizations one could use

for i=1:S.nsim
  subplot(4,3,i);
  imagesc(S.x,S.y,S.D(:,:,i));
  axis image
end