surf = regular_pyramids(elevation_angle=55, size=5, upright=True)

front_surf = Interface('RT_TMM',
                       texture=surf,
                       layers=[Layer(si('0.1nm'), Air)],
                       name='pyramids' + str(options['n_rays']))
back_surf = Interface('Lambertian', layers=[], name='lambertian')

bulk_Si = BulkLayer(201.8e-6, Si, name='Si_bulk')  # bulk thickness in m

SC = Structure([front_surf, bulk_Si, back_surf],
               incidence=Air,
               transmission=Air)

process_structure(SC, options)
results = calculate_RAT(SC, options)

RAT = results[0]
results_per_pass = results[1]

# load OPTOS/measured data

sim = np.loadtxt('data/optos_fig7_sim.csv', delimiter=',')

plt.figure()
plt.plot(wavelengths * 1e9, RAT['R'][0], label='R')
plt.plot(wavelengths * 1e9, RAT['T'][0], label='T')
plt.plot(wavelengths * 1e9, RAT['A_bulk'][0], 'ko-')
plt.plot(sim[:, 0], sim[:, 1], label='inv pyr/planar')
plt.ylim([0, 1])
                       name='GaInP_GaAs_SiGeSn_TMM',
                       coherent=True)
back_surf = Interface('TMM',
                      layers=back_materials,
                      name='SiN_Air_TMM',
                      coherent=True)

bulk_Si = BulkLayer(bulkthick, Ge, name='Ge_bulk')  # bulk thickness in m

SC = Structure([front_surf, bulk_Si, back_surf],
               incidence=Air,
               transmission=Air)

process_structure(SC, options)

results_TMM_Matrix = calculate_RAT(SC, options)

results_per_pass = results_TMM_Matrix[1]
R_per_pass = np.sum(results_per_pass['r'][0], 2)
R_0 = R_per_pass[0]
R_escape = np.sum(R_per_pass[1:, :], 0)

# only select absorbing layers, sum over passes
results_per_layer_front = np.sum(results_per_pass['a'][0], 0)
results_per_layer_back = np.sum(results_per_pass['a'][1], 0)
total = results_TMM_Matrix[0].R[0] + results_TMM_Matrix[0].T[
    0] + results_TMM_Matrix[0].A_bulk[0] + np.sum(results_per_layer_front, 1)

plt.figure()
plt.plot(options['wavelengths'] * 1e9, results_TMM_Matrix[0].R[0], label='R')
plt.plot(options['wavelengths'] * 1e9, results_TMM_Matrix[0].T[0], label='T')