# Calculate THD From DFT Plot

Consider the following DFT plot below, showing the output spectrum of an 9-bit ADC.

I want to calculate the THD (Total Harmonic Distortion). I am wondering how to do it correctly. I am aware of the following formula.

$$THD=10\log\Bigg(\frac{P_{HD}}{P_S}\Bigg)=10\log (P_{HD}) - 10\log (P_S)$$

So from my understanding $P_{HD}$ is the sum of all harmonics. But the signal power is shown in dBc, so I can only say how far the power of the harmonics are below the carrier, but I do not have the information about the absolute power levels. Is this correct? Then is it actually possible to calculate the THD, if yes, how?

What is shown in the plot is the PSD (Power Spectral density), which is measured in W/Hz (or dBc). So, in order to get the actual power in a given frequency range, you'd need to multiply with the bandwidth of each bin (which is determined by the length of the DFT window). Let the bandwidth of each bin be $B$.
$$THD = 10\log\left(\frac{P_{HD}}{P_S}\right)=10\log\left(\frac{\sum_i B\cdot S_i}{B S_{HD}}\right)$$
where $S_i$ denotes the Density at the $i$th harmonic and $S_HD$ denotes the density at the fundamental. As you see, B cancels in the expression, so you can ignore it. Note, that $S$ are in linear scale, (i.e. you'd need to transform the measurements in the diagram to linear scale before summing them up etc.)