Expand description
SPICE3 rawfile reader and writer.
The format contract is corpus/spice3f5/src/lib/fte/rawfile.c
(raw_write/raw_read, Wayne A. Christopher, 1986): a header of
Keyword: value lines (Title, Date, Plotname, Flags,
No. Variables, No. Points, optional Dimensions, Command,
Option), a Variables: table, and a Values: (ASCII) or Binary:
(native-endian f64) data section. One file may carry several plots
appended back to back; a plot is complex as a whole if any of its
vectors is complex.
The writer reproduces the 3f5 output byte for byte (15-digit %e
floats, point index starting each ASCII row, one value per line, a
blank line after each point). The reader is deliberately flexible,
like the C one: it only requires one Variables: and one data section
per plot, in that order, and treats whitespace loosely. Known
divergences between 3f5 and ngspice output are listed in
docs/dune-raw.md.
Malformed input produces a structured Error with a line number —
never a panic.
Structs§
- Plot
- One plot: a header plus a block of data (
struct plotin the C). - Rawfile
- A parsed rawfile: one or more plots, in file order.
- Variable
- One variable (a
dvecin the 3f5 sources) from theVariables:table.
Enums§
- Data
- Plot data, one column per variable, in
Variables:order. - Error
- Rawfile reading errors.
- Format
- Data section encoding. Binary is raw little-endian
f64s — the 3f5 writes native doubles, and every platform Dune targets (x86-64, aarch64, wasm32) is little-endian. - VarType
- Vector type, as named in the rawfile
Variables:table.
Functions§
- fmt_e
%.*ewith the given precision, as C’sprintfrenders it (1.000000000000000e+03): sign on the exponent, at least two exponent digits. Rust’s{:e}writes1e3, so this reshapes it. Public because every text surface that mimics the 3f5 (rawfiles, the CLI’s.printcolumns) needs the same rendering.