I want to create a DC superimposed current sequence using a script and set it as the current condition.
The following is an example in Python script.
In this sample, one DC superimposed current sequence is created and set to each specified current condition.
# -*- coding: utf-8 -*-
import numpy as np
#Creation Parameter Settings
amp = 15 #Current amplitude
frequency = 100 #Frequency [Hz]
div = 100 #Number of divisions per frequency cycle
DCBias = 30 #DC bias
#Specify the current condition name to set the point sequence
CurrentconName = ["I1","I2"] #specify using the list type
app = designer.GetApplication()
NowStudy = app.GetCurrentStudy()
#Create an array initialized with zeros to store the sequence of points
data = np.zeros([int(div) * 3 + 1, 2]) #Create an array for three cycles using [div*3]
#Create a point sequence
T = 1 / frequency #Calculate one cycle of frequency
dt = T / div #Calculate the time intervals of the point sequence
for j in range(int(div)*3 + 1): #Create a point sequence for each row
if j==0:
data[j][0] = 0.0 #Assign 0 to the first time point in the sequence
else:
data[j][0] = data[j-1][0] + dt #Calculate the time for the second line and subsequent lines and assign it
t = data[j][0] #Store the time in variable t
data[j][1] = DCBias + amp * np.sin(2 * np.pi * frequency * t) #Calculate the current value and substitute it
#Specify the name of the dataset to be created
name = u"frequency" + str(int(frequency)) + u"_amp" + str(int(amp)) + u"_DCBias" + str(int(DCBias))
#Create a dataset from a sequence of points
DataSet = app.GetDataManager().CreatePointArray(u"point_array/currentvstime")
DataSet.SetName(name) #Rename the dataset to the specified name
DataSet.SetTable(data) #Assign point sequence data to the dataset
#Set the created dataset to the current conditions
for j in range(len(CurrentconName)):
NowStudy.GetCondition(CurrentconName[j]).SetValue("FunctionType",0)
NowStudy.GetCondition(CurrentconName[j]).SetTableProperty("Time",DataSet)


