sf_readrow_s3bin in spicefile/ss_spice3.c:373 assumes that the first variable of any rawfile is the independent variable and is real-valued. If the variable has two columns, it discards the second column, presumably to tidy up the output ascii file. However, there are cases where this is not correct. For example, ngspice has a pole-zero analysis mode. The rawfile output of a pole-zero analysis contains a single row containing all poles and zeros, which are complex numbers. sp2sp will discard the imaginary part of the first pole.
IMO, the best solution would be to always print the imaginary part of the first variable if it is a 2-column variable. However, I don't know if this would cause any conflicts with existing programs that use spicefile. Attached is an example .cir and .raw file that illustrate the problem.
spice circuit file for pole-zero analysis
raw file that illustrates the problem
Good catch. If there is complete documentation on the spice3/ngspice rawfile format, I've never found it.
It appears that the pole-zero rawfile output contains no sort of independent variable at all. Gwave or any other plotting tool wouldn't be able to do much with that, but sp2sp ought to be able to translate such a file.
My best idea is to detect this case, generate a fake independent variable to keep the API consistent, and present a flag that sp2sp can use to supress the fake independent variable.
That sounds like a good idea, but difficult. I don't see any obvious feature of the file that you could use. Perhaps easier would be to require the calling program to request that all variables be returned.
BTW, I translated sp2sp.c and ss_spice3.c into python to use in my own app. It was fun and quick; I found the code to be very easy to understand. If you're interested, my translation is at http://mrfilter.sourceforge.net . Download the 0.2 release and look for spicefile.py .