# :MEASure:FFT:THDistortion

Total Harmonic Distortion Commands

- :MEASure:FFT:THDistortion
- :MEASure:FFT:THDistortion:FAVorite
- :MEASure:FFT:THDistortion:FFFMode
- :MEASure:FFT:THDistortion:FFFRequency
- :MEASure:FFT:THDistortion:FPLevel
- :MEASure:FFT:THDistortion:FPNumber
- :MEASure:FFT:THDistortion:LOCation?
- :MEASure:FFT:THDistortion:SOURce
- :MEASure:FFT:THDistortion:STATus?
- :MEASure:FFT:THDistortion:STATus:DETails?
- :MEASure:FFT:THDistortion:STATus:REASon?

## Command Syntax

    :MEASure:FFT:THDistortion

## Query Syntax

    :MEASure:FFT:THDistortion?

## Description

Total Harmonic Distortion (THD) measures the magnitude of the fundamental frequency and as many harmonics as are on the screen. See `:FUNCtion:FOPerator`.

THD is calculated using the following formula:

Where:

- Xn = voltage or current of each harmonic.
- X1 = fundamental frequency voltage or current value.

The fundamental frequency of the input signal can be specified directly, or it can be automatically determined based on the first peak above a certain magnitude threshold (similar to other FFT measurements). See `:MEASure:FFT:THDistortion:FFFMode`.

The query form of the command returns the measured value.

## Measurement Ready?

To confirm that the measurement is ready to read, you can query the measurement's status:

    if ('CORR' in Infiniium.query(':MEASure:FFT:THDistortion:STATus?')):
    	measurement = Infiniium.query(':MEASure:FFT:THDistortion?')

If averaging is turned on (`:ACQuire:SMODe AVERage`), you can also confirm if the measurement result is ready by comparing the number of specified averages (`:ACQuire:COUNt?`) versus the number of measurement sweeps that have occurred (`:ACQuire:COUNt?`). The technique uses the `:COUNt?` common measurement query. For example,

    if (Infiniium.query(':MEASure:FFT:THDistortion:COUNt?') >= Infiniium.query(':ACQuire:COUNt?')):
    	measurement = Infiniium.query(':MEASure:FFT:THDistortion?')

You can also use an acquisition limit test to test that a number of waveforms or samples have completed before returning a measurement. Refer to the `:LTESt:ACQuire:CTYPe` command.

## Querying Measurement Results and Statistics

You can query measurement results using the `:MEASure:FFT:THDistortion?` query after making the proper instance settings.

If a measurement is installed into Results table (using the `:MEASure:FFT:THDistortion` command) and you have made the proper instance settings, you can query statistics using common child queries.

Also, you can query measurement results and statistics directly from the Results table (without having to make the proper instance settings beforehand). See Querying Measurement Results and Statistics.