Either this or the calculation of `_cos`, `_sin` is wrong when `nx != ny`.  It might be easier if you just don't let them be different, so L = nx*pixel_size is the same for both kx and ky.