Hello! I have 2D data (images) which are results of Gaussian type beam diffraction. According to the theory of diffraction the pattern can be discribed by function ~ J1(r)/r. I tried to fit my data with this function using the FIndFit routine, but had an error :
Blockquote Power::infy: "Infinite expression 1/0. encountered" Blockquote
data01 = Import["366.0000cm_660.0000nm.png"];
data02 = ImageData[data01];
min02 = Min[data02];
max02 = Max[data02];
(*Dimensionalities of images*)
dim01a = Import["366.0000cm_660.0000nm.png", "ImageSize"] [[1]];
dim01b = Import["366.0000cm_660.0000nm.png", "ImageSize"] [[2]];
dim01 = Min[dim01a, dim01b];
ReducPix = 5;
data03 = Table[ (data02[[i]][[j]][[1]] - min02)/max02, {i, 1, dim01b,
ReducPix}, {j, 1, dim01a, ReducPix}];
(*Dimensionalities*)
dim03a = Dimensions[data03][[1]];
dim03b = Dimensions[data03][[2]];
dim03 = Min[dim03a, dim03b]
ListPlot3D[data03, PlotRange -> All]
s[x_, y_] := Sqrt[a2 (x - a1)^2 + b2 (y - b1)^2]
Bessel3D = Piecewise[
{{1/4, x == 0 && y == 0},
{(a0 BesselJ[1, s[x, 0]]/s[x, 0]), y == 0},
{(a0 BesselJ[1, s[0, y]]/s[0, y]), x == 0}},
{(a0 BesselJ[1, s[x, y]]/s[x, y])}]
data3D = Flatten[MapIndexed[{#2[[1]], #2[[2]], #1} &, data03, {2}], 1];
fit = NonlinearModelFit[
data3D, (Bessel3D)^2, {{a0, 1}, {a1, 50}, {a2, 10}, {b1, 50}, {b2,
10}}, {x, y}];
I tried to use different method in the function (NMinimize, Gradient, so on ) but it did not help. It is really puzzling for me. Will appreciate any suggestions!!