def scan_trigger(trigger_variable, prescale): '''Scans over one of the specified trigger varaibles, and returns a dict of results useful for analysis. The default range for each trigger should be suitable for most things. ''' nsteps = 20 scan_range = {'energy_thresh': [50, 700], 'occupancy_thresh': [2, 22]} steps = np.linspace(scan_range[trigger_variable][0], scan_range[trigger_variable][1], nsteps, endpoint = False) # v handy tip. results = {'fprs': [], 'tprs': [], 'scan_steps': steps, 'dtime_fracs': [], 'storage_space_bytes': []} for step in steps: data = DAQ.run({trigger_variable: step}, prescale) results['tprs'].append(data['tpr']) results['fprs'].append(data['fpr']) results['dtime_fracs'].append(data['deadtime_fraction']) results['storage_space_bytes'].append(data['storage_space_bytes']) return results
def test_digital_data_shape(self): di = DAQ.DigitalInput('cDAQ1Mod2/port0/line0:1', 2, 1000, 3) di.DoTask() print(di.digitalData.shape) self.assertEqual(di.digitalData.shape[0] * di.digitalData.shape[1], 2 * 1000 * 3)
def on_click(self): print('PyQt5 button click') for num_capture in range(int(self.input_times.text())): print('is Trigger' + str(self.is_trigger)) global overall_df wave_data = DAQ.take_waveform(osc_daq, self.is_trigger) placeholder_data = pd.DataFrame( [random.random() for i in range(25)]) overall_df = overall_df.append(wave_data, ignore_index=True) print("Shape: " + str(overall_df.shape)) self.m.setData(placeholder_data.iloc[:, 0]) self.on_export()
def __init__(self, instructionfile, ports, resultfile, run=True): pipeend1, pipeend2 = multiprocessing.Pipe() self.pipe = pipeend1 self.instructions = instructions(instructionfile) self.datastorage = [] self.resultfile = files(resultfile) self.resultfile.init_file( "#Nr Wavelength Ref RefErr Sig SigErr RefFreq RefFreqErr RefPhase RefPhaseErr SigFreq SigFreqErr SigPhase SigPhaseErr Misc\n", override=False) self.ploting = False #init devices if aplicable allow access to device in main programm if possible self.devices = {} if self.instructions.monochromator: self.devices['monochromator'] = CornerStone260( port=ports['monochromator']) self.devices['monochromator'].Units_NM() if self.instructions.XYZ_Scanner: self.devices['xyz-scanner'] = Scanner.Scanner( port=ports["xyz-scanner"], do_refrun=True, smooth_move=False, debug=False, show=False) if self.instructions.sLockIn: self.devices['sLockIn'] = lockIn.lockin(port=ports['sLockIn'], autogain=True, timeconstant=0.3) if self.instructions.rLockIn: self.devices['rLockIn'] = lockIn.lockin(port=ports['rLockIn'], autogain=True, timeconstant=0.3) if self.instructions.rotPlatform[0] or self.instructions.rotPlatform[ 1] or self.instructions.rotPlatform[2]: self.devices['rotPlatform'] = rotLib.rotStages( port=ports['rotPlatform'], unit="deg", Channels=self.instructions.rotPlatform, init=self.instructions.rotPlatform) #switch to init true self.DAQ = DAQ.DAQ(self.instructions, self.devices, pipeend2) if run: self.run()
import numpy import DAQ # Settings filename = 'Data/16V_Step.npy' curve = [] curve.append(numpy.zeros(50) + 0.950E-3) curve.append(numpy.ones(100) + 2.000E-3) curve.append(numpy.zeros(50) + 0.950E-3) curve = numpy.concatenate(curve) # Code daq = DAQ.DAQ() probe = daq.probeCurve(curve, 5) del daq print('Record: {:.1f} s'.format(probe.shape[0] / 200_000)) numpy.save(filename, probe)
from PyQt5.QtGui import * #****************************************************************** import matplotlib matplotlib.use("Qt5Agg") #****************************************************************** from PyQt5 import QtCore from PyQt5.QtCore import * from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas from matplotlib.figure import Figure import matplotlib.pyplot as plt import pandas as pd import random import DAQ #****************************************************************** osc_daq = DAQ.init_osc() overall_df = pd.DataFrame() def main(): app = QApplication(sys.argv) ex = App() sys.exit(app.exec_()) class App(QMainWindow): def __init__(self): super().__init__() # Panel setup option self.left = 100 self.top = 100
def initDAQ(self): # Connects DAQ self.daq = DAQ.DAQ() self.daq.listDevices() self.daq.connect(self.board_number)
def run_example(): '''Example function of how to use the run(trigger_settings) found in DAQ.py ''' data = DAQ.run({'energy_thresh': 500})
def test_digital_input(self): di = DAQ.DigitalInput('cDAQ1Mod2/port0/line0', 1, 1000, 1) di.DoTask() self.assertEqual(numpy.sum(di.digitalData[0]), 0)
def initDAQ(self): # Lists available DAQ devices and connects the selected board self.daq = DAQ.DAQ() self.daq.listDevices() self.daq.connect(self.Boardnum)