Commit 65cf0b87 authored by Tammo Jan Dijkema's avatar Tammo Jan Dijkema
Browse files

Move filename logic to record.py

parent 3b8e1b65
......@@ -27,16 +27,6 @@ def make_sigmf(metadatafilename, no_rename=False):
rx_gain = float(rx_gain)
time_first_sample = Time(float(time_first_sample), format="unix")
# sigmfname_data = sigmfname_meta.replace("-meta", "-data")
if dataformat.strip('"') == "short":
datatype = "ci16_le"
elif dataformat.strip('"') == "float":
datatype = "cf32_le"
elif dataformat.strip('"') == "double":
datatype = "cf64_le"
else:
datatype = "unknown"
newfilename = metadatafilename.rstrip(".metadata").rstrip(".iq") + "_" + \
f"{frequency/1e6:.3f}MHz" + \
f"_{rate/1e6:.1f}Msps" + \
......
......@@ -6,6 +6,18 @@ import os
from make_sigmf import make_sigmf
from datetime import datetime
def dataformat_to_str(dataformat):
if dataformat.strip('"') == "short":
datatype = "ci16_le"
elif dataformat.strip('"') == "float":
datatype = "cf32_le"
elif dataformat.strip('"') == "double":
datatype = "cf64_le"
else:
datatype = "unknown"
return datatype
if __name__ == "__main__":
parser = ArgumentParser(description="This application streams data from a single channel of a USRP device to a file; it wraps a C++ program")
......@@ -37,8 +49,14 @@ if __name__ == "__main__":
args = parser.parse_args()
if args.file is None:
args.file = f"camras-{datetime.utcnow():%Y_%m_%d_%H_%M_%S}.iq"
datatype = dataformat_to_str(args.type)
args.file = f"camras-{datetime.utcnow():%Y_%m_%d_%H_%M_%S}" + \
f"_{float(args.freq)/1e6:.3f}MHz" + \
f"_{float(args.rate)/1e6:.1f}Msps" + \
f"_{datatype}.sigmf-data"
print(args.file)
1/0
args_dict = vars(args)
bool_args = [key for key, value in args_dict.items() if value == True and isinstance(value, bool)]
......@@ -64,4 +82,4 @@ if __name__ == "__main__":
if exit_code != 0:
raise RuntimeError("Exit code of usrp_to_file was " + exit_code)
sigmf_filename = make_sigmf(args.file + ".metadata")
sigmf_meta_filename = make_sigmf(args.file + ".metadata")
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment