Ejemplo n.º 1
0
class CurvePlotter(object):
    """
    I do the plotting.
    """
    N = 100
    width = 1400
    height = 1400

    Vgs = [0.0, 10.0]

    def __init__(self):
        """
        Constructs a Yampex Plotter object for a figure with two subplots.
        """
        self.mList = []
        # Small MOSFET in an IC
        self.mList.append(MOSFET(2.5e-9, 5e17))
        # High-current Power MOSFET
        self.mList.append(MOSFET(4e-9, 2.7e19))
        # Plotter
        self.N_sp = len(self.mList)
        self.pt = Plotter(self.N_sp, width=self.width, height=self.height)
        self.pt.use_grid()
        self.pt.set_xlabel("Vgst")
        self.pt.set_ylabel("Vdsp")
        self.pt.add_legend("Vgst/n")
        self.pt.add_legend("(Vgst-f(x))/n")
        self.pt.use_labels()

    def Vdsp_1(self, m, Vgs):
        Vgst = Vgs - m.VT
        return Vgst / m.n(Vgs)

    def Vdsp_2(self, m, Vgs, x=0.1):
        Vgst = Vgs - m.VT
        n = m.n(Vgs)
        Pt = m.Pt
        second = 2 * n * Pt * np.log((1 + np.exp(Vgst /
                                                 (2 * n * Pt)))**np.sqrt(x) -
                                     1)
        return (Vgst - second) / n

    def plot(self):
        """
        """
        with self.pt as sp:
            for m in self.mList:
                sp.set_title("Vdsp vs Vgst, computed both ways, for {}", m)
                Vgs = np.linspace(self.Vgs[0], self.Vgs[1], 100)
                #sp(Vgs, self.Vdsp_1(m, Vgs), self.Vdsp_2(m, Vgs))
                sp(Vgs, self.Vdsp_2(m, Vgs))
        self.pt.show()
Ejemplo n.º 2
0
Illustrates the use of L{options.OptsBase.use_timex} and calls to a
subplot-context instance of L{plot.Plotter} with multiple y-axis
arguments. Also shows a couple of intelligently-positioned
annotations.
"""

import numpy as np
from yampex import Plotter

EQs = ("sin(10*t)*cos(10000*t)", "cos(10*t)*cos(10000*t)")

N = 6
t = np.linspace(0, 2E-6, 1000)
# This time, we specify the plot dimensions in pixels with a tuple
pt = Plotter(N, figSize=(1600, 1200))
pt.set_title("With {:d} time scales: {}, {}", N, *EQs)
pt.use_timex()
pt.use_grid()
for eq in EQs:
    pt.add_legend(eq)
with pt as sp:
    for mult in range(N):
        X = t * 10**mult
        Y1 = np.sin(10 * X) * np.sin(10000 * X)
        Y2 = np.cos(10 * X) * np.cos(10000 * X)
        sp.set_title("0 - {:.5g} seconds", X[-1])
        if mult < 5 and np.any(Y2 < 0):
            sp.add_annotation(0.0, "Zero Crossing", kVector=1, y=True)
        sp(X, Y1, Y2)
pt.show()