Getting started

Content

Starting surfit

surfit based on Tcl scripting language, so first of all you must start tclsh. It means that you must have Tcl installed on your computer.

After that you can load libsurfit shared library (or dll) with command:

$ load libsurfit[info sharedlibextension]

Under Windows this command can be simplified:

$ load libsurfit

Under Unix you can type

$ load libsurfit.so

If libsurfit was succesfully loaded into memory, you would see the license text:

surfit version 2.1, Copyright (c) 2002-2006 M.V.Dmitrievsky & V.N.Kutrunov
surfit comes with ABSOLUTELY NO WARRANTY; for details type `show_w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show_c' for details.

A common error received by first-time users is the following:

$ load libsurfit.so
couldn't load file "libsurfit.so": libsurfit.so: cannot open shared object file:
No such file or directory
$

Unix environment

This error is generated because the dynamic linker can't locate the libsurfit.so library. When shared libraries are loaded, the system normally only checks a few standard locations such as /usr/lib and /usr/local/lib. To fix this problem, there are several things you can do. First, you can set the LD_LIBRARY_PATH environment variable to include the directory with libsurfit library. If setting LD_LIBRARY_PATH, be aware that setting this variable can introduce a noticeable performance impact on all other applications that you run. To set it only for Tcl, you might want to do this instead:

$ env LD_LIBRARY_PATH=/home/beazley/projects/lib tclsh

Finally, you can use a command such as ldconfig to add additional search paths to the default system configuration (this requires root access and you will need to read the man pages).

Windows environment

This error is generated because system can't locate the libsurfit.dll library. To fix this probelm you must set the PATH environment variable to the directory with libsurfit.dll:

(Windows 95/98/Me): The search path in Windows is normally specified in the autoexec.bat file, which is typically located in the root directory (c:\). To add the surfit installation directory to your search path do the following from an MS-DOS Prompt Window:

(Windows NT/Windows 2000):

Loading data to surfit

Loading from text files

To examine data, already loaded use mem_info command.

loading points

The pnts_read command reads formatted text files containing interpolation scattered data points coordinates. The text file should organized as a rectangular table of numbers, separated by blanks, with one row per line, and an equal number of elements in each row. For example, outside of surfit, create a text file containing these four lines:

    16.0     3.0     2.0    13.0
     5.0    10.0    11.0     8.0
     9.0     6.0     7.0    12.0
     4.0    15.0    14.0     1.0

Store the file under the name points.txt Then the command

$ pnts_read points.txt my_points 4 1 2 3
13/01/05 15:02:52 : reading points "my_points" from file points.txt

reads the file and creates the points dataset. This dataset contains 4 points with X,Y and Z coordinates placed in first, second and third columns. If points.txt consists of only 3 columns:

    16.0     3.0     2.0
     5.0    10.0    11.0
     9.0     6.0     7.0
     4.0    15.0    14.0

then the command arguments can be truncated:

$ pnts_read points.txt my_points
13/01/05 15:02:52 : reading points "my_points" from file points.txt

You can get some info about points datasets with following commands:

# Get number of points dataset:
$ pnts_size
1
# If there is no points datasets in memory, surfit returns 0.
#
# Print points name (for first dataset)
$ pnts_getName 0
13/01/05 15:02:52 : my_points
#
# Print points name (for second dataset) 
$ pnts_getName 1
13/01/05 15:02:52 : Error! class surfit::d_points (1) : bad element requested
#
# Get number of points in points dataset
$ pnts_getCount
4
$ Minimum and maximum values:
$ pnts_minx
4.0
$ pnts_maxx
16.0
$ pnts_miny
3.0
$ pnts_maxy
15.0
$ pnts_minz
2.0
$ pnts_maxz
14.0

Here you can browse all commands for points.

loading curves

surfit supports several types of curves:
curve 2D piecewise linear curve
area polygonal region
contour 3D piecewise linear curve

The curves reading commands read formatted text files containing coordinates of curve nodes. The text file should organized as a rectangular table of numbers, separated by blanks, with one row per line, and an equal number of elements in each row. For example, outside of surfit, create a text file curve.txt containing these lines:

57099.085411 	60514.295924
57065.433147 	60505.330833
57003.367936 	60511.976722
56999.6438 	60513.47112
56948.876992 	60541.501355
56917.649718 	60581.114875
56914.83462 	60637.571493
56919.935389 	60652.716872
56959.468869 	60684.079163
56995.964528 	60685.666331
57018.666043 	60682.271289
57060.443913 	60665.765085
57102.780849 	60632.737514
57119.301496 	60610.562283
57133.154687 	60592.618067
57138.674487 	60577.882496
57131.297193 	60533.391477
57116.652575 	60516.980407
57099.085411 	60514.295924

To read curve from file curve.txt use command:
$ curv_read curve.txt my_curve
14/01/05 11:00:12 : reading curve "my_curve" from file curve.txt
1

loading surfaces

surfaces can be loaded from Surfer GRD-ASCII and surfit datafile format. To load surface from Surfer GRD-ASCII file use the command:

$ surf_load_grd surface.grd my_surface
14/01/05 16:32:50 : loading surface from Surfer GRD-ASCII format file surface.grd
1

To load surface from surfit datafile use the command:

$ surf_load surface.dat my_surface
14/01/05 16:33:20 : loading surf "my_surface" from file surface.dat
1

Here you can browse all commands for surfaces.

Creating grid

surfit uses equdistant grid for gridding procedures. This grid can be described with only 6 parameters:

You can create grid object with grid_get command. For example, command

$ grid_get 0 100 10 0 200 20 my_grid
15/01/05 22:38:32 : grid: (0.00 <-> 100.00) / 10.00; (0.00 <-> 200.00) / 20.00.

In most cases you can use grid command with only 2 parameters to specify cell sizes:

$ grid 10 20

surfit automatically produces grid with cells of specified size. This grid will cover all data objects, loaded into memory.

Gridding

Gridding methods produce a regularly spaced, rectangular array of Z values from regularly and irregularly spaced XYZ data. The term "irregularly spaced" means that the points follow no particular pattern over the extent of the map, so there are many "holes" where data are missing. Gridding fills in these holes by extrapolating or interpolating Z values at those locations where no data exists.

For each data, loaded into surfit memory you can specify gridding rule, which describes how to use your data in surfit gridding algorithm".

Gridding procedure consists of 4 steps:

Here is some examples:

Saving results

After gridding procedure result saves as new surface named with map_name variable value. You can export it to Surfer GRD-ASCII format with command surf_save_grd or to surfit datafile with command surf_save. Also you can save your results into surfit datafile with all other data in memory by command file_save.

Visualising results

The simplest way to visualise your results is to use funner program. This program can be founded here: www.gridding.info. funner accepts both Surfer GRD-ASCII and surfit datafiles.

funner window

Funner window screenshot

Also you can select file from command line:

$ funner my_map.dat



surfit: open source gridding and contouring software.