|
<< Click to Display Table of Contents >> Navigation: Math > Expression calculator |
Perform mathematical operations between gathers
The Expression calculator applies a user-defined mathematical formula to one or more seismic gathers or 2D matrices, producing a new gather or matrix as output. Every sample in the output is the result of evaluating the expression at that trace-and-sample position. The module is useful for any sample-by-sample arithmetic between two datasets — for example, dividing an AGC-corrected gather by the original gather to extract the scaling function, or multiplying a gather by a spatially-varying scalar map stored as a matrix. Because the formula is compiled once and applied in parallel across all traces, it executes efficiently even on large volumes.
All input gathers and matrices connected to this module must share identical dimensions — the same number of traces, the same number of samples, the same trace interval, and the same sample interval. If any dimension mismatch is detected, the module reports an error and does not produce output.
![]()
![]()
Expression calculator is a handy module to perform any mathematical and logical operations. With the help of this module, the user can do some of the mathematical operations like simple addition, subtractions to complex mathematical expressions.
The module takes one or more input gathers with same size and creates a new gather in which, value for each sample is a result of calculated expression defined by the user. Input gathers can be used as operands in this expression.
![]()
![]()
Connect one or more seismic gathers here. The Gathers list is dynamic — you can add as many inputs as needed by clicking the plus button. The first gather connected is automatically named Input gather A, the second becomes Input gather B, and so on up to the number of letters in the alphabet. In the mathematical expression, each gather is referenced by its corresponding lowercase letter: a for the first gather, b for the second, and so on. At least one gather must be connected; the module cannot run from matrices alone unless no gathers are provided at all.
Connect the primary seismic gather here. Its sample values are referenced as a in the expression. The output gather will have the same dimensions (number of traces and samples, trace spacing, sample rate) as this first input gather. All other connected gathers must match these dimensions exactly.
Connect a second gather whose sample values are referenced as b in the expression. This gather must have the same number of traces and samples as Input gather A. If you need only a single gather (for example, to apply a constant-factor scaling via a*2.5), leave this input unconnected.
You can optionally connect one or more 2D maps (GMatrixItem) to this section. Matrices are treated identically to gathers in the expression — the first matrix is referenced as a if no gathers are connected, or as the next letter after the last gather if gathers are also provided (for example, if one gather is connected and one matrix is connected, the gather is a and the matrix is b). When only matrices are connected and no gathers, the module writes its result to the Output matrix connector instead of the Output gather connector. Typical use: connect a 2D scalar map produced by the Interpolate headers from matrix module, then reference it in the expression alongside a gather to apply spatially-varying corrections.
Important: You cannot reference a gather variable and a matrix variable side by side inside one expression (for example, writing a*b when one input is a gather and the other is a matrix is not supported). If you need to scale a gather by spatially-varying values stored in a matrix, first transfer those values into a trace header using the Interpolate headers from matrix module, then reference the header variable (for example, a*a_BIN_PICKET) in the expression.
Connect the first 2D map here. The matrix list is dynamic — additional matrices are automatically named Input matrix B, C, and so on. Each matrix column corresponds to a trace and each row to a sample, so the matrix dimensions must be compatible with the gathers it is used alongside.
![]()
![]()
Type the formula to apply to every sample in the input data. The default expression is exp(a), which computes the natural exponential of each sample in gather A. Replace this with any expression of your own. The expression is compiled once before processing begins, so it must be syntactically correct before you execute the module. If the expression contains an error, the module reports the error message and stops without producing output.
Gather and matrix variables. Each connected gather or matrix is accessible in the expression by a single lowercase letter. The first input is a, the second is b, and so on. At each processing step, these variables hold the amplitude value of the current sample from the corresponding gather. Expressions such as a+b, a/b, sqrt(abs(a)), and a*1000 are all valid.
Position variables. Two built-in variables are always available regardless of which gathers are connected:
trace — the zero-based index of the current trace being processed (0 for the first trace, 1 for the second, and so on). Use this to create expressions that vary along the trace axis, for example to apply a linear ramp: a * trace.
sample — the zero-based index of the current sample within the trace (0 for the first time sample). Use this to create expressions that vary in time, for example to apply a linear time-weighting: a * sample.
Trace header variables. Every standard trace header field is automatically available in the expression under the naming convention <gather_letter>_<HEADER_NAME>. For example, the absolute offset stored in the first gather is a_ABS_OFFSET, and the inline number from the second gather is b_INLINE. Header values are constant across all samples within a trace — they change only from trace to trace. Any custom (user-defined) trace headers that have been added to the gather by upstream modules are also accessible using the same a_<CUSTOM_HEADER_NAME> convention.
Standard header names available include: TRACE_SEQ, FFID, CHANNEL, TRACE_TYPE, OFFSET, ABS_OFFSET, AZIMUTH, TRACE_STATIC, SURVEY_ID (trace headers); SOURCE_SEQ, SOURCE_LINE, SOURCE_SP, SOURCE_X, SOURCE_Y, SOURCE_ELEV, SOURCE_STATIC, SOURCE_REFSTATIC, SOURCE_ID, SOURCE_PICKET, SOURCE_PICKET_Y (source headers); RECEIVER_SEQ, RECEIVER_LINE, RECEIVER_SP, RECEIVER_X, RECEIVER_Y, RECEIVER_ELEV, RECEIVER_STATIC, RECEIVER_REFSTATIC, RECEIVER_ID, RECEIVER_PICKET, RECEIVER_PICKET_Y (receiver headers); BIN_SEQ, BIN_X, BIN_Y, INLINE, CROSSLINE, BIN_ELEV, BIN_SP, BIN_PICKET, BIN_PICKET_Y, BIN_INLINE_ANGLE, BIN_CROSSLINE_ANGLE (bin headers).
Built-in constants. The ExprTk library provides standard mathematical constants, including pi (3.14159...), epsilon (smallest representable float), and inf (positive infinity). These can be used directly in expressions without any prefix.
This module uses C++ Mathematical Expression Toolkit Library (ExprTk) for calculation. It can contain mathematical operators, functions etc;
ExprTk library has the following capabilities:
•Mathematical operators (+, -, *, /, %, ^)
•Functions (min, max, avg, sum, abs, ceil, floor, round, roundn, exp, log, log10, logn, root, sqrt, clamp, inrange)
•Trigonometry (sin, cos, tan, acos, asin, atan, atan2, cosh, cot, csc, sec, sinh, tanh, d2r, r2d, d2g, g2d, hyp)
•Equalities, Inequalities (=, ==, <>, !=, <, <=, >, >=)
•Boolean logic (and, mand, mor, nand, nor, not, or, xor, xnor)
•Control Structures (if-then-else, ternary conditional, switch case)
Documentation for ExprTk is available here: https://www.partow.net/programming/exprtk/index.html
Note: When the user works with the expression calculator, the user should pay attention to the mathematical expression. In the mathematical expression, the user can't use the combination of one gather and one matrix inside the mathematical expression. Either it should be completely gather or matrix but not both.
For example, the user tries to update the trace headers (BIN_PICKET) with a scalar value which the user generated by using Interpolate headers from matrix module. In the expression calculator, the user should provide the Input gather A only and should not provide the matrix however in the mathematical expression, the user should write the expression as a*a_header_name. Here a_header_name is nothing but the Gather A with the interpolated trace header (a_bin_picket) which was previously updated in the previous module i.e., Interpolate headers from Matrix.
![]()
![]()
Controls how many CPU cores are used during execution. The module processes traces in parallel — each thread handles a separate set of traces simultaneously. Increase this value on machines with many cores to reduce total processing time for large gathers. Set it to 1 to use only a single core, which can be useful for debugging expressions or when running on a shared compute node.
When checked, the module is disabled and passes its input through unchanged. Use this to temporarily disable the expression without removing the module from the workflow. Default: unchecked (the expression is applied).
![]()
![]()
The result of evaluating the mathematical expression at every trace and sample position. The output gather has exactly the same geometry as the first input gather: same number of traces, same number of samples, same sample rate, and the same trace headers copied from Input gather A. Connect this output to the next module in the workflow. Note: if only matrices (and no gathers) are connected as input, the result is sent to the Output matrix connector instead, and this Output gather connector remains empty.
When no gathers are connected and one or more matrices are connected, the module writes its output here instead of to the Output gather. The output matrix has the same dimensions as the input matrices. A map view of the output matrix is displayed in the Location map vista panel after execution.
![]()
![]()
In this example, we are working on a shot gather where we would like to calculate the amplitude relationship function of an AGC (Automatic Gain Control) applied shot gather. Later, we would like to take off this AGC by using the expression calculator.

In the 1st expression calculator, we connect/reference the Input gather of AGC as Input Gather A and Output Gather of AGC as Input Gather B.


Now, we'll define the mathematical expression as "a/b". This will gives us a Output gather. This output is the amplitude relation function.

In the second expression calculator module, we use Output gather of AGC module as Input Gather A and Output gather of Expression calculator 1 as Input Gather 2 and define the mathematical expression.


Now in the 2nd Expression calculator mathematical expression, we define the expression as "a*b". This will gives us the output gather without any AGC applied. In other words, the original input gather before the application of AGC.

To make sure that the original input and the output from the 2nd Expression calculation is same, we can add additional expression calculator and do a simple mathematical subtraction. It should give zero response.



There is another example where the user wants to apply scalars to the input seismic file by using expression calculator.



In the above expression, "a" denotes the input gather (A/a) and "a_bin_picket" is the nothing but the trace header bin_picket which has the updated scalar values (by using Interpolate headers from matrix module shown below image)

![]()
![]()
There are no action items are available for this module so the user can ignore it.
![]()
![]()
YouTube video lesson, click here to open [VIDEO IN PROCESS...]
![]()
![]()
Yilmaz. O., 1987, Seismic data processing: Society of Exploration Geophysicist
* * * If you have any questions, please send an e-mail to: support@geomage.com * * *