{
    "command": "sgfieldmath",
    "description": "Supported indexing variables:\n\titime: sample index within a vector\n\tix: global processed-column index\n\tjx: column index within the current group\n\tigroup: processed-group index\n\tnx: number of columns in the current group\n\nSupported scalar variables:\n\tfield, field.previous\n\nSupported vector values:\n\tdata, data[index]\n\nSupported vector coordinates:\n\tdata.s0, data.ds, data.time, data.ns",
    "examples": [
        {
            "command": "sgfieldmath offset:f='((sx-gx)^2+(sy-gy)^2)^0.5' <input.sg >offset.sg",
            "expected": "Input must contain scalar sx, gx, sy and gy fields with compatible units.\nThe new float field offset contains the Euclidean source-receiver distance.",
            "title": "Create a scalar offset from source and receiver coordinates"
        },
        {
            "command": "sgfieldmath data2:F='data+0.5' <input.sg >derived.sg",
            "expected": "Input must contain a data vector; data2 contains data plus 0.5 per sample.\nThe uppercase type requests a vector rather than a scalar.",
            "title": "Create a vector by adding a constant to each sample"
        },
        {
            "command": "sgfieldmath offset='abs(soffset)' data='sin(data)' <input.sg >updated.sg",
            "expected": "Input must contain soffset and existing offset and data fields.\nSine interprets its argument in radians; verify that this is meaningful for data.\nSupported built-in functions are: sin, cos, tan, asin, acos, atan, if,\nreal, imag, abs, conj, exp, log, log10, sigmoid,ricker, sinc, erf, erfc, erfinv,\nrandu, randn, randr, randc, randl",
            "title": "Update a scalar offset and apply sine to vector samples"
        },
        {
            "command": "sgfieldmath data='ricker(2*PI*30*(data.time-0.5))' <input.sg >wavelet.sg",
            "expected": "Input must contain data with correct sampling origin and interval.\nFor time in seconds, 30 is central frequency of Hz and 0.5 is the centre\ntime in seconds; verify the resulting spectrum rather than assuming a peak frequency.\nSupported built-in phsycial constants are: PI, I",
            "title": "Replace a vector with a sampled Ricker wavelet"
        },
        {
            "command": "sgfieldmath data.rename=vector1 data1.rename=vector2 <input.sg >renamed.sg",
            "expected": "Input must contain data and data1; choose unused output names.",
            "title": "Rename two existing fields while retaining their values"
        },
        {
            "command": "sgfieldmath mean:f=data.mean <input.sg >means.sg",
            "expected": "Input must contain a data vector; mean is a float scalar per input column,\nnot an aggregate across categorical records.\nSupported vector statistics include: data.sum, data.sum2, data.mean, data.rms,\ndata.min, data.max, data.amin, data.amax, data.imin, data.imax",
            "title": "Create a scalar containing the mean of each data vector"
        },
        {
            "command": "sgfieldmath positive:F='if((data>=0),data,0)' <input.sg >positive.sg",
            "expected": "Input must contain a real data vector; positive retains nonnegative values.\nCommands are illustrative and require output checks on the intended datasets.",
            "title": "Create a vector with negative samples replaced by zero"
        }
    ],
    "input_description": "input data",
    "notes": [],
    "output_description": "output data",
    "package": "sigclear-dsp",
    "parameters": [
        {
            "choices": [],
            "default": "stdin",
            "default_known": false,
            "description": "input data",
            "name": "in",
            "required": false,
            "type": "ifile",
            "units": null
        },
        {
            "choices": [],
            "default": "stdout",
            "default_known": false,
            "description": "output data",
            "name": "out",
            "required": false,
            "type": "ofile",
            "units": null
        }
    ],
    "related": [],
    "schema_version": 1,
    "summary": "Calculate fields using mathematical expressions",
    "synopsis": "sgfieldmath <stdin >stdout",
    "version": "1.2.0-2"
}