# Creating realization of 2D Gaussian field in Fourier space

I want to generate a 2D Gaussian field with dimensions $L\times L$ with $N^2$ cells each of size $l = L/N$. I'm doing this by producing a realization of this field in Fourier space by producing Gaussian random numbers with variance $\sigma^2(k) \propto P(k)$ where $P(k)$ is some input power spectrum.

To do this I need to have a grid in Fourier space with each cell defining a $k$-value. But I'm not sure how each component $k$-value combines in each cell, i.e. each cell will presumably have a $k_x, k_y, k_z$ value depending on the cells position in Fourier space.

Do I combine them by doing $\textbf{k} = \sqrt{k_x^2 + k_y^2 + k_z^2}$? But then surely $\textbf{k}_{max}$ will then be too large in the corners i.e. larger than $2\pi/l$

Do I define different values of $\sigma$ i.e. $\sigma_i(k_i) \propto P(k_i)$ for different $x,y$ and $z$ then combine all these different $\sigma$'s when generating Gaussian random numbers.

I'm also confused by the range of values that my $k$ should have since examples such as the attached image suggest that I should include a value of $k=0$ (representing the DC frequency) but I can't then generate a Gaussian random number for this cell since my power spectrum will be undefined at $k=0$.

Layout of discrete Fourier space