def correct_TR(struct, incidence="top"): if not struct._TR_calculated: struct.calculate_TR() # Commented out because right now wl_A and struct.wl # have the same range and step T0 = calc.interpolate(struct.wl, struct.T, wl_A) R0 = calc.interpolate(struct.wl, struct.R, wl_A) ## T0 = struct.T ## R0 = struct.R _layers_list = struct._layers_list[:] _layers_list.reverse() struct_rev = ML(_layers_list, unit=struct.unit, label=struct.label+"_rev", min_wl=struct._min_wl, max_wl = struct._max_wl, wl_step=struct._wl_step, n0=struct.ns, ns=struct.n0) struct_rev.calculate_TR() Tr0 = calc.interpolate(struct_rev.wl, struct_rev.T, wl_A) Rr0 = calc.interpolate(struct_rev.wl, struct_rev.R, wl_A) ## Tr0 = struct_rev.T ## Rr0 = struct_rev.R if incidence == "top": T = (1 - A) * Tg * T0 / (1 - (1 - A)**2 * Rg * Rr0) R = R0 + (1 - A)**2 * Rg * T0 * Tr0 / (1 - (1 - A)**2 * Rg * Rr0) elif incidence == "bot": T = (1 - A) * Tg * Tr0 / (1 - (1 - A)**2 * Rg * Rr0) R = Rg + (1 - A)**2 * Rr0 * Tg * Tg / (1 - (1 - A)**2 * Rg * Rr0) struct_rev.wl = wl_A struct_rev.T = T struct_rev.R = R return struct_rev