chiark / gitweb /
@@ -1,6 +1,7 @@
authorianmdlvl <ianmdlvl>
Thu, 25 Mar 2004 00:29:59 +0000 (00:29 +0000)
committerianmdlvl <ianmdlvl>
Thu, 25 Mar 2004 00:29:59 +0000 (00:29 +0000)
 chiark-utils (4.0.99.0.6) unstable; urgency=low

-  * gnucap2gnuplot split with new genspic intermediate format.
+  * ngspice2genspic script
+  * gnucap2gnuplot split with new genspic int
   * gnucap2gnuplot script.

  --

debian/changelog
scripts/Makefile
scripts/genspic2gnuplot
scripts/gnucap2genspic
scripts/ngspice2genspic [new file with mode: 0755]

index 5ff5150591d0ef726ef8b315a8840e5fb6fb7a08..dad9df68e958ba195d604ea3011a1e5ccd30056d 100644 (file)
@@ -1,6 +1,7 @@
 chiark-utils (4.0.99.0.6) unstable; urgency=low
 
-  * gnucap2gnuplot split with new genspic intermediate format.
+  * ngspice2genspic script
+  * gnucap2gnuplot split with new genspic int
   * gnucap2gnuplot script.
 
  --
index 9a465f0b7c89f875cd3cac9b7eab37e655ae8fd7..514a050ceffc2cf9ae34e6a2f6d7689be87dab5d 100644 (file)
@@ -21,7 +21,8 @@
 
 include ../settings.make
 
-SCRIPTS=       palm-datebook-reminders gnucap2genspic genspic2gnuplot
+SCRIPTS=       palm-datebook-reminders \
+               genspic2gnuplot gnucap2genspic ngspice2genspic
 MANPAGES1=     palm-datebook-reminders
 
 CSCRIPTS=      named-conf
index 86df13e4ae71da7aa3919a5b0cfcac684b659f9d..1cb0fff5e5657d7b1dad97f2bfe68ae5a6987f81 100755 (executable)
@@ -54,7 +54,8 @@ for (;;) {
     ($c,@s)= split /\s+/, <STDIN>;
 print STDERR ">$c< >@s<\n";
     if ($c eq 'S') {
-       ($cplot,$logy2,@columns) = @s;
+       ($cplot,$logxy,@columns) = @s;
+       $cplot .= $counter{$cplot}++;
        unshift @columns, 'x:';
        @mmm= map { s/^(\w+)\:// or die; $1; } @columns;
        open S, "> $ofb,$cplot.gnuplot-cmd" or die $!;
@@ -63,7 +64,7 @@ set data style linespoints
 set title '$cplot'
 END
         or die $!;
-       print S "set logscale xy\n" or die $! if $logy2;
+       print S "set logscale xy\n" or die $! if $logxy;
        print S "set y2tics autofreq\n" or die $! if grep { $_ eq 'y2' } @mmm;
        undef %min;
        undef %max;
@@ -125,4 +126,4 @@ close A or die $!;
 
 print ": generated ; $sof\n" or die $!;
 
-# $Id: genspic2gnuplot,v 1.1 2004-03-24 23:53:41 ianmdlvl Exp $
+# $Id: genspic2gnuplot,v 1.2 2004-03-25 00:29:59 ianmdlvl Exp $
index d7eed1ed9eb9744e1565fee3d3b588a190efd0c0..60722d606965746a6f949adb5341b00cb1cc3857 100755 (executable)
@@ -44,18 +44,18 @@ die if @ARGV;
               T 1e12);
 
 sub startplot () {
-    $logy2= 0;
+    $logxy= 0;
     for ($yn=1; $yn<=$#columns; $yn++) {
        $mmm[$yn]= 'y';
     }
     if ($kind eq 'Freq') {
-       $logy2= 1;
+       $logxy= 1;
        for ($yn=1; $yn<=$#columns; $yn++) {
            die unless $columns[$yn] =~ m/.*([MP])\(\d+\)$/i;
            $mmm[$yn]= 'y2' if uc $1 eq 'P';
        }
     }
-    printf "S %s %d", $cplot, $logy2 or die $!;
+    printf "S %s %d", $cplot, $logxy or die $!;
     for ($yn=1; $yn<=$#columns; $yn++) {
        printf " %s:%s", $mmm[$yn], $columns[$yn] or die $!;
     }
@@ -84,7 +84,7 @@ for (;;) {
        endplot();
        $kind= $1;
        @columns= split /\s+/;
-       $cplot= $kind.($counter{$kind}++);
+       $cplot= $kind;
        startplot();
        next;
     } elsif (!defined $kind) {
@@ -106,4 +106,4 @@ die "no plots" unless defined $kind;
 endplot();
 print "F\n" or die $!;
 
-# $Id: gnucap2genspic,v 1.1 2004-03-24 23:53:41 ianmdlvl Exp $
+# $Id: gnucap2genspic,v 1.2 2004-03-25 00:29:59 ianmdlvl Exp $
diff --git a/scripts/ngspice2genspic b/scripts/ngspice2genspic
new file mode 100755 (executable)
index 0000000..284235a
--- /dev/null
@@ -0,0 +1,95 @@
+#!/usr/bin/perl
+#   ngspice2genspic - Copyright 2004 Ian Jackson - see below
+#
+# Reads the output from ngspice and outputs a `genspic' file
+# for use with genspic2gnuplot.  Takes no arguments or options.
+#
+# Limitations
+#
+#  Only frequency (.AC) and transient plots have been tested.
+#
+#  Displaying voltages and currents on the same .TRAN graph won't work
+#   well because they currently have to have the same Y scale.
+#
+#  This whole scheme is very clumsy.  There should be a driver program
+#  with command-line option parsing.
+
+# This program and its documentation are free software; you can
+# redistribute them and/or modify them under the terms of the GNU
+# General Public License as published by the Free Software Foundation;
+# either version 2, or (at your option) any later version.
+# 
+# This program and its documentation are distributed in the hope that
+# they will be useful, but WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE.  See the GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+die if @ARGV;
+
+while (<STDIN>) {
+    if (m/^Total CPU/) {
+       die if $mode ne '';
+       $seentcpu=1;
+    } elsif (m/^Current dynamic memory/ ||
+            m/^Dynamic memory limit/ ||
+            m/^Level not specified/ ||
+            m/^Doing analysis/ ||
+            m/^CPU time since/ ||
+            m/^Circuit\:/) {
+       die if length $mode;
+    } elsif (m/\f/) {
+       die if m/\S/;
+    } elsif (!m/\S/ && $mode eq InitTransSkip) {
+       $mode= '';
+    } elsif (m/^Initial Transient/ && $mode eq '') {
+       $mode= InitTrans;
+    } elsif (m/^Node/ && $mode eq InitTrans) {
+       $mode= InitTransSkip;
+    } elsif (m/\w/ && $mode eq InitTransSkip) {
+    } elsif (m/^\-\-/ && length $mode) {
+    } elsif (m/^\s\s+(\w+) Analysis /) {
+       if ($mode eq '') {
+           $mode= Table;
+           $ctable= $1;
+           $dokey= 1;
+       } else {
+           $dokey= 0;
+       }
+    } elsif (m/^\s\s+/ && ($mode eq Table or !length $mode)) {
+    } elsif (m/^Index / && $mode eq Table) {
+       s/\s+$//;
+       ($index,$key,@nowheadings) = split /\s+/, $_;
+       $logxy= 0+($key eq 'frequency');
+    } elsif (m/^\d+\s/ && $mode eq Table) {
+       ($index,$key,@nowcolumns) = split /\s+/, $_;
+       shift @nowcolumns if $key =~ s/\,$//;
+       $coldata[$index] .= " $key" if $dokey;
+       $coldata[$index] .= " @nowcolumns";
+       if (!$index) {
+           foreach $c (@nowheadings) {
+               $h= 'y';
+               $h= 'y2' if $c =~ m/^ph\(/;
+               push @columns, "$h:$c";
+           }
+       }
+    } elsif (!m/\S/ && $mode eq Table) {
+       print "S $ctable $logxy @columns\n" or die $!;
+       foreach $l (@coldata) { printf "D%s\n", $l or die $!; }
+       print "T\n" or die $!;
+       $mode= '';
+       @columns= ();
+       @coldata= ();
+    } elsif (!m/\S/) {
+       $mode= '' if $mode eq InitTransSkip;
+    } else {
+       die "$mode: $_ ?";
+    }
+}
+die "no plots" unless defined $ctable;
+print "F\n" or die $!;
+
+# $Id: ngspice2genspic,v 1.1 2004-03-25 00:29:59 ianmdlvl Exp $