This Python script converts .dat files containing IQ samples into the SigMF format, generating .bin and .json files. It is designed for processing IQ data collected in radio frequency experiments, such as those involving SDRs (Software-Defined Radios).
- Converts
.datfiles to SigMF-compliant.binand.jsonfiles. - Supports interleaved I/Q samples in
float32orfloat16format. - Dynamically generates metadata for each input file based on customizable base metadata.
- Includes error handling for incomplete or invalid input files.
This script requires the following Python libraries:
numpytqdm
You can install these dependencies using:
pip install numpy tqdmUpdate the paths in the script:
dat_input_path: Path to your.datfiles directory.sigmf_output_path: Directory where the SigMF files will be saved.
Edit the base_metadata dictionary in the script to reflect your experiment setup, such as:
- Sample rate
- Hardware details
- Test environment
Execute the script with the following command:
python sigmf_converter.py- Input files must be
.datfiles containing interleaved I/Q samples. - Supported data types are
float32andfloat16.
For each .dat file:
- A
.binfile containing I/Q samples. - A
.jsonfile with metadata in SigMF format.
These files are saved in the directory specified by sigmf_output_path.
/home/mohammed/ztxdata/iq_samples/
/home/mohammed/ztxdata/sigmf_files/
For a file named example.dat, the output will include:
/home/mohammed/ztxdata/sigmf_files/example.bin
/home/mohammed/ztxdata/sigmf_files/example.json
- Verify that the
.datfiles are valid and properly formatted. - Ensure the files contain interleaved I/Q samples in
float32orfloat16format.
- Check the
base_metadatadictionary and update it to match your experimental setup.
Below is an example of the base metadata structure used in the script:
{
"global": {
"core:datatype": "cf32_le",
"core:sample_rate": 23040000,
"core:version": "0.0.1",
"core:author": "Mohammed",
"core:description": "IQ samples from the srsRAN OTA 5G testbed setup."
},
"captures": {
"core:center_frequency": 3500000000,
"core:sample_start": 0
},
"annotations": {
"core:sample_start": 0,
"core:sample_count": 0
}
}This project is licensed under the MIT License. Feel free to modify and adapt it to your needs.