Skip to content

Read SGeMS Grid

The Stanford Geostatistical Modeling Software (SGeMS) ASCII format is much like the GSLIB) file format. The reader we have developed for this format assumes the data to be defined on a regularly spaced grid and that the first line of the file will specify the dimensions of that grid.

The SGeMS File Format

The general format is the same as the GSLIB format except that the header line has three integer values to specify the extent of the gridded data.

n1 n2 n3
numberOfColumns
Col1_name
Col2_name
Col3_name
dataCol1 dataCol2 dataCol3
dataCol1 dataCol2 dataCol3
dataCol1 dataCol2 dataCol3
dataCol1 dataCol2 dataCol3
dataCol1 dataCol2 dataCol3
...

An example file might look something like this, where we have a 400 by 150 by 40 (x by y by z) grid with uniform spacing along each axis with three data arrays:

400 150 40
3
Variable1
Variable2
Variable3
0.908793985844 -0.141859993339 0.76693302393
0.909209012985 0.0264630001038 0.935671985149
0.908389985561 -0.0224980004132 0.885891973972
0.906355023384 -0.0762720033526 0.83008402586
0.895779013634 0.0125150000677 0.908294022083
0.876645028591 -0.0550080016255 0.821636974812
0.856096029282 0.0719339996576 0.928031027317
...

Reader

The output of this file reader is a vtkImageData object which is essentially a regularly spaced grid with varying dimensionality along each axis. The reader will only work if the format of the file strictly follows what is below. If your SGeMS file does not strictly follow the uniform grid format below then we recommend use the GSLIB file reader.

ParaView Example

PVGeo: SGeMS Grid Reader from Bane Sullivan on Vimeo.

For example files to use with this reader, download any of the 2D or 3D files from this website and load them into ParaView using the ‘Read SGeMS File to Uniform Grid’ file reader. A 2D or 3D block of data should automatically be built and visualized.

Here is the Walker Lake Exhaustive DEM Categorized with a categorized color scale and the surface warped by categorization to give it an interesting 3D representation:

and here is the FLUVSIM object-based model with a categorized color scale (bounding surfaces are set to be transparent):

Down the Pipeline


Python Example

For this example, please download one of the above data files to use or use you own SGeMS grid file and be sure to change the filename

from PVGeo.gslib import SGeMSGridReader

##################################
# Get the file name
filename = 'topexample.sgems'
##################################
# Now use the filter:
grid = SGeMSGridReader().Apply(filename)

# Or you can set the grid options:
grid = SGeMSGridReader(origin=(100.0, 10.0, 345.0),
                       spacing=(10.0, 10.0, 10.0)).Apply(filename)
# Or you could directly edit the output vtkImageData object
grid = SGeMSGridReader().Apply(filename)
grid.SetOrigin(100.0, 10.0, 345.0)
grid.SetSpacing(10.0, 10.0, 10.0)

Note you could use a time series of data files:

from PVGeo.gslib import SGeMSGridReader

##################################
# Get the file name
filenames = ['data%d.sgems' for i in range(100)]
##################################
# Now use the filter:
reader = SGeMSGridReader()
grid = reader.Apply(filenames)
# NOTE: the default output is at time step 0. To request a time step:
reader.UpdateTimeStep(25)
# the grid object is now updated to the 25th time step

Writer

The SGeMS Grid writer takes vtkImageData objects as an input and saves them to the SGeMS Grid file format.

Take a look at WriteImageDataToSGeMS‘s code docs here

Comments