5 def electric_loss_function(infile,outfile):
\r
7 Converts data of the form: wavelength Re(eps) Im(eps) => wavelength Im(1/eps)
\r
9 file1 = open(infile, "r")
\r
10 file2 = open(outfile, "w")
\r
12 data = str.split(line)
\r
13 elf = -float(data[2]) / ((float(data[1])**2.0) + (float(data[2])** 2.0))
\r
14 file2.write(str(data[0]) + " " + str(elf) + "\n")
\r
19 def split_into_angles(infile, angleStep=5.0, start=0.0):
\r
21 Splits data as output by VASE (into sequential curves, single file) into multiple files based on angle
\r
23 file = open(infile, "r")
\r
24 angleStep = float(angleStep)
\r
25 currentAngle = start
\r
27 outputFile = open(infile + "["+str(currentAngle)+"]", "w")
\r
28 lastWavelength = 0.0
\r
30 wavelength = float(str.split(line)[0])
\r
31 if wavelength < lastWavelength:
\r
32 currentAngle += angleStep
\r
34 outputFile = open(infile + "["+str(currentAngle)+"]", "w")
\r
35 outputFile.write(str(line))
\r
36 lastWavelength = wavelength
\r
39 if __name__ == "__main__":
\r
41 TODO: Overwrite with particular task
\r
43 split_into_angles("black-au_si",2.5,60.0)
\r
45 while angle <= 80.0:
\r
46 electric_loss_function("black-au_si["+str(angle)+"]", "black-au_si["+str(angle)+"].dat")
\r