Online version Topic: Grid mathematics
×
Menu
Index

Grid mathematics

 
Mathematical operations on grids can be performed on input grids (see Properties/Input in the project workspace) and in the operations window of the Explorer utility. In both cases we use the pipe character, |, to separate each command, gridfile and constant in the mathematical string.
 
 MigriX uses the “HP calculator" (reverse Polish notation) stack approach by first entering the numbers and then the commands. Adding two numbers would therefore be written: |2|3|+| and the result would be 5. Each of these numbers can be replaced by a grid, so you can write |mygrid.gri|3|+| and then 3 would be added to the grid in mygrid.gri, assuming that this grid is available in the db directory.
 
The mathematical operation should always start with a grid, and loaded grids will be resampled to the resolution of the first grid in the operation.
The nullgrid, onegrid and undgrid commands can be used to create a starting grid that has the same AOI and resolution as the model.
 
When a coarser grid is loaded, the loaded grid will be "smoothed". When e.g. mygrid.gri#2 is used, each second grid node will be loaded and the loaded grid size will be 25% of the gridfile. Setting mygrid.gri#0 when loading a coarser grid will ensure that no "smoothing" is performed when loading the gridfile, and all grid values will be set to the nearest value of the coarse grid.
 
Units can be converted using the [] construct. Using eg. |mygrid.gri|[ft]|*| will convert from ft to meter because [ft] will be converted to 0.3048. Units that are not recognized will be set to zero, so the operation will get a value of 0.0.
 
Command
Description
Example(s)
command
Perform command with g1, g2, g3 being input (grids or constants)
or c1,c2,c3 (constants).
Polygon-files (p1) and tables (t1) may sometimes also be used as input
|g3|g2|g1|command|
|g3|c2|p1|command|
|g2|t1|command|
 
Arithmetic                                                    
+
Add two grids or numbers
|g2|g1|+|
-
Subtract two grids or numbers
|g2|g1|-|
*
Multiply two grids or numbers
|g2|g1|*|
/
Divide two grids or numbers
|g2|g1|/|
sq
Square ( g1**2)
|g1|sq|
**
Power ( g2**g1)
|g1|**|
sqrt
Square root (g1**0.5)
|g1|sqrt|
abs
Absolute value
|g1|abs|
int
Convert from real to integer (1.7 -> 1)
|g1|abs|
nint
Convert from real to nearest integer (1.7->2)
|g1|int|
exp
Exponent (e**g1)
|g1|nint|
ln
Natural logarithm
|g1|ln|
log
Log10
|g1|log|
sindeg, cosdeg
sine, cosine of g1. Input in degrees
 |g1|sindeg|
sin, cos, tan
sine, cosine, tangens of g1. Input in radians
|g1|tan|
asin, acos, atan
arcsine, arccosine, arcus tangens of g1
|g1|atan|
radians
Convert from degrees to radians
|g1|radians|
degrees
Convert from radians to degrees
|g1|degrees|
nullgrid
Grid is set to undefined with existing AOI
|nullgrid|
onegrid
Grid is set to 1, with existing AOI
|onegrid|
undgrid
Grid is set to 0 with existing AOI
|undgrid|
und
Convert from undefined -> 0 and x -> undefined
|g1|und|
und0
Insert zero where grid is undefined
|g1|und0|
km->node
multiply with 1000/nodedistance
|g1|km->node|
node->km
multiply with nodedistance/1000
|g1|node->km|
 
 
 
 Surface                                                            
dip
dipp dipi dipx dipj dipy
Dip (first derivative) of grid
|g1|dip|
curve
d2i d2x d2j d2y
Second derivative of grid
|g1|curve|
strike
Strike of grid
|g1|strike|
1-x
 1.0 - g1
|g1|1-x|
1/x
 1.0 / g1
|g1|1/x|
dx/x
(g2-g1) / g1
|g2|g1|dx/x|
AC
Autocorrelation in x and y
|g2|g1|AC|
flips
Flip North to South and South to North
|g1|flips|
flipw
Flip West to East and East to West
|g1|flipw|
peaks
Keep extremes in g1 that are maximums only
|g1|peaks|
lows
Keep extremes in g1 that are minimums only
|g1|lows|
extremes
Keep extremes in g1 that are either peaks or lows
|g1|extremes|
ridges
Keep maximums in g1 that are ridges
|g1|ridges|
random
Multiply g1 values with random number(s) in range 0-1
|g1|random|
white
Create a grid with random white noise
|white|
flat
Keep only flat areas in g1
|g1|flat|
switch
Switch position of g1 and g2 in stack
|g2|g1|switch|
copy
Make a copy of g1 in the stack
|g1|copy|
grid
Make grid of constant
|g1|grid|
middle
Grid is in the middle between g1and g2 : 0.5 * (g1 + g2 )
|g2|g1|middle|
between
Grid is at fraction between 2 grids : (g3-g2)*c1 + g2
When c1 is 1, the result will be equal to g3
When c1 is 0, the result will be equal to g2
|g3|g2|c1|between|
 
 
Logical                                                     
intersect
Use g2 only where g1 exists
|g2|g1|intersect|
union
Make union by adding g1 where g2 does not exist
|g2|g1|union|
outside
Use g2 only where g1 does not exist
|g2|g1|outside|
differ
Keep only node-values where g1 differ from g2
|g2|g1|differ|
same
Keep only node-values where g1 and g2 are the same
|g2|g1|same|
substitute
Substitute with g1 where g2 and g3 are the same
|g3|g2|g1|substitute|
set1
Existing gridnodes are set to a value of 1
|g1|set1|
set0
Existing gridnodes are set to a value of 0
|g1|set0|
set10
Insert 1 where grid is defined, 0 where grid is undefined
|g1|set10|
set01
Insert 0 where grid is defined, 1 where grid is undefined
|g1|set01|
set00
Set defined and undefined areas to 0
|g1|set00|
set11
Set defined and undefined areas to 1
|g1|set11|
gt
Grid is g2 where it is greater than g1 (g2 > g1)
|g2|g1|gt|
ge
Keep g2 where greater than or equal to g1  (g2 => g1)
|g2|g1|ge|
lt
Keep g2 where less than g1 (g2 < g1)
|g2|g1|lt|
le
Keep g2 less than or equal to g1 (g2 <= g1)
|g2|g1|le|
absgt
Keep g2 where abs(g2) > abs(g1)
|g2|g1|absgt|
abslt
Keep g2 where abs(g2) < abs(g1)
|g2|g1|abslt|
min
Minimum values of two grids in each node
|g2|g1|min|
min+
Minimum + add values where one grid is undefined
|g2|g1|min+|
max
Maximum values of two grids in each node
|g2|g1|max|
max+
Maximum + add values where one grid is undefined
|g2|g1|max+|
 
 
Areas                                                
grow
Grow node-value where g1 is undefined
|g1|grow|
grown
Grow node-values where g2 is undefined g1 times (c1 is N)
|g2|c1|grown|
grows
Grow g3 towards the value of g2 at a distance of c1 nodes
|g3|g2|c1|grows|
growmax
Grow node-values > min (g1) and neighbours to max (g2)
|g2|g1|growmax|
growc
Grow g2 points c1 times using circular outlines
|g2|c1|growc|
area
Area of grid with defined node values
|g1|area|
sum
Sum of all node values with values
|g1|sum|
volume
Volume of grid
|g1|volume|
average
Compute average value of a grid.
|g1|average|
rimaoi
Keep only nodes that are at grid AOI boundary.
|g1|rimaoi|
shrinkn
Shrink g2 grid c1 times.
|g2|c1|shrinkN|
shrink
Set undefined all nodes that are neighbours with undefined node values
|g1|shrink|
trim
Trim away nodes in g1 with only 1 neighbour of same type.
|g1|trim|
polyin
Keeps g1 only inside the polygon(s). See also Grid areas.
e.g. |g1.gri|polygonfile.pol|polyin|
|g2|p1|polyin|
polyout
Keeps g1 only outside the polygon(s). See also Grid areas.
|g2|p1|polyout|
tablein
Keeps g1 only inside the table polygon(s). See also Grid areas.
|g2|t1|tablein|
tableout
Keeps g1 only outside the table polygon(s)
|g2|t1|tableout|
xyge
Set lower left corner of AOI.  (keep g3 where x >= c2 and y >= c1 )
|g3|c2|c1|xyge|
xyle
Set upper right corner of AOI. (keep g3 where x <= c2 and y <= c1)
|g3|c2|c1|xyle|
xle
Keep g2 where x <= c1
|g2|c1|xle|
yle
Keep g2 where y <= c1
|g2|c1|yle|
xge
Keep g2 where x >= c1
|g2|c1|yxge|
 yge
Keep g2 where y >= c1
|g2|c1|yge|
xy+
g3 + c2 * y + c1 * x  
|g3|c2|c1|xy+|
window
Keep g5 where c4 <= x <= c2  & c3 <= y <= c1
|g5|c4|c3|c2|c1|window|
windows
Select a window # (c1) from UserData in migri-windows.csv and
keep data from g2 inside ( > 0) or outside ( < 0) this window. See also Grid areas.
|g2|c1|windows|
 
                                           
Filling                                                   
fill
Fill g2 by interpolation a distance (c1=# cells) into holes
|g2|c1|fill|
infill
Fill in the grid by gridding between existing points
 (can be used to grid up “well data nodes” from tabcol)
|g1|infill|
smooth
Smooth g2 with 5-point operator c1 times
|g2|c1|smooth|
smoothed
Smooth g2 over a distance c1 (single pass)
|g2|c1|smooth|
home
Home of Nearest Point
|g1|home|
dist
Distance to Nearest Point
|g1|dist|
gri.f
Fast gridding of point and line data in g1
|g1|gri.f|
gri.d
Gridding g2 with Home-grid as control in g1
|g2|copy|home|gri.d|
tiegrid
Make tiegrid that connects nodes from g1 to g2 according to codes in g1
|g2|g1|tiegrid|
triangles
Make interpolation triangles from Home grid
|g1|home|triangles|
regions
Split input grid into connected regions identity (node number)
|g1|regions|
region
Grid becomes # of nodes in each region
|g1|region|
regfill
Fill g2 by interpolation a distance c1 (# cells) into holes of same region
|g2|c1|regfill|
rimnodes
Set rim-nodes in g1 to a value > 0  and set nodes inside of rim to 0
|g1|rimnodes|
single
Remove single nodes and fill single undefined nodes in g1
|g1|single|
sort
Sort input grid is index to sort
|g2|g1|sort|
inbetween
Fraction of g1 between g2 and g3 grids : (g1-g2) /(g3-g2)
|g3|g2|g1|inbetween|
minbetween
Grid is between 2 grids : (g3-X)*g1+X  &
X = min(g2, g3)
|g3|g2|g1|minbetween|
fillbetween
Fill holes in g1 between g2 and g3
|g3|g2|g1|fillbetween|
merge
Merge local grid into regional grid with gradual transition across a merge zone (width=number of cells).
|local.gri|regional.gri|10|merge|
|g2|g1|c1|merge|
 
 
Points                                                                 
facies
Make facies (compartments #) grid from polygon file
e.g. |nullgrid|faults.pol|facies|+| produces a facies-gridding.csv file and a facies # grid  (*)
|nullgrid|p1|facies| 
(*)
tablefacies
Make facies (compartments #) grid from table (.csv) file
e.g. |nullgrid|faults.csv|tablefacies|+| produces a facies-gridding.csv file and a facies # grid  (*)
 
|nullgrid|t1|tablefacies| 
(*)
faciesmap
Perform lookup with “facies”  in grid g2 and
the “Table column #” of output in g1. Load first Table, e.g.
|facies.gri|migri-facies.csv|7|faciesmap|
could produce a grid with Vsh in each facies from column 7 of Table
|g3|p2|g1|faciesmap|
tabletopol
Make polygon dataset from csv table dataset
|nullgrid|t1|tabletopol| 
(*)
usermap
Replace g1 with the content of UserData column in table and fill polygons
e.g. |g1.gri|table.csv|usermap|
(note that the Userdata column must contain numeric data)
|g2|t1|usermap|
points
Map point values into grid, method
c1=1: point z-values (column 3)
c1=2:point values (column 4)
c1=3: interpolate along lines between z-values
c1=4: interpolate along lines between point-values
e.g. |nullgrid|points.dat|3|points|+|
|nullgrid|p2|c1|points|
(*)
tablepoints
Map column c1 from loaded table into grid
e.g. |nullgrid|wells.csv|3|tablepoints|+| will map column #3 in the wells.csv into a grid with values at well locations
|nullgrid|t2|c1|tablepoints|
(*)
tablelines
Map column g1 from loaded Table into grid
e.g. |nullgrid|wells.csv|3|tablelines|+| will map column #3 in the wells.csv into a grid with "lines" between well locations
|nullgrid|t2|c1|tablelines|
(*)
tablefill
Make grid of column g1 in table and fill the grid using polygon fill
e.g. |nullgrid|table.csv|4|tablefill|+|
This will fill column 4 in table and then add it to grid g2.gri
|nullgrid|t2|c1|tablefill|
(*)
scattergrid
Make scatter.gri & scattered.csv
by cross-plotting g2 as y versus g1 as x
|g2|g1|scattergrid|
stitch
  Stitch holes in the map by connecting tielines across the holes.
The tielines are read from a polygon file, which can be created by digitizing points  in Selection Info.
|g1|p1|stitch|
tablestitch
Stitch holes in the map by connecting tielines  across the holes.
The tielines are read from a csv file, which can be created by digitizing points in Selection Info.
|g1|c1|tablestitch|
(*): These commands must operate on a starting grid, e.g. the facies command may be combined with nullgrid: |nullgrid|faults.pol|facies|+|
 
 
Special                                                                    
wellsgrid
set location of well(s) to row number in migri-wells.csv and the rest of the area to undefined
|nullgrid|wellsgrid|
maturitiesgrid
set location of maturities observation to row number in table and the rest of the area to undefined
|nullgrid|maturitiesgrid|
 
comments powered by Disqus