<jupyter_start><jupyter_text>Unit Waveforms  Libraries<jupyter_code>import matplotlib.pyplot as plt
import numpy as np<jupyter_output><empty_output><jupyter_text>Classes<jupyter_code>class Three_state:
    
    def __init__(self,t1,t2,t3=0):
      
        self.t1,self.t2,self.t3 = t1,t2,t3
        self.Ts = self.t1+self.t2+self.t3
    
    def step(self,t):
        if t<0:
            kd=0.0
        elif t==0:
            kd=0.0
        else:
            kd=1.0
        return kd
            
    def t1_unit_pulse(self,t):
        if t<0:
            k=1.0
        else:
            k=self.step(self.t1-t)
        return k
      
    def t3_unit_pulse(self,t):
        return self.step(t-self.t1-self.t2)
      
    def t2_unit_pulse(self,t):
        return 1-self.t1_unit_pulse(t)-self.t3_unit_pulse(t)
    
    
    def repeating(self,t):
        period=self.Ts
        return t-(t//period)*period<jupyter_output><empty_output><jupyter_text>Input parameters<jupyter_code>Vin = 12
Vout = 6
fs = 0.5e6

duty = Vout/Vin
Ts = 1/fs
t1=duty*Ts
t2=(1-duty)*Ts

numdatapoints=1000  
numcycles = 10
tstep = np.round(numcycles*Ts/numdatapoints,10)<jupyter_output><empty_output><jupyter_text>Create single pulse sequence<jupyter_code>tarray=np.arange(0,Ts,tstep, dtype=float)
tarray_nperiod=np.arange(0,numcycles*Ts,tstep, dtype=float)


singlecycleobject=Three_state(t1=t1,t2=t2)
t1singlecycle=np.vectorize(singlecycleobject.t1_unit_pulse)
t2singlecycle=np.vectorize(singlecycleobject.t2_unit_pulse)




f = plt.figure(figsize=(10,3))
ax = f.add_subplot(121)
ax2 = f.add_subplot(122)
ax.plot(tarray*1e6,t1singlecycle(tarray), 'b')
ax2.plot(tarray*1e6,t2singlecycle(tarray), 'r')<jupyter_output><empty_output><jupyter_text>Create multi pulse sequence<jupyter_code>t1multicycle=t1singlecycle(singlecycleobject.repeating(tarray_nperiod))
t2multicycle=t2singlecycle(singlecycleobject.repeating(tarray_nperiod))<jupyter_output><empty_output><jupyter_text>Results<jupyter_code>f = plt.figure(figsize=(10,3))
ax = f.add_subplot(121)
ax2 = f.add_subplot(122)
ax.plot(tarray_nperiod*1e6,t1multicycle, 'b')
ax2.plot(tarray_nperiod*1e6,t2multicycle, 'r')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12759097190234914, 'fraction_numerical': 0.045601105481345, 'mean_word_length': 4.171428571428572, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '113909', 'license': 'MIT', 'n_tokens_mistral': 964, 'n_tokens_neox': 916, 'n_words': 100, 'path': 'unit_waveforms.ipynb', 'repo_name': 'grkidwell/time_based_waveforms', 'size': '2171'}