2 # gnucap2genspic - Copyright 2004 Ian Jackson - see below
4 # Reads the output from gnucap and outputs a `genspic' file
5 # for use with genspic2gnuplot. Takes no arguments or options.
9 # Only Freq (.AC) and Time (.TRAN) plots have been tested. If
10 # other types go wrong they can probably be fixed by adding code for
11 # them to startplot().
13 # Displaying voltages and currents on the same .TRAN graph won't work
14 # well because they currently have to have the same Y scale. This
15 # could be fixed by assigning carefully to $mmm in startplot().
17 # This whole scheme is very clumsy. There should be a driver program
18 # with command-line option parsing.
20 # This program and its documentation are free software; you can
21 # redistribute them and/or modify them under the terms of the GNU
22 # General Public License as published by the Free Software Foundation;
23 # either version 3, or (at your option) any later version.
25 # This program and its documentation are distributed in the hope that
26 # they will be useful, but WITHOUT ANY WARRANTY; without even the
27 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
28 # PURPOSE. See the GNU General Public License for more details.
30 # You should have received a copy of the GNU General Public License along
31 # with this program; if not, consult the Free Software Foundation's
32 # website at www.fsf.org, or the GNU Project website at www.gnu.org.
36 %facttimes= qw(f 1e-15
48 for ($yn=1; $yn<=$#columns; $yn++) {
51 if ($kind eq 'Freq') {
53 for ($yn=1; $yn<=$#columns; $yn++) {
54 die unless $columns[$yn] =~ m/.*([MP])\(\d+\)$/i;
55 $mmm[$yn]= 'y2' if uc $1 eq 'P';
58 printf "S %s %d", $cplot, $logxy or die $!;
59 for ($yn=1; $yn<=$#columns; $yn++) {
60 printf " %s:%s", $mmm[$yn], $columns[$yn] or die $!;
65 return unless defined $kind;
66 print "T\n" or die $!;
71 $linesofar= $readahead;
74 last unless $readahead =~ s/^\+//;
75 die unless length $linesofar;
76 $linesofar =~ s/\n$//;
77 $linesofar .= $readahead;
86 @columns= split /\s+/;
90 } elsif (!defined $kind) {
93 @numbers= split /\s+/;
95 if (m/^(\-?\d+\.\d*)([A-Za-z]+)$/) {
96 die "factor $2" unless exists $facttimes{$2};
97 $_= $1*$facttimes{$2};
100 print "D @numbers\n" or die $!;
105 die "no plots" unless defined $kind;
107 print "F\n" or die $!;
109 # $Id: gnucap2genspic,v 1.4 2007-09-21 21:21:15 ianmdlvl Exp $