import SkyNEt.modules.SaveLib as SaveLib import matplotlib.pyplot as plt from SkyNEt.instruments import InstrumentImporter import numpy as np import os import config_IV as config # Load the information from the config class. config = config.experiment_config() # Initialize save directory. saveDirectory = SaveLib.createSaveDirectory(config.filepath, config.name) # Define the device input using the function in the config class. Input = config.Sweepgen(config.v_high, config.v_low, config.n_points, config.direction) # Measure using the device specified in the config class. if config.device == 'nidaq': Output = InstrumentImporter.nidaqIO.IO(Input, config.fs) elif config.device == 'adwin': adwin = InstrumentImporter.adwinIO.InitInstrument() Output = InstrumentImporter.adwinIO.IO(adwin, Input, config.fs) else: print('specify measurement device') # Save the Input and Output SaveLib.saveExperiment(saveDirectory, input=Input, output=Output) # Plot the IV curve. plt.figure()
w = cf.InputGen()[3] # Weight array target = cf.TargetGen()[1] # Target signal # np arrays to save genePools, outputs and fitness geneArray = np.zeros((cf.generations, cf.genomes, cf.genes)) outputArray = np.zeros((cf.generations, cf.genomes, len(x[0]))) fitnessArray = np.zeros((cf.generations, cf.genomes)) # Temporary arrays, overwritten each generation fitnessTemp = np.zeros((cf.genomes, cf.fitnessavg)) outputAvg = np.zeros((cf.fitnessavg, len(x[0]))) outputTemp = np.zeros((cf.genomes, len(x[0]))) controlVoltages = np.zeros(cf.genes) # Initialize save directory saveDirectory = SaveLib.createSaveDirectory(cf.filepath, cf.name) # Initialize main figure mainFig = PlotBuilder.initMainFigEvolution(cf.genes, cf.generations, cf.genelabels, cf.generange) # Initialize instruments ivvi = InstrumentImporter.IVVIrack.initInstrument() # Initialize genepool genePool = Evolution.GenePool(cf) #%% Measurement loop for i in range(cf.generations): for j in range(cf.genomes): # Set the DAC voltages
input1 = [-900, 0, 900] voltageGrid = [*controlVoltages, input2, input1] electrodes = len(voltageGrid) #amount of electrodes acqTime = 0.01 samples = 50 #construct configuration array voltages = grid(electrodes, voltageGrid) voltages = voltages[:, ::-1] print('First two indices are inputs, rest CV. Fastest CV has the last index!') # init data container data = np.zeros((voltages.shape[0], voltages.shape[1] + samples)) data[:, :voltages.shape[1]] = voltages # initialize save directory saveDirectory = SaveLib.createSaveDirectory(filepath, name) # initialize instruments ivvi = IVVIrack.initInstrument(dac_step=500, dac_delay=0.001) nr_blocks = len(input1) * len(input2) blockSize = int(len(voltages) / nr_blocks) assert len( voltages ) == blockSize * nr_blocks, 'Nr of gridpoints not divisible by nr_blocks!!' #main acquisition loop for j in range(nr_blocks): print('Getting Data for block ' + str(j) + '...') start_block = time.time() IVVIrack.setControlVoltages(ivvi, voltages[j * blockSize, :]) time.sleep(1) #extra delay to account for changing the input voltages for i in range(blockSize):