Hello everyone. I have a program which performs the 2d Shannon interpolation for different random variables. I have to send that code to another person who uses python. For that, and with help from people of this forum I built the following code, which construct the Shannon interpolation for each random variable as a row of a text file and then replaces the Mathematica output to look like a Python's. The problem is that for each random variable I need to separate the look of the output. My current code alters all the rows equally. I would need to change the string replace to make each row have it's number, but I haven't seen any option to do this in the documentation.
The Shannon interpolation is as follows:
savedX = Table[XposX = aaa[[All, 1]]; YposX = aaa[[All, 2]];
windXVal = aaa[[All, i]];
windXMat = Transpose[{XposX, YposX, windXVal}];
ifuncEPSX = Interpolation[windXMat //. {x_List} :> x];
intDataVectorEPSX =
Flatten[Table[{t, u, ifuncEPSX[t, u]}, {t, xmin, xmax,
dDeltaX}, {u, ymin, ymax, dDeltaY}]];
leEPSX = Length@intDataVectorEPSX;
vectorXintEPSX =
Table[intDataVectorEPSX[[i]], {i, 1, leEPSX - 2, 3}];
vectorYintEPSX =
Table[intDataVectorEPSX[[i]], {i, 2, leEPSX - 1, 3}];
vectorFintEPSX = Table[intDataVectorEPSX[[i]], {i, 3, leEPSX, 3}];
interpolatedDataEPSX =
Transpose[{vectorXintEPSX, vectorYintEPSX, vectorFintEPSX}];
Total[#3*sinc[(t - #1)/dDeltaX]*sinc[(u - #2)/dDeltaY] & @@@
interpolatedDataEPSX], {i, 3, countMax + 2}];
And the string replace
Export["savedWindX.txt", savedX]
savedXPython = Import["savedWindX.txt"] // StringReplace[#, {"[" -> "(", "]" -> ")", "t" -> "m.lammda[i]*180/np.pi", "u" -> "m.phi[i]*180/np.pi"}] &
What I need is to replace t by m.lammda1[i]180/np.pi on the first row, m.lammda2[i]180/np.pi in the second and so on; same thing for m.phi.
Is there a way to do this? Regards. Jaime