def get_config_screen(self): """Returns the current measurements' configuration. Parameters ---------- nothing Returns ------- configuration : dict as {'Source': int, 'Type': str} It states the source and type of configured measurement. """ configuration = {} xze, xin, yze, ymu, yoff = self.osci.query_ascii_values( 'WFMPRE:XZE?;XIN?;YZE?;YMU?;YOFF?;', separator=';') configuration.update({ 'Source': # channel find_1st_number(self.osci.query('MEASU:IMM:SOU?')) }) configuration.update({ 'Type': # type of measurement self.osci.query('MEASU:IMM:TYP?') }) return configuration
def get_config_measure(self): """Returns the current measurements' configuration. Parameters ---------- nothing Returns ------- configuration : dict as {'Source': int, 'Type': str} It states the source and type of configured measurement. """ configuration = {} configuration.update({ 'Source': # channel find_1st_number(self.osci.query('MEASU:IMM:SOU?')) }) configuration.update({ 'Type': # type of measurement self.osci.query('MEASU:IMM:TYP?') }) return configuration
plt.grid() plt.show() #%% by Marcos name = 'Frequency_Sweep' folder = os.path.join(os.getcwd(), 'Measurements', name) # Por Fourier: fourierfiles = sorted([ os.path.join(folder, f) for f in os.listdir(folder) if f.endswith('Fourier.txt') ]) f = fourierfiles[20] samplingrate = fstr.find_1st_number(f) * 1.012 actual_freq, fourier_freq, fourier_power = np.loadtxt(f, unpack=True) #plt.stem(actual_freq, np.ones_like(actual_freq)) #plt.stem(fourier_freq, fourier_power) #expected curve: fr = np.arange(actual_freq[0], actual_freq[-1], 100) fa = np.array([np.abs(fr - n * samplingrate) for n in range(10)]) fa = np.min(fa, axis=0) yrange = (0, max(fourier_freq) * 1.1) #plotting range plt.plot(fr, fa, label='Alias de frecuencias esperado', linewidth=2) plt.plot(actual_freq, fourier_freq, 'o',
ds = np.diff(signal) picos = find_peaks(ds, **kwargs)[0] vel = np.diff(picos).astype(float) t = time[picos[:-1]] return t, 1 / vel #def fix_vel(vel, threshold): #%% #Select file and extract stuff gen_freq = 10e3 #in Hz file = contenidos_completos[1] salto = fst.find_numbers(file)[0:1] samplerate = fst.find_1st_number(retrieve_footer(file)) #in Hz points_per_gen_period = samplerate / gen_freq #load data time, signal, gen = np.loadtxt(file, unpack=True) signal = np.abs(signal) gen /= np.mean(gen[gen > 4]) # gen now goes between 0 and 1, approx cada = 200 #integral = np.array([np.trapz(gen[i:i+cada]) for i in range(len(gen)-cada)]) #duty_cycle = np.array([np.mean(gen[i:i+cada]) for i in range(len(gen)-cada)]) ds = normalize(np.diff(signal), 3) signal = normalize(signal, 4) picos = find_peaks(ds, height=.6, prominence=.4)[0] #vel = np.diff(picos)
def get_config_output(self): """Returns current outputs' configuration on a dictionary. Parameters ---------- nothing Returns ------- configuration : dic Current outputs' configuration. i.e.: {1:{ 'Status': True, 'Waveform': 'SIN', 'Frequency': 1000.0, 'Amplitude': 1.0, 'Offset': 0.0, 'Phase': 0.0, 'Symmetry': 50.0, 'Duty Cycle': 50.0,}} """ configuration = {i: dict() for i in range(1, self.nchannels + 1)} for channel in range(1, self.nchannels + 1): # On or off? configuration[channel].update({ 'Status': bool(int(self.gen.query('OUTP{}:STAT?'.format(channel)))) }) # Waveform configuration configuration[channel].update({ 'Waveform': self.gen.query('SOUR{}:FUNC:SHAP?'.format(channel)) }) # Frequency configuration aux = self.gen.query('SOUR{}:FREQ?'.format(channel)) configuration[channel]['Frequency'] = find_1st_number(aux) # Amplitude configuration aux = self.gen.query('SOUR{}:VOLT:LEV:IMM:AMPL?'.format(channel)) configuration[channel]['Amplitude'] = find_1st_number(aux) # Offset configuration aux = self.gen.query('SOUR{}:VOLT:LEV:IMM:OFFS?'.format(channel)) configuration[channel]['Offset'] = find_1st_number(aux) # Phase configuration aux = self.gen.query('SOUR{}:PHAS?'.format(channel)) configuration[channel]['Phase'] = find_1st_number(aux) # PULS's Duty Cycle configuration try: aux = self.gen.query('SOUR{}:PULS:DCYC?'.format(channel)) configuration.update({'Duty Cycle': find_1st_number(aux)}) except: configuration[channel]['Duty Cycle'] = 50.0 # RAMP's Symmetry configuration try: aux = self.gen.query('SOUR{}:FUNC:RAMP:SYMM?'.format(channel)) configuration[channel]['Symmetry'] = find_1st_number(aux) except: configuration[channel]['Symmetry'] = 50.0 return configuration