def transmission_corrected( data, theta_in=0.008, index_optic=N_HPFS, index_lab=N_AIR): """Return the background subtracted and Fresnel loss corrected internal transmission coefficient from a set of data in the form [signal, signal_background, reference, reference_background] where each element is a 2D list. The first sublist column is the beam monitor photodiode reading and the second is the downstream photodiode reading. The Fresnel correction requires the input angle theta_in (in radians) and the indexes of refraction.""" t_correction, t_correction_error = _fresnel_correction( theta_in, index_lab, index_optic) t_raw, t_raw_error = transmission_raw(data) return (t_raw / t_correction, ratio_error(t_raw, t_correction, t_raw_error, t_correction_error))
def transmission_raw(data): """Return the background subtracted raw transmission coefficient from a set of data in the form [signal, signal_background, reference, reference_background] where each element is a 2D list. The first sublist column is the beam monitor photodiode reading and the second is the downstream photodiode reading.""" # averages = [np.mean(i, axis=0) for i in data] # uncertainties = [np.std(i, axis=0) / np.sqrt(len(i)) for i in data] backgrounds = [np.mean(i, axis=0) for i in (data[1], data[3])] intensities = np.array( [((data[s][:, 1] - backgrounds[s/2][1]) / (data[s][:, 0] - backgrounds[s/2][0])) for s in (0, 2)]) signal, reference = np.mean(intensities, axis=1) signal_error, reference_error = ( np.std(intensities, axis=1) / np.sqrt(len(intensities[0]))) return (signal / reference, ratio_error(signal, reference, signal_error, reference_error))
def transmission_per_unit_length(data, **kwargs): """Return the background subtracted and Fresnel loss corrected internal transmission per unit length from a set of data in the form [signal, signal_background, reference, reference_background] where each element is a 2D list. The first sublist column is the beam monitor photodiode reading and the second is the downstream photodiode reading. Keyword arguments: 'length' (0.450): Beam path length in desired units through optic. 'length_error (0.001): Uncertainty on length. All other keywords are passed to 'transmission_corrected'. """ length = kwargs.pop('length', 0.450) length_error = kwargs.pop('length_error', 0.00001) t_corrected, t_corrected_error = transmission_corrected(data, **kwargs) scale = 1.0 / float(length) scale_error = ratio_error(1.0, float(length), 0, length_error) t_error = power_error(t_corrected, scale, t_corrected_error, scale_error) return (t_corrected**scale, t_error)