def _smithchart_recalc(self, new=False):
     for sset in self.__ssets:
         dname = self.__sset_dname[sset]
         fcol = self.__sset_fdcol[sset]
         rcol = self.__sset_rdcol[sset]
         icol = self.__sset_idcol[sset]
         fdata = self.__sset_fdata[sset]
         rdata = self.__sset_rdata[sset]
         idata = self.__sset_idata[sset]
         dsmith = Data()
         dsmith.read_inline(fcol, fdata, rcol, rdata, icol, idata)
         # if input data is admittance or impedance, convert to s-parameter
         if new:
             self.add_curve(dsmith, rcol, icol, dname=dname)
         else:
             curve = "%s_:_%s_%s_vs_%s" % (dname, rcol, icol, fcol)
             self._curve_xdata[curve] = dsmith.get(rcol)
             self._curve_ydata[curve] = dsmith.get(icol)
#! /usr/bin/env python
import decida
import decida.test
from decida.Data import Data
from decida.XYplotm import XYplotm
from decida.FrameNotebook import FrameNotebook

test_dir = decida.test.test_dir()

fn = FrameNotebook()
d = Data(verbose=False)

d.read_hspice(test_dir + "data/hspice/binary/tr.tr0")
XYplotm(fn.new_page("bin_tr"), command=[d, "TIME v(1) v(2)"])

d.read_hspice(test_dir + "data/hspice/binary/tr2.tr0")
XYplotm(fn.new_page("bin_tr2"), command=[d, "TIME v(1) v(2) v(3) v(4) v(5)"])

d.read_hspice(test_dir + "data/hspice/binary/ac.ac0")
XYplotm(fn.new_page("bin_ac"), command=[d, "HERTZ DB(v(2))"], xaxis="log")

d.read_hspice(test_dir + "data/hspice/ascii/tr.tr0")
XYplotm(fn.new_page("asc_tr"), command=[d, "TIME v(1) v(2)"])

d.read_hspice(test_dir + "data/hspice/ascii/tr2.tr0")
XYplotm(fn.new_page("asc_tr2"), command=[d, "TIME v(1) v(2) v(3) v(4) v(5)"])

d.read_hspice(test_dir + "data/hspice/ascii/ac.ac0")
XYplotm(fn.new_page("asc_ac"), command=[d, "HERTZ DB(v(2))"], xaxis="log")

fn.wait()
#!/usr/bin/env python
import math
import decida
from decida.Data import Data
from decida.XYplotm import XYplotm

d = Data()
npts, xmin, xmax = 10000, 0, 10
x_data = decida.range_sample(xmin, xmax, num=npts)
y_data = []
for x in x_data:
    y_data.append(math.sin(x * 10))
d.read_inline("X", x_data, "Y", y_data)
XYplotm(command=[d, "X Y"])
Example #4
0
#!/usr/bin/env python
from __future__ import print_function
import decida
import decida.test
from decida.Data import Data

test_dir = decida.test.test_dir()
d = Data()
d.read(test_dir + "data/data.csv")
d.show()

d.sort("freq")
d.show()

d1 = d.dup()

f3 = d.get_entry(3, "freq")
print("freq(3) = ", f3)
d.set_entry(3, "freq", f3 * 3)
d.show()

col = d1.unique_name("M")
d1.append(col)
d1.set("$col = wc")
print(col, "index = ", d1.index(col))
d1.show()

d1.insert(col, "wc2", "wc3")
d1.name(col, "wc1")
d1.set("point = index")
d1.show()
Example #5
0
def tr(detail="simulate"):
    global tckt
    test = tckt.get_test()
    modelfile = tckt.get_modelfile()
    tckt["circuit"] = "crrc"
    tckt["netlistfile"] = "data/crrc.sp"
    #--------------------------------------------------------------------------
    # signals to monitor
    #--------------------------------------------------------------------------
    tckt.monitor("""
        qp cm 0 ip n p in qn
    """)
    #--------------------------------------------------------------------------
    # loop through experiments
    #--------------------------------------------------------------------------
    poststart = True
    cases = ['tt', 'ss', 'ff', 'fs', 'sf']
    if True:
        cases = ["tt"]
    for case in cases:
        tckt["case"] = case
        ckey = tckt.get_case_key()
        process = tckt.get_process()
        vdd = tckt.get_vdd()
        temp = tckt.get_temp()
        prefix  = "%s.%s.%s" % \
            (test, tckt["circuit"], case)
        print(prefix)
        tckt["title"] = prefix
        tckt["prefix"] = prefix
        tstop = 500e-12
        tstep = 1e-12
        tckt.elements("""
            vp netlist
            vn netlist
        """)
        tckt.control("""
            .options rawpts=150 nomod brief=1 probe
            .options itl1=50000 itl2=50000 gmin=0 dcpath=0
            .options conv=-1 accurate=1 gmin=0 dcpath=0
            .prot
            .lib '$modelfile' $process
            .unprot
            .temp $temp
            .tran $tstep $tstop
            .parameter fosc=14G res=50 cap=220f
        """)
        if detail == "simulate":
            if False and tckt.is_already_done():
                continue
            tckt.generate_inputfile()
            tckt.simulate(clean=False)
        elif detail == "view":
            if poststart:
                poststart = False
            if tckt.no_data():
                continue
            d = Data()
            d.read_nutmeg(tckt.get_datafile())
            xy = XYplotm(command=[d, "time v(ip) v(qn) v(in) v(qp)"])
        elif detail == "report":
            if poststart:
                poststart = False
                point = 0
                rpt = Report(test + ".report", verbose=True, csv=True)
                header = "point case temp vdd"
                rpt.header(header)
            if tckt.no_data():
                continue
            d = Data()
            d.read_nutmeg(tckt.get_datafile())
            rpt.report(point, ckey, temp, vdd)
            point += 1
            del d
        else:
            print("detail " + detail + " not supported")
Example #6
0
 def __sample(self):
     plot_type = self.__Component["plot_type_var"].get()
     sample_type = self.__Component["sample_type_var"].get()
     key = "%s_entry" % (self.__swept_col)
     sweep = self.__Component[key].get()
     npts = int(self.__Component["npts_entry"].get())
     xmin = float(self.__Component["min_entry"].get())
     xmax = float(self.__Component["max_entry"].get())
     mode = sample_type[0:3]
     values = decida.range_sample(xmin, xmax, num=npts, mode=mode)
     #-------------------------------
     # get and preprocess equations
     #-------------------------------
     tobj = self.__Component["text"]
     eqns = tobj.get(1.0, "end")
     eqns = str(eqns)
     #-------------------------------
     # split on newline and semicolon
     #-------------------------------
     eqnlines = eqns.split("\n")
     newlines = []
     for eqnline in eqnlines:
         sublines = eqnline.split(";")
         for subline in sublines:
             newlines.append(subline)
     eqnlines = newlines
     #-----------------------------------
     # eliminate comments and blank lines
     #-----------------------------------
     eqnlist = []
     for eqnline in eqnlines:
         eqnline = re.sub("#.*$", "", eqnline)
         eqnline = eqnline.strip()
         if eqnline:
             eqnlist.append(eqnline)
     #--------------------------------------
     # start with new data object, sample x
     #--------------------------------------
     if self.__data_obj is not None:
         del self.__data_obj
     self.__data_obj = Data()
     self.__data_obj.read_inline(sweep, values)
     #--------------------------------------
     # evaluate equations
     #--------------------------------------
     for eqn in eqnlist:
         self.__data_obj.set(eqn)
     #--------------------------------------
     # polar to cartesian
     #--------------------------------------
     angle = "radians"
     if angle == "degrees":
         cvt = math.pi / 180.0
     else:
         cvt = 1.0
     if plot_type in ["polar", "polar-parametric"]:
         xcol = self.__Component["xcol_entry"].get()
         ycol = self.__Component["ycol_entry"].get()
         acol = self.__Component["acol_entry"].get()
         rcol = self.__Component["rcol_entry"].get()
         self.__data_obj.set("%s=%s*cos(%s*%s)" % (xcol, rcol, acol, cvt))
         self.__data_obj.set("%s=%s*sin(%s*%s)" % (ycol, rcol, acol, cvt))
    dataobj.set("Cc = (floor(vc/4.0)+fmod(vc,4)*0.25)*$Cu")
    dataobj.set("Cf = $a2 - $b2*vf + $c2*vf^2")
    dataobj.set("Ct = $Co + Cc + Cf")
    dataobj.set("fhat = 1.0/(2*pi*sqrt($L*Ct))")
    dataobj.set("residual = fhat - freq")


parobj = Parameters(specs=(
    ("L", 2400e-12, False, True, False, 0.0, 0.0),
    ("Co", 250e-15, True, True, False, 0.0, 0.0),
    ("Cu", 60e-15, True, True, False, 0.0, 0.0),
    ("C1", 23e-15, True, True, False, 0.0, 0.0),
    ("C2", 27e-15, True, True, False, 0.0, 0.0),
))

dataobj = Data()
dataobj.read(test_dir + "data/lcdata.col")

optobj = LevMar(lcfunc,
                parobj,
                dataobj,
                meast_col="freq",
                model_col="fhat",
                error_col="residual",
                quiet=False,
                debug=False)
optobj.fit()
print(optobj.status())
print("parameters = ", list(parobj.values()))

XYplotm(command=[dataobj, "vf freq fhat"])