<jupyter_start><jupyter_text>Test 1Check bare interface ellipsometry calcualtion against wvase<jupyter_code>dname = 'TestData_bareSI.txt'
data = DataSE(data=dname)

si     = RI('../materials/silicon.csv')
void   = RI('../materials/void.csv')
struc  = void() | si()
model  = ReflectModelSE(struc, wavelength=658)

fig, ax = plt.subplots()
axt = ax.twinx()
test_arr = []

for dat in data:
    model.wav = dat._current_wav
    aois = dat.aoi
    psi, delta = model(aois)
    ax.scatter(aois, psi, facecolor='none', color='r', marker='s')
    p = ax.scatter(dat.aoi, dat.psi, facecolor='none', color='r')
    test_arr.append(np.abs(np.array(psi-dat.psi)/dat.psi)<0.01)
    test_arr.append(np.abs(np.array(delta-dat.delta)/dat.delta)<0.01)

    axt.scatter(aois, delta, facecolor='none', color='b', marker='s')
    d = axt.scatter(dat.aoi, dat.delta, facecolor='none', color='b')

    ax.legend(handles=[p,d], labels=['Psi', 'Delta'])
    ax.set(ylabel='Psi', xlabel='AOI, °')
    axt.set(ylabel='Delta')
    
test_arr = np.array(test_arr)

if np.prod(test_arr, dtype=np.bool):
    print ('Test passed')
else:
    print ('test failed')<jupyter_output>Test passed<jupyter_text>Test 2Check the cauchy model behaves as expected<jupyter_code>fig, ax = plt.subplots()

A = 1.47
B = 0.00495
C = 0

si     = RI('../materials/silicon.csv')
void   = RI('../materials/void.csv')
cauchy = RI(A=A, B=B, C=C)
struc  = void() | cauchy(1000) | si()
model  = ReflectModelSE(struc, wavelength=658)


wvase_output = np.loadtxt('Cauchynk_fromWVASE.txt')
wavs = wvase_output[:,0]
refin = A + B/((wavs/1000)**2) + C/((wavs/1000)**4)

ax.scatter(wvase_output[:,0], wvase_output[:,1], marker='x', color='k', label='wvase output')
ax.plot(wavs, refin, color='b', label='Theoretical output')


refellips_RI = [] 
for wav in wavs:
    model.wav = wav
    refellips_RI.append(cauchy.real.value)

ax.scatter(wavs, refellips_RI, color='r', marker='+', label='refellips output')

ax.set(ylabel='n', xlabel='wavelength, nm')
ax.legend()

passarr_wvase  = np.abs(refellips_RI - wvase_output[:,1])/wvase_output[:,1] < 0.01
passarr_theory = np.abs(refellips_RI - refin)/refin < 0.01

if np.all([passarr_wvase, passarr_theory]):
    print('test passed')
else:
    print('test failed')<jupyter_output>test passed<jupyter_text>Test 3Three layer stack (cauchy & from file) compared to wvaseAlso tests behaviour of Delta around 180°<jupyter_code>dname = 'TestData_cauchy.txt'
data = DataSE(data=dname)

si     = RI('../materials/silicon.csv')
void   = RI('../materials/void.csv')
cauchy = RI(A=1.47, B=0.00495, C=0)
struc  = void() | cauchy(1000) | si()
model  = ReflectModelSE(struc, wavelength=658)
model._flip_delta = True # This will be automatically set when analysing data

fig, ax = plt.subplots()
axt = ax.twinx()
test_arr = []

for dat in data:
    model.wav = dat._current_wav
    aois = dat.aoi
    psi, delta = model(aois)
    ax.scatter(aois, psi, facecolor='none', color='r', marker='s')
    p = ax.scatter(dat.aoi, dat.psi, facecolor='none', color='r')
    test_arr.append(np.abs(np.array(psi-dat.psi)/dat.psi)<0.01)
    test_arr.append(np.abs(np.array(delta-dat.delta)/dat.delta)<0.01)

    axt.scatter(aois, delta, facecolor='none', color='b', marker='s')
    d = axt.scatter(dat.aoi, dat.delta, facecolor='none', color='b')

    ax.legend(handles=[p,d], labels=['Psi', 'Delta'])
    ax.set(ylabel='Psi', xlabel='AOI, °')
    axt.set(ylabel='Delta')
    
test_arr = np.array(test_arr)

if np.prod(test_arr, dtype=np.bool):
    print ('Test passed')
else:
    print ('test failed')<jupyter_output>Test passed
{'fraction_non_alphanumeric': 0.1829608938547486, 'fraction_numerical': 0.021229050279329607, 'mean_word_length': 4.517719568567026, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '141653', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 1540, 'n_tokens_neox': 1444, 'n_words': 266, 'path': 'refellips/tests/TestSuite.ipynb', 'repo_name': 'igresh/refellips', 'size': '3580'}