Microwave phase is not working for a single-line spectrum
The following should give two dispersion spectra (Exp.mwPhase=pi/2), but the one without Lorentzian broadening incorrectly returns the absorption spectrum.
clear, clc, clf
Exp.mwFreq = 9.5;
Exp.Range = [335 343];
Exp.mwPhase = pi/2;
Sys.lwpp = [1 0];
[B,spc_abs] = pepper(Sys,Exp);
Sys.lwpp = [1 0.1];
[B,spc_dis] = pepper(Sys,Exp);
plot(B,spc_abs,B,spc_dis);
legend('only Gaussian','incl Lorentzian')
In these cases, the spectrum is constructed using a template lineshape. If only a Gaussian broadening is given, then a Gaussian template is used, but gaussian does not have dispersion implemented for its integral. The Gaussian dispersion function is Dawson's integral, and the integral of that is the generalized hypergeometric function 1/2k^2 2F2(1,1;3/2,2;-k^2), where k = (x-x0)/sig/sqrt(2).
MATLAB's Symbolic Toolbox has hypergeom, which can evaluate this function, Since it uses exact arithmetic, it is very slow but accurate. Other purely numerical approaches (see e.g Julia's HypergeometricFunctions.jl) have challenges in the wings of the lineshape.
A numerical Hilbert transform is possible, but is inaccurate in the wings (shown here with a Lorentzian):
clear, clc
x = linspace(-1,1,1001)*5;
fwhm = 1;
Labs = lorentzian(x,0,fwhm,0,0);
Ldisp_exact = imag(hilberttrans(Labs));
Ldisp_transform = lorentzian(x,0,fwhm,0,pi/2);
plot(x,Ldisp_exact,x,Ldisp_transform)
legend('exact','Hilbert transform')