Analysis Fitting Routine Use to convert b from inverse pixels to inverse mm units = 19.79331; Include the Sqrt[2 Pi]: f[x_] := Exp[- x^2/2]/Sqrt[2 Pi] ; g[x_] := f[units b x] (c0 HermiteH[0,units b x] + c1 HermiteH[1, units b x] + c2 HermiteH[2, units b x] + c3 HermiteH[3, units b x] + c4 HermiteH[4, units b x]) < 0; mtf2[w_] := mtf4[w] /. {c4 -> 0, c3 -> 0}; mtf1[w_] := mtf4[w] /. {c4 -> 0, c3 -> 0, c2 -> 0}; mtf0[w_] := mtf4[w] /. {c4 -> 0, c3 -> 0, c2 -> 0, c1 -> 0}; ****************** Now do the fits ******************** <AbsolutePointSize[2.3],PlotLabel-> FontForm[" Typical data averaged over 8 squares",{"Times-Bold",15}]] This file reads in with the name data << dalsa.data ddat = ListPlot[data, PlotRange->{{0,20.1},{0,1.1}}, AxesOrigin->{0,0}, Frame->True,Prolog->AbsolutePointSize[3]] Zeroth Order Fit ********************** Apply PL Smiths approach *************************** Fit will give b in pixels, so dont use ``units'' here z[x_, l_] := b (x - (((stop - start)/2) + c + jump l + start)); ******* Zeroth order fit to data ************* fitfun0[x_,l_] := c0 Erf[z[x, l]] + d; terms0 = NonlinearFit[dta[4],fitfun0[x,4],{b, c, d, c0}, x,\ InitialGuess->{.46, 3.55 , (big + bot)/2, (big - bot)/2} ,MaxIterations->40]; plot0 = Plot[fitfun0[x, 4] /. terms0, {x, 1710, 1740},PlotLabel-> FontForm["0th order fit",{"Times-Bold",15}],PlotStyle->{Thickness[.0001]}] fit0=Show[points, plot0,PlotLabel->FontForm["0th order fit", {"Times-Bold",15}]] m0 = Plot[mtf0[x] /. terms0, {x, 0, 20}, \ PlotRange->{{0,20.1}, {0,1.1}}, Frame->True, AxesOrigin->{0,0}, PlotLabel->FontForm["MTF for the 0th order fit",{"Times-Bold",15}]] mfit0=Show[ddat, m0, PlotRange->{{0,20.1}, {0,1.1}}, Frame->True, AxesOrigin->{0,0},PlotLabel->FontForm["MTF for the 0th order", {"Times-Bold",15}]] Show[GraphicsArray[{{mfit0},{fit0}}]] First Order Fit ********** First order ******************** fitfun1[x_,l_] := c0 Erf[z[x, l]] - \ (Exp[-(z[x,l]^2)/2]/Sqrt[2 Pi]) (c1 HermiteH[0, z[x,l]]) + d; terms1 = NonlinearFit[dta[4],fitfun1[x,4],{b, c, d, c0, c1}, x,\ InitialGuess->{.464911, 3.42083 , (big + bot)/2, (big - bot)/2, 10}]; plot1 = Plot[fitfun1[x, 4] /. terms1, {x, 1710, 1740},PlotLabel-> FontForm["Fit function for the 1st order",{"Times-Bold",15}],PlotStyle-> {Thickness[.0001]}] fit1=Show[points, plot1,PlotLabel->FontForm[ "1st order fit", {"Times-Bold",15}]] m1 = Plot[Evaluate[mtf1[x]] /. terms1, {x, 0, 20}, PlotRange-> {{0,20.1},{0,1.1}},PlotLabel->FontForm["MTF for the 1st order fit", {"Times-Bold",15}]] mfit1=Show[ddat, m1, PlotRange->{{0,20.1}, {0,1.1}}, Frame->True,AxesOrigin->{0,0},PlotLabel->FontForm ["MTF for 1st order",{"Times-Bold",15}]] Show[GraphicsArray[{{mfit1},{fit1}}]] Second Order Fit ************* Second order ****************** fitfun2[x_,l_] := c0 Erf[z[x, l]] - \ (Exp[-(z[x,l]^2)/2]/Sqrt[2 Pi]) (c1 + c2 HermiteH[1,z[x,l]]) + d; terms2=NonlinearFit[dta[4],fitfun2[x,4],{b,c,d,c0,c1,c2},x,\ InitialGuess->{.464229,3.26988,(big+bot)/2,(big-bot)/2,19.1599,10}] plot2 = Plot[fitfun2[x, 4] /. terms2, {x, 1710, 1740},PlotStyle->{Thickness[.0001]}] fit2=Show[points, plot2,PlotLabel->FontForm["2nd order fit",{"Times-Bold",15}]] m2 = Plot[mtf2[x] /. terms2, {x, 0, 20}, PlotRange->{{0,20.1},{0,1.1}}] mfit2=Show[m2, ddat, PlotRange->{{0,20.1}, {0,1.1}}, Frame->True, AxesOrigin->{0,0},PlotLabel->FontForm ["MTF for the 2nd order",{"Times-Bold",15}]] Show[GraphicsArray[{{mfit2},{fit2}}]]//PSPrint Third Order Fit ************ Third order ************* fitfun3[x_,l_] := c0 Erf[z[x, l]] - (Exp[-(z[x,l]^2)/2]/Sqrt[2 Pi]) *( c1 HermiteH[0, z[x, l]] + c2 HermiteH[1, z[x, l]] + c3 HermiteH[2, z[x, l]] ) + d; terms3 = NonlinearFit[dta[4],fitfun3[x,4],{b, c, d, c0, c1, c2, c3}, x, InitialGuess->{.583477, 3.18453 , (big + bot)/2, (big - bot)/2, 24.2164,21.8726, 5}]>>>TERMS; plot3 = Plot[fitfun3[x, 4] /. terms3, {x, 1710, 1740},PlotStyle-> {Thickness[.0001]}] fit3=Show[points, plot3,PlotLabel->FontForm["3rd order fit", {"Times-Bold",15}]] m3 = Plot[mtf3[x] /. terms3, {x, 0, 20}, PlotRange->{{0,20.1}, {0,1.1}}] mfit3=Show[m3, ddat, PlotRange->{{0,20.1}, {0,1.1}}, Frame->True, AxesOrigin->{0,0},PlotLabel->FontForm ["MTF for the 3rd order",{"Times-Bold",15}]] Show[GraphicsArray[{{mfit3},{fit3}}]] Fourth Order Fit ************ Fourth order ********************** fitfun4[x_,l_] := c0 Erf[z[x, l]] - (Exp[-(z[x,l]^2)/2]/Sqrt[2 Pi]) *( c1 HermiteH[0, z[x, l]] + c2 HermiteH[1, z[x, l]] + c3 HermiteH[2, z[x, l]] + c4 HermiteH[3, z[x, l]] ) + d; terms4 = NonlinearFit[dta[4],fitfun4[x,4],{b, c, d, c0, c1, c2, c3, c4}, x,InitialGuess->{.596284, 3.4371 , (big + bot)/2, (big - bot)/2, -7.97937, 23.6496, 2.09462, 5},MaxIterations->100]>>>TERMS; plot4 = Plot[fitfun4[x, 4] /. terms4, {x, 1710, 1740}, PlotStyle->{Thickness[.0001]}] fit4=Show[points, plot4,PlotLabel->FontForm[" 4th order fit", {"Times-Bold",15}]] m4=Plot[mtf4[x] /. terms4, {x, 0, 20}, PlotRange->{{0,20.1},{0,1.1}}] mfit4=Show[m4,ddat,PlotRange->{{0,20.1},{0,1.1}},Frame->True, PlotLabel->FontForm["MTF for the 4th order",{"Times-Bold",15}]] Show[GraphicsArray[{{mfit4},{fit4}}]] Show[GraphicsArray[{{mfit0,fit0},{mfit1,fit1},{mfit2,fit2}, {mfit3,fit3},{mfit4,fit4}}]]