Hi all, I am looking at neat ways of re writing this code below, especially the for loops as I would have over 50 of these statements if I did this the manual way shown below.
n = 50
files = [open("files%i.txt" % i, "w") for i in range (n)]
for w,x,y,z in zip(ar1.values, br1.values, ar0.values, br0.values):
val = (sqrt((w.data**2)+(x.data**2)))-(sqrt((y.data**2)+(z.data**2)))
files[0].write(('%6.20f\n') % (val))
for w,x,y,z in zip(ar2.values, br2.values, ar1.values, br1.values):
val = (sqrt((w.data**2)+(x.data**2)))-(sqrt((y.data**2)+(z.data**2)))
files[1].write(('%6.20f\n') % (val))
for w,x,y,z in zip(ar3.values, br3.values, ar2.values, br2.values):
val = (sqrt((w.data**2)+(x.data**2)))-(sqrt((y.data**2)+(z.data**2)))
files[2].write(('%6.20f\n') % (val))
Ideally, I would like an option which would use arrays as then I can then call specific data from the array index number.
Thanks for your help!