Data¶
-
class
decida.Data.
Data
(**kwargs)¶ Bases:
decida.ItclObjectx.ItclObjectx
synopsis:
Read, write, and manipulate data.
Data manages a 2-dimensional data structure. Each data column has an associated name which can be used to index the data column. It has methods for reading and writing various formats of data files, appending, sorting, filtering or deleting columns. It has methods for performing column-wise operations, finding level crossings, edges, and jitter of transient “signals” (time and signal columns), and low-pass filter parameters of ac “signals” (frequency and complex signal columns). And there are many other methods for managing data.
Data uses the numpy array as the basic 2-dimensional numerical structure. Numpy is used to perform column-wise operations and so are performed very quickly.
constructor arguments:
**kwargs (dict)
keyword=value specifications: configuration-optionsconfiguration options:
verbose (bool, default=False)
if True, print out messagestitle (str, default=””)
specify data set titleexample:
>>> from decida.Data import Data >>> d = Data(title="prelayout_data", verbose=True) >>> d["verbose"] = False
public methods:
- public methods from ItclObjectx
-
a2d
(col, colspec, slice)¶ convert bus of digital signals to decimal values.
arguments:
col (int or str)
the column to place analog to digital values. If col is a string, it refers to the column named col.col_spec (str)
bus specification for columns to convert. The specification is bus<msb:lsb>, where bus is the bus name, msb is the most-sigificant bit and lsb is the least-significant bit. All bits of the bus must be present in the data set. For example, for bus<1:0>, the columns bus<1> and bus<0> must be present.slice (float)
value to slice the column data into digital values. if data > slice, digital value = 1, else 0.example:
>>> from decida.Data import Data >>> d = Data() >>> d.read("data.csv") >>> d.a2d("bus_a2d", "bus<3:0>", slice=0.5)
-
append
(*cols)¶ append empty (0.0) columns if not already present.
arguments:
cols (tuple)
list of column names or lists of column names.results:
- A list of column names is developed by flattening the cols argument(s).
- For each column name in the column list, if the column isn’t already present, add a new column at the end of the data array.
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read("data.csv") >>> d.append("t12", "t13", ("t15", "t18"))
-
append_data
(data1)¶ append data columns from another Data object.
arguments:
data1 (Data)
Another Data object with the same number of rows as this Data object.results:
- Does not ensure that data column names don’t collide
- data1 is concatenated to this Data object.
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read("data.csv") >>> d1 = Data() >>> d1.read("data1.csv") >>> d.append_data(d1)
-
become
(d)¶ copy data from another Data object.
arguments:
d (Data)
another Data object.results:
- Replaces data array with copy of data array from the other Data object.
- replace data array column names with names from the other Data object.
- replace data title with title from the other Data object.
example:
>>> from decida.Data import Data >>> d2 = Data() >>> d2.read("data.csv") >>> d = Data() >>> d.become(d2)
-
crossings
(xcol, ycol, level=0, edge='both')¶ xcol values when ycol crosses level.
arguments:
xcol (int or str)
x-column to use for crossing values. If xcol is a string, it refers to the column named xcol.ycol (int or str)
y-column to use for crossing values. If ycol is a string, it refers to the column named ycol.level (float, default=None)
signal crossing level to use. If level is None, use 0.5*(max(ycol) + min(ycol))edge (str, default=”both”)
signal edge(s) to use to accumulate crossings. values must be in (“rising”, “falling”, “both”)results:
- Returns a list of xcol crossings of edge of ycol of level.
- Crossing values are linearly-interpolated.
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read("data.csv") >>> ycrossings = d.crossings("time", "v(out)", level=0.4)
-
cxmag
(zcol)¶ generate magnitude, dB and phase columns.
arguments:
zcol (str)
column to generate dB and phase columns. zcol must be represented by REAL(zcol) and IMAG(zcol).results:
- columns MAG(zcol), DB(zcol) and PH(zcol) are generated, using REAL(zcol) and IMAG(zcol).
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read("data.csv") >>> d.cxmag("zout")
-
cxreim
(cxvar, create=False, nocomplain=False)¶ return real and imaginary column indices.
arguments:
cxvar (str)
complex variable name, represented by data array columns REAL(cxvar) and IMAG(cxvar)create (bool, default=False)
if True, create new data columns REAL(cxvar) and IMAG(cxvar), if they do not already exist.nocomplain (bool, default=False)
if True, don’t complain if REAL(cxvar) or IMAG(cxvar) data columns are not present and create is False.results:
- return real and imaginary columns for the complex variable cxvar (REAL(cxvar) and IMAG(cxvar).
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read("data.csv") >>> re, im = d.cxreim("s11")
-
cxset
(eqn)¶ parse and evaluate an equation with complex variables.
arguments:
eqn (str)
Equation to evaluate. The equation must include a left-hand-side variable, an equals and a right-hand-side expression.results:
- The equation string eqn is first interpolated to substitute frame variable values into the eqn string.
- Any existing complex variables are interpolated into the right-hand-side expression. For example if REAL(x1) and IMAG(x1) are present in the data array, the reference x1 in the right-hand-side expression is to the complex variable x1.
- the equation is parsed and evaluated using Data.cxset_parsed.
- The left-hand-side variable REAL() and IMAG() components are added to the data array if not already present. If already present, they are replaced with the calculated results.
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read("data.csv") >>> d.names() 'freq REAL(gout) IMAG(gout) REAL(zout) IMAG(zout)' >>> vz = 3.3 >>> d.cxset("z = gout + zout + $vz") >>> d.names() 'freq REAL(gout) IMAG(gout) REAL(zout) IMAG(zout) REAL(z) IMAG(z)'
-
cxset_parsed
(equation)¶ basic column operations on parsed equation (complex).
arguments:
equation (str)
An equation which has been parsed into space-separated tokens. Data.cxset() uses Data.cxset_parsed() after parsing equations into a set of parsed equations.results:
The left-hand-side variable (lhsvar) is the first token.
The equals sign is the second token.
The following tokens are the right-hand side expression
If the right-hand-side expression has 1 token:
- If the rhs is another complex variable, cxvar, set REAL(lhsvar) and IMAG(lhsvar) to REAL(cxvar) and IMAG(cxvar)
- If the rhs is a variable, var, which is already in the data array, set REAL(lhsvar) to var, IMAG(lhsvar) to 0
- If the rhs is a real number, rnum, set REAL(lhsvar) to rnum, IMAG(lhsvar) to 0
If the right-hand-side expression has 2 tokens (unary operation):
- The first token is the unary operation
- The second token is either another complex variable, another variable already in the array, or a real number.
- Set REAL(lhsvar), IMAG(lhsvar) to the unary operation of the right-hand side.
- Supported unary operations are: - sign reciprocal sqrt square abs sin cos tan asin acos atan exp expm1 exp2 log log10 log2 log1p sinh cosh tanh asinh acosh atanh degrees radians deg2rad rad2deg rint fix floor ceil trunc
If the right-hand-side expression has 3 tokens (binary operation):
- The first token is the first operand
- The second token is the binary operation
- The third token is the second operand
- The two operands can be either other complex variables, other variables already in the array, or real numbers.
- Set REAL(lhsvar), IMAG(lhsvar) to the binary operation of the two operands.
- Supported binary operations are: + - * / ^ true_divide floor_divide fmod mod rem hypot max min
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read("data.csv") >>> d.cxset_parsed("z = sqrt gout") >>> d.cxset_parsed("z = zout + z") >>> d.cxset_parsed("z = abs z")
-
static
datafile_format
(file)¶ determine data file format by examining top of file.
arguments:
file
data file to detect formatfile types:
- nutmeg : binary or ascii spice output
- csdf : common simulator data format
- hspice : tr or ac analysis output
- csv : comma-separated values
- ssv : space-separated values
examples:
>>> import decida.Data >>> data_format = decida.Data.Data.datafile_format("data.csv") >>> print data_format 'csv'
>>> from decida.Data import Data >>> data_format = Data.datafile_format("data.csv") >>> print data_format 'csv'
-
delays
(time, sig1, sig2, level=0.0, level2=None, edge='rising', edge2=None)¶
-
delete
(*cols)¶ delete columns if present.
arguments:
cols (tuple)
list of column names or lists of column names.results:
- A list of column names is developed by flattening the cols argument(s).
- For each column name in the column list, if the column is present, delete it from the data array.
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read("data.csv") >>> d.delete("t12", "t13", ("t15", "t18"))
-
dup
()¶ create and copy data to a new Data object.
results:
- Returns a new Data object with the same data.
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read("data.csv") >>> dnew = d.dup()
-
edges
(xcol, ycol, vlow=None, vhigh=None)¶ find edge metrics.
arguments:
xcol (int or str)
time column. If xcol is a string, it refers to the column named xcol.ycol (int or str)
signal column to measure edges. If ycol is a string, it refers to the column named ycol.vlow (float, default=None)
low signal value for calculating edges. If vlow is None, use min(ycol).vhigh (float, default=None)
high signal value for calculating edges. If vhigh is None, use max(ycol).results:
calculate all of the following rise time and fall time metrics:
- rise_time_10_90 : rising edge time 10% to 90%
- rise_time_20_80 : rising edge time 20% to 80%
- rise_time_30_70 : rising edge time 30% to 70%
- rise_time_40_60 : rising edge time 40% to 60%
- fall_time_10_90 : falling edge time 90% to 10%
- fall_time_20_80 : falling edge time 80% to 20%
- fall_time_30_70 : falling edge time 70% to 30%
- fall_time_40_60 : falling edge time 60% to 40%
- rise_slew_10_90 : rising edge slew 10% to 90%
- rise_slew_20_80 : rising edge slew 20% to 80%
- rise_slew_30_70 : rising edge slew 30% to 70%
- rise_slew_40_60 : rising edge slew 40% to 60%
- fall_slew_10_90 : riseing edge slew 90% to 10%
- fall_slew_20_80 : falling edge slew 80% to 20%
- fall_slew_30_70 : falling edge slew 70% to 30%
- fall_slew_40_60 : falling edge slew 60% to 40%
return a new Data object with the edge metrics for each edge.
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read("data.csv") >>> d1 = d.edges("time", "v(z)", vlow=0.0, vhigh=1.2)
-
edit
()¶ make array editable.
notes:
- in some cases the data array comes up read-only
- flag the data array as editable
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read("data.csv") >>> d.edit()
-
eye_time
(time, eyetime, period, offset=0.0)¶ create eye_diagram time column.
arguments:
time (str or int)
time columneyetime (str)
eye_time column to generate or overwriteperiod (float)
eye-diagram periodoffset (float, default=0.0)
eye-diagram time offsetexample:
>>> from decida.Data import Data >>> from decida.XYplotx import XYplotx >>> d = Data() >>> d.read("data.csv") >>> d.eye_time("time", "eye_time", 10e-9, 0.0) >>> XYplotx(command=[d, "eye_time v(dout)"])
-
fft
(zcol, ycol, xcol, window='hamming')¶ fast-fourier transform (FFT).
arguments:
zcol (str)
FFT complex variable name to create.ycol (int or str)
input signal column to transform. If ycol is a string, it refers to the column named ycol.xcol (int or str)
input time column for FFT. If xcol is a string, it refers to the column named xcol.window (str, default=”hamming”)
FFT windowing type. Must be one of: “bartlett”, “blackman”, “hamming”, or “hanning”results:
- xcol and ycol values are linearly interpolated on an equally-spaced set of 2^power values, where 2^power is the next power of 2 greater than the number of rows in the data array.
- the ycol interpolated values are windowed using the specified windowing function.
- frequency and FFT values are created and entered into a new Data object, which is returned.
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read("data.csv") >>> dfft = d.fft("zcol", "v(out)","time", window="hamming")
-
filter
(condition)¶ delete rows if column condition not true.
arguments:
condition (str)
a boolean expression of data columnsresults:
- Remove all data rows where the condition evaluates False.
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read("data.csv") >>> d.filter("time > 10e-9")
-
fourcoeff
(xcol, ycol, nfour=8)¶ fourier coefficients.
arguments:
xcol (int or str)
time column. If xcol is a string, it refers to the column named xcol.ycol (int or str)
signal column. If ycol is a string, it refers to the column named ycol.nfour (int, default=8)
number of harmonics.results:
Return dictionary of :
“report” :
report Fourier expansion in terms of the basis functions sin(n*2*pi*xcol/T) and cos(n*2*pi*xcol/T), where T is the maximum - minimum of the time column (xcol). The report also includes the equivalent Fourier expansion in terms of coeff*sin(2*pi*xcol/T + phase)
“coefficients” :
list of fourier coefficients of cosine and sine basis functions
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read("data.csv") >>> V = d.nfour("time", "v(z)", nfour=8) >>> print V["report"]
-
get
(col)¶ return column vector.
arguments:
col (int or str)
the column in the data array. If col is a string, it refers to the column named colresults:
- Feturn (numpy) vector of values in the data array column.
- If col is not present in the data array, print warning.
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read("data.csv") >>> d.get("gds")
-
get_entry
(row, col)¶ get a data array entry.
arguments:
row (int)
the row in the data arraycol (int or str)
the column in the data array. If col is a string, it refers to the column named colresults:
- Return the value in data array at the specified row and column.
notes:
- get_entry(0, col) returns the first row entry of col
- get_entry(-1, col) returns the last row entry of col
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read("data.csv") >>> temp = d.get_entry(1, "temp")
-
index
(col)¶ find column index of column named col or trial col index = col.
arguments:
col (int or str)
the column in the data array. If col is a string, it refers to the column named colresults:
- return int corresponding to the column index in the data array
- if column name not found, return None
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read("data.csv") >>> itemp = d.index("temp")
-
insert
(col_before, *cols)¶ insert empty columns after col_before.
arguments:
col_before (int or str)
existing column (index or name) to insert column after.cols (tuple)
list of column names or lists of column names.results:
- A list of column names is developed by flattening the cols argument(s).
- If col_before doesn’t exist, return without doing anything.
- For each column name in the column list, if the column isn’t already present, add a new column at the end of the data array.
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read("data.csv") >>> d.insert("gm", "t12", "t13", ("t15", "t18"))
-
is_equally_spaced
(col, threshold=1e-15)¶ examines data column to see if it is equally-spaced.
arguments:
col (int or str)
the column in the data array. If col is a string, it refers to the column named colthreshold (float, default=1e-15)
maximum value that values can be different before considering them as unequally-spaced.results:
- If values are unequally-spaced, return False, else True.
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read("data.csv") >>> d.is_equally_spaced("time")
-
jitter
(time, signal, tmin=None, tmax=None, freq=None, level=None, nbins=21, prefix='jitter', edge='rising', clock=True, prt=True, plot=False)¶ measure jitter metrics of clock waveform.
arguments:
time (int or str)
time column. If time is a string, it refers to the column named time.signal (int or str)
clock signal column. If signal is a string, it refers to the column named signal.tmin (float, default=None)
minimum time to use to calculate jitter metrics. If tmin is not specified, use minimum time in the data array.tmax (float, default=None)
maximum time to use to calculate jitter metrics. If tmax is not specified, use maximum time in the data array.freq (float, default=None)
frequency of the reference clock to compare with the clock signal. If not specified, use the average frequency of the signal.level (float, default=None)
level to use for level crossings of the signal. If not specified, use 0.5*(max(signal) + min(signal))nbins (int, default=21)
number of bins for histogram calculations of the jitter.prefix (str, default=”jitter”)
prefix of files for storing calculated jitter data.edge (str, default=”rising”)
edge of signal to use for level crossings. Must be one of “rising”, “falling” or “both”clock (bool, default=True)
if clock=True, signal is assumed to be a clock signal, and jitter is calculated with respect to the same crossing as the reference clock. If clock=False, signal is assumed to be a data signal, and jitter is calculated with respect to the closest reference clock edge.prt (bool, default=True)
if True, print out report textplot (bool, default=False)
if True, generate a plot of the jitter metrics. (TBD)results:
Calculates absolute jitter, period jitter and cycle-to cycle jitter.
- absolute jitter values are the difference between the signal level crossings and the crossings of the reference clock.
- period jitter values are the difference between adjacent signal jitter values.
- cycle-to-cycle jitter values are the differences between adjacent signal periods.
Returns dictionary of statistics of the different jitter metrics, and jitter analysis report.
- Ja_pp : peak-to-peak of the absolute jitter values
- Jp_pp : peak-to-peak of the period jitter values
- Jc_pp : peak-to-peak of the cycle-to-cycle jitter values
- Ja_rms : RMS of the absolute jitter values
- Jp_rms : RMS of the period jitter values
- Jc_rms : RMS of the cycle-to-cycle jitter values
- report : jitter report
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read("data.csv") >>> d.jitter("time", "vout")
-
linreg
(xcol, ycol)¶ linear regression.
arguments:
xcol (int or str)
x values of data to regress. If xcol is a string, it refers to the column named xcol.ycol (int or str)
y values of data to regress. If ycol is a string, it refers to the column named ycol.results:
- Calculate linear regression of data points x, y.
- Return dictionary of : “report” : regression line equation. “coefficients” : list of y-intercept and slope of the regression line.
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read("data.csv") >>> V = d.linreg("xvalues", "yvalues") >>> yint, slope = V["coefficients"] >>> print = V["report"]
-
low_pass_pars
(frequency, signal, dcph_assumed=None)¶ low-pass response metrics: dcgain, phase_margin, gain_margin, etc.
arguments:
frequency (int or str)
column of frequency values of low-pass signal to characterize. If frequency is a string, it refers to the column named frequency.signal (int or str)
column of (complex) signal of low-pass signal to characterize. If signal is a string, it refers to the column named signal. REAL(signal) and IMAG(signal) must be present in data array.dcph_assumed (float, default=None)
specify phase of signal at DC. If not specified, use value at lowest frequency.results:
- Returns dictionary of low-pass metrics:
- dcmag : DC magnitude of signal
- dcdb : DC magnitude in dB (20*log10(magnitude)) of the signal
- dcph : DC phase of the signal
- f0db : frequency where signal is 0dB (unity gain)
- pm : phase-margin of the signal
- f180deg : frequency where the phase is -180 degrees (if so)
- gm : gain-margin of the signal
- gbw_dec : gain-bandwidth of the signal based on the signal
- value 1 decade below the 0dB frequency.
- f3db : 3dB bandwidth of the signal
- gbw_3db : gain-bandwidth of the signal using the DC gain
- times the 3dB bandwidth
- f1db : 1dB bandwidth of the signal
- gbw_1db : gain-bandwidth of the signal using the DC gain
- times the 1dB bandwidth
- peakdb : the peak of the signal in dB
- fpeak : frequency of the peak of the signal
- rolloff : rolloff of the signal in dB/decade
- g125deg : gain of the signal where the phase is -125 degrees.
- f125deg : frequency where the phase is -125 degrees.
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read("data.csv") >>> LPFpars = d.low_pass_pars("frequency", "V(9)") >>> for par in LPFpars : ... print "%s = %s" % (par, LPFpars[par])
- Returns dictionary of low-pass metrics:
-
lpf
(filter_col, signal, time, fpole)¶ low-pass filter.
arguments:
filter_col (str)
output filter column.signal (int or str)
input signal column. If signal is a string, it refers to the column named signal.time (int or str)
input time column. If time is a string, it refers to the column named time.fpole (float)
the low-pass filter pole.results:
- Calculate low-pass filtered data values.
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read("data.csv") >>> d.lpf("y_filtered", "y", "time", fpole=1e8)
-
max
(col)¶ maximum number in column.
arguments:
col (int or str)
the column in the data array. If col is a string, it refers to the column named colresults:
- return maximum value in column col.
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read("data.csv") >>> vmax = d.max("v(z)")
-
mean
(col)¶ mean of column.
arguments:
col (int or str)
the column in the data array. If col is a string, it refers to the column named colresults:
- return meanvalue in column col.
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read("data.csv") >>> vavg = d.mean("v(z)")
-
measure_duty
(xcol, ycol, level=None)¶ measure duty-cycle of a signal column.
arguments:
xcol (int or str)
time column. If xcol is a string, it refers to the column named xcol.ycol (int or str)
signal column. If ycol is a string, it refers to the column named ycol.level (float, default=None)
signal crossing level to use. If level is None, use 0.5*(max(ycol) + min(ycol))results:
- Returns the duty-cycle of the last few signal crossings.
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read("data.csv") >>> freq = d.measure_duty("time", "v(out)", level=0.4)
-
measure_freq
(xcol, ycol, level=None, edge='rising')¶ measure frequency of a signal column.
arguments:
xcol (int or str)
time column. If xcol is a string, it refers to the column named xcol.ycol (int or str)
signal column. If ycol is a string, it refers to the column named ycol.level (float, default=None)
signal crossing level to use. If level is None, use 0.5*(max(ycol) + min(ycol))edge (str, default=”both”)
signal edge(s) to use to accumulate crossings. values must be in (“rising”, “falling”)results:
- Returns the frequency of the last few signal crossings.
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read("data.csv") >>> freq = d.measure_freq("time", "v(out)", level=0.4)
-
median
(col)¶ median of column.
arguments:
col (int or str)
the column in the data array. If col is a string, it refers to the column named colresults:
- return median value in column col.
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read("data.csv") >>> vmed = d.median("v(z)")
-
min
(col)¶ minimum number in column.
arguments:
col (int or str)
the column in the data array. If col is a string, it refers to the column named colresults:
- return minimum value in column col.
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read("data.csv") >>> vmin = d.min("v(z)")
-
moving_average_filter
(filter_col, signal, navg=21)¶ moving-average filter.
arguments:
filter_col (int or str)
output filtered column. If filter_col is a string, it refers to the column named filter_col.signal (int or str)
input signal column to filter. If signal is a string, it refers to the column named signal.navg (int, default=21)
number of points in the averaging window.results:
- number of points in the averaging window must be odd, so if navg is specified as an even number, the averaging window is increased by 1.
- does not check to see if navg is greater than the number of rows in the data array, or if it is specified as < 1.
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read("data.csv") >>> d.moving_average("in_filter", "in", navg=21)
-
name
(col, name=None)¶ get or set column name.
arguments:
col (int or str)
the column in the data array. If col is a string, it refers to the column named col.name (str, default=None)
the name to assign to column col. If name is None, return the name of column col.results:
- If name is not None, rename column col to name
- If name is None, return the column name of column col
- If column col not found, print warning, return None
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read("data.csv") >>> print "column %d = %s" % (1, d.name(1)) column 1 = freq
-
names
()¶ return list of column names.
results:
- Returns a list of Data column names.
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read("data.csv") >>> print "columns = ", d.names() columns = ['wc', 'freq']
-
ncols
()¶ return the number of columns in the data array.
results:
- Return the number of columns in the data array.
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read("data.csv") >>> print "number of columns = ", d.ncols() number of columns = 2
-
nrows
()¶ return the number of rows in the data array.
results:
- Return the number of rows in the data array.
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read("data.csv") >>> print "number of rows = ", d.nrows() number of rows = 12
-
static
nutmeg_blocks
(datafile)¶ find number of data blocks in a nutmeg format data file.
arguments:
datafile
nutmeg format data file
-
oneport_StoY
(s, y, r0=50.0)¶ one-port S-parameters to Y-parameters.
arguments:
s (int or str)
S-parameter (complex) variable. REAL(s) and IMAG(s), etc. must exist.y (str)
Y-parameter (complex) variable to create (or overwrite, if already existing).r0 (float, default=50)
normal impedance in ohms.results:
- The Y-parameter columns are created (or overwritten).
- y0 = 1/r0 y = y0*(1-s)/(1+s)
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read("spars.col") >>> d.oneport_StoY("S11", "Y11")
-
oneport_StoZ
(s, z, r0=50.0)¶ one-port S-parameters to Z-parameters.
arguments:
s (int or str)
S-parameter (complex) variable. REAL(s) and IMAG(s), etc. must exist.z (str)
Z-parameter (complex) variable to create (or overwrite, if already existing).r0 (float, default=50)
normal impedance in ohms.results:
- The Z-parameter columns are created (or overwritten).
- z = r0*(1+s)/(1-s)
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read("spars.col") >>> d.oneport_StoZ("S11", "Z11")
-
oneport_YtoS
(y, s, r0=50.0)¶ one-port Y-parameters to S-parameters.
arguments:
y (int or str)
Y-parameter (complex) variable. REAL(y) and IMAG(y), etc. must exist.s (str)
S-parameter (complex) variable to create (or overwrite, if already existing).r0 (float, default=50)
normal impedance in ohms.results:
- The S-parameter columns are created (or overwritten).
- y0 = 1/r0 s = (1-y/y0)/(1+y/y0)
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read("spars.col") >>> d.oneport_YtoS("Y11", "S11")
-
oneport_ZtoS
(z, s, r0=50.0)¶ one-port Z-parameters to S-parameters.
arguments:
z (int or str)
Z-parameter (complex) variable. REAL(z) and IMAG(z), etc. must exist.s (str)
S-parameter (complex) variable to create (or overwrite, if already existing).r0 (float, default=50)
normal impedance in ohms.results:
- The S-parameter columns are created (or overwritten).
- s = (z/r0-1)/(z/r0+1)
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read("spars.col") >>> d.oneport_ZtoS("Z11", "S11")
-
osc_time
(time, osctime, trigger, period, level=None, edge='rising')¶ create oscilloscope time column.
arguments:
time (str or int)
time columnosctime (str)
osc_time column to generate or overwritetrigger (str or int)
trigger column.period (float)
time periodlevel (float, default = None)
trigger level. If not specified, level = 0.5*(max(trigger) - min(trigger))edge (str, default=”rising”)
edge of trigger column to use to trigger the osc_time sweep. must be one of “rising”, “falling”, or “both”example:
>>> from decida.Data import Data >>> from decida.XYplotx import XYplotx >>> d = Data() >>> d.read("data.csv") >>> d.osc_time("time", "osc_time", "clock", 10e-9, 0.5, "rising") >>> XYplotx(command=[d, "osc_time v(dout)"])
-
period_time_average
(time, col, trigger=None, level=0, edge='rising', period=0, offset=0)¶ measure time average of a column within each cycle of time.
arguments:
time (int or str)
the column corresponding to time in the data array. If time is a string, it refers to the column named time.col (int or str)
the column corresponding to the signal in the data array to measure time average. If col is a string, it refers to the column named col.trigger (int or str, default=None)
the column corresponding to the signal in the data array to split up time into cycles of time. If trigger is a string, it refers to the column named trigger. If not specified, then the offset and period options are used to split up time into cycles of time.level (float, default=0.0)
the level crossing of the trigger column to use to split up time into cycles of time.edge (str, default=”rising”)
the edge crossing of the trigger column to use to split up time into cycles of time (using Data.crossings). one of (“rising”, “falling”, or “both”).period (float, default=0.0)
if trigger is not specified, the time period for splitting up time into cycles of time.offset (float, default=0.0)
if trigger is not specified, the time offset for splitting up time into cycles of time.results:
- The time axis is split up into cycles of time either by specifying a trigger column or by using period and offset.
- Time averages are computed for each cycle of time.
- A data object is returned with time and time-average columns.
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read("data.csv") >>> tavg = d.period_time_average("time", "ivout", trigger="zout")
-
periods
(xcol, ycol, level=None, interp=False)¶ find period, freq, duty-cycle list.
arguments:
xcol (int or str)
time column. If xcol is a string, it refers to the column named xcol.ycol (int or str)
signal column. If ycol is a string, it refers to the column named ycol.level (float, default=None)
signal crossing level to use. If level is None, use 0.5*(max(ycol) + min(ycol))interp (bool, default=False)
results:
- Returns a Data object with frequency, period and duty_cycle columns. These are calculated at each signal crossing of level.
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read("data.csv") >>> d1 = d.periods("time", "v(out)", level=0.4)
-
quadreg
(xcol, ycol)¶ quadradic regression.
arguments:
xcol (int or str)
x values of data to regress. If xcol is a string, it refers to the column named xcol.ycol (int or str)
y values of data to regress. If ycol is a string, it refers to the column named ycol.results:
- Calculate quadradic regression of data points x, y.
- Return dictionary of : “report” : regression curve equation. “coefficients” : list of coefficients of the regression curve, b0 + b1*x + b2*x^2
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read("data.csv") >>> V = d.quadreg("xvalues", "yvalues") >>> print = V["report"] >>> b0, b1, b2 = V["coefficients"]
-
read
(file=None, block=0, format=None)¶ read data-file in one of the supported data formats.
arguments:
file (string, default=None)
data file to read. If None, use dialog to get file name.block (int, default=0)
the block of data within the data-file to read.format (str, default=None)
the format of the data-file. If format=None, use Data.datafile_format to try to determine the file format. If not None, must be one of: “nutmeg”, “csdf”, “hspice”, “csv”, “ssv”.results:
- If data-file format is specified or can be determined, and file is in that format, reads data from file and sets the data array and column names.
- If data format cannot be determined, returns None.
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read("data.csv")
-
read_csdf
(csdffile=None)¶ read CSDF-format format.
arguments:
csdffile (string, default=None)
data file to read. If None, use dialog to get file name.results:
- Reads data from file and sets the data array and column names.
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read_csdf("data.csdf")
-
read_csv
(csvfile=None, block=0)¶ read comma-separated value file.
arguments:
csvfile (string, default=None)
data file to read. If None, use dialog to get file name.block (int, default=0)
the block of data within the data-file to read.results:
- Reads data from file and sets the data array and column names.
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read_ssv("data.csv")
-
read_hspice
(hspicefile)¶ read HSpice-format file (.tr0, .ac0).
arguments:
hspicefile (string, default=None)
data file to read. If None, use dialog to get file name.results:
- Reads data from file and sets the data array and column names.
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read_hspice("cmf.tr0")
-
read_inline
(*args)¶ read data directly.
arguments:
*args (tuple)
tuple of (name, list or tuple of values) pairs. where name is the column to be appended (or rewritten), and list or tuple of values is the data for the column.results:
- Data is read into the data array.
- All columns must have the same number of data values. If not, fatal error message is generated.
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read_inline("X", (1, 2, 3), "Y", (2, 4, 6))
-
read_inline_ssv
(ssvlines, block=0)¶ read space-separated data string.
arguments:
ssvlines (str)
string in space-separated value format.block (int, default=0)
block of data to read.results:
- Data is read into the data array.
example:
>>> from decida.Data import Data >>> d = Data() >>> ssvdata = """ ... X Y ... 1 2 ... 2 4 ... 3 6 ... """ >>> d.read_inline_ssv(ssvdata)
-
read_nutmeg
(rawfile=None, block=0)¶ read nutmeg-format format (spice rawfile).
arguments:
rawfile (string, default=None)
data file to read. If None, use dialog to get file name.block (int, default=0)
the block of data within the data-file to read.results:
- Reads data from file and sets the data array and column names.
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read_nutmeg("data.raw")
-
read_psf
(psffile=None)¶ read PSF-ASCII file.
arguments:
psffile (str, default=None)
data file to read. If None, use dialog to get file name.results:
- Reads data from file and sets the data array and column names.
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read_psf("mckt.psf")
-
read_sspar
(file=None)¶ read Cadence Spectre S-parameter file.
arguments:
file (string, default=None)
Cadence Spectre S-parameter file. If file is None, get file from dialog.notes:
Currently, Data:read_spectre_spars only supports the (real,imag) format
The : separator in s-parameter names is removed if the ports have one digit. For example, S1:1 is changed to S11.
A description of the Cadence Spectre S-parameter file format is at:
http://www.ece.tufts.edu/~srout01/doc/manuals/spectreuser/chap6.html
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read_sspar("spar.data")
-
read_ssv
(ssvfile=None, block=0)¶ read space-separated value file.
arguments:
ssvfile (string, default=None)
data file to read. If None, use dialog to get file name.block (int, default=0)
the block of data within the data-file to read.results:
- Reads data from file and sets the data array and column names.
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read_ssv("data.ssv")
-
read_touchstone
(file=None)¶ read Touchstone S-parameter file.
arguments:
file (string, default=None)
Touchstone S-parameter file. If file is None, get file from dialog.notes:
- The : separator in s-parameter names is removed if the ports have one digit. For example, S1:1 is changed to S11.
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read_touchstone("spar.s2p")
-
read_utmost
(utmostfile=None, block=0)¶ read utmost file.
arguments:
utmostfile (str, default=None)
data file to read. If None, use dialog to get file name.block (int, default=0)
the block of data within the data-file to read.results:
- Reads data from file and sets the data array and column names.
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read_utmost("nmos.utm")
-
rms
(time, col)¶ measure RMS value of a column.
arguments:
time (int or str)
the column corresponding to time in the data array. If time is a string, it refers to the column named time.col (int or str)
the column corresponding to the signal in the data array to measure RMS value. If col is a string, it refers to the column named col.results:
- The RMS value of col vs time is calculated as the square-root of the integrated squared(col) divided by the time interval.
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read("data.csv") >>> tavg = d.rms("time", "ivout")
-
row_append
(number=1)¶ append empty (0.0) rows.
arguments:
number (int, default=1)
number of rows to append.results:
- Append rows to data array.
- Each data entry is set to 0.0.
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read("data.csv") >>> d.row_append(2)
-
row_append_data
(data1)¶ append data rows from another Data object.
arguments:
data1 (Data)
Another Data object with the same number of columns as this Data object.results:
- Does not ensure that Data column names don’t collide.
- data1 is concatenated to this data object.
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read("data.csv") >>> d1 = Data() >>> d1.read("data1.csv") >>> d.row_append_data(d1)
-
row_get
(row)¶ get row vector.
arguments:
row (int)
The row index.results:
- Return row of values from specified row.
- If row index is out of range, print warning.
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read("data.csv") >>> d.row_get(7)
-
row_set
(row, row_vector)¶ set row vector.
arguments:
row (int)
The row index.row_vector (array-like: list, tuple, or numpy array)
Vector of values to set row entries.results:
- Values in specified row are set to specified vector.
- If row index is out of range, print warning.
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read("data.csv") >>> d.row_set(3, (2.3, 3.3))
-
select
(*cols)¶ delete columns which aren’t selected.
arguments:
cols (tuple)
list of column names or lists of column names.results:
- A list of column names is developed by flattening the cols argument(s). Add to this list complex columns REAL, IMAG, MAG, DB, PH for each selected column (REAL(col), etc.)
- For each column in the data array, if it is not in the column list, delete it from the data array.
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read("data.csv") >>> d.select("time", "V(zout)")
-
set
(eqn)¶ parse and evaluate an equation.
arguments:
eqn (str)
Equation to evaluate. The equation must include a left-hand-side variable, an equals and a right-hand-side expression.results:
- The equation string eqn is first interpolated to substitute frame variable values into the eqn string.
- Any existing variables are interpolated into the right-hand-side expression. For example if x1 is present in the data array, the reference x1 in the right-hand-side expression is to the variable x1.
- the equation is parsed and evaluated using Data.set_parsed.
- The left-hand-side variable is added to the data array if not already present. If already present, it is replaced with the calculated results.
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read("data.csv") >>> d.names() 'freq V(out_p) V(out_n)' >>> vref = 1.5 >>> d.set("out_dm = V(out_p) - V(out_n)") >>> d.set("out_cm = 0.5*(V(out_p) + V(out_n))") >>> d.set("dif_cm = out_cm - $vref")
-
set_entry
(row, col, value)¶ set a data array entry.
arguments:
row (int)
the row in the data arraycol (int or str)
the column in the data array. If col is a string, it refers to the column named colvalue (float)
the value to set the data array entryresults:
- The value in data array at the specified row and column is set to the specified value.
notes:
- set_entry(0, col, val) sets the first row entry of col
- set_entry(-1, col, val) sets the last row entry of col
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read("data.csv") >>> d.set_entry(1, "temp", 45.0)
-
set_parsed
(equation)¶ basic column operations on parsed equation.
arguments:
equation (str)
An equation which has been parsed into space-separated tokens. Data.set() uses Data.set_parsed() after parsing equations into a set of parsed equations.results:
The left-hand-side variable (lhsvar) is the first token.
The equals sign is the second token.
The following tokens are the right-hand side expression.
If the right-hand-side expression has 1 token:
- If the rhs is another variable, rhsvar, which is already present in the data array, set lhsvar to rhsvar.
- If the rhs is a real number, rnum, set lhsvar to rnum.
- If the rhs is one of the following constants, set the lhsvar
to the value of the constant.
- pi : 3.14159 ...
- e0 : 8.854215e-14
- qe : 1.602192e-19
- kb : 1.380622e-23
- kbev : 8.61708e-5
- tabs : 273.15
- If the rhs is “index”, set the lhsvar to the row index (0 to nrows-1).
If the right-hand-side expression has 2 tokens (unary operation):
- The first token is the unary operation.
- The second token is either another variable already in the array, or a real number.
- Set lhsvar to the unary operation of the right-hand side.
- Supported unary operations are: - sign reciprocal sqrt square abs sin cos tan asin acos atan exp expm1 exp2 log log10 log2 log1p sinh cosh tanh asinh acosh atanh degrees radians deg2rad rad2deg rint fix floor ceil trunc
If the right-hand-side expression has 3 tokens (binary operation):
- The first token is the first operand
- The second token is the binary operation
- The third token is the second operand
- The two operands can be either other variables already in the array, or real numbers.
- Set lhsvar to the binary operation of the two operands.
- Supported binary operations are: + - * / ^ true_divide floor_divide fmod mod rem hypot max min
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read("data.csv") >>> d.set_parsed("z = sqrt gout") >>> d.set_parsed("z = zout + z") >>> d.set_parsed("z = abs z")
-
show
()¶ display Data information.
results:
- Display Data size, column names and data.
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read("data.csv") >>> d.show() number of rows: 10 number of cols: 2 column-names: ['wc', 'freq'] data: [[ 11.9 4.017 ] [ 11.92 4.0112] [ 11.95 4.0026] [ 11.96 4.0005] [ 11.961 4.0004] [ 11.962 4.0002] [ 11.965 3.9987] [ 11.968 3.9976] [ 11.97 3.9974] [ 12. 3.9891]]
-
skews
(time, sig1, sig2, level=0.0, level2=None, edge='rising', edge2=None)¶
-
sort
(*cols)¶ sort according to cols.
arguments:
cols (tuple)
list of column names or lists of column names.results:
- Data is re-ordered such that data entries in the specified columns and rows run in ascending numerical order.
- If more than one column is specified, for each set of constant first specified columns, data for the last specified column runs in ascending order.
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read("data.csv") >>> d.show() number of rows: 10 number of cols: 2 column-names: ['wc', 'freq'] data: [[ 11.9 4.017 ] [ 11.92 4.0112] [ 11.95 4.0026] [ 11.96 4.0005] [ 11.961 4.0004] [ 11.962 4.0002] [ 11.965 3.9987] [ 11.968 3.9976] [ 11.97 3.9974] [ 12. 3.9891]] >>> d.sort("freq") >>> d.show() number of rows: 10 number of cols: 2 column-names: ['wc', 'freq'] data: [[ 12. 3.9891] [ 11.97 3.9974] [ 11.968 3.9976] [ 11.965 3.9987] [ 11.962 4.0002] [ 11.961 4.0004] [ 11.96 4.0005] [ 11.95 4.0026] [ 11.92 4.0112] [ 11.9 4.017 ]]
-
std
(col)¶ standard-deviation of column.
arguments:
col (int or str)
the column in the data array. If col is a string, it refers to the column named colresults:
- return standard-deviation in column col.
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read("data.csv") >>> vstd = d.std("v(z)")
-
thd
(xcol, ycol, fund, nharm=8, window='hamming', tstart=None, tstop=None, prt=True)¶ total harmonic distortion analysis.
arguments:
xcol (int or str)
input time column. If xcol is a string, it refers to the column named xcol.ycol (int or str)
input signal column. If ycol is a string, it refers to the column named ycol.nharm (int, default=8)
Number of harmonics.window (str, default=”hamming”)
FFT windowing type. Must be one of: “bartlett”, “blackman”, “hamming”, or “hanning”tstart (float, default=None)
start time for the signal window. If None, use first timepoint.tstop (float, default=None)
stop time for the signal window. If None, use last timepoint.prt (bool, default=True)
if True, print out report textresults:
Calculates total harmonic distortion, and per-harmonic distortion
Returns dictionary of the results and analysis report.
- thd : total harmonic distortion in percent
- vharms : FFT harmonic peak values (normalized to fundamental at 0dB)
- vdists : per-harmonic distorion values in percent
- report : thd report
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read("data.csv") >>> d.thd("time", "vout", fund=1e6, nharm=4)
-
time_average
(time, col)¶ measure time average of a column.
arguments:
time (int or str)
the column corresponding to time in the data array. If time is a string, it refers to the column named time.col (int or str)
the column corresponding to the signal in the data array to measure time average. If col is a string, it refers to the column named col.results:
- The time average of col vs time is calculated as the integrated col divided by the time interval.
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read("data.csv") >>> tavg = d.time_average("time", "ivout")
-
twin
()¶ display data in text-window.
results:
- Display data in a TextWindow object, with columns lined-up.
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read("data.csv") >>> d.twin()
-
twoport_HtoY
(h11, h12, h21, h22, y11, y12, y21, y22)¶ two-port H-parameters to Y-parameters.
arguments:
h11, h12, h21, h22 (int or str)
H-parameter (complex) variables. REAL(h11) and IMAG(h11), etc. must exist.y11, y12, y21, y22 (str)
Y-parameter (complex) variables to create (or overwrite, if already existing).results:
- The Y columns are created (or overwritten).
- on a matrix-element basis: y11 = 1/h11 y12 = -h12/h11 y21 = h21/h11 y22 = (h11*h22 - h12*h21)/h11
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read("spars.col") >>> d.twoport_HtoY("H11", "H12", "H21", "H22", "Y11", "Y12", "Y21", "Y22")
-
twoport_StoY
(s11, s12, s21, s22, y11, y12, y21, y22, r0=50.0)¶ two-port S-parameters to Y-parameters.
arguments:
s11, s12, s21, s22 (int or str)
S-parameter (complex) variables. REAL(s11) and IMAG(s11), etc. must exist.y11, y12, y21, y22 (str)
Y-parameter (complex) variables to create (or overwrite, if already existing).r0 (float, default=50)
normal impedance in ohms.results:
- The Y columns are created (or overwritten).
- on a matrix-element basis: y0 = 1/r0 den = (1 + s11)*(1 + s22) - s12*s21) y11 = y0*((1 - s11)*(1 + s22) + s12*s21))/den y22 = y0*((1 + s11)*(1 - s22) + s12*s21))/den y12 = y0*(-2*s12)/den y21 = y0*(-2*s21)/den
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read("spars.col") >>> d.twoport_StoY("S11", "S12", "S21", "S22", "Y11", "Y12", "Y21", "Y22")
-
twoport_YtoH
(y11, y12, y21, y22, h11, h12, h21, h22)¶ two-port Y-parameters to H-parameters.
arguments:
y11, y12, y21, y22 (int or str)
Y-parameter (complex) variables. REAL(y11) and IMAG(y11), etc. must exist.h11, h12, h21, h22 (str)
H-parameter (complex) variables to create (or overwrite, if already existing).results:
- The H columns are created (or overwritten).
- on a matrix-element basis: h11 = 1/y11 h12 = -y12/y11 h21 = y21/y11 h22 = (y11*y22 - y12*y21)/y11
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read("spars.col") >>> d.twoport_YtoH("Y11", "Y12", "Y21", "Y22", "H11", "H12", "H21", "H22")
-
twoport_YtoS
(y11, y12, y21, y22, s11, s12, s21, s22, r0=50.0)¶ two-port Y-parameters to S-parameters.
arguments:
y11, y12, y21, y22 (int or str)
Y-parameter (complex) variables. REAL(y11) and IMAG(y11), etc. must exist.s11, s12, s21, s22 (str)
S-parameter (complex) variables to create (or overwrite, if already existing).r0 (float, default=50)
normal impedance in ohms.results:
- The S columns are created (or overwritten).
- on a matrix-element basis: yo = 1/r0 y11n = y11/y0 y12n = y12/y0 y21n = y21/y0 y22n = y22/y0 den = (1 + y11n)*(1 + y22n) - y12n*y21n) s11 = (1 - y11n)*(1 + y22n) + y12n*y21n)/den s22 = (1 + y11n)*(1 - y22n) + y12n*y21n)/den s12 = -2*y12n/den s21 = -2*y21n/den
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read("spars.col") >>> d.twoport_YtoS("Y11", "Y12", "Y21", "Y22", "S11", "S12", "S21", "S22")
-
twoport_YtoZ
(y11, y12, y21, y22, z11, z12, z21, z22)¶ two-port Y-parameters to Z-parameters.
arguments:
y11, y12, y21, y22 (int or str)
Y-parameter (complex) variables. REAL(y11) and IMAG(y11), etc. must exist.z11, z12, z21, z22 (str)
Z-parameter (complex) variables to create (or overwrite, if already existing).results:
- The Z columns are created (or overwritten).
- Z = 1/Y (4x4 matrix of complex values)
- on a matrix-element basis: det = y11*y22-y12*y21 z11 = y22/det z12 = -y12/det z21 = -y21/det z22 = y11/det
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read("spars.col") >>> d.twoport_YtoZ("Y11", "Y12", "Y21", "Y22", "Z11", "Z12", "Z21", "Z22")
-
twoport_ZtoY
(z11, z12, z21, z22, y11, y12, y21, y22)¶ two-port Z-parameters to Y-parameters.
arguments:
z11, z12, z21, z22 (int or str)
Z-parameter (complex) variables. REAL(z11) and IMAG(z11), etc. must exist.y11, y12, y21, y22 (str)
Y-parameter (complex) variables to create (or overwrite, if already existing).results:
- The Y columns are created (or overwritten).
- Y = 1/Z (4x4 matrix of complex values)
- on a matrix-element basis: det = z11*z22-z12*z21 y11 = z22/det y12 = -z12/det y21 = -z21/det y22 = z11/det
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read("spars.col") >>> d.twoport_ZtoY("Z11", "Z12", "Z21", "Z22", "Y11", "Y12", "Y21", "Y22")
-
unique
(col)¶ return unique numbers in column.
arguments:
col (int or str)
the column in the data array. If col is a string, it refers to the column named colresults:
- return unique values in column col.
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read("data.csv") >>> values = d.unique("v(z)")
-
unique_name
(prefix='z')¶ come up with a unique column name with the given prefix.
arguments:
prefix (str, default=”z”)
prefix of a trial column name.results:
- Returns a trial column name which isn’t in the list of existing column names.
- First tries prefix as a unique column name. If that column already exists, try prefix + “_” + str(int), where int is incremented until a the trial column name isn’t already present in the data array names. If int is > 10000, give up.
- The trial name is not used yet to create a new data column.
example:
>>> from decida.Data import Data >>> d = Data() >>> new_col = d.unique_name("z") 'z_1'
-
var
(col)¶ variance of column.
arguments:
col (int or str)
the column in the data array. If col is a string, it refers to the column named colresults:
- return variance in column col.
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read("data.csv") >>> vvar = d.var("v(z)")
-
write_csv
(csvfile=None, column_limit=None)¶ write comma-separated value file.
arguments:
csvfile (string, default=None)
comma-separated value format file to write. If None, use dialog to get file name.column_limit (int, default=None)
limit number of output columns to column_limit. If None, there is no limitresults:
- comma-separated value format file is written using data array data and column-names. If column_limit is specified, then only write up to column_limit columns of data.
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read("data.csv") >>> d.write_csv("data1.csv", column_limit=None)
-
write_nutmeg
(rawfile=None, title='nutmeg data', plotname='decida data', first_vars=False)¶ write nutmeg format file.
arguments:
rawfile (string, default=None)
nutmeg format file to write. If None, use dialog to get file name.title (string, default=”nutmeg data”)
data title to place in the nutmeg file.plotname (string, default=”decida data”)
plot name to place in the nutmeg file.first_vars (bool, default=False)
if True, put first variables line on the Variables: mode lineresults:
- nutmeg-format file is written using data array data and column-names. plotname and title fields are filled into the nutmeg header.
- if first_vars is specified, variables are written on the Variables: line in the nutmeg file.
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read("data.csv") >>> d.write_nutmeg("data.raw", first_vars=True)
-
write_pwl
(pwlfile=None, *cols)¶ write piece-wise linear format file.
arguments:
pwlfile (string, default=None)
piece-wise linear format file to write. If None, use dialog to get file name.cols (tuple)
tuple of column names to use to generate the PWL file cols = xcol, ycol1, ycol2, ...results:
- the piece-wise linear file is a list of xcol, ycol values in Spice piece-wise linear format.
- for each ycol, generate a separate piece-wise linear specification.
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read("data.csv") >>> d.write_pwl("data.pwl", "time v(vc) v(vd)")
-
write_ssv
(ssvfile=None)¶ write space-separated value file.
arguments:
ssvfile (string, default=None)
space-separated value format file to write. If None, use dialog to get file name.results:
- space-separated value format file is written using data array data and column-names.
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read("data.csv") >>> d.write_ssv("data1.ssv")
-
write_vcsv
(vcsvfile=None, xcol=None)¶ write Cadence VCSV-format file.
arguments:
vcsvfile (string, default=None)
VCSV-format file to write. If None, use dialog to get file name.xcol (string, default=None)
data-column to use for each signal’s x data. If None, use first data-column.results:
- VCSV-format file is written using data array data and column-names.
example:
>>> from decida.Data import Data >>> d = Data() >>> d.read("data.csv") >>> d.write_vcsv("data1.ssv", xcol="time")