Skip to content
Snippets Groups Projects
Commit fe84b81b authored by Niklas Borchers's avatar Niklas Borchers
Browse files

Merge branch 'SignalImportfromFile' into 'master'

Signal_import _from_file finished

See merge request !3
parents 3dec4b7d 743fb904
No related branches found
No related tags found
1 merge request!3Signal_import _from_file finished
# Instrument driver configuration file.
[General settings]
# The name is shown in all the configuration windows
name: Signal_Import_by_File
# The version string should be updated whenever changes are made to this config file
version: 1.0
# Name of folder containing the code defining a custom driver. Do not define this item
# or leave it blank for any standard driver based on the built-in VISA interface.
driver_path: Signal_Import_by_File
# Define that the driver is a Signal Generator
signal_generator: True
# Define quantities in sections. This list is a selection of allowed keywords,
# see the manual for a full list of options
# datatype: The datatype should be one of DOUBLE, BOOLEAN, COMBO,
# STRING, COMPLEX, VECTOR, VECTOR_COMPLEX, PATH or BUTTON.
# unit: Quantity unit
# set_cmd: Command used to send data to the instrument. Put <*> where the value should appear.
# get_cmd: Command used to get the data from the instrument. Default is set_cmd?
# def_value: Default value
# low_lim: Lowest allowable value. Defaults to -INF
# high_lim: Highest allowable values. Defaults to +INF
# combo_def_1: First option in a pull-down combo box. Only used when datatype=COMBO
# combo_def_2: Second option in a pull-down combo box. Only used when datatype=COMBO
# ...
# combo_def_n: nth option in a pull-down combo box. Only used when datatype=COMBO
# state_quant: Quantity that determines this control's visibility
# state_value_1: Value of "state_quant" for which the control is visible
# state_value_2: Value of "state_quant" for which the control is visible
# ...
# state_value_n: Value of "state_quant" for which the control is visible
# permission: Sets read/writability, options are BOTH, READ, WRITE or NONE. Default is BOTH
# group: Name of the group where the control belongs.
# section: Name of the section where the control belongs.
[Datapath]
datatype: STRING
def_value: C:\Users\
[Skip Header]
datatype: DOUBLE
def_value: 1
[Skip Footer]
datatype: DOUBLE
def_value: 0
[Delimiter]
datatype: STRING
def_value: ,
[Add noise]
datatype: BOOLEAN
def_value: False
[Noise amplitude]
datatype: DOUBLE
unit: V
def_value: 0.1
state_quant: Add noise
state_value_1: True
[Signal]
datatype: VECTOR
permission: READ
x_name: Time
x_unit: s
# -*- coding: utf-8 -*-
"""
Created on Thu Aug 30 18:36:00 2018
@author: tebbe
"""
import InstrumentDriver
import numpy as np
class Driver(InstrumentDriver.InstrumentWorker):
""" This class implements a simple signal generator driver"""
def performOpen(self, options={}):
"""Perform the operation of opening the instrument connection"""
pass
def performClose(self, bError=False, options={}):
"""Perform the close instrument connection operation"""
pass
def performSetValue(self, quant, value, sweepRate=0.0, options={}):
"""Perform the Set Value instrument operation. This function should
return the actual value set by the instrument"""
# just return the value
return value
def performGetValue(self, quant, options={}):
"""Perform the Get Value instrument operation"""
# proceed depending on quantity
if quant.name == 'Signal':
# if asking for signal, start with getting values of other controls
DATAPATH=self.getValue('Datapath')
skiph=int(self.getValue('Skip Header'))
skipf=int(self.getValue('Skip Footer'))
delim=self.getValue('Delimiter')
if not len(delim):
delim=' '
data= np.genfromtxt(DATAPATH, delimiter = delim, skip_header=skiph, skip_footer=skipf)
time=data[:,0]
signal=data[:,1]
add_noise = self.getValue('Add noise')
if add_noise:
noise_amp = self.getValue('Noise amplitude')
signal += noise_amp * np.random.randn(len(signal))
# create trace object that contains timing info
self.log(signal, level=30)
self.log(time, level=30)
trace = quant.getTraceDict(signal,time)
# finally, return the trace object
return trace
else:
# for other quantities, just return current value of control
return quant.getValue()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment