def real2complex(rfield):
    """
    convert raw qg_model output to complex numpy array
    suppose input has shape
        psi(time_step (optional), real_and_imag, ky, kx, z(optional))
    """
    if rfield.shape[-2]+1 == 2*rfield.shape[-3]:
        return rfield[...,0,:,:,:]+1j*rfield[...,1,:,:,:]
    elif rfield.shape[-1]+1 == 2*rfield.shape[-2]:
        return rfield[...,0,:,:]+1j*rfield[...,1,:,:]
    else:
        raise NotImplementedError('Unrecognized field type')