readINW
Description
readINW is a utility designed to parse raw binary Optech INW (Integrated Navigational and Waveform) data files and extract waveform information. It processes these files, identifies different waveform types (PMT, GAPD, IR, RAMAN), and then writes a summary of each waveform record (timestamp, counter, and byte offsets/lengths) to a .wave file, and the actual 16-bit waveform trace data to a .16_data file.
This tool essentially “unpacks” the raw INW data into a more usable format for subsequent processing by other Optech-related tools.
Usage
readINW <infile> <outfile_prefix> [-noraman] [-v]
Arguments
| Option | Description | |
|---|---|---|
<infile> | Required. The path to the input raw binary Optech INW file. | |
<outfile_prefix> | Required. The base name for the output files. The tool will generate <outfile_prefix>.wave (summary) and <outfile_prefix>.16_data (raw waveform traces). | |
-noraman | (Present in USAGE but its effect is inverted in code logic) Intended to ignore RAMAN waveforms, but its current implementation seems to manage handling with or without RAMAN based on existence. | |
-v | Enable verbose output. |
Data Structures
optech_waveform: This structure holds summary information for each waveform record, includingtimestamp,counter, and byte offsets/number of samples for PMT, GAPD, IR, and RAMAN waveforms.
How It Works
- File Opening: Opens the input raw INW file for reading. Opens two output files:
<outfile_prefix>.wavefor writing waveform record summaries, and<outfile_prefix>.16_datafor writing raw 16-bit waveform traces. - INW Header Skipping: Reads and discards the first 4096 bytes, assumed to be a header (
inw_head). - Record Processing Loop: Reads the INW file in fixed-size blocks (992 bytes, representing
all_trace) until the end of the file:- Timestamp Extraction: Extracts
timestampfrom the first 8 bytes of theall_traceblock. - Waveform Trace Data Writing: For records beyond a
SKIP_PINGSthreshold (4 pings), it writes 984 bytes ofall_trace(converted to 16-bit shorts) to the.16_datafile. - Waveform Structure Population: Populates an
optech_waveformstructure (owave) with the extracted timestamp, a counter, and fixed numbers of samples for PMT, GAPD, IR, and RAMAN channels. It setsPMT_byte_offsetto the current file position indatfile. - Waveform Structure Writing: If the current record
counteris greater thanSKIP_PINGS, it writes theowavestructure to the.wavefile.
- Timestamp Extraction: Extracts
- Cleanup: Closes all open files.
Output Files
<outfile_prefix>.wave: A binary file containingoptech_waveformsummary structures.<outfile_prefix>.16_data: A binary file containing raw 16-bit waveform trace data.
Dependencies
support.h: For general utility functions and error handling.Optech_waveform.h: Foroptech_waveformdata structure.
Notes
Byte Order and Alignment: The code explicitly warns that writing and reading is “not byte order or dstructure alignment independent.” This means the binary files (.wave, .16_data) generated by this tool (and expected by mergeOpWave) should ideally be processed on the same machine architecture to avoid endianness or padding issues. -noraman flag: The -noraman option’s description in USAGE and its actual implementation logic in the provided code snippet (if (noraman) { error(...) }) appear contradictory or incomplete. It seems designed to prevent processing if RAMAN data exists while this flag is set. The code includes a commented-out section for parsing an ASCII version of the waveform data, suggesting an alternative input format was considered or used previously.