Grid Math

Use the Grid and Image > Grid Math menu option (geogxnet.dll(Geosoft.GX.MathExpressionBuilder.MathExpressionBuilder;RunGrid)*) to create, save, load, and execute math expressions for your grid data. This easy-to-use, standardized dialog provides all the math expression options on a single tabbed dialog.

Grid Math dialog options

Step 1: Enter a mathematical expression, or alternatively, build the expression using the buttons and tabs located below the Expression box.

Expression

Enter your mathematical expression in this box. The syntax is straightforward and based on the C programming language conventions. The expression can include any combination of functions and operators, absolute and/or variable grid names, reserved variables, DUMMY values, and numbers, spanning multiple equations. (See the Application Notes for a simple example.) You can enter the expression directly or construct it using the provided Variables and Operators and Functions tabs.

For further details, see the Expression section under Application Notes.

Click this button to expand and display the available Operators and Functions to build the Grid Math expression. Use the keyboard to enter numerical values.

For more detailed information about the operators and functions in this expanded section, click on the links below:

  • Common Keys: Buttons consisting of the most commonly used operations and values, grouped along the left, right below Operators and Functions.

  • Frequent Tab: Frequently used conditional and logarithmic operators and functions.

  • Special Tab: Special limit and mathematical functions.

  • Trig Tab: Trigonometry functions.

  • Statistics Tab: Statistical properties of one or more lines.

Click this button to add a new grid variable at the cursor's location in the Expression box. The variable grid naming convention is G#, where # is the next available number.

This is not to be confused with temporary variables (see Common Keys), which only exist at runtime and are not saved.

Step 2: Assign grids to the variable names used in the expression.

Assign grids

This box is populated with all the grid variables present in the Expression box. Each variable can be set either by choosing a grid from the drop-down list of the grids used in the current project or by using the browse button to navigate and select the appropriate grid.

The tool distinguishes between input and output grids. Input grids must exist and are preceded by a , while you can enter the output grid name.

For further details, see the Assign Grids section under Application Notes.

Common tasks

To speed up building the expression, this drop-down list offers a number of simple common math expressions:

  • Add 2 grids: G0 = G1 + G2;

  • Divide 2 grids: G0 = G1 / G2;

  • Multiply 2 grids: G0 = G1 * G2;

  • Multiply grid by factor 2: G0 = G1 * 2;

  • Remove 5000 from grid: G0 = G1 - 5000;

  • Subtract 2 grids: G0 = G1 - G2;

  • True/False statement: G0 = (G1>5000) ? G2 :G3;

You can select an expression from the list and, if needed, continue to further edit it.

  • An expression is parsed from right to left. In the conditional expression G0 = (condition)?G2:G3, the data type of the rightmost channel, G3, defines the data type of the output.
  • Expression file

    Once you have built the expression, you can save it to a file for future use. Similarly, if you have previously saved expressions, you can load them from file.

    The expression files are simple ASCII text files and can be viewed outside of Oasis montaj using a text editor.

    Click on Clear to remove all entries, including the expression, grid assignment, and expression file.

    Click on Apply to apply the expression without exiting the dialog. This is useful when you intend to apply the same expression to multiple grids.

    Application Notes

    If an equation yields a value outside the data range, the output is set to DUMMY.

    In Geosoft convention, the DUMMY value depends on the data type:

    • For signed integer data types, the DUMMY value is set to the minimum value of the corresponding data range.

    • For unsigned integer data types, the DUMMY value is set to the maximum value of the corresponding data range.

    • The DUMMY values and data ranges for floating data types do not follow this convention. Instead, they are set to limits outside the data ranges you would typically handle in geophysical processing.

    ClosedClick the link to expand and view the Geosoft data ranges and DUMMY values for the different data types.

    Expression

    Expressions are parsed from right to left. For example, in the conditional expression G0 = (condition)?G2:G3, the data type of the rightmost channel, G3, defines the data type of the output.

    Longer, more complex expressions spanning multiple lines remain visible as you work. When new rows are added to the Expression box, its height automatically expands to display up to 12 lines. Beyond this, a scroll bar appears along the right margin for navigation.

    To further increase the vertical height of the box, while the focus is on the Expression box, hover the cursor over the top or bottom edge of the dialog until the double arrow appears. Click and drag the edge of the dialog to resize the box accordingly.

    When working with long expressions, the dialog can also be widened. Hover the cursor over the left or right edge of the dialog until the double arrow appears, then click and drag to adjust the width as needed.

    Assign Grids

    To further increase the vertical height of the Assign grids box, click on an editable entry within the box until it becomes underlined, indicating it is in focus. Then, hover the cursor over the top or bottom edge of the dialog until a double arrow appears. Click and drag the edge to resize the dialog, which will also adjust the height of the Assign grids box. Note that clicking elsewhere inside the box will not activate the desired resizing function.

    You will not see the temporary variable listed in this window.

    Using Spatial Coordinates (X, Y, Z) as Grid Math Variables

    Since Oasis montaj is spatially aware, location coordinates can be directly accessed using the “reserved” variable designations X, Y, and Z . Use X & Y for a plan grid, X & Z or Y& Z for a straight section, and X, Y & Z for a curvilinear section.

    The expression below uses the reserved coordinates X and Y of a plan grid to generate a sinusoidal masking pattern. The image below illustrates the resulting masked grid.

    //G0=.\Sinusoidal.grd(GRD)
    //G1=.\DEM.grd(GRD)
    G0 =(Y>(sin_deg((X-454000)/700*180)*500+5443000))?DUMMY:G1;

    The following is an example of a Grid Math expression that uses Y and Z coordinates as variables to partially mask a section grid along a slope. The image below illustrates the resulting section grid.

    //G0=.\Chopped.grd(GRD)
    //G1=.\Section.grd(GRD)
    G0 =(Z>(Y-5440800)/6-200)?DUMMY:G1;

    Temporary Variable Definition

    Temporary variables can be defined in a math expression. These variables exist only during the computation stage and are not saved in the output. To define a temporary variable, precede it with the "@" symbol (e.g., @Var1). Multiple temporary variables can be included in an expression.

    *The GX.NET tools are embedded in the geogxnet.dll file located in the "...\Geosoft\Desktop Applications \bin" folder. If running this GX interactively, bypassing the menu, first change the folder to point to the "bin" directory, then supply the GX.NET tool in the specified format. See the topic Run GX for more details on running a GX.NET interactively.