Spectra, Welch, FRF, and Metrics

Compute periodograms, Welch PSDs, and frequency response functions. Interpret frequency axes, units, coherence, and spectral metrics.

From Frequency to Physical Meaning

Pass the sample rate in Hz as operand C in the spectral.* methods. The PSD is one-sided for real input and two-sided for complex input. The normalization uses the window energy and sample rate fs. In Welch’s method, an integer window greater than three selects a Hamming window of that length. A vector supplies the coefficients directly. Specify overlap as a fraction. NFFT controls bin spacing and any zero-padding.

Direction in Cross-Spectral Estimation

With X as the input and Y as the output, the cross-spectrum follows Y·conj(X). H1 is Pxy/Pxx and H2 is Pyy/conj(Pxy). Check the denominators and compare coherence before interpreting phase. The units are U²/Hz for PSD and U/√Hz for ASD. FRF units follow the ratio of output units to input units.

Interpret a Bin or an Entire Spectrum

The script signal_spectral_meaning.py checks an 8 Hz tone sampled at 128 Hz, with the output doubled in amplitude and delayed by three samples. At the center bin, H1 and H2 are approximately 0.765367−1.847759j, and the integrated input power is 0.5. Pass interpret_result a single bin with its counts, normalization, method, and input units. Calls with missing units are rejected. For the entire spectrum, use from_numeric_columns with row IDs, columns, and common metadata, or use a Dataset binding. Interpretation and publication are separate steps.

Operation Reference

Jump to an Operation

spectral.periodogram

Access
Registered in the Python Job
Arguments
Typed operands a, b, and c, with an optional typed options struct.
Shape
Vectors and a positive scalar
Units
Hz and squared signal unit per Hz
Result
Numeric and diagnostic fields.
Purpose
Computes the periodogram.
gxtxt_api_call("SIGNAL_API_v1", "spectral.periodogram", args)
Fields and Options

In the examples run for this operation, c carries the sample rate in Hz. The field below reproduces the reference schema for the documented version, where c is marked as unused.

  • a

    Purpose
    Signal
    Type
    array
    Required
    Yes (1)
    Units
    Signal unit
    Shape
    Vector
    Error
    InvalidOperand
  • b

    Purpose
    Unused protocol operand
    Type
    empty
    Required
    No (0)
    Units
    1
    Shape
    Unused
    Error
    DimensionMismatch
  • c

    Purpose
    Unused protocol operand
    Type
    empty
    Required
    No (0)
    Units
    1
    Shape
    Unused
    Error
    InvalidSampleRate
  • options.window

    Purpose
    Window coefficients
    Type
    array
    Required
    No (0)
    Default
    Computation backend default
    Units
    1
    Shape
    Periodogram: vector with the same length as the signal. Welch: scalar integer greater than 3, or a real vector.
    Error
    InvalidArguments
  • options.overlap

    Purpose
    Overlap fraction
    Type
    number
    Required
    No (0)
    Default
    .5
    Units
    1
    Minimum
    0
    Maximum
    0.95
    Error
    InvalidPolicy
  • options.nfft

    Purpose
    FFT length
    Type
    integer
    Required
    No (0)
    Default
    Computation backend default
    Units
    1
    Minimum
    1
    Shape
    Positive for the periodogram. Welch extends it to at least the window length.
    Error
    InvalidLength
Recorded Result · spectral.periodogram:complex

Download the example script (extract the ZIP first).

Example Operands Preview

[
  {
    "kind": "array",
    "shape": [
      128,
      1
    ],
    "real": [
      1.0,
      0.9238795325112867,
      0.7071067811865476,
      0.38268343236508984,
      6.123233995736766e-17,
      -0.3826834323650897,
      -0.7071067811865475,
      -0.9238795325112867,
      -1.0,
      -0.9238795325112868
    ],
    "imaginary": [
      0.0,
      0.3826834323650898,
      0.7071067811865475,
      0.9238795325112867,
      1.0,
      0.9238795325112867,
      0.7071067811865476,
      0.3826834323650899,
      1.2246467991473532e-16,
      -0.38268343236508967
    ]
  },
  {
    "kind": "empty"
  },
  {
    "kind": "array",
    "shape": [
      1,
      1
    ],
    "real": [
      128.0
    ]
  },
  {
    "kind": "struct",
    "fields": {
      "nfft": {
        "kind": "array",
        "shape": [
          1,
          1
        ],
        "real": [
          128
        ]
      }
    }
  }
]

Result Preview

{
  "frequency_hz": {
    "dtype": "float64",
    "shape": [
      128,
      1
    ],
    "values": [
      0.0,
      1.0,
      2.0,
      3.0,
      4.0,
      5.0,
      6.0,
      7.0,
      8.0,
      9.0,
      10.0,
      11.0
    ]
  },
  "psd_real": {
    "dtype": "float64",
    "shape": [
      128,
      1
    ],
    "values": [
      8.408273901976662e-09,
      1.4531838105030757e-08,
      2.741145430360886e-08,
      5.84520889203366e-08,
      1.500295160336116e-07,
      5.291707257501901e-07,
      3.791770151582523e-06,
      0.13517343565765305,
      0.7296439336756718,
      0.13517343565765275,
      3.791770151582176e-06,
      5.291707257502215e-07
    ]
  },
  "psd_imaginary": {
    "dtype": "float64",
    "shape": [
      128,
      1
    ],
    "values": [
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0
    ]
  },
  "n": 128.0,
  "sample_rate": 128.0,
  "fft_length": 128.0,
  "bin_count": 128.0,
  "window_length": 128.0,
  "overlap_samples": 0.0,
  "window_count": 1.0,
  "used_sample_count": 128.0,
  "method": "octave_periodogram_window_energy",
  "spectral_operation": "periodogram",
  "sidedness": "twosided",
  "detrend": "none",
  "input_kind": "complex",
  "normalization": "window_energy_and_sample_rate"
}
Negative Test or Attempt Result · spectral.periodogram

Download the example script (extract the ZIP first).

Result Preview

"GXTXT:Signal:InvalidOperand: sample rate must be finite and nonempty"

spectral.welch

Access
Registered in the Python Job
Arguments
Typed operands a, b, and c, with an optional typed options struct.
Shape
Vectors and a positive scalar
Units
Hz and squared signal unit per Hz
Result
Numeric and diagnostic fields.
Purpose
Estimates the power spectral density with Welch’s method.
gxtxt_api_call("SIGNAL_API_v1", "spectral.welch", args)
Fields and Options

In the examples run for this operation, c carries the sample rate in Hz. The field below reproduces the reference schema for the documented version, where c is marked as unused.

  • a

    Purpose
    Signal
    Type
    array
    Required
    Yes (1)
    Units
    Signal unit
    Shape
    Vector
    Error
    InvalidOperand
  • b

    Purpose
    Unused protocol operand
    Type
    empty
    Required
    No (0)
    Units
    1
    Shape
    Unused
    Error
    DimensionMismatch
  • c

    Purpose
    Unused protocol operand
    Type
    empty
    Required
    No (0)
    Units
    1
    Shape
    Unused
    Error
    InvalidSampleRate
  • options.window

    Purpose
    Window coefficients
    Type
    array
    Required
    No (0)
    Default
    Computation backend default
    Units
    1
    Shape
    Periodogram: vector with the same length as the signal. Welch: scalar integer greater than 3, or a real vector.
    Error
    InvalidArguments
  • options.overlap

    Purpose
    Overlap fraction
    Type
    number
    Required
    No (0)
    Default
    .5
    Units
    1
    Minimum
    0
    Maximum
    0.95
    Error
    InvalidPolicy
  • options.nfft

    Purpose
    FFT length
    Type
    integer
    Required
    No (0)
    Default
    Computation backend default
    Units
    1
    Minimum
    0
    Shape
    Positive for the periodogram. Welch extends it to at least the window length.
    Error
    InvalidLength
Recorded Result · spectral.welch

Download the example script (extract the ZIP first).

Example Operands Preview

[
  {
    "kind": "array",
    "shape": [
      256,
      1
    ],
    "real": [
      1.0,
      0.9238795325112867,
      0.7071067811865476,
      0.38268343236508984,
      6.123233995736766e-17,
      -0.3826834323650897,
      -0.7071067811865475,
      -0.9238795325112867,
      -1.0,
      -0.9238795325112868
    ]
  },
  {
    "kind": "empty"
  },
  {
    "kind": "array",
    "shape": [
      1,
      1
    ],
    "real": [
      128.0
    ]
  },
  {
    "kind": "struct",
    "fields": {
      "window": {
        "kind": "array",
        "shape": [
          128,
          1
        ],
        "real": [
          1.0,
          1.0,
          1.0,
          1.0,
          1.0,
          1.0,
          1.0,
          1.0,
          1.0,
          1.0
        ]
      },
      "overlap": {
        "kind": "array",
        "shape": [
          1,
          1
        ],
        "real": [
          0.0
        ]
      },
      "nfft": {
        "kind": "array",
        "shape": [
          1,
          1
        ],
        "real": [
          128
        ]
      }
    }
  }
]

Result Preview

{
  "frequency_hz": {
    "dtype": "float64",
    "shape": [
      65,
      1
    ],
    "values": [
      0.0,
      1.0,
      2.0,
      3.0,
      4.0,
      5.0,
      6.0,
      7.0,
      8.0,
      9.0,
      10.0,
      11.0
    ]
  },
  "psd_real": {
    "dtype": "float64",
    "shape": [
      65,
      1
    ],
    "values": [
      1.2185511617508177e-32,
      5.681705801959767e-33,
      1.1569837495124349e-32,
      5.57711427598781e-32,
      7.046741499200674e-31,
      1.4790658267700833e-31,
      8.85509606837798e-32,
      4.4340767396073056e-32,
      0.49999999999999994,
      2.5637212950911756e-32,
      5.042096911373439e-32,
      3.635513617903586e-32
    ]
  },
  "psd_imaginary": {
    "dtype": "float64",
    "shape": [
      65,
      1
    ],
    "values": [
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0
    ]
  },
  "n": 256.0,
  "sample_rate": 128.0,
  "fft_length": 128.0,
  "bin_count": 65.0,
  "window_length": 128.0,
  "overlap_samples": 0.0,
  "window_count": 2.0,
  "used_sample_count": 256.0,
  "method": "octave_native_welch_window_energy",
  "spectral_operation": "welch",
  "sidedness": "onesided",
  "detrend": "global_mean_over_used_segment_span",
  "input_kind": "real",
  "normalization": "window_energy_and_sample_rate"
}
Negative Test or Attempt Result · spectral.welch

Download the example script (extract the ZIP first).

Result Preview

"GXTXT:Signal:InvalidOperand: sample rate must be finite and nonempty"

spectral.cross_psd

Access
Registered in the Python Job
Arguments
Typed operands a, b, and c, with an optional typed options struct.
Shape
Vectors and a positive scalar
Units
Hz and squared signal unit per Hz
Result
Numeric and diagnostic fields.
Purpose
Estimates the cross power spectral density.
gxtxt_api_call("SIGNAL_API_v1", "spectral.cross_psd", args)
Fields and Options

In the examples run for this operation, c carries the sample rate in Hz. The field below reproduces the reference schema for the documented version, where c is marked as unused.

  • a

    Purpose
    Signal
    Type
    array
    Required
    Yes (1)
    Units
    Signal unit
    Shape
    Vector
    Error
    InvalidOperand
  • b

    Purpose
    Second signal
    Type
    array
    Required
    Yes (1)
    Units
    Signal unit
    Shape
    Same length as a
    Error
    DimensionMismatch
  • c

    Purpose
    Unused protocol operand
    Type
    empty
    Required
    No (0)
    Units
    1
    Shape
    Unused
    Error
    InvalidSampleRate
  • options.window

    Purpose
    Window coefficients
    Type
    array
    Required
    No (0)
    Default
    Computation backend default
    Units
    1
    Shape
    Periodogram: vector with the same length as the signal. Welch: scalar integer greater than 3, or a real vector.
    Error
    InvalidArguments
  • options.overlap

    Purpose
    Overlap fraction
    Type
    number
    Required
    No (0)
    Default
    .5
    Units
    1
    Minimum
    0
    Maximum
    0.95
    Error
    InvalidPolicy
  • options.nfft

    Purpose
    FFT length
    Type
    integer
    Required
    No (0)
    Default
    Computation backend default
    Units
    1
    Minimum
    0
    Shape
    Positive for the periodogram. Welch extends it to at least the window length.
    Error
    InvalidLength
Recorded Result · spectral.cross_psd

Download the example script (extract the ZIP first).

Example Operands Preview

[
  {
    "kind": "array",
    "shape": [
      256,
      1
    ],
    "real": [
      1.0,
      0.9238795325112867,
      0.7071067811865476,
      0.38268343236508984,
      6.123233995736766e-17,
      -0.3826834323650897,
      -0.7071067811865475,
      -0.9238795325112867,
      -1.0,
      -0.9238795325112868
    ]
  },
  {
    "kind": "array",
    "shape": [
      256,
      1
    ],
    "real": [
      0.7653668647301797,
      1.4142135623730951,
      1.8477590650225735,
      2.0,
      1.8477590650225735,
      1.4142135623730951,
      0.7653668647301797,
      1.2246467991473532e-16,
      -0.7653668647301795,
      -1.414213562373095
    ]
  },
  {
    "kind": "array",
    "shape": [
      1,
      1
    ],
    "real": [
      128.0
    ]
  },
  {
    "kind": "struct",
    "fields": {
      "window": {
        "kind": "array",
        "shape": [
          128,
          1
        ],
        "real": [
          1.0,
          1.0,
          1.0,
          1.0,
          1.0,
          1.0,
          1.0,
          1.0,
          1.0,
          1.0
        ]
      },
      "overlap": {
        "kind": "array",
        "shape": [
          1,
          1
        ],
        "real": [
          0.0
        ]
      },
      "nfft": {
        "kind": "array",
        "shape": [
          1,
          1
        ],
        "real": [
          128
        ]
      }
    }
  }
]

Result Preview

{
  "frequency_hz": {
    "dtype": "float64",
    "shape": [
      65,
      1
    ],
    "values": [
      0.0,
      1.0,
      2.0,
      3.0,
      4.0,
      5.0,
      6.0,
      7.0,
      8.0,
      9.0,
      10.0,
      11.0
    ]
  },
  "value_real": {
    "dtype": "float64",
    "shape": [
      65,
      1
    ],
    "values": [
      1.8738828478791452e-32,
      1.4216026716919354e-32,
      1.9527074061025306e-32,
      1.0569226119411136e-31,
      1.1409179161230903e-30,
      2.2528020526501876e-31,
      1.0749523820179636e-31,
      3.457661852458013e-32,
      0.3826834323650897,
      1.619006405725719e-32,
      9.80424830974701e-33,
      -1.0531192272128879e-32
    ]
  },
  "value_imaginary": {
    "dtype": "float64",
    "shape": [
      65,
      1
    ],
    "values": [
      0.0,
      1.6738584199925175e-33,
      -7.642454534883563e-33,
      -5.247814165189543e-32,
      -7.921596085356375e-31,
      -1.8504689549296794e-31,
      -1.2349297508853368e-31,
      -6.942893454569048e-32,
      -0.9238795325112866,
      -4.5334481479158817e-32,
      -9.222010949017691e-32,
      -6.79884589424066e-32
    ]
  },
  "n": 256.0,
  "sample_rate": 128.0,
  "fft_length": 128.0,
  "bin_count": 65.0,
  "window_length": 128.0,
  "overlap_samples": 0.0,
  "window_count": 2.0,
  "used_sample_count": 256.0,
  "method": "octave_native_welch_window_energy",
  "spectral_operation": "cross_psd",
  "sidedness": "onesided",
  "detrend": "global_mean_over_used_segment_span",
  "input_kind": "real",
  "normalization": "window_energy_and_sample_rate"
}
Negative Test or Attempt Result · spectral.cross_psd

Download the example script (extract the ZIP first).

Result Preview

"GXTXT:Signal:InvalidOperand: sample rate must be finite and nonempty"

spectral.coherence

Access
Registered in the Python Job
Arguments
Typed operands a, b, and c, with an optional typed options struct.
Shape
Vectors and a positive scalar
Units
Hz and squared signal unit per Hz
Result
Numeric and diagnostic fields.
Purpose
Estimates the spectral coherence.
gxtxt_api_call("SIGNAL_API_v1", "spectral.coherence", args)
Fields and Options

In the examples run for this operation, c carries the sample rate in Hz. The field below reproduces the reference schema for the documented version, where c is marked as unused.

  • a

    Purpose
    Signal
    Type
    array
    Required
    Yes (1)
    Units
    Signal unit
    Shape
    Vector
    Error
    InvalidOperand
  • b

    Purpose
    Second signal
    Type
    array
    Required
    Yes (1)
    Units
    Signal unit
    Shape
    Same length as a
    Error
    DimensionMismatch
  • c

    Purpose
    Unused protocol operand
    Type
    empty
    Required
    No (0)
    Units
    1
    Shape
    Unused
    Error
    InvalidSampleRate
  • options.window

    Purpose
    Window coefficients
    Type
    array
    Required
    No (0)
    Default
    Computation backend default
    Units
    1
    Shape
    Periodogram: vector with the same length as the signal. Welch: scalar integer greater than 3, or a real vector.
    Error
    InvalidArguments
  • options.overlap

    Purpose
    Overlap fraction
    Type
    number
    Required
    No (0)
    Default
    .5
    Units
    1
    Minimum
    0
    Maximum
    0.95
    Error
    InvalidPolicy
  • options.nfft

    Purpose
    FFT length
    Type
    integer
    Required
    No (0)
    Default
    Computation backend default
    Units
    1
    Minimum
    0
    Shape
    Positive for the periodogram. Welch extends it to at least the window length.
    Error
    InvalidLength
Recorded Result · spectral.coherence

Download the example script (extract the ZIP first).

Example Operands Preview

[
  {
    "kind": "array",
    "shape": [
      128,
      1
    ],
    "real": [
      0.0,
      0.45339411048374456,
      0.8071067811865474,
      0.9945902106299415,
      1.0,
      0.853168854392632,
      0.6071067811865476,
      0.3119727542464351,
      9.797174393178826e-17,
      -0.31197275424643495
    ]
  },
  {
    "kind": "array",
    "shape": [
      128,
      1
    ],
    "real": [
      -1.790262379133897,
      -1.4527922061357845,
      -0.8161093988707413,
      0.0,
      0.8161093988707402,
      1.4527922061357854,
      1.7902623791338947,
      1.8,
      1.5357039379067376,
      1.0927922061357858
    ]
  },
  {
    "kind": "array",
    "shape": [
      1,
      1
    ],
    "real": [
      128.0
    ]
  },
  {
    "kind": "struct",
    "fields": {
      "sample_rate": {
        "kind": "array",
        "shape": [
          1,
          1
        ],
        "real": [
          128.0
        ]
      },
      "window": {
        "kind": "array",
        "shape": [
          1,
          1
        ],
        "real": [
          32
        ]
      },
      "overlap": {
        "kind": "array",
        "shape": [
          1,
          1
        ],
        "real": [
          0.5
        ]
      },
      "nfft": {
        "kind": "array",
        "shape": [
          1,
          1
        ],
        "real": [
          64
        ]
      }
    }
  }
]

Result Preview

{
  "frequency_hz": {
    "dtype": "float64",
    "shape": [
      33,
      1
    ],
    "values": [
      0.0,
      2.0,
      4.0,
      6.0,
      8.0,
      10.0,
      12.0,
      14.0,
      16.0,
      18.0,
      20.0,
      22.0
    ]
  },
  "value_real": {
    "dtype": "float64",
    "shape": [
      33,
      1
    ],
    "values": [
      0.9999999999999999,
      1.0,
      1.0000000000000004,
      0.9999999999999999,
      1.0000000000000002,
      1.0000000000000002,
      1.0000000000000004,
      0.9999999999999998,
      0.9999999999999999,
      0.9999999999999998,
      1.0,
      0.9999999999999996
    ]
  },
  "value_imaginary": {
    "dtype": "float64",
    "shape": [
      33,
      1
    ],
    "values": [
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0
    ]
  },
  "n": 128.0,
  "sample_rate": 128.0,
  "fft_length": 64.0,
  "bin_count": 33.0,
  "window_length": 32.0,
  "overlap_samples": 16.0,
  "window_count": 7.0,
  "used_sample_count": 128.0,
  "method": "octave_native_welch_window_energy",
  "spectral_operation": "coherence",
  "sidedness": "onesided",
  "detrend": "global_mean_over_used_segment_span",
  "input_kind": "real",
  "normalization": "window_energy_and_sample_rate"
}
Negative Test or Attempt Result · spectral.coherence

Download the example script (extract the ZIP first).

Result Preview

"GXTXT:Signal:InvalidOperand: sample rate must be finite and nonempty"

spectral.frf_h1

Access
Registered in the Python Job
Arguments
Typed operands a, b, and c, with an optional typed options struct.
Shape
Vectors and a positive scalar
Units
Hz and squared signal unit per Hz
Result
Numeric and diagnostic fields.
Purpose
Estimates the frequency response with the H1 estimator.
gxtxt_api_call("SIGNAL_API_v1", "spectral.frf_h1", args)
Fields and Options

In the examples run for this operation, c carries the sample rate in Hz. The field below reproduces the reference schema for the documented version, where c is marked as unused.

  • a

    Purpose
    Signal
    Type
    array
    Required
    Yes (1)
    Units
    Signal unit
    Shape
    Vector
    Error
    InvalidOperand
  • b

    Purpose
    Second signal
    Type
    array
    Required
    Yes (1)
    Units
    Signal unit
    Shape
    Same length as a
    Error
    DimensionMismatch
  • c

    Purpose
    Unused protocol operand
    Type
    empty
    Required
    No (0)
    Units
    1
    Shape
    Unused
    Error
    InvalidSampleRate
  • options.window

    Purpose
    Window coefficients
    Type
    array
    Required
    No (0)
    Default
    Computation backend default
    Units
    1
    Shape
    Periodogram: vector with the same length as the signal. Welch: scalar integer greater than 3, or a real vector.
    Error
    InvalidArguments
  • options.overlap

    Purpose
    Overlap fraction
    Type
    number
    Required
    No (0)
    Default
    .5
    Units
    1
    Minimum
    0
    Maximum
    0.95
    Error
    InvalidPolicy
  • options.nfft

    Purpose
    FFT length
    Type
    integer
    Required
    No (0)
    Default
    Computation backend default
    Units
    1
    Minimum
    0
    Shape
    Positive for the periodogram. Welch extends it to at least the window length.
    Error
    InvalidLength
Recorded Result · spectral.frf_h1:zero-denominator

Download the example script (extract the ZIP first).

Example Operands Preview

[
  {
    "kind": "array",
    "shape": [
      256,
      1
    ],
    "real": [
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0
    ]
  },
  {
    "kind": "array",
    "shape": [
      256,
      1
    ],
    "real": [
      0.7653668647301797,
      1.4142135623730951,
      1.8477590650225735,
      2.0,
      1.8477590650225735,
      1.4142135623730951,
      0.7653668647301797,
      1.2246467991473532e-16,
      -0.7653668647301795,
      -1.414213562373095
    ]
  },
  {
    "kind": "array",
    "shape": [
      1,
      1
    ],
    "real": [
      128.0
    ]
  },
  {
    "kind": "struct",
    "fields": {
      "window": {
        "kind": "array",
        "shape": [
          128,
          1
        ],
        "real": [
          1.0,
          1.0,
          1.0,
          1.0,
          1.0,
          1.0,
          1.0,
          1.0,
          1.0,
          1.0
        ]
      },
      "overlap": {
        "kind": "array",
        "shape": [
          1,
          1
        ],
        "real": [
          0.0
        ]
      },
      "nfft": {
        "kind": "array",
        "shape": [
          1,
          1
        ],
        "real": [
          128
        ]
      }
    }
  }
]

Result Preview

{
  "frequency_hz": {
    "dtype": "float64",
    "shape": [
      65,
      1
    ],
    "values": [
      0.0,
      1.0,
      2.0,
      3.0,
      4.0,
      5.0,
      6.0,
      7.0,
      8.0,
      9.0,
      10.0,
      11.0
    ]
  },
  "value_real": {
    "dtype": "float64",
    "shape": [
      65,
      1
    ],
    "values": [
      NaN,
      NaN,
      NaN,
      NaN,
      NaN,
      NaN,
      NaN,
      NaN,
      NaN,
      NaN,
      NaN,
      NaN
    ]
  },
  "value_imaginary": {
    "dtype": "float64",
    "shape": [
      65,
      1
    ],
    "values": [
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0
    ]
  },
  "n": 256.0,
  "sample_rate": 128.0,
  "fft_length": 128.0,
  "bin_count": 65.0,
  "window_length": 128.0,
  "overlap_samples": 0.0,
  "window_count": 2.0,
  "used_sample_count": 256.0,
  "method": "octave_native_welch_window_energy",
  "spectral_operation": "frf_h1",
  "sidedness": "onesided",
  "detrend": "global_mean_over_used_segment_span",
  "input_kind": "real",
  "normalization": "window_energy_and_sample_rate"
}
Negative Test or Attempt Result · spectral.frf_h1

Download the example script (extract the ZIP first).

Result Preview

"GXTXT:Signal:InvalidOperand: sample rate must be finite and nonempty"

spectral.frf_h2

Access
Registered in the Python Job
Arguments
Typed operands a, b, and c, with an optional typed options struct.
Shape
Vectors and a positive scalar
Units
Hz and squared signal unit per Hz
Result
Numeric and diagnostic fields.
Purpose
Estimates the frequency response with the H2 estimator.
gxtxt_api_call("SIGNAL_API_v1", "spectral.frf_h2", args)
Fields and Options

In the examples run for this operation, c carries the sample rate in Hz. The field below reproduces the reference schema for the documented version, where c is marked as unused.

  • a

    Purpose
    Signal
    Type
    array
    Required
    Yes (1)
    Units
    Signal unit
    Shape
    Vector
    Error
    InvalidOperand
  • b

    Purpose
    Second signal
    Type
    array
    Required
    Yes (1)
    Units
    Signal unit
    Shape
    Same length as a
    Error
    DimensionMismatch
  • c

    Purpose
    Unused protocol operand
    Type
    empty
    Required
    No (0)
    Units
    1
    Shape
    Unused
    Error
    InvalidSampleRate
  • options.window

    Purpose
    Window coefficients
    Type
    array
    Required
    No (0)
    Default
    Computation backend default
    Units
    1
    Shape
    Periodogram: vector with the same length as the signal. Welch: scalar integer greater than 3, or a real vector.
    Error
    InvalidArguments
  • options.overlap

    Purpose
    Overlap fraction
    Type
    number
    Required
    No (0)
    Default
    .5
    Units
    1
    Minimum
    0
    Maximum
    0.95
    Error
    InvalidPolicy
  • options.nfft

    Purpose
    FFT length
    Type
    integer
    Required
    No (0)
    Default
    Computation backend default
    Units
    1
    Minimum
    0
    Shape
    Positive for the periodogram. Welch extends it to at least the window length.
    Error
    InvalidLength
Recorded Result · spectral.frf_h2

Download the example script (extract the ZIP first).

Example Operands Preview

[
  {
    "kind": "array",
    "shape": [
      256,
      1
    ],
    "real": [
      1.0,
      0.9238795325112867,
      0.7071067811865476,
      0.38268343236508984,
      6.123233995736766e-17,
      -0.3826834323650897,
      -0.7071067811865475,
      -0.9238795325112867,
      -1.0,
      -0.9238795325112868
    ]
  },
  {
    "kind": "array",
    "shape": [
      256,
      1
    ],
    "real": [
      0.7653668647301797,
      1.4142135623730951,
      1.8477590650225735,
      2.0,
      1.8477590650225735,
      1.4142135623730951,
      0.7653668647301797,
      1.2246467991473532e-16,
      -0.7653668647301795,
      -1.414213562373095
    ]
  },
  {
    "kind": "array",
    "shape": [
      1,
      1
    ],
    "real": [
      128.0
    ]
  },
  {
    "kind": "struct",
    "fields": {
      "window": {
        "kind": "array",
        "shape": [
          128,
          1
        ],
        "real": [
          1.0,
          1.0,
          1.0,
          1.0,
          1.0,
          1.0,
          1.0,
          1.0,
          1.0,
          1.0
        ]
      },
      "overlap": {
        "kind": "array",
        "shape": [
          1,
          1
        ],
        "real": [
          0.0
        ]
      },
      "nfft": {
        "kind": "array",
        "shape": [
          1,
          1
        ],
        "real": [
          128
        ]
      }
    }
  }
]

Result Preview

{
  "frequency_hz": {
    "dtype": "float64",
    "shape": [
      65,
      1
    ],
    "values": [
      0.0,
      1.0,
      2.0,
      3.0,
      4.0,
      5.0,
      6.0,
      7.0,
      8.0,
      9.0,
      10.0,
      11.0
    ]
  },
  "value_real": {
    "dtype": "float64",
    "shape": [
      65,
      1
    ],
    "values": [
      1.6049922566868315,
      2.721088414130156,
      1.9663101845831215,
      1.9401213239089263,
      1.6214534427395666,
      1.5375155665522253,
      1.2337406199154213,
      0.7996201978009898,
      0.7653668647301795,
      0.6748065222184466,
      0.2018428631733057,
      -0.3029231622142977
    ]
  },
  "value_imaginary": {
    "dtype": "float64",
    "shape": [
      65,
      1
    ],
    "values": [
      0.0,
      0.3203930918415484,
      -0.7695692729075442,
      -0.9633057378814798,
      -1.125803974420857,
      -1.2629271268103723,
      -1.4173492909045076,
      -1.6056161864142595,
      -1.8477590650225735,
      -1.8895542151863747,
      -1.8985617615526675,
      -1.9556455190184674
    ]
  },
  "n": 256.0,
  "sample_rate": 128.0,
  "fft_length": 128.0,
  "bin_count": 65.0,
  "window_length": 128.0,
  "overlap_samples": 0.0,
  "window_count": 2.0,
  "used_sample_count": 256.0,
  "method": "octave_native_welch_window_energy",
  "spectral_operation": "frf_h2",
  "sidedness": "onesided",
  "detrend": "global_mean_over_used_segment_span",
  "input_kind": "real",
  "normalization": "window_energy_and_sample_rate"
}
Negative Test or Attempt Result · spectral.frf_h2

Download the example script (extract the ZIP first).

Result Preview

"GXTXT:Signal:InvalidOperand: sample rate must be finite and nonempty"

frequency_metric.gain

Access
Registered in the Python Job
Arguments
Typed operands a, b, and c, with an optional typed options struct.
Shape
Increasing vector and complex vector
Units
Hz, seconds, dB, dimensionless
Result
Numeric and diagnostic fields.
Purpose
Measures the gain.
gxtxt_api_call("SIGNAL_API_v1", "frequency_metric.gain", args)
Fields and Options
  • a

    Purpose
    Unused protocol operand
    Type
    empty
    Required
    No (0)
    Units
    1
    Shape
    Unused
    Error
    InvalidGrid
  • b

    Purpose
    Complex response
    Type
    array
    Required
    Yes (1)
    Units
    Response unit
    Shape
    Vector with the same length as the frequency axis
    Error
    InvalidOperand
  • c

    Purpose
    Unused protocol operand
    Type
    empty
    Required
    No (0)
    Units
    1
    Shape
    Unused
    Error
    InvalidOperand
Recorded Result · frequency_metric.gain

Download the example script (extract the ZIP first).

Example Operands Preview

[
  {
    "kind": "empty"
  },
  {
    "kind": "array",
    "shape": [
      64,
      1
    ],
    "real": [
      0.9798279403047728,
      0.9217371412632333,
      0.832335453671342,
      0.7207309587205422,
      0.5965713676367299,
      0.4684821996880966,
      0.3432128698307402,
      0.22543746239452572,
      0.11797794276541049,
      0.022210760746361413
    ],
    "imaginary": [
      -0.17330959955841002,
      -0.3345730173734037,
      -0.4739713970507837,
      -0.5853339650652518,
      -0.6664102365030429,
      -0.7182050864637909,
      -0.7438722105172789,
      -0.7476189190423772,
      -0.7338715097795699,
      -0.7067578666750501
    ]
  },
  {
    "kind": "empty"
  }
]

Result Preview

{
  "magnitude": {
    "dtype": "float64",
    "shape": [
      64,
      1
    ],
    "values": [
      0.995037190209989,
      0.9805806756909201,
      0.9578262852211513,
      0.9284766908852593,
      0.8944271909999159,
      0.8574929257125443,
      0.8192319205190405,
      0.7808688094430304,
      0.7432941462471664,
      0.7071067811865476,
      0.6726727939963124,
      0.6401843996644799
    ]
  },
  "gain_db": {
    "dtype": "float64",
    "shape": [
      64,
      1
    ],
    "values": [
      -0.043213737826426554,
      -0.17033339298780395,
      -0.374264979406237,
      -0.6445798922691849,
      -0.9691001300805644,
      -1.3353890837021738,
      -1.7318626841227402,
      -2.148438480476978,
      -2.5767857486918437,
      -3.0102999566398116,
      -3.443922736851108,
      -3.873898263387294
    ]
  },
  "phase_rad": {
    "dtype": "float64",
    "shape": [
      64,
      1
    ],
    "values": [
      -0.1750668761773171,
      -0.34819200722219085,
      -0.5176514655363321,
      -0.682099271856985,
      -0.8406387274315813,
      -0.9928088423875143,
      -1.1385135301922937,
      -1.2779267317127931,
      -1.4113991149619018,
      -1.5393804002589988,
      -1.662361727222137,
      -1.780836734832054
    ]
  }
}

frequency_metric.group_delay

Access
Registered in the Python Job
Arguments
Typed operands a, b, and c, with an optional typed options struct.
Shape
Increasing vector and complex vector
Units
Hz, seconds, dB, dimensionless
Result
Numeric and diagnostic fields.
Purpose
Computes the group delay.
gxtxt_api_call("SIGNAL_API_v1", "frequency_metric.group_delay", args)
Fields and Options
  • a

    Purpose
    Frequency
    Type
    array
    Required
    Yes (1)
    Units
    Hz
    Shape
    Increasing real vector, positive values for phase_delay.
    Error
    InvalidGrid
  • b

    Purpose
    Complex response
    Type
    array
    Required
    Yes (1)
    Units
    Response unit
    Shape
    Vector with the same length as the frequency axis
    Error
    InvalidOperand
  • c

    Purpose
    Unused protocol operand
    Type
    empty
    Required
    No (0)
    Units
    1
    Shape
    Unused
    Error
    InvalidOperand
Recorded Result · frequency_metric.group_delay

Download the example script (extract the ZIP first).

Example Operands Preview

[
  {
    "kind": "array",
    "shape": [
      64,
      1
    ],
    "real": [
      1.0,
      2.0,
      3.0,
      4.0,
      5.0,
      6.0,
      7.0,
      8.0,
      9.0,
      10.0
    ]
  },
  {
    "kind": "array",
    "shape": [
      64,
      1
    ],
    "real": [
      0.9798279403047728,
      0.9217371412632333,
      0.832335453671342,
      0.7207309587205422,
      0.5965713676367299,
      0.4684821996880966,
      0.3432128698307402,
      0.22543746239452572,
      0.11797794276541049,
      0.022210760746361413
    ],
    "imaginary": [
      -0.17330959955841002,
      -0.3345730173734037,
      -0.4739713970507837,
      -0.5853339650652518,
      -0.6664102365030429,
      -0.7182050864637909,
      -0.7438722105172789,
      -0.7476189190423772,
      -0.7338715097795699,
      -0.7067578666750501
    ]
  },
  {
    "kind": "empty"
  }
]

Result Preview

{
  "delay_seconds": {
    "dtype": "float64",
    "shape": [
      64,
      1
    ],
    "values": [
      0.027553720379223805,
      0.027262015411797187,
      0.026571495850460553,
      0.02570250964317274,
      0.024725482007946813,
      0.023704123640945367,
      0.022688960725023032,
      0.02171554485730278,
      0.020805821869319313,
      0.019970970136235566,
      0.01921448459407612,
      0.018534856912869782
    ]
  }
}

frequency_metric.phase_delay

Access
Registered in the Python Job
Arguments
Typed operands a, b, and c, with an optional typed options struct.
Shape
Increasing vector and complex vector
Units
Hz, seconds, dB, dimensionless
Result
Numeric and diagnostic fields.
Purpose
Computes the phase delay.
gxtxt_api_call("SIGNAL_API_v1", "frequency_metric.phase_delay", args)
Fields and Options
  • a

    Purpose
    Frequency
    Type
    array
    Required
    Yes (1)
    Units
    Hz
    Shape
    Increasing real vector, positive values for phase_delay.
    Error
    InvalidGrid
  • b

    Purpose
    Complex response
    Type
    array
    Required
    Yes (1)
    Units
    Response unit
    Shape
    Vector with the same length as the frequency axis
    Error
    InvalidOperand
  • c

    Purpose
    Unused protocol operand
    Type
    empty
    Required
    No (0)
    Units
    1
    Shape
    Unused
    Error
    InvalidOperand
Recorded Result · frequency_metric.phase_delay

Download the example script (extract the ZIP first).

Example Operands Preview

[
  {
    "kind": "array",
    "shape": [
      64,
      1
    ],
    "real": [
      1.0,
      2.0,
      3.0,
      4.0,
      5.0,
      6.0,
      7.0,
      8.0,
      9.0,
      10.0
    ]
  },
  {
    "kind": "array",
    "shape": [
      64,
      1
    ],
    "real": [
      0.9798279403047728,
      0.9217371412632333,
      0.832335453671342,
      0.7207309587205422,
      0.5965713676367299,
      0.4684821996880966,
      0.3432128698307402,
      0.22543746239452572,
      0.11797794276541049,
      0.022210760746361413
    ],
    "imaginary": [
      -0.17330959955841002,
      -0.3345730173734037,
      -0.4739713970507837,
      -0.5853339650652518,
      -0.6664102365030429,
      -0.7182050864637909,
      -0.7438722105172789,
      -0.7476189190423772,
      -0.7338715097795699,
      -0.7067578666750501
    ]
  },
  {
    "kind": "empty"
  }
]

Result Preview

{
  "delay_seconds": {
    "dtype": "float64",
    "shape": [
      64,
      1
    ],
    "values": [
      0.02786275871527679,
      0.0277082395472503,
      0.02746226317962372,
      0.027139867698855426,
      0.02675836176504333,
      0.026335072468552555,
      0.02588572230101534,
      0.025423544532670175,
      0.02495901620241255,
      0.024500000000000004,
      0.024052098735834915,
      0.023619080765679354
    ]
  }
}

frequency_metric.peak

Access
Registered in the Python Job
Arguments
Typed operands a, b, and c, with an optional typed options struct.
Shape
Increasing vector and complex vector
Units
Hz, seconds, dB, dimensionless
Result
Numeric and diagnostic fields.
Purpose
Finds the peak.
gxtxt_api_call("SIGNAL_API_v1", "frequency_metric.peak", args)
Fields and Options
  • a

    Purpose
    Frequency
    Type
    array
    Required
    Yes (1)
    Units
    Hz
    Shape
    Increasing real vector, positive values for phase_delay.
    Error
    InvalidGrid
  • b

    Purpose
    Complex response
    Type
    array
    Required
    Yes (1)
    Units
    Response unit
    Shape
    Vector with the same length as the frequency axis
    Error
    InvalidOperand
  • c

    Purpose
    Unused protocol operand
    Type
    empty
    Required
    No (0)
    Units
    1
    Shape
    Unused
    Error
    InvalidOperand
Recorded Result · frequency_metric.peak

Download the example script (extract the ZIP first).

Example Operands Preview

[
  {
    "kind": "array",
    "shape": [
      64,
      1
    ],
    "real": [
      1.0,
      2.0,
      3.0,
      4.0,
      5.0,
      6.0,
      7.0,
      8.0,
      9.0,
      10.0
    ]
  },
  {
    "kind": "array",
    "shape": [
      64,
      1
    ],
    "real": [
      0.9798279403047728,
      0.9217371412632333,
      0.832335453671342,
      0.7207309587205422,
      0.5965713676367299,
      0.4684821996880966,
      0.3432128698307402,
      0.22543746239452572,
      0.11797794276541049,
      0.022210760746361413
    ],
    "imaginary": [
      -0.17330959955841002,
      -0.3345730173734037,
      -0.4739713970507837,
      -0.5853339650652518,
      -0.6664102365030429,
      -0.7182050864637909,
      -0.7438722105172789,
      -0.7476189190423772,
      -0.7338715097795699,
      -0.7067578666750501
    ]
  },
  {
    "kind": "empty"
  }
]

Result Preview

{
  "peak_frequency_hz": 1.0,
  "peak_magnitude": 0.995037190209989,
  "peak_db": -0.043213737826426554
}

frequency_metric.resonance

Access
Registered in the Python Job
Arguments
Typed operands a, b, and c, with an optional typed options struct.
Shape
Increasing vector and complex vector
Units
Hz, seconds, dB, dimensionless
Result
Numeric and diagnostic fields.
Purpose
Determines the resonance characteristics.
gxtxt_api_call("SIGNAL_API_v1", "frequency_metric.resonance", args)
Fields and Options
  • a

    Purpose
    Frequency
    Type
    array
    Required
    Yes (1)
    Units
    Hz
    Shape
    Increasing real vector, positive values for phase_delay.
    Error
    InvalidGrid
  • b

    Purpose
    Complex response
    Type
    array
    Required
    Yes (1)
    Units
    Response unit
    Shape
    Vector with the same length as the frequency axis
    Error
    InvalidOperand
  • c

    Purpose
    Unused protocol operand
    Type
    empty
    Required
    No (0)
    Units
    1
    Shape
    Unused
    Error
    InvalidOperand
Recorded Result · frequency_metric.resonance

Download the example script (extract the ZIP first).

Example Operands Preview

[
  {
    "kind": "array",
    "shape": [
      64,
      1
    ],
    "real": [
      1.0,
      2.0,
      3.0,
      4.0,
      5.0,
      6.0,
      7.0,
      8.0,
      9.0,
      10.0
    ]
  },
  {
    "kind": "array",
    "shape": [
      64,
      1
    ],
    "real": [
      4.785117392129009e-06,
      2.586810022265412e-05,
      0.00012340980408667956,
      0.0005195746821548384,
      0.0019304541362277093,
      0.006329715427485747,
      0.01831563888873418,
      0.04677062238395898,
      0.10539922456186433,
      0.2096113871510978
    ],
    "imaginary": [
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0
    ]
  },
  {
    "kind": "empty"
  }
]

Result Preview

{
  "peak_frequency_hz": 15.0,
  "peak_magnitude": 1.0,
  "peak_db": 0.0
}

frequency_metric.bandwidth

Access
Registered in the Python Job
Arguments
Typed operands a, b, and c, with an optional typed options struct.
Shape
Increasing vector and complex vector
Units
Hz, seconds, dB, dimensionless
Result
Numeric and diagnostic fields.
Purpose
Measures the bandwidth.
gxtxt_api_call("SIGNAL_API_v1", "frequency_metric.bandwidth", args)
Fields and Options
  • a

    Purpose
    Frequency
    Type
    array
    Required
    Yes (1)
    Units
    Hz
    Shape
    Increasing real vector, positive values for phase_delay.
    Error
    InvalidGrid
  • b

    Purpose
    Complex response
    Type
    array
    Required
    Yes (1)
    Units
    Response unit
    Shape
    Vector with the same length as the frequency axis
    Error
    InvalidOperand
  • c

    Purpose
    Unused protocol operand
    Type
    empty
    Required
    No (0)
    Units
    1
    Shape
    Unused
    Error
    InvalidOperand
Recorded Result · frequency_metric.bandwidth

Download the example script (extract the ZIP first).

Example Operands Preview

[
  {
    "kind": "array",
    "shape": [
      64,
      1
    ],
    "real": [
      1.0,
      2.0,
      3.0,
      4.0,
      5.0,
      6.0,
      7.0,
      8.0,
      9.0,
      10.0
    ]
  },
  {
    "kind": "array",
    "shape": [
      64,
      1
    ],
    "real": [
      4.785117392129009e-06,
      2.586810022265412e-05,
      0.00012340980408667956,
      0.0005195746821548384,
      0.0019304541362277093,
      0.006329715427485747,
      0.01831563888873418,
      0.04677062238395898,
      0.10539922456186433,
      0.2096113871510978
    ],
    "imaginary": [
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0
    ]
  },
  {
    "kind": "empty"
  }
]

Result Preview

{
  "lower_3db_hz": 12.656995970805195,
  "upper_3db_hz": 17.343004029194805,
  "bandwidth_hz": 4.686008058389611,
  "peak_frequency_hz": 15.0,
  "q": 3.2010188230779284
}

frequency_metric.q

Access
Registered in the Python Job
Arguments
Typed operands a, b, and c, with an optional typed options struct.
Shape
Increasing vector and complex vector
Units
Hz, seconds, dB, dimensionless
Result
Numeric and diagnostic fields.
Purpose
Computes the quality factor Q.
gxtxt_api_call("SIGNAL_API_v1", "frequency_metric.q", args)
Fields and Options
  • a

    Purpose
    Frequency
    Type
    array
    Required
    Yes (1)
    Units
    Hz
    Shape
    Increasing real vector, positive values for phase_delay.
    Error
    InvalidGrid
  • b

    Purpose
    Complex response
    Type
    array
    Required
    Yes (1)
    Units
    Response unit
    Shape
    Vector with the same length as the frequency axis
    Error
    InvalidOperand
  • c

    Purpose
    Unused protocol operand
    Type
    empty
    Required
    No (0)
    Units
    1
    Shape
    Unused
    Error
    InvalidOperand
Recorded Result · frequency_metric.q

Download the example script (extract the ZIP first).

Example Operands Preview

[
  {
    "kind": "array",
    "shape": [
      64,
      1
    ],
    "real": [
      1.0,
      2.0,
      3.0,
      4.0,
      5.0,
      6.0,
      7.0,
      8.0,
      9.0,
      10.0
    ]
  },
  {
    "kind": "array",
    "shape": [
      64,
      1
    ],
    "real": [
      4.785117392129009e-06,
      2.586810022265412e-05,
      0.00012340980408667956,
      0.0005195746821548384,
      0.0019304541362277093,
      0.006329715427485747,
      0.01831563888873418,
      0.04677062238395898,
      0.10539922456186433,
      0.2096113871510978
    ],
    "imaginary": [
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0
    ]
  },
  {
    "kind": "empty"
  }
]

Result Preview

{
  "lower_3db_hz": 12.656995970805195,
  "upper_3db_hz": 17.343004029194805,
  "bandwidth_hz": 4.686008058389611,
  "peak_frequency_hz": 15.0,
  "q": 3.2010188230779284
}

frequency_metric.margins

Access
Registered in the Python Job
Arguments
Typed operands a, b, and c, with an optional typed options struct.
Shape
Increasing vector and complex vector
Units
Hz, seconds, dB, dimensionless
Result
Numeric and diagnostic fields.
Purpose
Computes the stability margins.
gxtxt_api_call("SIGNAL_API_v1", "frequency_metric.margins", args)
Fields and Options
  • a

    Purpose
    Frequency
    Type
    array
    Required
    Yes (1)
    Units
    Hz
    Shape
    Increasing real vector, positive values for phase_delay.
    Error
    InvalidGrid
  • b

    Purpose
    Complex response
    Type
    array
    Required
    Yes (1)
    Units
    Response unit
    Shape
    Vector with the same length as the frequency axis
    Error
    InvalidOperand
  • c

    Purpose
    Unused protocol operand
    Type
    empty
    Required
    No (0)
    Units
    1
    Shape
    Unused
    Error
    InvalidOperand
Recorded Result · frequency_metric.margins

Download the example script (extract the ZIP first).

Example Operands Preview

[
  {
    "kind": "array",
    "shape": [
      64,
      1
    ],
    "real": [
      1.0,
      2.0,
      3.0,
      4.0,
      5.0,
      6.0,
      7.0,
      8.0,
      9.0,
      10.0
    ]
  },
  {
    "kind": "array",
    "shape": [
      64,
      1
    ],
    "real": [
      1.9596558806095457,
      1.8434742825264665,
      1.664670907342684,
      1.4414619174410843,
      1.1931427352734598,
      0.9369643993761932,
      0.6864257396614803,
      0.45087492478905145,
      0.23595588553082097,
      0.044421521492722826
    ],
    "imaginary": [
      -0.34661919911682004,
      -0.6691460347468074,
      -0.9479427941015675,
      -1.1706679301305036,
      -1.3328204730060857,
      -1.4364101729275818,
      -1.4877444210345578,
      -1.4952378380847544,
      -1.4677430195591399,
      -1.4135157333501003
    ]
  },
  {
    "kind": "empty"
  }
]

Result Preview

{
  "gain_crossover_hz": 17.328393245093228,
  "phase_margin_deg": 45.14354266601711,
  "phase_crossover_hz": 25.747735131920088,
  "gain_margin_db": 2.8035393393943195
}
Negative Test or Attempt Result · frequency_metric.margins

Download the example script (extract the ZIP first).

Result Preview

"GXTXT:Signal:NoCrossing: loop response has no unity-gain crossover"

spectral.asd

Access
Registered in the Python Job
Arguments
Typed operands a, b, and c, with an optional typed options struct.
Shape
Vectors and a positive scalar
Units
Hz and squared signal unit per Hz
Result
Numeric and diagnostic fields.
Purpose
Computes the amplitude spectral density from the Welch PSD.
gxtxt_api_call("SIGNAL_API_v1", "spectral.asd", args)
Fields and Options

In the examples run for this operation, c carries the sample rate in Hz. The field below reproduces the reference schema for the documented version, where c is marked as unused.

  • a

    Purpose
    Signal
    Type
    array
    Required
    Yes (1)
    Units
    Signal unit
    Shape
    Vector
    Error
    InvalidOperand
  • b

    Purpose
    Unused protocol operand
    Type
    empty
    Required
    No (0)
    Units
    1
    Shape
    Unused
    Error
    DimensionMismatch
  • c

    Purpose
    Unused protocol operand
    Type
    empty
    Required
    No (0)
    Units
    1
    Shape
    Unused
    Error
    InvalidSampleRate
  • options.window

    Purpose
    Window coefficients
    Type
    array
    Required
    No (0)
    Default
    Computation backend default
    Units
    1
    Shape
    Periodogram: vector with the same length as the signal. Welch: scalar integer greater than 3, or a real vector.
    Error
    InvalidArguments
  • options.overlap

    Purpose
    Overlap fraction
    Type
    number
    Required
    No (0)
    Default
    .5
    Units
    1
    Minimum
    0
    Maximum
    0.95
    Error
    InvalidPolicy
  • options.nfft

    Purpose
    FFT length
    Type
    integer
    Required
    No (0)
    Default
    Computation backend default
    Units
    1
    Minimum
    0
    Shape
    Positive for the periodogram. Welch extends it to at least the window length.
    Error
    InvalidLength
Recorded Result · spectral.asd

Download the example script (extract the ZIP first).

Example Operands Preview

[
  {
    "kind": "array",
    "shape": [
      128,
      1
    ],
    "real": [
      0.0,
      0.45339411048374456,
      0.8071067811865474,
      0.9945902106299415,
      1.0,
      0.853168854392632,
      0.6071067811865476,
      0.3119727542464351,
      9.797174393178826e-17,
      -0.31197275424643495
    ]
  },
  {
    "kind": "empty"
  },
  {
    "kind": "array",
    "shape": [
      1,
      1
    ],
    "real": [
      128.0
    ]
  },
  {
    "kind": "struct",
    "fields": {
      "sample_rate": {
        "kind": "array",
        "shape": [
          1,
          1
        ],
        "real": [
          128.0
        ]
      },
      "window": {
        "kind": "array",
        "shape": [
          1,
          1
        ],
        "real": [
          32
        ]
      },
      "overlap": {
        "kind": "array",
        "shape": [
          1,
          1
        ],
        "real": [
          0.5
        ]
      },
      "nfft": {
        "kind": "array",
        "shape": [
          1,
          1
        ],
        "real": [
          64
        ]
      }
    }
  }
]

Result Preview

{
  "frequency_hz": {
    "dtype": "float64",
    "shape": [
      33,
      1
    ],
    "values": [
      0.0,
      2.0,
      4.0,
      6.0,
      8.0,
      10.0,
      12.0,
      14.0,
      16.0,
      18.0,
      20.0,
      22.0
    ]
  },
  "asd": {
    "dtype": "float64",
    "shape": [
      33,
      1
    ],
    "values": [
      0.0008458565296826926,
      0.04010322253701529,
      0.13381436443295652,
      0.24877314160387345,
      0.2991774269140187,
      0.24823676231074113,
      0.14627996819008804,
      0.06637366879477825,
      0.03264096711326442,
      0.02204903842158683,
      0.012370659186112685,
      0.003768787154084776
    ]
  },
  "n": 128.0,
  "sample_rate": 128.0,
  "fft_length": 64.0,
  "bin_count": 33.0,
  "window_length": 32.0,
  "overlap_samples": 16.0,
  "window_count": 7.0,
  "used_sample_count": 128.0,
  "method": "octave_native_welch_window_energy",
  "spectral_operation": "asd",
  "sidedness": "onesided",
  "detrend": "global_mean_over_used_segment_span",
  "input_kind": "real",
  "normalization": "window_energy_and_sample_rate"
}
Negative Test or Attempt Result · spectral.asd

Download the example script (extract the ZIP first).

Result Preview

"GXTXT:Signal:InvalidOperand: sample rate must be finite and nonempty"

spectral.window_metrics

Access
Registered in the Python Job
Arguments
Typed operands a, b, and c, with an optional typed options struct.
Shape
Vectors and a positive scalar
Units
Hz and squared signal unit per Hz
Result
Numeric and diagnostic fields.
Purpose
Computes coherent gain, power gain, and equivalent noise bandwidth (ENBW) for the specified window.
gxtxt_api_call("SIGNAL_API_v1", "spectral.window_metrics", args)
Fields and Options

In the examples run for this operation, c carries the sample rate in Hz. The field below reproduces the reference schema for the documented version, where c is marked as unused.

  • a

    Purpose
    Window coefficients
    Type
    array
    Required
    Yes (1)
    Units
    1
    Shape
    Vector
    Error
    InvalidOperand
  • b

    Purpose
    Unused protocol operand
    Type
    empty
    Required
    No (0)
    Units
    1
    Shape
    Unused
    Error
    DimensionMismatch
  • c

    Purpose
    Unused protocol operand
    Type
    empty
    Required
    No (0)
    Units
    1
    Shape
    Unused
    Error
    InvalidSampleRate
Recorded Result · spectral.window_metrics

Download the example script (extract the ZIP first).

Example Operands Preview

[
  {
    "kind": "array",
    "shape": [
      32,
      1
    ],
    "real": [
      0.0,
      0.010235029373752758,
      0.0405210941898847,
      0.08961827939636186,
      0.15551654046215685,
      0.23551799483651875,
      0.3263473735775899,
      0.4242861112477116,
      0.5253245844193565,
      0.6253262661293603
    ]
  },
  {
    "kind": "empty"
  },
  {
    "kind": "array",
    "shape": [
      1,
      1
    ],
    "real": [
      128.0
    ]
  }
]

Result Preview

{
  "n": 32.0,
  "sample_rate": 128.0,
  "coherent_gain": 0.484375,
  "power_gain": 0.36328125,
  "equivalent_noise_bandwidth_hz": 6.193548387096774,
  "method": "discrete_window_moments"
}
Negative Test or Attempt Result · spectral.window_metrics

Download the example script (extract the ZIP first).

Result Preview

"GXTXT:Signal:InvalidOperand: sample rate must be finite and nonempty"