示例#1
0
    def __sample_plot(self, new=True):
        self.__sample()
        xcol = self.__Component["xcol_entry"].get()
        ycol = self.__Component["ycol_entry"].get()
        if not xcol in self.__data_obj.names():
            self.warning("data object does not have (x) column %s" % (xcol))
            return
        if not ycol in self.__data_obj.names():
            self.warning("data object does not have (y) column %s" % (ycol))
            return

        if new or self.__dataview is None:
            if self.__dataview is not None:
                # del should have destroyed it
                self.__dataview.destroy()
                del self.__dataview
            fplt = self.__Component["plot_frame"]
            fplt.pack_forget()
            # dataview command partially implemented
            if True:
                self.__dataview = DataViewm(
                    fplt,
                    use_matplotlib=self.__use_matplotlib,
                    data=self.__data_obj,
                    command=[
                        [
                            "%s %s" % (xcol, ycol),
                            "traces=[\"both\"], legend=False"
                        ],
                    ],
                    plot_height=self["plot_height"])
            else:
                self.__dataview = XYplotm(
                    fplt,
                    use_matplotlib=self.__use_matplotlib,
                    command=[self.__data_obj,
                             "%s %s" % (xcol, ycol)],
                    traces=["both"],
                    legend=False)
            fplt.pack(side="top", expand=True, fill="both", padx=2, pady=2)
            self.update()
        else:
            if True:
                xyplot = self.__dataview.current_plot()
            else:
                xyplot = self.__dataview
            curve = "data_%d_:_%s_vs_%s" % (1, ycol, xcol)
            xyplot.delete_curve(curve)
            xyplot.add_curve(self.__data_obj,
                             xcol,
                             ycol,
                             start=True,
                             autoscale_x=True,
                             autoscale_y=True,
                             strict=False)
#! /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"])
#!/usr/bin/env python
import decida
import decida.test
from decida.Data import Data
from decida.XYplotm import XYplotm

test_dir = decida.test.test_dir()
d = Data()
d.read(test_dir + "data/sspice/binary/tr.raw")
d.show()
xyplot = XYplotm(None, command=[d, "time v(cint) v(osc) v(q_2)"])
#!/usr/bin/env python
import decida
import decida.test
from decida.Data import Data
from decida.XYplotm import XYplotm

test_dir = decida.test.test_dir()
d = Data()
d.read(test_dir + "data/LTspice/ascii/ac.raw")
XYplotm(None,
        command=[d, "frequency DB(V(vout1))"],
        title="AC analysis",
        xaxis="log",
        ymin=-60.0,
        ymax=0.0)
示例#6
0
#! /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(tab_location="right")
d = Data()

d.read_nutmeg(test_dir + "data/sspice/binary/tr.raw")
XYplotm(fn.new_page("(mat)bin_tr"),
        command=[d, "time v(cint)"],
        title="TR analysis",
        ymin=0,
        ymax=3)
XYplotm(fn.new_page("(xmat)bin_tr"),
        command=[d, "time v(cint)"],
        title="TR analysis",
        ymin=0,
        ymax=3,
        use_matplotlib=False)

d.read_nutmeg(test_dir + "data/sspice/ascii/dc.raw")
d.set("i(vd) = -i(vd)")
XYplotm(fn.new_page("(mat)asc_dc"),
        command=[d, "v(d) i(vd)"],
        title="DC analysis",
        ymin=0,
示例#7
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")
f2 = fn.new_page("Page_2")
b2 = tk.Button(f2, text="Destroy Page 1", command=lambda: f1.destroy())
b3 = tk.Button(f2, text="Beep", command=lambda: tk._default_root.bell())
b2.pack()
b3.pack()

tw = TextWindow(fn.new_page("text"))

test_dir = decida.test.test_dir()
d = Data()
d.read(test_dir + "data/LTspice/ascii/ac.raw")
XYplotm(fn.new_page("plot"),
        command=[d, "frequency DB(V(vout1)) PH(V(vout1))"],
        title="AC analysis",
        xaxis="log",
        ymin=-60.0,
        ymax=0.0,
        wait=False)

fn.status("waiting to add new page")
fn.wait("CONTINUE 1")
fn.status("")

tw = TextWindow(fn.new_page("text 1"))

fn.status("waiting to delete 1 page")
fn.wait("CONTINUE 2a")
fn.status("")
fn.del_page()
示例#9
0
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(tab_location="right")
d = Data()

d.read_nutmeg(test_dir + "data/NGspice/binary/tr.raw")
d.edit()
XYplotm(fn.new_page("(mat)bin_tr"),
        command=[d, "time v(c) v(x) v(z)"],
        title="TR analysis",
        ymin=-10,
        ymax=20)
XYplotm(fn.new_page("(xmat)bin_tr"),
        command=[d, "time v(c) v(x) v(z)"],
        title="TR analysis",
        ymin=-10,
        ymax=20,
        use_matplotlib=False)

d.read_nutmeg(test_dir + "data/NGspice/binary/dc.raw")
d.edit()
d.set("i(vd) = -i(vd)")
XYplotm(fn.new_page("(mat)asc_dc"),
        command=[d, "v(d) i(vd)"],
        title="DC analysis",
示例#10
0
d.twoport_HtoY("Hdd11", "Hdd12", "Hdd21", "Hdd22", "Yx11", "Yx12", "Yx21",
               "Yx22")
d.twoport_ZtoY("Zdd11", "Zdd12", "Zdd21", "Zdd22", "Y11", "Y12", "Y21", "Y22")
d.twoport_YtoS("Y11", "Y12", "Y21", "Y22", "S11", "S12", "S21", "S22")

cmd1 = []
cmd2 = []
for par in (
    ("Ydd11", "Yx11"),
    ("Ydd12", "Yx12"),
    ("Ydd21", "Yx21"),
    ("Ydd22", "Yx22"),
    ("Ydd11", "Y11"),
    ("Ydd12", "Y12"),
    ("Ydd21", "Y21"),
    ("Ydd22", "Y22"),
    ("Sdd11", "S11"),
    ("Sdd12", "S12"),
    ("Sdd21", "S21"),
    ("Sdd22", "S22"),
):
    p1, p2 = par
    for ri in ("REAL", "IMAG"):
        col = "ERROR_%s(%s)" % (ri, p1)
        d.set("$col = $ri($p1) - $ri($p2)")
        cmd1.extend([d, "freq %s" % (col)])
        cmd2.extend([d, "freq %s(%s) %s(%s)" % (ri, p1, ri, p2)])

XYplotm(command=cmd1, xaxis="log", wait=False)
XYplotm(command=cmd2, xaxis="log")
#!/usr/bin/env python
import decida
import decida.test
from decida.Data import Data
from decida.XYplotm import XYplotm

test_dir = decida.test.test_dir()
d = Data()
d.read(test_dir + "data/sspice/ascii/dc.raw")
XYplotm(None, command=[d, "v(d) i(vd)"])
#! /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_nutmeg(test_dir + "data/LTspice/binary/ac.raw")
XYplotm(fn.new_page("bin_ac"),
        command=[d, "frequency DB(V(vout1)) PH(V(vout1))"],
        title="AC analysis",
        xaxis="log",
        ymin=-60.0,
        ymax=0.0)

d.read_nutmeg(test_dir + "data/LTspice/ascii/ac.raw")
XYplotm(fn.new_page("asc_ac"),
        command=[d, "frequency DB(V(vout1)) PH(V(vout1))"],
        title="AC analysis",
        xaxis="log",
        ymin=-60.0,
        ymax=0.0)

fn.wait()
示例#13
0
    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"])