the phase spectrum of a zero-phase wavelet is not zero!
Your vector w is not symmetric, so don't expect a zero-phase FFT result. Just do plot(t,w) to see what the FFT sees as its input. The reason is that you computed w only for positive t. What you need to do is the following:


Choose an odd number of equidistant time domain points $2N+1$
Compute N+1 points of the Ricker wavelet for non-negative $t$ starting with $t_0=0$
Since the wavelet is symmetric, the $N$ points for $t&lt;0$ are identical to the $N$ points for $t&gt;0$
append these values for negative $t$ at the end of the time domain vector to be transformed: w = [r_0,r_1,...,r_N,r_N,r_{N-1},...,r_1]. The reason for doing this is that the DFT/FFT assumes the first vector entry to be the value for $t=0$. Appending the values for negative $t$ at the end simply reflects the implied periodicity of all signals transformed by the DFT.


The result will be a real-valued FFT up to numerical errors.

In Matlab this would look like this:

Fs = 250;
N = 50;
t = (0:50)/Fs;
f1 = 30;
w = (1-2*pi^2*f1^2.*t.^2) .* exp(-(pi*f1.*t).^2);
w = [w, w(N+1:-1:2)];
X = fft(w);
max(abs(imag(X)))     % 2.2682e-16 on my machine