Commit 29b1a46a authored by Lucas Laplanche's avatar Lucas Laplanche
Browse files

nettoyage code

parent 44da8d0a
...@@ -275,6 +275,31 @@ def benchmark_refractive_index(): ...@@ -275,6 +275,31 @@ def benchmark_refractive_index():
def surface_fit_550_test():
# import data
data = np.load('data/550C_AlGaAs_refractive_indices/indices_arrays.npz')
al = data['al_array']
wavelength = data['wavelength_array']
n = data['n_array']
# al and wavelength must be of same size
wavelength_length = wavelength.shape[0]
al_length = al.shape[0]
indices_list = np.linspace(0, wavelength_length -1, num=al_length).astype(int)
wavelength = wavelength[indices_list]
# then of course, n and k must be square matrices
n = n[indices_list, :]
n_calc = op.almuneau_complex_550C_algaas_refractive_index(al, wavelength)
plt.plot_2_std_heatmaps(al, wavelength, n, al, wavelength, np.real(n_calc))
def oes_test(): def oes_test():
time, wavelength, peaks, data_mean_sample, data_empty, data_diff = oe.import_data_march_2021() time, wavelength, peaks, data_mean_sample, data_empty, data_diff = oe.import_data_march_2021()
data_mean_sample = oe.temporal_mean(data_mean_sample) data_mean_sample = oe.temporal_mean(data_mean_sample)
......
...@@ -30,6 +30,8 @@ NALOX = 1.6 # oxided Al refractive index ...@@ -30,6 +30,8 @@ NALOX = 1.6 # oxided Al refractive index
# refractive indices at 550°C # refractive indices at 550°C
# loads al_array, wavelength_array, n_array (real part) and k_array (imaginary part) # loads al_array, wavelength_array, n_array (real part) and k_array (imaginary part)
REFRA_DATA_550 = np.load('data/550C_AlGaAs_refractive_indices/indices_arrays.npz') REFRA_DATA_550 = np.load('data/550C_AlGaAs_refractive_indices/indices_arrays.npz')
# loads n and k coefficients to use with polyval in polynomial_fit
REFRA_MODEL_550 = np.load('data/550C_AlGaAs_refractive_indices/model.npz')
# distributed Bragg Reflectors constants @ 850nm # distributed Bragg Reflectors constants @ 850nm
......
import numpy as np import numpy as np
from globals import C, HEV, NALOX, N0, REFRA_DATA_550, T from globals import C, HEV, NALOX, N0, REFRA_MODEL_550, T
from sqw_lengyel_absorption import gaas_sqw_absorption_at_wavelength from sqw_lengyel_absorption import gaas_sqw_absorption_at_wavelength
...@@ -144,22 +144,18 @@ def almuneau_complex_550C_algaas_refractive_index(al, wavelength, temperature=55 ...@@ -144,22 +144,18 @@ def almuneau_complex_550C_algaas_refractive_index(al, wavelength, temperature=55
print('error : temperature out of range') print('error : temperature out of range')
if 'refra_data_550' in globals() : if 'refra_model_550' in globals() :
pass pass
else : else :
global refra_data_550 global refra_model_550
refra_data_550 = REFRA_DATA_550 refra_model_550 = REFRA_MODEL_550
idx_al = find_nearest_index(al, refra_data_550['al_array']) n = 1j * np.polynomial.polynomial.polyval2d(al, wavelength, refra_model_550['k'])
idx_wavelength = find_nearest_index(wavelength, refra_data_550['wavelength_array']) n += np.polynomial.polynomial.polyval2d(al, wavelength, refra_model_550['n'])
n = refra_data_550['n_array'][idx_wavelength, idx_al] return n
k = refra_data_550['k_array'][idx_wavelength, idx_al]
return n + 1j * k
......
...@@ -135,6 +135,20 @@ def cut_sl_at_time(sl, time): ...@@ -135,6 +135,20 @@ def cut_sl_at_time(sl, time):
return sl_cut
def cut_sl_at_first_layer_named(sl, name):
# get index of corresponding layer
idx = sl.loc[sl['name'].str.contains(name)].head().index.values[0]
# copy and remove the unneeded
sl_cut = sl.loc[0:idx]
# reset the indices so the following lines can work
sl_cut = sl_cut.reset_index(drop=True)
return sl_cut return sl_cut
......
...@@ -12,7 +12,7 @@ ACCOMPLI ...@@ -12,7 +12,7 @@ ACCOMPLI
Nettoyer le code de la structure python. Nettoyer le code de la structure python.
Faire les calculs VCSEL EAM avec oxydation eam. Faire les calculs VCSEL EAM avec oxydation eam.
Réinstaller crystal XE et faire les recettes EAM-VCSELs. Réinstaller crystal XE et faire les recettes EAM-VCSELs.
Corriger le tmm !!!!!!!!! Corriger le scattering tmm !!!!!!!!!
ECHOUÉ ECHOUÉ
......
...@@ -561,6 +561,23 @@ def plot_std_heatmap(x, y, r): ...@@ -561,6 +561,23 @@ def plot_std_heatmap(x, y, r):
fig.show() fig.show()
def plot_2_std_heatmaps(x1, y1, r1, x2, y2, r2):
# define xaxes, yaxes
fig = go.Figure(data=
go.Heatmap(x=x1, y=y1, z=r1, colorscale='jet'))
# show the figure
fig.show()
fig = go.Figure(data=
go.Heatmap(x=x2, y=y2, z=r2, colorscale='jet'))
# show the figure
fig.show()
def plot_reflectivity_heatmap(time, wavelength, r): def plot_reflectivity_heatmap(time, wavelength, r):
fig = go.Figure(data= fig = go.Figure(data=
go.Heatmap(x=time, y=wavelength, z=r, colorscale='jet')) go.Heatmap(x=time, y=wavelength, z=r, colorscale='jet'))
......
import numpy as np
def generate_550C_polynomial_regression():
# this function generate a polynomial function that fit the x y response
# to use it store the coefficients in m, store them
# and call it using :
# zz = polyval2d(xx, yy, m)
# import data
data = np.load('data/550C_AlGaAs_refractive_indices/indices_arrays.npz')
al = data['al_array']
wavelength = data['wavelength_array']
n = data['n_array']
k = data['k_array']
# al and wavelength must be of same size
wavelength_length = wavelength.shape[0]
al_length = al.shape[0]
indices_list = np.linspace(0, wavelength_length -1, num=al_length).astype(int)
wavelength = wavelength[indices_list]
# then of course, n and k must be square matrices
n = n[indices_list, :]
k = k[indices_list, :]
# Fit a 3rd order, 2d polynomial
n = polyfit2d(al, wavelength, n)
k = polyfit2d(al, wavelength, k)
# save the coeffs
np.savez('data/550C_AlGaAs_refractive_indices/model.npz', n=n, k=k)
def polyfit2d(x, y, z, deg=np.array([2, 2])):
vander = np.polynomial.polynomial.polyvander2d(x, y, deg)
#vander = vander.reshape((-1,vander.shape[-1]))
#z = z.reshape((vander.shape[0],))
c = np.linalg.lstsq(vander, z)[0]
#return c.reshape(deg +1)
return c
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment