The PSD of a sine observerved for infinite time is indeed a dirac impulse.
Is this something to do with windowing?
But: you're not observing the actual PSD of a sine, but you're observing a small excerpt of time. So, yes, this is due to windowing.
Think about it: because you don't do anything with an infinite duration of observation, it's like you take a rectangular window, and use it to cut out a piece of infinity (your observation length). Now, that's multiplication with a rectangle in time domain, which is equivalent to convolution with a sinc in frequency domain.
You can get a very sharp PSD if you just apply the DFT to a sine signal actually sampled exactly for a multiple of its period, but that's not the case in general, either.
Or is my understanding of PSD wrong?
That's hard to tell, because I don't know your understanding of Power Spectral Density!
Being strict, the PSD is actually a property of a random process, namely:
The power spectral density is the Fourier Transform of the autocorrelation function of a wide-sense stationary random process.
As you can see, that's a property of a random process that you'll never be able to observe directly, but can only deduct from other observations, given some assumptions on the process observed.
Now, the "technical" understanding of PSD is "I went, and looked into infinitesimally small parts of the spectrum, and noted down the Energy in there, after observing those for a finite amount of time".
What's implicit in there is that by observing for a finite time, you can make assumptions on the expectation value of the magnitude square of the Fourier Transform of the observed signal (which is a random process); by the Theorem of Wiener-Chintschin, this is the same as the Fourier Transform of the autocorrelation function – but that, again, makes the assumptions
- that your random process is wide-sense stationary (which it isn't if your observation window is not a multiple of a period) and
- that your observation's is an efficient estimator of the signals properties.