FIXED: IPython version detection with alphabetical characters inside
[oscopy.git] / test / demo.oscopy
blob1e0823c008319eee70081a9d555ea522f76a71d6
1 import os
2 # First read data from IRF540 simulation
3 oread demo/irf540.dat
4 oadd vgs
5 ocreate
6 oadd iRD
7 oadd vgs
8 oadd vgs
9 oadd vds
10 # Fig 2 layout to quad
11 olayout quad
12 # Oops, forgot a signal in figure 2 graph 3
13 oselect 2-3
14 oinsert vds
15 # Plot filter response
16 oread demo/ac.dat
17 ocreate
18 oadd vout
19 oscale loglog
20 # Plot square signal, its FFT and a math signal
21 oread demo/tran.dat
22 ocreate
23 oadd vsqu
24 vsqufft=fft(vsqu)
25 oimport vsqufft
26 oadd vsqufft
27 orange 0 15 -.002 .010
28 ounit V
29 v1=vsqu*3+10
30 oimport v1
31 oadd v1
32 ounit V
33 # Insert and remove a signal
34 oselect 4-1
35 oinsert v1
36 oremove v1
37 # Create from reference signal. Note with Signal unit can be defined
38 vs=sin(vsqu.ref*1e6)
39 vs.ref = vsqu.ref
40 vs2=Signal(sin(vsqu.ref*1e6), 'V')
41 vs2.ref = vsqu.ref
42 oimport vs
43 oimport vs2
44 ocreate vs
45 ounit V
46 print '***'
47 print "*** List of figures"
48 print '***'
49 ofiglist
50 # Create a copy of vout and freeze it
51 vo=vout
52 oimport vo
53 ofreeze vo
54 oselect 3-1
55 oinsert vo
56 osiglist
57 # Updating
58 print '***'
59 print '*** Now we will show the updating capabilties of ioscopy.'
60 print '*** We will use Figure 3 that has currently two identical signals'
61 print '*** \'vout\' and \'vo\' where \'vo\' is a frozen copy of vout.'
62 print '*** vout is the response of a simple RC lowpass filter.'
63 print '***'
64 print '*** We will change a value in the schematics and then run simulation'
65 print '*** tools. Make sure you have gschem, gnetlist and gnucap installed'
66 print '***'
67 print '*** Before updating simulation results we will run gschem.'
68 print '*** In the schematics, change value of capacitor \'C\' eg from 10n to 1n.'
69 print '*** Close gschem when finished to continue'
70 cmd = 'gschem demo/demo.sch'
71 c = raw_input('Command: %s [Y/n/c] ' % cmd)
72 if not c: c = 'y'
73 if c in ['e','E']: cmd = raw_input('Enter command to execute: ')
74 if c in ['e', 'E', 'y', 'Y']: os.system(cmd)
75 #pause...
76 print '***'
77 print '*** Now we will run gnetlist'
78 print '*** press enter or \'y\' to continue, \'n\' to skip, \'e\' to change'
79 print '***'
80 cmd = 'cd demo && gnetlist -g spice-sdb -s -o demo.net demo.sch'
81 c = raw_input('Command: %s [Y/n/c] ' % cmd)
82 if not c: c = 'y'
83 if c in ['e','E']: cmd = raw_input('Enter command to execute: ')
84 if c in ['e', 'E', 'y', 'Y']: os.system(cmd)
85 print '***'
86 print '*** Now we will run gnucap'
87 print '*** press enter or \'y\' to continue, \'n\' to skip, \'e\' to change'
88 print '***'
89 cmd = 'cd demo && gnucap -b demo.net'
90 c = raw_input('Command: %s [Y/n/c] ' % cmd)
91 if not c: c = 'y'
92 if c in ['e','E']: cmd = raw_input('Enter command to execute: ')
93 if c in ['e', 'E', 'y', 'Y']: os.system(cmd)
94 print '***'
95 print "*** Unless there are errors simulation is complete we can update ioscopy"
96 print '***'
97 oupdate
98 print '***'
99 print "*** Now you should look at figure 3"
100 print '***'
102 # Saving results
103 owrite gnucap (ow:1) demo/res.dat v1,vsqu