def load_power_sweep(filename, description=''): d = dict(np.load(filename)) uu.copy_string('\n'.join(d.keys())) o = Bunch(data_dict=d, keys=d.keys(), filename=filename, filetitle=uu.get_file_title(filename), description=description, powers=d['power_meter_power'], N=d['Np']) if d['power_scan_motorized_collect_apd']: raise NotImplementedError('APD power scan not implemented') if d['power_scan_motorized_collect_lifetime']: o.rep_rate = d['picoharp_count_rate0'] o.bin_size = d['picoharp_Resolution'] o.num_bins = int(np.ceil((1 / o.rep_rate) / (o.bin_size * 1e-12))) o.time = d['time_array'][0:o.num_bins] # already in ns o.intensity = d['time_traces'][:, 0:o.num_bins] if d['power_scan_motorized_collect_lockin']: raise NotImplementedError('Lockin power scan not implemented') if d['power_scan_motorized_collect_spectrum']: o.wavelength = d['wls'] o.intg_time = d['andor_ccd_exposure_time'] o.center_wl = d['acton_spectrometer_center_wl'] o.specs = d['spectra'] o.intg_spectrum_ints = np.sum(o.specs, axis=1) if d['power_scan_motorized_collect_step_and_glue']: N = d['Np'] for i in range(N): wls, ints = merge_step_and_glue_specs( d['step_and_glue_centers'], d['step_and_glue_wavelengths'][i], d['step_and_glue_specs'][i]) if i == 0: o.specs = np.empty([N, wls.shape[0]], dtype=float) o.wavelength = wls o.specs[i] = ints o.intg_time = d['andor_ccd_exposure_time'] o.centers = d['step_and_glue_centers'][0] o.everything = Bunch() for key in o.keys: setattr(o.everything, key, d[key]) return o
def load_picoharp_transient(filename, description="", truncate_bins=False): d = dict(np.load(filename)) #uu.copy_string('\n'.join(d.keys())) o = Bunch(data_dict=d, keys=d.keys(), filename=filename, filetitle=uu.get_file_title(filename), description=description, intensity=d['time_histogram'], time=d['time_array'], resolution=d['picoharp_Resolution'], rep_rate=d['picoharp_count_rate0']) o.num_bins = int(np.ceil((1 / o.rep_rate) / (o.resolution * 1e-12))) if truncate_bins: o.time = o.time[0:o.num_bins] o.intensity = o.intensity[0:o.num_bins] o.everything = Bunch() for key in o.keys: setattr(o.everything, key, d[key]) return o