def _kpad(self, field, finalshape, zpad=False, norm=True):
currshape = np.array(field.shape)<EOL>if any(finalshape < currshape):<EOL><INDENT>raise IndexError("<STR_LIT>")<EOL><DEDENT>d = finalshape - currshape<EOL>o = d % <NUM_LIT:2><EOL>d = np.floor_divide(d, <NUM_LIT:2>)<EOL>if not zpad:<EOL><INDENT>o[<NUM_LIT:0>] = <NUM_LIT:0><EOL><DEDENT>axes = None<EOL>pad = tuple((d[i]+o[i],d[i]) for i in [<NUM_LIT:0>,<NUM_LIT:1>,<NUM_LIT:2>])<EOL>rpsf = np.pad(field, pad, mode='<STR_LIT>', constant_values=<NUM_LIT:0>)<EOL>rpsf = np.fft.ifftshift(rpsf, axes=axes)<EOL>kpsf = fft.rfftn(rpsf, **fftkwargs)<EOL>if norm:<EOL><INDENT>kpsf /= kpsf[<NUM_LIT:0>,<NUM_LIT:0>,<NUM_LIT:0>]<EOL><DEDENT>return kpsf<EOL>
fftshift and pad the field with zeros until it has size finalshape.
if zpad is off, then no padding is put on the z direction. returns
the fourier transform of the field