Expression calculator

<< Click to Display Table of Contents >>

Navigation:  AVO >

Expression calculator

 

Description

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. At every sample position the module evaluates the expression you type, using the amplitude values from each connected input as variables. This makes it possible to combine datasets, compute attribute volumes, scale amplitudes by a function of offset or time, or apply any custom per-sample transformation without writing any code.

The formula uses standard C-style mathematical syntax powered by the ExprTk library, which supports arithmetic operators, comparison and logical operators, trigonometric and exponential functions, conditional (if/else) constructs, and all common mathematical constants such as pi and e. Up to 26 gathers and 26 matrices can be connected simultaneously, referenced in the formula by the letters A, B, C and so on. Additionally, every standard SEG-Y trace header value from each input (for example offset, shot point number, bin coordinates) is available as a named variable so that you can make the formula dependent on acquisition geometry as well as amplitude.

When only matrices are connected (and no gathers), the result is written to the Output matrix connector and displayed as a 2D map. When at least one gather is connected the result is written to the Output gather connector and displayed as a seismic section. The output always has the same number of traces, samples, sample interval, and trace spacing as the first input.

 

Input data and parameters

Gathers

A dynamic collection of seismic gathers to use as input data. You can add as many gathers as you need by clicking the plus button inside the collection. The first gather you add is automatically labelled Input gather A, the second Input gather B, and so on. In the formula, the amplitude of the current sample from the first gather is referred to as A, the second as B, and so forth.

All gathers in the collection must have the same number of traces and the same number of samples, and must share the same sample interval. If any pair of inputs differs in these dimensions the module will report an error before processing begins. The output gather inherits its geometry (number of traces, number of samples, sample interval, and trace spacing) from the first gather in the list.

Input gather A

The first (mandatory) seismic gather, referenced in the formula as the variable A. This gather defines the output geometry. At least one gather must be connected unless you are working exclusively with matrices. Additional gathers (B, C, ...) are added by expanding the Gathers collection.

Matrices

A dynamic collection of 2D matrices (maps) to use as additional input data. Matrices are auto-labelled Input matrix A, Input matrix B, and so on, and their letter index continues from where the Gathers collection left off. For example, if two gathers are connected (A and B), the first matrix is available in the formula as C.

When matrices are used together with gathers, the matrix columns must match the number of traces in the gather so that each column of the matrix is paired with the corresponding trace. If only matrices are connected (no gathers at all), the output is a matrix rather than a gather, and the result is displayed as a 2D map.

Input matrix A

The first 2D matrix input. Its letter variable in the formula depends on how many gathers are already connected. If no gathers are connected, it is accessible as A; if one gather is connected as A, then this matrix is accessible as B, and so on. Additional matrices can be added by expanding the Matrices collection.

Mathematical expression

The formula that is evaluated independently at every sample of every trace. Type any valid mathematical expression using C-style syntax. The default value is exp(a), which computes the natural exponential of the amplitude from the first input gather.

Amplitude variables. Each connected gather or matrix contributes a single-letter variable holding the amplitude at the current trace and sample position: A for the first input, B for the second, and so on. Letters are case-insensitive in the ExprTk engine.

Position variables. Two built-in variables are always available regardless of what inputs are connected:

trace — the zero-based index of the current trace (0 for the first trace, 1 for the second, and so on). Use this to make the formula depend on trace position, for example to apply a linear amplitude taper across the gather.

sample — the zero-based index of the current time or depth sample. Use this together with the sample interval of the gather when you need the actual time value in seconds, for example: sample * 0.002 gives the two-way time in seconds for a 2 ms sample interval.

Trace header variables. Every standard SEG-Y trace header field for each input gather is available as a named variable with the prefix GatherLetter_HeaderName. For example, the offset header of the first gather is A_OFFSET, and the source shot point number is A_SP. For the second gather the same headers are prefixed with B_, and so on. Custom (non-standard) trace headers are also available using the same naming convention. Header values are constant within a sample loop for a given trace and change only when the trace index advances.

Supported operators and functions. The ExprTk library recognises all standard arithmetic operators (+ - * / ^), comparison operators (< <= > >= == !=), logical operators (and or not), and a rich set of built-in functions including abs, sqrt, log, log10, exp, sin, cos, tan, atan2, min, max, clamp, and conditional expressions such as if(condition, value_if_true, value_if_false). The built-in constants pi and e are predefined.

Example expressions.

A + B — sum two gathers sample by sample.

A * 1000 — scale amplitudes by a constant factor of 1000.

abs(A) — compute the absolute value (envelope approximation) of the input amplitudes.

A / A_OFFSET — divide the amplitude at each sample by the offset of the trace from the first gather.

if(A > 0, A, 0) — zero out all negative amplitudes, keeping only positive half-cycles.

A * exp(-0.001 * sample * 0.004) — apply a time-variant exponential gain correction to data sampled at 4 ms.

The expression is compiled before the first iteration and reused throughout processing. If the expression contains a syntax error the module will report a descriptive message and will not start. The expression field is case-insensitive for function names and variable letters.

Settings

Bulk size

Controls how many gathers are grouped into a single processing chunk. Larger values can improve throughput when the input dataset is very large and I/O is the bottleneck. The default value is suitable for most workflows.

Limit number of threads on nodes

When running the module on a distributed cluster, this option caps the number of CPU threads used on each remote node. Enable it to prevent the module from monopolising all cores on shared compute resources.

Job suffix

An optional text label appended to the job name when submitting to a distributed processing cluster. Use this to distinguish runs of the same module with different parameter settings in the job queue.

Set custom affinity

Enables manual CPU affinity assignment, which pins the processing threads to specific CPU cores. This is an advanced performance tuning option for dedicated processing servers and is not needed in normal use.

Set custom affinity - true
Affinity

Specifies which CPU cores the module may use when custom affinity is enabled. Visible only when Set custom affinity is turned on.

Number of threads

Sets the number of parallel CPU threads used to evaluate the expression. The module processes traces in parallel so increasing this value proportionally reduces run time on multi-core machines. Set it to match the number of physical CPU cores available to the job, or leave it at the default to let the system decide automatically.

Skip

When enabled, the module passes the input data through to the output unchanged without performing any calculation. Use this to temporarily bypass the expression calculator in a workflow without disconnecting it.

Output data

Output gather

The seismic gather produced by evaluating the expression at every sample of every trace. The output has the same number of traces, the same number of samples, and the same sample interval as the first input gather. All original trace headers are preserved from the first input gather. This output is populated only when at least one gather is connected in the Gathers collection. When only matrices are connected (no gathers), the Output matrix connector is used instead and this connector remains empty.

Output matrix

A 2D map produced when the Gathers collection is empty and only matrices are connected. The output matrix has the same spatial dimensions as the input matrices. It is also displayed in the map view panel inside the module for immediate QC. This connector is inactive when any gather is connected.

Information

Graphics

Custom actions

The Expression Calculator has no custom action buttons. All processing is triggered by the standard Execute command.