forked from gyger/OpenFilters
-
Notifications
You must be signed in to change notification settings - Fork 0
/
optical_filter.py
7366 lines (5863 loc) · 291 KB
/
optical_filter.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# optical_filter.py
#
# optical_filter class for Filters and helpers functions to read
# and write a filter file.
#
# Copyright (c) 2000-2010,2012,2014,2015 Stephane Larouche.
#
# This file is part of OpenFilters.
#
# OpenFilters is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or (at
# your option) any later version.
#
# OpenFilters is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA
# REMOVE when Python 3.0 will be out.
from __future__ import division
import math
import cmath
import array
import string
import copy
import warnings
import time
try:
from ast import literal_eval as _eval
except ImportError:
_eval = eval
from definitions import *
import config
import abeles
import materials
import stack
import graded
import simple_parser
import color
import optimization_Fourier
one_hundred_eighty_over_pi = 180.0/math.pi
########################################################################
# #
# filter_error #
# #
########################################################################
class filter_error(Exception):
"""Exception class for filter errors"""
def __init__(self, value = ""):
self.value = value
def __str__(self):
if self.value:
return "Filter error: %s." % self.value
else:
return "Filter error."
########################################################################
# #
# optical_filter #
# #
########################################################################
class optical_filter(object):
"""A class to define an optical filter and calculate its properties."""
######################################################################
# #
# __init__ #
# #
######################################################################
def __init__(self, material_catalog = None):
"""Initialize the optical filter
This method takes a single optional input argument:
material_catalog (optional) the catalog of materials to use in
the filter, if omitted, the default materials
are used."""
# If a material catalog is given, use it. Otherwise, use the default
# materials.
if material_catalog:
self.material_catalog = material_catalog
else:
self.material_catalog = materials.material_catalog()
# A description of the filter.
self.description = ""
# Materials used in the filter. If the analysis was done, the
# indices structures are kept for later use. The 3 different kind
# of structures are kept in 3 different lists.
self.materials = []
self.material_indices = []
self.N = []
# The angles at which the analysis have already been done and the
# matrices for the front and back coatings.
self.sin2_theta_0 = []
self.matrices_front = []
self.matrices_back = []
# The center wavelength is the wavelength at which the index
# profile is defined. By default, the center wavelength is 550nm.
self.center_wavelength = 550.0
# By default, the analysis is done at every nm betwenn 300 nm and
# 1000 nm.
self.from_wavelength = 0.0
self.to_wavelength = 0.0
self.by_wavelength = 0.0
self.wvls = None
self.set_wavelengths_by_range(300.0, 1000.0, 1.0)
# By default, steps of inhomogeneous layers are separated by
# index steps of 0.01 and have a minimal thickness of 0 nm.
self.step_spacing = 0.01
self.minimum_thickness = 0.0
# Does the analysis consider the back side of the substrate. By
# default, it does.
self.consider_backside = True
# Same thing, for monitoring.
self.consider_backside_on_monitoring = True
# Ellipsometer type is used to determine Delta. Possible values
# are RAE for a rotating analyser, RPE for a rotating polarizer
# ellipsometer and RCE for a rotating compensator ellipsometer. By
# default, a RAE is used as a J. A. Woollam VASE. The minimum
# possible value of Delta, this is used to express Delta between 0
# degres and 360 degres, -180 degres and +180 degres or any other
# values between -180 and 0 degres. By default, the minimum value
# is -90 degres as for J. A. Woollam Co. ellipsometers.
self.ellipsometer_type = RAE
self.Delta_min = -90.0
# Same thing, for monitoring.
self.monitoring_ellipsometer_type = RAE
self.monitoring_Delta_min = -90.0
# What illuminant and what colorimetric observer are used to
# calculate the color.
self.observer_name = config.OBSERVER
self.illuminant_name = config.ILLUMINANT
# The maximum thickness of the sublayers for the monitoring and
# for the circle and admitance diagrams. By default, 1nm.
self.monitoring_sublayer_thickness = 1.0
# For special cases where you don't want to consider the substrate.
self.dont_consider_substrate = False
# The stack formula and its list of materials.
self.front_stack_formula = ""
self.front_stack_materials = {}
self.back_stack_formula = ""
self.back_stack_materials = {}
# The materials of the medium, the substrate and the coating, the
# thickness of the layers of the coating (a list for an
# inhomogeneous layer) and the index of mixture layers (at the
# center wavelength, only the real part) or a lists of steps for
# graded-index layers. By default, there is no coating, the
# substate is fused silica and 1mm (1000000nm) thick and the medium
# is void. The descriptions allows the possibility to describe each
# layer so that the module used to create it can be re-executed to
# recreate it. The description of each layer can be an empty list,
# or a list of two elements, the first one being the name of the
# module that was used to create the layer and the second one being
# a tuple of the parematers used by the module to create the layer.
self.substrate = self.get_material_nb("FusedSilica")
self.substrate_thickness = 1000000.0
self.front_medium = self.get_material_nb("void")
self.front_layers = []
self.front_layer_descriptions = []
self.front_thickness = []
self.front_step_profiles = []
self.front_index = []
self.back_medium = self.get_material_nb("void")
self.back_layers = []
self.back_layer_descriptions = []
self.back_thickness = []
self.back_step_profiles = []
self.back_index = []
# Lists indicating if the thickness and the index should be refined
# and if needles and steps should be added in a layer.
self.front_refine_thickness = []
self.back_refine_thickness = []
self.front_refine_index = []
self.back_refine_index = []
self.front_preserve_OT = []
self.back_preserve_OT = []
self.front_add_needles = []
self.back_add_needles = []
self.front_add_steps = []
self.back_add_steps = []
# The wavelengths at which the monitoring have been calculated and
# the refractive indices at those wavelengths.
self.monitoring_wvls = []
self.monitoring_n = []
# Saved matrices for monitoring conditions and the thicknesses for
# those matrices.
self.monitoring_sin2_theta_0 = []
self.monitoring_thicknesses = []
self.monitoring_matrices_front = []
self.monitoring_matrices_back = []
# The materials to use for needles and for the Fourier transform
# method.
self.needle_materials = None
self.Fourier_parameters = None
# The progress of the current operation.
self.progress = 0.0
# Set this true if you want to cancel an operation.
self.stop_ = False
# Remember if the filter was modified.
self.modified = True
######################################################################
# #
# clone #
# #
######################################################################
def clone(self):
"""Get a copy of the filter
This method returns a clone of the filter."""
clone = self.__class__(self.material_catalog)
clone.set_description(self.description)
clone.set_center_wavelength(self.center_wavelength)
if self.from_wavelength:
clone.set_wavelengths_by_range(self.from_wavelength, self.to_wavelength, self.by_wavelength)
else:
clone.set_wavelengths(self.wvls)
clone.set_step_spacing(self.step_spacing)
clone.set_minimum_thickness(self.minimum_thickness)
clone.set_consider_backside(self.consider_backside)
clone.set_consider_backside_on_monitoring(self.consider_backside_on_monitoring)
clone.set_ellipsometer_type(self.ellipsometer_type)
clone.set_Delta_min(self.Delta_min)
clone.set_monitoring_ellipsometer_type(self.monitoring_ellipsometer_type)
clone.set_monitoring_Delta_min(self.monitoring_Delta_min)
clone.set_observer(self.observer_name)
clone.set_illuminant(self.illuminant_name)
clone.set_monitoring_sublayer_thickness(self.monitoring_sublayer_thickness)
clone.set_dont_consider_substrate(self.dont_consider_substrate)
clone.set_substrate(self.materials[self.substrate].get_name())
clone.set_substrate_thickness(self.substrate_thickness)
clone.set_medium(self.materials[self.front_medium].get_name(), FRONT)
clone.set_medium(self.materials[self.back_medium].get_name(), BACK)
if self.front_stack_formula:
clone.set_stack_formula(self.front_stack_formula, self.front_stack_materials, FRONT)
if self.back_stack_formula:
clone.set_stack_formula(self.back_stack_formula, self.back_stack_materials, BACK)
for i in range(len(self.front_layers)):
material = self.materials[self.front_layers[i]]
material_name = material.get_name()
if self.front_step_profiles[i]:
clone.add_graded_layer_from_steps(material_name, self.front_step_profiles[i], self.front_thickness[i], TOP, FRONT, description = self.front_layer_descriptions[i])
elif material.is_mixture():
clone.add_layer(material_name, self.front_thickness[i], TOP, FRONT, index = self.front_index[i], description = self.front_layer_descriptions[i])
clone.set_refine_layer_thickness(i, self.front_refine_thickness[i], FRONT)
clone.set_refine_layer_index(i, self.front_refine_index[i], FRONT)
clone.set_preserve_OT(i, self.front_preserve_OT[i], FRONT)
clone.set_add_needles(i, self.front_add_needles[i], FRONT)
clone.set_add_steps(i, self.front_add_steps[i], FRONT)
else:
clone.add_layer(material_name, self.front_thickness[i], TOP, FRONT, description = self.front_layer_descriptions[i])
clone.set_refine_layer_thickness(i, self.front_refine_thickness[i], FRONT)
clone.set_add_needles(i, self.front_add_needles[i], FRONT)
for i in range(len(self.back_layers)):
material = self.materials[self.back_layers[i]]
material_name = material.get_name()
if self.back_step_profiles[i]:
clone.add_graded_layer_from_steps(material_name, self.back_step_profiles[i], self.back_thickness[i], TOP, BACK, description = self.back_layer_descriptions[i])
elif material.is_mixture():
clone.add_layer(material_name, self.back_thickness[i], TOP, BACK, index = self.back_index[i], description = self.back_layer_descriptions[i])
clone.set_refine_layer_thickness(i, self.back_refine_thickness[i], BACK)
clone.set_refine_layer_index(i, self.back_refine_index[i], BACK)
clone.set_preserve_OT(i, self.back_preserve_OT[i], BACK)
clone.set_add_needles(i, self.back_add_needles[i], BACK)
clone.set_add_steps(i, self.back_add_steps[i], BACK)
else:
clone.add_layer(material_name, self.back_thickness[i], TOP, BACK, description = self.back_layer_descriptions[i])
clone.set_refine_layer_thickness(i, self.back_refine_thickness[i], BACK)
clone.set_add_needles(i, self.back_add_needles[i], BACK)
if self.needle_materials:
clone.set_needle_materials(self.needle_materials)
if self.Fourier_parameters:
clone.set_Fourier_parameters(self.Fourier_parameters)
clone.set_modified(False)
return clone
######################################################################
# #
# get_material_catalog #
# #
######################################################################
def get_material_catalog(self):
"""Get the material catalog used by the filter
This method returns the material catalog of the filter."""
return self.material_catalog
######################################################################
# #
# set_description #
# #
######################################################################
def set_description(self, description):
"""Set the description of the filter
This method takes a single input argument:
description the description."""
if description != self.description:
self.description = description
self.modified = True
######################################################################
# #
# get_description #
# #
######################################################################
def get_description(self):
"""Get the description of the filter
This method returns the description of the filter."""
return self.description
######################################################################
# #
# set_center_wavelength #
# #
######################################################################
def set_center_wavelength(self, center_wavelength):
"""Set the center wavelength of the filter
This method takes a single input argument:
center_wavelength the center wavelength.
The center wavelengths serves as a reference when giving the index
of refraction of a layer and to calculate its optical thickness.
It is necessary that all the mixtures used are monotone at the new
center wavelength. Thie method checks this and raises an error if
the refractive index is not monotone. An error may also occur when
graded-index layers are converted to a new center wavelength. If
either errors are raised, this method guaranties that the optical
filter instance is not modified. The caller is left responsible to
decide what to do with the error."""
if center_wavelength != self.center_wavelength:
new_material_indices = [None]*len(self.materials)
# Calculate new material indices.
for i_mat in range(len(self.materials)):
if self.materials[i_mat].is_mixture():
if not self.materials[i_mat].check_monotonicity(center_wavelength):
raise materials.material_error("Refractive index is not monotonic at reference wavelength")
new_material_indices[i_mat] = graded.calculate_steps(self.materials[i_mat], self.step_spacing, center_wavelength)
else:
new_material_indices[i_mat] = self.materials[i_mat].get_index(center_wavelength)
# Try to convert step profiles.
filter_has_graded_index_layers = False
nb_front_layers = len(self.front_layers)
new_front_thickness = [None]*nb_front_layers
new_front_step_profiles = [None]*nb_front_layers
new_front_index = [None]*nb_front_layers
for i_layer in range(nb_front_layers):
if self.is_graded(i_layer, FRONT):
filter_has_graded_index_layers = True
new_front_step_profiles[i_layer], new_front_thickness[i_layer] = graded.change_step_profile(self.materials[self.front_layers[i_layer]], self.front_step_profiles[i_layer], self.front_thickness[i_layer], self.material_indices[self.front_layers[i_layer]], self.center_wavelength, new_material_indices[self.front_layers[i_layer]], center_wavelength, self.minimum_thickness)
new_front_index[i_layer] = graded.steps_to_index(new_front_step_profiles[i_layer], new_material_indices[self.front_layers[i_layer]])
elif self.materials[self.front_layers[i_layer]].is_mixture():
new_front_thickness[i_layer] = self.front_thickness[i_layer]
new_front_index[i_layer] = self.materials[self.front_layers[i_layer]].change_index_wavelength(self.front_index[i_layer], self.center_wavelength, center_wavelength)
else:
new_front_thickness[i_layer] = self.front_thickness[i_layer]
new_front_index[i_layer] = new_material_indices[self.front_layers[i_layer]]
nb_back_layers = len(self.back_layers)
new_back_thickness = [None]*nb_back_layers
new_back_step_profiles = [None]*nb_back_layers
new_back_index = [None]*nb_back_layers
for i_layer in range(nb_back_layers):
if self.is_graded(i_layer, BACK):
filter_has_graded_index_layers = True
new_back_step_profiles[i_layer], new_back_thickness[i_layer] = graded.change_step_profile(self.materials[self.back_layers[i_layer]], self.back_step_profiles[i_layer], self.back_thickness[i_layer], self.material_indices[self.back_layers[i_layer]], self.center_wavelength, new_material_indices[self.back_layers[i_layer]], center_wavelength, self.minimum_thickness)
new_back_index[i_layer] = graded.steps_to_index(new_back_step_profiles[i_layer], new_material_indices[self.back_layers[i_layer]])
elif self.materials[self.back_layers[i_layer]].is_mixture():
new_back_thickness[i_layer] = self.back_thickness[i_layer]
self.back_index[i_layer] = self.materials[self.back_layers[i_layer]].change_index_wavelength(self.back_index[i_layer], old_center_wavelength, self.center_wavelength)
else:
new_back_thickness[i_layer] = self.back_thickness[i_layer]
self.back_index[i_layer] = self.material_indices[self.back_layers[i_layer]]
# If no error occured, we can now safely save modified values in
# class attributes.
self.center_wavelength = center_wavelength
self.material_indices = new_material_indices
self.front_thickness = new_front_thickness
self.front_step_profiles = new_front_step_profiles
self.front_index = new_front_index
self.back_thickness = new_back_thickness
self.back_step_profiles = new_back_step_profiles
self.back_index = new_back_index
# If there are graded-index layers, their steps have been
# modified: indices, monitoring and analysis must be
# recalculated.
if filter_has_graded_index_layers:
self.reset_n()
self.reset_analysis()
self.reset_monitoring()
self.modified = True
######################################################################
# #
# get_center_wavelength #
# #
######################################################################
def get_center_wavelength(self):
"""Get the center wavelength of the filter
This method returns the center wavelength."""
return self.center_wavelength
######################################################################
# #
# set_wavelengths #
# #
######################################################################
def set_wavelengths(self, wavelengths):
"""Set the wavelengths of the filter
This method takes a single input argument:
wavelengths a list of wavelengths.
The wavelengths are used in the calculation of all the properties
of the filter, except color."""
if wavelengths != self.wvls:
self.from_wavelength = 0.0
self.to_wavelength = 0.0
self.by_wavelength = 0.0
self.reset_n()
self.reset_analysis()
nb_wvls = len(wavelengths)
self.wvls = abeles.wvls(nb_wvls)
for i in range(nb_wvls):
self.wvls.set_wvl(i, wavelengths[i])
self.modified = True
######################################################################
# #
# get_wavelengths #
# #
######################################################################
def get_wavelengths(self):
"""Get the wavelengths of the filter
This method returns the list of the wavelengths used in
calculations."""
return self.wvls
######################################################################
# #
# set_wavelengths_by_range #
# #
######################################################################
def set_wavelengths_by_range(self, from_wavelength, to_wavelength, by_wavelength):
"""Set the wavelengths of the filter using a range
This method takes 3 arguments:
from_wavelength the lowest limit of the range;
to_wavelength the largets limit of the range;
by_wavelength the increment inside of the range.
If the range is not exactly divisible by the increment, the last
interval will be smaller."""
if from_wavelength != self.from_wavelength or to_wavelength != self.to_wavelength or by_wavelength != self.by_wavelength:
self.from_wavelength = from_wavelength
self.to_wavelength = to_wavelength
self.by_wavelength = by_wavelength
self.reset_n()
self.reset_analysis()
nb_wvls = int(math.ceil((self.to_wavelength-self.from_wavelength)/self.by_wavelength)+1)
self.wvls = abeles.wvls(nb_wvls)
self.wvls.set_wvls_by_range(self.from_wavelength, self.by_wavelength)
self.wvls.set_wvl(nb_wvls-1, self.to_wavelength)
self.modified = True
######################################################################
# #
# get_wavelengths_by_range #
# #
######################################################################
def get_wavelengths_by_range(self):
"""Set the range of wavelengths
This method returns 3 arguments:
from_wavelength the lowest limit of the range;
to_wavelength the largets limit of the range;
by_wavelength the increment inside of the range."""
return self.from_wavelength, self.to_wavelength, self.by_wavelength
######################################################################
# #
# set_step_spacing #
# #
######################################################################
def set_step_spacing(self, step_spacing):
"""Set the step spacing used in graded-index layers
This method takes a single input argument:
step_spacing the step spacing.
The step spacing is the spacing, in index of refraction, used in
the discretization of graded-index layers. When a material is used
in a graded-index layers, a list of index of refraction exactly
divisible and seperated by the step spacing is done. Depending on
the range of index of refraction of the material, the first and
last steps might not be divisible by the step spacing.
The discretization is done to this list of index of refraction
instead of creating a list of layers of all the same thickness to
speed up the calculation. This way, it is only necessary to
calculate the dispersion of the index of refraction of a limited
number of mixtures instead of having to calculate it for every
step.
An error may occur when graded-index layers are converted to a new
step spacing. If such an error is raised, this method guaranties
that the optical filter instance is not modified. The caller is
left responsible to decide what to do with the error."""
if step_spacing != self.step_spacing:
new_material_indices = [None]*len(self.materials)
for i_mat in range(len(self.materials)):
if self.materials[i_mat].is_mixture():
new_material_indices[i_mat] = graded.calculate_steps(self.materials[i_mat], step_spacing, self.center_wavelength)
else:
new_material_indices[i_mat] = self.material_indices[i_mat]
# Try to convert step profiles.
filter_has_graded_index_layers = False
nb_front_layers = len(self.front_layers)
new_front_thickness = [None]*nb_front_layers
new_front_step_profiles = [None]*nb_front_layers
new_front_index = [None]*nb_front_layers
for i_layer in range(nb_front_layers):
if self.is_graded(i_layer, FRONT):
filter_has_graded_index_layers = True
new_front_step_profiles[i_layer], new_front_thickness[i_layer] = graded.change_step_profile(self.materials[self.front_layers[i_layer]], self.front_step_profiles[i_layer], self.front_thickness[i_layer], self.material_indices[self.front_layers[i_layer]], self.center_wavelength, new_material_indices[self.front_layers[i_layer]], self.center_wavelength, self.minimum_thickness)
new_front_index[i_layer] = graded.steps_to_index(new_front_step_profiles[i_layer], new_material_indices[self.front_layers[i_layer]])
else:
new_front_thickness[i_layer] = self.front_thickness[i_layer]
new_front_index[i_layer] = self.front_index[i_layer]
nb_back_layers = len(self.back_layers)
new_back_thickness = [None]*nb_back_layers
new_back_step_profiles = [None]*nb_back_layers
new_back_index = [None]*nb_back_layers
for i_layer in range(nb_back_layers):
if self.is_graded(i_layer, BACK):
filter_has_graded_index_layers = True
new_back_step_profiles[i_layer], new_back_thickness[i_layer] = graded.change_step_profile(self.materials[self.back_layers[i_layer]], self.back_step_profiles[i_layer], self.back_thickness[i_layer], self.material_indices[self.back_layers[i_layer]], self.center_wavelength, new_material_indices[self.back_layers[i_layer]], self.center_wavelength, self.minimum_thickness)
new_back_index[i_layer] = graded.steps_to_index(new_back_step_profiles[i_layer], new_material_indices[self.back_layers[i_layer]])
else:
new_back_thickness[i_layer] = self.back_thickness[i_layer]
new_back_index[i_layer] = self.back_index[i_layer]
# If no error occured, we can now safely save modified values in
# class attributes.
self.step_spacing = step_spacing
self.material_indices = new_material_indices
self.front_thickness = new_front_thickness
self.front_step_profiles = new_front_step_profiles
self.front_index = new_front_index
self.back_thickness = new_back_thickness
self.back_step_profiles = new_back_step_profiles
self.back_index = new_back_index
# If there are graded-index layers, their steps have been
# modified: indices, monitoring and analysis must be
# recalculated.
if filter_has_graded_index_layers:
self.reset_n()
self.reset_analysis()
self.reset_monitoring()
self.modified = True
######################################################################
# #
# get_step_spacing #
# #
######################################################################
def get_step_spacing(self):
"""Set the step spacing used in graded-index layers
This methon returns the step spacing used in graded-index layers."""
return self.step_spacing
######################################################################
# #
# set_minimum_thickness #
# #
######################################################################
def set_minimum_thickness(self, minimum_thickness):
"""Set the minimum thickness of sublayers in graded-indexlayers
This function takes a singler input argument:
minimum_thickness the minimum thickness.
Since the discretization of graded-index layer is done by index, it
might create very thin layers in the regions where the index
changes rapidly. By imposing a minimal thickness, it is possible to
avoid this problem.
An error may occur when graded-index layers are converted to a new
minimum thickness. If such an error is raised, this method
guaranties that the optical filter instance is not modified. The
caller is left responsible to decide what to do with the error."""
if minimum_thickness != self.minimum_thickness:
# Try to convert step profiles.
filter_has_graded_index_layers = False
nb_front_layers = len(self.front_layers)
new_front_thickness = [None]*nb_front_layers
new_front_step_profiles = [None]*nb_front_layers
new_front_index = [None]*nb_front_layers
for i_layer in range(len(self.front_layers)):
if self.is_graded(i_layer, FRONT):
filter_has_graded_index_layers = True
new_front_step_profiles[i_layer], new_front_thickness[i_layer] = graded.change_step_profile(self.materials[self.front_layers[i_layer]], self.front_step_profiles[i_layer], self.front_thickness[i_layer], self.material_indices[self.front_layers[i_layer]], self.center_wavelength, self.material_indices[self.front_layers[i_layer]], self.center_wavelength, minimum_thickness)
new_front_index[i_layer] = graded.steps_to_index(new_front_step_profiles[i_layer], self.material_indices[self.front_layers[i_layer]])
else:
new_front_thickness[i_layer] = self.front_thickness[i_layer]
new_front_index[i_layer] = self.front_index[i_layer]
nb_back_layers = len(self.back_layers)
new_back_thickness = [None]*nb_back_layers
new_back_step_profiles = [None]*nb_back_layers
new_back_index = [None]*nb_back_layers
for i_layer in range(len(self.back_layers)):
if self.is_graded(i_layer, BACK):
filter_has_graded_index_layers = True
new_back_step_profiles[i_layer], new_back_thickness[i_layer] = graded.change_step_profile(self.materials[self.back_layers[i_layer]], self.back_step_profiles[i_layer], self.back_thickness[i_layer], self.material_indices[self.back_layers[i_layer]], self.center_wavelength, self.material_indices[self.back_layers[i_layer]], self.center_wavelength, minimum_thickness)
new_back_index[i_layer] = graded.steps_to_index(new_back_step_profiles[i_layer], self.material_indices[self.back_layers[i_layer]])
else:
new_back_thickness[i_layer] = self.back_thickness[i_layer]
new_back_index[i_layer] = self.back_index[i_layer]
# If no error occured, we can now safely save modified values in
# class attributes.
self.minimum_thickness = minimum_thickness
self.front_thickness = new_front_thickness
self.front_step_profiles = new_front_step_profiles
self.front_index = new_front_index
self.back_thickness = new_back_thickness
self.back_step_profiles = new_back_step_profiles
self.back_index = new_back_index
# If there are graded-index layers, their steps have been
# modified: monitoring and analysis must be recalculated.
if filter_has_graded_index_layers:
self.reset_analysis()
self.reset_monitoring()
self.modified = True
######################################################################
# #
# get_minimum_thickness #
# #
######################################################################
def get_minimum_thickness(self):
"""Get the minimum thickness of sublayers in graded-index layers
This method returns the mimimum thickness of sublayer in
graded-index layers."""
return self.minimum_thickness
######################################################################
# #
# set_monitoring_sublayer_thickness #
# #
######################################################################
def set_monitoring_sublayer_thickness(self, monitoring_sublayer_thickness):
"""Set the monitoring sublayer thickness
This function takes a singler input argument:
monitoring_sublayer_thickness the sublayer thickness.
When calculating a monitoring curve, the homogeneous layers are
calculated every sublayer thickess."""
if monitoring_sublayer_thickness != self.monitoring_sublayer_thickness:
self.monitoring_sublayer_thickness = monitoring_sublayer_thickness
self.reset_monitoring()
self.modified = True
######################################################################
# #
# get_monitoring_sublayer_thickness #
# #
######################################################################
def get_monitoring_sublayer_thickness(self):
"""Get the monitoring sublayer thickness
This method returns the sublayer thickness used in the calculation
of monitoring curves."""
return self.monitoring_sublayer_thickness
######################################################################
# #
# set_consider_backside #
# #
######################################################################
def set_consider_backside(self, consider_backside):
"""Set the consideration of backside
This method takes a single input argument:
consider backside a boolean indicating if the backside should
be considered during the calculation of the
properties.
If the backside is not considered, the substate is considered
semi-infinite."""
if self.dont_consider_substrate:
return
if consider_backside != self.consider_backside:
self.consider_backside = consider_backside
self.modified = True
######################################################################
# #
# get_consider_backside #
# #
######################################################################
def get_consider_backside(self):
"""Get the consideration of backside
This function returns a boolean value indicating if the backside is
considered during calculations."""
return self.consider_backside
######################################################################
# #
# set_consider_backside_on_monitoring #
# #
######################################################################
def set_consider_backside_on_monitoring(self, consider_backside_on_monitoring):
"""Set the consideration of backside on monitoring
This method takes a single input argument:
consider_backside_on_monitoring a boolean indicating if the
backside should be considered
during the calculation of the
monitoring curves.
If the backside is not considered, the substate is considered
semi-infinite."""
if self.dont_consider_substrate:
return
if consider_backside_on_monitoring != self.consider_backside_on_monitoring:
self.consider_backside_on_monitoring = consider_backside_on_monitoring
self.reset_monitoring()
self.modified = True
######################################################################
# #
# get_consider_backside_on_monitoring #
# #
######################################################################
def get_consider_backside_on_monitoring(self):
"""Get the consideration of backside on monitoring
This function returns a boolean value indicating if the backside is
considered during monitoring."""
return self.consider_backside_on_monitoring
######################################################################
# #
# set_ellipsometer_type #
# #
######################################################################
def set_ellipsometer_type(self, ellipsometer_type):
"""Set the ellipsometer type
This method takes a single input argument:
ellipsometer_type the type of ellipsometer (RAE, RPE or
RCE).
Depending on the type of ellipsometer, Delta is defined over a full
360 degres (RCE), or over only 180 degres (RAE or RCE)."""
if ellipsometer_type != self.ellipsometer_type:
self.ellipsometer_type = ellipsometer_type
self.modified = True
######################################################################
# #
# get_ellipsometer_type #
# #
######################################################################
def get_ellipsometer_type(self):
"""Get the ellipsometer type
This method returns the ellipsometer type."""
return self.ellipsometer_type
######################################################################
# #
# set_Delta_min #
# #
######################################################################
def set_Delta_min(self, Delta_min):
"""Set the minimum Delta for ellipsometric calculations
This method takes a single input argument:
Delta_min the minimum Delta.
When Delta is defined over a 360 degres range, different
conventions define it between -180 and +180 degres or 0 and 360
degres."""
if Delta_min != self.Delta_min:
self.Delta_min = Delta_min
self.modified = True
######################################################################
# #
# get_Delta_min #
# #
######################################################################
def get_Delta_min(self):
"""Get the minimum Delta for ellipsometric calculations
This method returns the mimimun Delta used for ellipsometric
calculations."""
return self.Delta_min
######################################################################
# #
# set_monitoring_ellipsometer_type #
# #
######################################################################
def set_monitoring_ellipsometer_type(self, monitoring_ellipsometer_type):
"""Set the monitoring ellipsometer type
This method takes a single input argument:
monitoring_ellipsometer_type the type of ellipsometer (RAE, RPE
or RCE).
Depending on the type of ellipsometer, Delta is defined over a full
360 degres (RCE), or over only 180 degres (RAE or RCE)."""
if monitoring_ellipsometer_type != self.monitoring_ellipsometer_type:
self.monitoring_ellipsometer_type = monitoring_ellipsometer_type
self.modified = True
######################################################################
# #
# get_monitoring_ellipsometer_type #
# #
######################################################################
def get_monitoring_ellipsometer_type(self):
"""Get the monitoring ellipsometer type
This method returns the monitoring ellipsometer type."""
return self.monitoring_ellipsometer_type
######################################################################
# #
# set_monitoring_Delta_min #
# #
######################################################################
def set_monitoring_Delta_min(self, monitoring_Delta_min):
"""Set the minimum Delta for ellipsometric monitoring
This method takes a single input argument:
monitoring_Delta_min the minimum Delta.
When Delta is defined over a 360 degres range, different
conventions define it between -180 and +180 degres or 0 and 360
degres."""
if monitoring_Delta_min != self.monitoring_Delta_min:
self.monitoring_Delta_min = monitoring_Delta_min
self.modified = True
######################################################################