Status (2026-11-29): the local entry points work and are tested; opening a generated file in the real IBA Analyzer is still unverified.
What is verified here, on this machine, offline and with synthetic data only:
python -m iba_pyconverts JSON to a PDA2 3.2.datand back, using the documented default names and an optional explicit output path.- The reader accepts files written by the previous release and by this one; analog channels are compared as float32, digital channels as booleans.
- Bad, truncated, mislabelled, or compressed inputs produce one readable error line and leave any existing output file untouched.
python -m unittest discover -s testspasses all 28 tests.tools/verify_export.pyturns an Analyzer CSV export into an auditable pass/fail against the source JSON, so the remaining manual step is a single command.
What is not verified: that a real ibaAnalyzer installation opens the generated .dat with the
expected channel names, start time, sample interval, frame count, and sample values. No Analyzer or
official sample file was available, so round-tripping this project's own files is not evidence of
Analyzer compatibility. See Compatibility for the exact pending check.
From this checkout, no dependencies are needed:
pip install -e .
# or simply run it in place:
python -m iba_py --helpRequires Python 3.10 or newer (the code uses X | Y type syntax).
python -m iba_py your_data.json # writes your_data.json.dat
python -m iba_py your_data.json -o plant.dat # explicit output namepython -m iba_py your_existing.dat # writes your_existing.dat.json
python -m iba_py your_existing.dat -o data.jsonThe input name decides the direction: .json is converted to .dat, .dat is converted to
.json (case-insensitive). Without -o, the output name is the input name with the other
extension appended, so both files stay distinguishable.
Behaviour worth knowing:
- An existing output file is replaced only after the whole conversion succeeded. A failure leaves it byte-for-byte unchanged and leaves no temporary files behind.
- The input file (also via a symbolic or hard link) is never used as the output.
- Decoded JSON uses
"YYYY-MM-DD HH:MM:SS"for the start time, plus.ffffffwhen the time is not a whole second (a space, not the ISOTused on input; the fraction is truncated to the 0.1 ms the DAT stores, so.123456comes back as.123400). That JSON is valid input again. - gzip- or ZIP-wrapped input is rejected with
...-wrapped input is unsupported; extract the DAT first; unknown signatures are rejected asnot a PDA2 DAT file. - Exit status is 0 on success, 1 on any conversion error, 2 on a usage error.
from iba_py import FormatError, UnsupportedFormatError, dec, enc
begin = "2024-05-20T09:00:00"
interval = 0.2 # seconds between samples
channels = {
"Temperature C": [22.5, 22.6, 22.7],
"Pump on": [False, False, True], # bools become a digital channel
}
enc("plant.dat", begin, interval, channels)
start, step, data = dec("plant.dat")enc and dec accept either a path or a binary file object. All bytes are prepared before a path
is opened, so an invalid write never truncates an existing file. dec requires a seekable stream.
Both raise FormatError for bad input and data; UnsupportedFormatError (a subclass) for a layout
this tool does not implement. Both derive from ValueError.
A three-element list:
[
"2024-05-20T09:00:00",
0.2,
{
"Temperature C": [22.5, 22.6, 22.7],
"Pump on": [false, false, true]
}
]- Start time: ISO 8601 date and time, no time zone. Written with 0.1 ms resolution; extra digits
are truncated. Read back as
"YYYY-MM-DD HH:MM:SS", or with.ffffffappended when the stored time is not a whole second. - Interval: positive, finite number of seconds, written in the shortest text that reads back to
the same float (
0.1,1,5e-07all round-trip exactly). - Channels: a non-empty object. Every channel needs at least one sample and all channels need the same number of samples. A list must be all booleans (digital) or all numbers (analog); mixing is an error. Keep channel names non-blank and free of line breaks. A JSON object cannot repeat a key, so build channel names that are unique.
- Values are stored as float32, so
0.1reads back as0.10000000149011612. Values outside the float32 range andNaN/Infinityare rejected.
A ready-to-run sample is in examples/sample.json. EVIDENCE.md
records what was measured for this release and how to rerun it.
Implemented and tested subset:
- Signature
PDA2followed by3e c2 8f 9d, a 32-bit header offset, 20 reserved bytes, then run-length-encoded channel chunks (uint16run count,uint32next-chunk offset, then 1-byte count + float32 per analog run or 1-byte count +40/c0per digital run). ibaFiles:3.2withtyp:real, where analog anddigchannelchannels mix freely (the analyzer numbering is reproduced).typ:int16is read for all-digital files;int16analog samples are not implemented.- Every byte of the data section (
[32, header offset)) must belong to some channel block. Unreferenced bytes make the file be reported instead of read as a shorter, valid-looking one; this is what catches a file cut atendchannel:. Two channels may point at the same block, and a file missing only its final line break still reads. - Runs are capped at 255 samples and chunks at 5000 runs, matching the original implementation.
- Channel offsets use the original project's
O…token encoding, which is only 24 bits wide. A file whose channel data would start beyond 16 MiB is refused instead of written incorrectly.
Not supported, reported as UnsupportedFormatError:
- Other
PDA2signatures,ibaFilesversions other than 3.2,typvalues other thanrealandint16, and channel offsets that are not theO…form. - gzip and ZIP wrappers. The previous release did not support these either; there is no evidence of an official compressed variant, so no decompression is attempted.
Unknown key:value header fields (unit:…, comment:…) are ignored, so files with extra metadata
still read. A line without a colon is not metadata but damage, and is reported.
The compatibility tests show which tested inputs produce the same bytes as 0.1.0. These four differences matter when reading or writing files next to an older installation:
- A run of exactly 255 equal samples. 0.1.0 wrote 256 samples into the file and its own reader returned all 256. This writer writes and returns 255.
- A digital channel whose first sample is
false. 0.1.0 computed a wrong header offset andtyp:real, and its reader then returned bogus floats instead of booleans. This writer emits the correct offset andtyp:int16. - Sub-second start times are kept. 0.1.0 always wrote
.0000and parsed only the whole second. This tool stores09:00:00.123456as09:00:00.1234and reads it back as09:00:00.123400; the 0.1.0 reader raisesValueErroron such a file. A whole-second start time is written as.0000, exactly as 0.1.0 wrote it. Dropping the fraction to stay readable by 0.1.0 would lose information the format holds, so it is not done and there is no switch for it. - Channel names are read in full. 0.1.0's writer stored the whole name but its reader stopped at
the first space, so
Temperature °Cappeared asTemperature. The bytes are unchanged; only this reader returns the full name.
The pending acceptance check needs an ibaAnalyzer installation of a recorded version in an environment where testing third-party generated files is permitted (iba AG's own terms tie free standard functionality to native-data conditions and list third-party generated files separately; check the licence that applies to you). The procedure is:
python -m iba_py examples/sample.json -o sample.json.dat- Open
sample.json.datin the Analyzer; confirm the three channels, the start time20.05.2024 09:00:00, and an interval of0.2 s. - Export those channels to CSV.
python tools/verify_export.py examples/sample.json sample.csv
The script compares channel names, sample count, start time, interval, and every sample (booleans
as 0/1, analog within --tolerance), and prints what mismatched. The reverse direction needs a
small file exported from the same Analyzer so the reader can be checked against real output.
Until such a run is recorded, treat the writer as "produces a valid PDA2 3.2 RLE subset", not as "opens in ibaAnalyzer".
python -m unittest discover -s tests -vtests/test_format.py checks a hand-assembled file (independent of this writer), byte-level writer
output, every truncation offset of a three-channel file, the interval values that are written and
read back, that the channel blocks tile the data section, the documented 0.1.0 differences, the
255-run and 5000-chunk boundaries, float32 tolerance, rejection of corrupt files, and
files produced by the previous release, including a known offset bug that is now reported instead of
misread. tests/fixtures/legacy_*.dat were generated by the 0.1.0 code and are kept as read-only
regressions. tests/test_cli.py drives the real python -m iba_py entry point.
tests/test_verify_export.py checks the Analyzer-export comparison, including semicolon/decimal-comma
exports, a trailing unit row, missing or extra channels, wrong counts, and tolerance control.
input filename must end in .dat or .json— the extension picks the direction.not a PDA2 DAT file (invalid signature)— the file is not an iba DAT, or is gzip/ZIP-wrapped.unsupported ibaFiles version …— the file uses a layout this tool does not implement.channel 'X' must contain only numbers or only booleans— a channel mixestrue/falsewith numbers, or containsnull/strings.all channels must contain the same number of samples— pad or trim the lists.