Skip to content

Commit 8b055ca

Browse files
committed
stylistic and documentation improvements
1 parent a0b357e commit 8b055ca

File tree

5 files changed

+389
-388
lines changed

5 files changed

+389
-388
lines changed

LICENSE.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
Copyright 2012 Steven Byrnes
1+
Copyright (C) 2012-2017 Steven Byrnes
22

33
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
44

55
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
66

7-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
7+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

examples.py

+40-40
Original file line numberDiff line numberDiff line change
@@ -33,26 +33,26 @@ def sample1():
3333
different incident angles.
3434
"""
3535
# list of layer thicknesses in nm
36-
d_list = [inf,100,300,inf]
36+
d_list = [inf, 100, 300, inf]
3737
# list of refractive indices
38-
n_list = [1,2.2,3.3+0.3j,1]
38+
n_list = [1, 2.2, 3.3+0.3j, 1]
3939
# list of wavenumbers to plot in nm^-1
40-
ks=linspace(0.0001,.01,num=400)
40+
ks = linspace(0.0001, .01, num=400)
4141
# initialize lists of y-values to plot
42-
Rnorm=[]
43-
R45=[]
42+
Rnorm = []
43+
R45 = []
4444
for k in ks:
4545
# For normal incidence, s and p polarizations are identical.
4646
# I arbitrarily decided to use 's'.
47-
Rnorm.append(coh_tmm('s',n_list, d_list, 0, 1/k)['R'])
47+
Rnorm.append(coh_tmm('s', n_list, d_list, 0, 1/k)['R'])
4848
R45.append(unpolarized_RT(n_list, d_list, 45*degree, 1/k)['R'])
4949
kcm = ks * 1e7 #ks in cm^-1 rather than nm^-1
5050
plt.figure()
51-
plt.plot(kcm,Rnorm,'blue',kcm,R45,'purple')
51+
plt.plot(kcm, Rnorm, 'blue', kcm, R45, 'purple')
5252
plt.xlabel('k (cm$^{-1}$)')
5353
plt.ylabel('Fraction reflected')
5454
plt.title('Reflection of unpolarized light at 0$^\circ$ incidence (blue), '
55-
'45$^\circ$ (purple)')
55+
'45$^\circ$ (purple)')
5656

5757
def sample2():
5858
"""
@@ -70,14 +70,14 @@ def sample2():
7070
[750, 2.2+0.5j]])
7171
material_nk_fn = interp1d(material_nk_data[:,0].real,
7272
material_nk_data[:,1], kind='quadratic')
73-
d_list = [inf,300,inf] #in nm
74-
lambda_list = linspace(200,750,400) #in nm
73+
d_list = [inf, 300, inf] #in nm
74+
lambda_list = linspace(200, 750, 400) #in nm
7575
T_list = []
7676
for lambda_vac in lambda_list:
7777
n_list = [1, material_nk_fn(lambda_vac), 1]
78-
T_list.append(coh_tmm('s',n_list,d_list,0,lambda_vac)['T'])
78+
T_list.append(coh_tmm('s', n_list, d_list, 0, lambda_vac)['T'])
7979
plt.figure()
80-
plt.plot(lambda_list,T_list)
80+
plt.plot(lambda_list, T_list)
8181
plt.xlabel('Wavelength (nm)')
8282
plt.ylabel('Fraction of power transmitted')
8383
plt.title('Transmission at normal incidence')
@@ -89,16 +89,16 @@ def sample3():
8989
ellipsometry. This reproduces Fig. 1.14 in Handbook of Ellipsometry by
9090
Tompkins, 2005.
9191
"""
92-
n_list=[1,1.46,3.87+0.02j]
93-
ds=linspace(0,1000,num=100) #in nm
94-
psis=[]
95-
Deltas=[]
92+
n_list = [1, 1.46, 3.87+0.02j]
93+
ds = linspace(0, 1000, num=100) #in nm
94+
psis = []
95+
Deltas = []
9696
for d in ds:
97-
e_data=ellips(n_list, [inf,d,inf], 70*degree, 633) #in nm
97+
e_data = ellips(n_list, [inf, d, inf], 70*degree, 633) #in nm
9898
psis.append(e_data['psi']/degree) # angle in degrees
9999
Deltas.append(e_data['Delta']/degree) # angle in degrees
100100
plt.figure()
101-
plt.plot(ds,psis,ds,Deltas)
101+
plt.plot(ds, psis, ds, Deltas)
102102
plt.xlabel('SiO2 thickness (nm)')
103103
plt.ylabel('Ellipsometric angles (degrees)')
104104
plt.title('Ellipsometric parameters for air/SiO2/Si, varying '
@@ -113,24 +113,24 @@ def sample4():
113113
"""
114114
d_list = [inf, 100, 300, inf] #in nm
115115
n_list = [1, 2.2+0.2j, 3.3+0.3j, 1]
116-
th_0=pi/4
117-
lam_vac=400
118-
pol='p'
119-
coh_tmm_data = coh_tmm(pol,n_list,d_list,th_0,lam_vac)
120-
121-
ds = linspace(0,400,num=1000) #position in structure
122-
poyn=[]
123-
absor=[]
116+
th_0 = pi/4
117+
lam_vac = 400
118+
pol = 'p'
119+
coh_tmm_data = coh_tmm(pol, n_list, d_list, th_0, lam_vac)
120+
121+
ds = linspace(0, 400, num=1000) #position in structure
122+
poyn = []
123+
absor = []
124124
for d in ds:
125-
layer, d_in_layer = find_in_structure_with_inf(d_list,d)
126-
data=position_resolved(layer,d_in_layer,coh_tmm_data)
125+
layer, d_in_layer = find_in_structure_with_inf(d_list, d)
126+
data = position_resolved(layer, d_in_layer, coh_tmm_data)
127127
poyn.append(data['poyn'])
128128
absor.append(data['absor'])
129129
# convert data to numpy arrays for easy scaling in the plot
130130
poyn = array(poyn)
131131
absor = array(absor)
132132
plt.figure()
133-
plt.plot(ds,poyn,'blue',ds,200*absor,'purple')
133+
plt.plot(ds, poyn, 'blue', ds, 200*absor, 'purple')
134134
plt.xlabel('depth (nm)')
135135
plt.ylabel('AU')
136136
plt.title('Local absorption (purple), Poynting vector (blue)')
@@ -174,8 +174,8 @@ def sample5():
174174
print('air / 300nm SiO2 / Si --- rgb =', color_dict['rgb'], ', xyY =', color_dict['xyY'])
175175
plt.figure()
176176
color.plot_reflectances(reflectances,
177-
title='air / 300nm SiO2 / Si -- '
178-
'Fraction reflected at each wavelength')
177+
title='air / 300nm SiO2 / Si -- '
178+
'Fraction reflected at each wavelength')
179179
plt.figure()
180180
color.plot_spectrum(spectrum,
181181
title='air / 300nm SiO2 / Si -- '
@@ -184,7 +184,7 @@ def sample5():
184184
# Calculate irgb color (i.e. gamma-corrected sRGB display color rounded to
185185
# integers 0-255) versus thickness of SiO2
186186
max_SiO2_thickness = 600
187-
SiO2_thickness_list = linspace(0,max_SiO2_thickness,num=80)
187+
SiO2_thickness_list = linspace(0, max_SiO2_thickness, num=80)
188188
irgb_list = []
189189
for SiO2_d in SiO2_thickness_list:
190190
d_list = [inf, SiO2_d, inf]
@@ -198,15 +198,15 @@ def sample5():
198198
print('Making color vs SiO2 thickness graph. Compare to (for example)')
199199
print('http://www.htelabs.com/appnotes/sio2_color_chart_thermal_silicon_dioxide.htm')
200200
plt.figure()
201-
plt.plot([0,max_SiO2_thickness],[1,1])
202-
plt.xlim(0,max_SiO2_thickness)
203-
plt.ylim(0,1)
201+
plt.plot([0, max_SiO2_thickness], [1, 1])
202+
plt.xlim(0, max_SiO2_thickness)
203+
plt.ylim(0, 1)
204204
plt.xlabel('SiO2 thickness (nm)')
205205
plt.yticks([])
206206
plt.title('Air / SiO2 / Si color vs SiO2 thickness')
207207
for i in range(len(SiO2_thickness_list)):
208208
# One strip of each color, centered at x=SiO2_thickness_list[i]
209-
if i==0:
209+
if i == 0:
210210
x0 = 0
211211
else:
212212
x0 = (SiO2_thickness_list[i] + SiO2_thickness_list[i-1]) / 2
@@ -216,7 +216,7 @@ def sample5():
216216
x1 = (SiO2_thickness_list[i] + SiO2_thickness_list[i+1]) / 2
217217
y0 = 0
218218
y1 = 1
219-
poly_x = [x0, x1, x1, x0]
219+
poly_x = [x0, x1, x1, x0]
220220
poly_y = [y0, y0, y1, y1]
221221
color_string = colorpy.colormodels.irgb_string_from_irgb(irgb_list[i])
222222
plt.fill(poly_x, poly_y, color_string, edgecolor=color_string)
@@ -229,15 +229,15 @@ def sample6():
229229
Prism Configuration") Fig 6a
230230
"""
231231
# list of layer thicknesses in nm
232-
d_list = [inf,5,30,inf]
232+
d_list = [inf, 5, 30, inf]
233233
# list of refractive indices
234234
n_list = [1.517, 3.719+4.362j, 0.130+3.162j, 1]
235235
# wavelength in nm
236-
lam_vac=633
236+
lam_vac = 633
237237
# list of angles to plot
238238
theta_list = linspace(30*degree, 60*degree, num=300)
239239
# initialize lists of y-values to plot
240-
Rp=[]
240+
Rp = []
241241
for theta in theta_list:
242242
Rp.append(coh_tmm('p', n_list, d_list, theta, lam_vac)['R'])
243243
plt.figure()

setup.py

+11-10
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,26 @@
33
import os
44
from setuptools import setup
55

6-
# Utility function to read the README file.
76
def read(fname):
7+
"""utility function to read the README file"""
88
return open(os.path.join(os.path.dirname(__file__), fname)).read()
99

1010
descrip = ("Simulate light propagation in multilayer thin and/or thick "
1111
"films using the fresnel equations and transfer matrix "
1212
"method.")
1313

14-
data_files = ['README.rst','LICENSE.txt','Changes.txt','manual.pdf','examples.ipynb']
14+
data_files = ['README.rst', 'LICENSE.txt', 'Changes.txt', 'manual.pdf',
15+
'examples.ipynb']
1516

1617
setup(
17-
name = "tmm",
18-
version = '0.1.6',
19-
author = "Steven Byrnes",
20-
author_email = "[email protected]",
21-
description = descrip,
22-
license = "MIT",
23-
keywords = "optics, fresnel, reflection, absorption, photovoltaics, ellipsometry, transfer matrix method",
24-
url = "http://pypi.python.org/pypi/tmm",
18+
name="tmm",
19+
version='0.1.6',
20+
author="Steven Byrnes",
21+
author_email="[email protected]",
22+
description=descrip,
23+
license="MIT",
24+
keywords="optics, fresnel, reflection, absorption, photovoltaics, ellipsometry, transfer matrix method",
25+
url="http://pypi.python.org/pypi/tmm",
2526
packages=['tmm'],
2627
package_data={'tmm':data_files},
2728
package_dir={'tmm': '.'},

0 commit comments

Comments
 (0)