diff --git a/recordings/rec_0Hz_2025-05-15_09-45-10_0264b4a.npy b/recordings/rec_0Hz_2025-05-15_09-45-10_0264b4a.npy deleted file mode 100644 index c099ad4..0000000 --- a/recordings/rec_0Hz_2025-05-15_09-45-10_0264b4a.npy +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:7b05da5de57afd3e9b70fe69483ba3dfec7c9e5c16509558964de97fb461cdf2 -size 17104 diff --git a/recordings/rec_0Hz_2025-05-15_09-45-10_0b3b80f.npy b/recordings/rec_0Hz_2025-05-15_09-45-10_0b3b80f.npy deleted file mode 100644 index 9d962d5..0000000 --- a/recordings/rec_0Hz_2025-05-15_09-45-10_0b3b80f.npy +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:34787243d616952741ae11444478f967e9d38851609f006cafdbc0d0ce38d7fe -size 17103 diff --git a/recordings/rec_0Hz_2025-05-15_09-45-10_1effc4c.npy b/recordings/rec_0Hz_2025-05-15_09-45-10_1effc4c.npy deleted file mode 100644 index deee079..0000000 --- a/recordings/rec_0Hz_2025-05-15_09-45-10_1effc4c.npy +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:c419fe64b7cba90f5323154742aa73ce759abafda9893ddc90d57db832b6b8a5 -size 17103 diff --git a/recordings/rec_0Hz_2025-05-15_09-45-10_37a73db.npy b/recordings/rec_0Hz_2025-05-15_09-45-10_37a73db.npy deleted file mode 100644 index 9c6df67..0000000 --- a/recordings/rec_0Hz_2025-05-15_09-45-10_37a73db.npy +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:65a25e6375871ab3556900abc7b96c9240827ec6c51d5d2f2d864cf0786128f4 -size 17103 diff --git a/recordings/rec_0Hz_2025-05-15_09-45-10_3d557a9.npy b/recordings/rec_0Hz_2025-05-15_09-45-10_3d557a9.npy deleted file mode 100644 index ad80691..0000000 --- a/recordings/rec_0Hz_2025-05-15_09-45-10_3d557a9.npy +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:f38ac9a0f7192325b3cf9c03cc311439bf2b020772f019587a1e338969ae0a1f -size 17107 diff --git a/recordings/rec_0Hz_2025-05-15_09-45-10_442fcb9.npy b/recordings/rec_0Hz_2025-05-15_09-45-10_442fcb9.npy deleted file mode 100644 index 09158a9..0000000 --- a/recordings/rec_0Hz_2025-05-15_09-45-10_442fcb9.npy +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:f76cae7448b608f024baea6685978929458103bc83196aae2ddd1a47af69ea43 -size 17107 diff --git a/recordings/rec_0Hz_2025-05-15_09-45-10_491c457.npy b/recordings/rec_0Hz_2025-05-15_09-45-10_491c457.npy deleted file mode 100644 index 7af0b08..0000000 --- a/recordings/rec_0Hz_2025-05-15_09-45-10_491c457.npy +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:9f4f8c00a9937d7245d017b792df0390692a9dd201fcd156d24255a6f0450692 -size 17103 diff --git a/recordings/rec_0Hz_2025-05-15_09-45-10_4fff84f.npy b/recordings/rec_0Hz_2025-05-15_09-45-10_4fff84f.npy deleted file mode 100644 index 32f69ec..0000000 --- a/recordings/rec_0Hz_2025-05-15_09-45-10_4fff84f.npy +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:47d51d307292089b66018d00ff39ba1e3ccafadc87829f46d5ad45599c5c7d97 -size 17104 diff --git a/recordings/rec_0Hz_2025-05-15_09-45-10_6676600.npy b/recordings/rec_0Hz_2025-05-15_09-45-10_6676600.npy deleted file mode 100644 index eb3825b..0000000 --- a/recordings/rec_0Hz_2025-05-15_09-45-10_6676600.npy +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:108e4fff19e390b1b66da936752e8341b4cf36443fd511d4114b5082f8b20580 -size 17104 diff --git a/recordings/rec_0Hz_2025-05-15_09-45-10_6d35ff9.npy b/recordings/rec_0Hz_2025-05-15_09-45-10_6d35ff9.npy deleted file mode 100644 index 736b9aa..0000000 --- a/recordings/rec_0Hz_2025-05-15_09-45-10_6d35ff9.npy +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:c62ff017c8666fa06555fdd102f75409781d98679f010e11fca6105fbd8b7e85 -size 17104 diff --git a/recordings/rec_0Hz_2025-05-15_09-45-10_6d85f3e.npy b/recordings/rec_0Hz_2025-05-15_09-45-10_6d85f3e.npy deleted file mode 100644 index 9f70c2d..0000000 --- a/recordings/rec_0Hz_2025-05-15_09-45-10_6d85f3e.npy +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:b2f07fecedf5718257bf7837c2f28d7a6f83d9bfa43473a6d0aa7baa69a1b7ac -size 17104 diff --git a/recordings/rec_0Hz_2025-05-15_09-45-10_85a8c83.npy b/recordings/rec_0Hz_2025-05-15_09-45-10_85a8c83.npy deleted file mode 100644 index 3771ab4..0000000 --- a/recordings/rec_0Hz_2025-05-15_09-45-10_85a8c83.npy +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:db2e9425c889ee30d3f7c8e15996d3ce201dfb413a3e864ec95ac1c1e15d56a4 -size 17107 diff --git a/recordings/rec_0Hz_2025-05-15_09-45-10_940988e.npy b/recordings/rec_0Hz_2025-05-15_09-45-10_940988e.npy deleted file mode 100644 index 3e280c6..0000000 --- a/recordings/rec_0Hz_2025-05-15_09-45-10_940988e.npy +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:9be736990738b2fba0e70a59b920d6ebadfbf7e4d4ba7c01afb4712d4b7b8ad0 -size 17104 diff --git a/recordings/rec_0Hz_2025-05-15_09-45-10_9f88dc2.npy b/recordings/rec_0Hz_2025-05-15_09-45-10_9f88dc2.npy deleted file mode 100644 index 9915d10..0000000 --- a/recordings/rec_0Hz_2025-05-15_09-45-10_9f88dc2.npy +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:b684a66eb335dc79ec669b9e8a6b2a73babd1c2a6394dc00b27f62762be20e68 -size 17103 diff --git a/recordings/rec_0Hz_2025-05-15_09-45-10_a4a6ba6.npy b/recordings/rec_0Hz_2025-05-15_09-45-10_a4a6ba6.npy deleted file mode 100644 index 06fa5e1..0000000 --- a/recordings/rec_0Hz_2025-05-15_09-45-10_a4a6ba6.npy +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:9e36174699020ff6f5571b43b323ab3daa59cf819e26424cb462d26577637c91 -size 17103 diff --git a/recordings/rec_0Hz_2025-05-15_09-45-10_a60964b.npy b/recordings/rec_0Hz_2025-05-15_09-45-10_a60964b.npy deleted file mode 100644 index b56a221..0000000 --- a/recordings/rec_0Hz_2025-05-15_09-45-10_a60964b.npy +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:3dfd1c4ef497a0530235fff62a9b642ae356845eca9e5db25062ce7773e21f96 -size 17104 diff --git a/recordings/rec_0Hz_2025-05-15_09-45-10_ad350fe.npy b/recordings/rec_0Hz_2025-05-15_09-45-10_ad350fe.npy deleted file mode 100644 index e45671e..0000000 --- a/recordings/rec_0Hz_2025-05-15_09-45-10_ad350fe.npy +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:ad8f2ec6dae3c1ecf46f5e18a782436ccee6cbd7154340b156a5790d786664d2 -size 17107 diff --git a/recordings/rec_0Hz_2025-05-15_09-45-10_ae5224a.npy b/recordings/rec_0Hz_2025-05-15_09-45-10_ae5224a.npy deleted file mode 100644 index 7f54193..0000000 --- a/recordings/rec_0Hz_2025-05-15_09-45-10_ae5224a.npy +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:8fba3e786b31e41c624fa01228c81a430b32b562d6ae245840e72d25aa83d556 -size 17103 diff --git a/recordings/rec_0Hz_2025-05-15_09-45-10_b68f080.npy b/recordings/rec_0Hz_2025-05-15_09-45-10_b68f080.npy deleted file mode 100644 index 60bfa88..0000000 --- a/recordings/rec_0Hz_2025-05-15_09-45-10_b68f080.npy +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:cb45074f11187e4e2461efe47536b9704f47bc2ccd59801193fbc5c1a1261c09 -size 17103 diff --git a/recordings/rec_0Hz_2025-05-15_09-45-10_c00477b.npy b/recordings/rec_0Hz_2025-05-15_09-45-10_c00477b.npy deleted file mode 100644 index 3dbc92d..0000000 --- a/recordings/rec_0Hz_2025-05-15_09-45-10_c00477b.npy +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:2ddc93a5d31248700f4a5152af49d951b80712132c35c6f26f6838b5c5613402 -size 17104 diff --git a/recordings/rec_0Hz_2025-05-15_09-45-10_cca57ca.npy b/recordings/rec_0Hz_2025-05-15_09-45-10_cca57ca.npy deleted file mode 100644 index d323569..0000000 --- a/recordings/rec_0Hz_2025-05-15_09-45-10_cca57ca.npy +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:c8e8aa5d85ca26b34e47b02022aae3006981f1d386a91a8b6e6afe54d75bacaf -size 17106 diff --git a/recordings/rec_0Hz_2025-05-15_09-45-10_db8a5b4.npy b/recordings/rec_0Hz_2025-05-15_09-45-10_db8a5b4.npy deleted file mode 100644 index 47f65fc..0000000 --- a/recordings/rec_0Hz_2025-05-15_09-45-10_db8a5b4.npy +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:4cb0bcde7d2ef19ead6bf460198cb8c3b32a4324f0148bb95425ba1bfe96f63c -size 17106 diff --git a/recordings/rec_0Hz_2025-05-15_09-45-10_dd021f7.npy b/recordings/rec_0Hz_2025-05-15_09-45-10_dd021f7.npy deleted file mode 100644 index 7b0edad..0000000 --- a/recordings/rec_0Hz_2025-05-15_09-45-10_dd021f7.npy +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:7d1a52d4634b04cc6dd0f50f2c6882f139e0165a0a29be1076cb784f0629a10f -size 17104 diff --git a/recordings/rec_0Hz_2025-05-15_09-45-10_e0cc41d.npy b/recordings/rec_0Hz_2025-05-15_09-45-10_e0cc41d.npy deleted file mode 100644 index ca89984..0000000 --- a/recordings/rec_0Hz_2025-05-15_09-45-10_e0cc41d.npy +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:f54fe5742a134f08dd21f3fbe8c8f2c72905dcd03ce771550d8b785d9c27aa8d -size 17103 diff --git a/recordings/rec_0Hz_2025-05-15_09-45-10_e61d9bf.npy b/recordings/rec_0Hz_2025-05-15_09-45-10_e61d9bf.npy deleted file mode 100644 index d6cd072..0000000 --- a/recordings/rec_0Hz_2025-05-15_09-45-10_e61d9bf.npy +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:4d21bdc3474e20bd951da6e61bebfbd091113594f1f4d5d02fa173ca813a6f06 -size 17106 diff --git a/recordings/rec_0Hz_2025-05-15_09-45-10_f024082.npy b/recordings/rec_0Hz_2025-05-15_09-45-10_f024082.npy deleted file mode 100644 index 4768b30..0000000 --- a/recordings/rec_0Hz_2025-05-15_09-45-10_f024082.npy +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:cba2de88026b625c954c9c6b875ee764e60ebe76587f00ba5e6a7f7f5dcfa814 -size 17103 diff --git a/recordings/rec_0Hz_2025-05-15_09-45-10_f2013fa.npy b/recordings/rec_0Hz_2025-05-15_09-45-10_f2013fa.npy deleted file mode 100644 index e71fe04..0000000 --- a/recordings/rec_0Hz_2025-05-15_09-45-10_f2013fa.npy +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:f278f5ed086f9edd365200f2498f24ef26aa8259e684b932cf804dc14c09b282 -size 17104 diff --git a/recordings/rec_0Hz_2025-05-15_09-45-10_f2ae593.npy b/recordings/rec_0Hz_2025-05-15_09-45-10_f2ae593.npy deleted file mode 100644 index 192ed4a..0000000 --- a/recordings/rec_0Hz_2025-05-15_09-45-10_f2ae593.npy +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:e327873b5962e61ca11bd0221e79547f4f69f0f655a6e44450d80b7ac4ec9ff9 -size 17106 diff --git a/results/interference_recognition_model.ckpt b/results/interference_recognition_model.ckpt new file mode 100644 index 0000000..cd1a382 Binary files /dev/null and b/results/interference_recognition_model.ckpt differ diff --git a/scripts/data_gen.py b/scripts/data_gen.py deleted file mode 100644 index 5ca8563..0000000 --- a/scripts/data_gen.py +++ /dev/null @@ -1,69 +0,0 @@ -from utils.data import Recording -import numpy as np -from utils.signal import block_generator - -mods = { - "bpsk": {"num_bits_per_symbol": 1, "constellation_type": "psk"}, - "qpsk": {"num_bits_per_symbol": 2, "constellation_type": "psk"}, - "qam16": {"num_bits_per_symbol": 4, "constellation_type": "qam"}, - "qam64": {"num_bits_per_symbol": 6, "constellation_type": "qam"}, -} - - -def generate_modulated_signals(): - for modulation in ["bpsk", "qpsk", "qam16", "qam64"]: - for snr in np.arange(-6, 13, 3): - - recording_length = 1024 - beta = 0.3 # the rolloff factor, can be changed to add variety - sps = 4 # samples per symbol, or the relative bandwidth of the digital signal. Can also be changed. - - # blocks don't directly take the string 'qpsk' so we use the dict 'mods' to get parameters - constellation_type = mods[modulation]["constellation_type"] - num_bits_per_symbol = mods[modulation]["num_bits_per_symbol"] - - # construct the digital modulation blocks with these parameters - # we have bit source -> mapper -> upsampling -> pulse shaping - - bit_source = block_generator.RandomBinarySource() - mapper = block_generator.Mapper( - constellation_type=constellation_type, - num_bits_per_symbol=num_bits_per_symbol, - ) - upsampler = block_generator.Upsampling(factor=sps) - pulse_shaping_filter = block_generator.RaisedCosineFilter( - upsampling_factor=sps, beta=beta - ) - - pulse_shaping_filter.connect_input([upsampler]) - upsampler.connect_input([mapper]) - mapper.connect_input([bit_source]) - - modulation_recording = pulse_shaping_filter.record( - num_samples=recording_length - ) - - # add noise by calculating the power of the modulation recording and generating AWGN from the snr parameter - signal_power = np.mean(np.abs(modulation_recording.data[0] ** 2)) - awgn_source = block_generator.AWGNSource( - variance=(signal_power / 2) * (10 ** (((-1 * snr) / 20))) - ) - noise = awgn_source.record(num_samples=recording_length) - samples_with_noise = modulation_recording.data + noise.data - output_recording = Recording(data=samples_with_noise) - - # add metadata for ML later - output_recording.add_to_metadata(key="modulation", value=modulation) - output_recording.add_to_metadata(key="snr", value=int(snr)) - output_recording.add_to_metadata(key="beta", value=beta) - output_recording.add_to_metadata(key="sps", value=sps) - - # view if you want - # output_recording.view() - - # save to file - output_recording.to_npy() # optionally add path and filename parameters - - -if __name__ == "__main__": - generate_modulated_signals() diff --git a/scripts/produce_dataset.py b/scripts/produce_dataset.py deleted file mode 100644 index d593618..0000000 --- a/scripts/produce_dataset.py +++ /dev/null @@ -1,159 +0,0 @@ -import os, h5py, numpy as np -from utils.io import from_npy -from split_dataset import split -from helpers.app_settings import get_app_settings - -meta_dtype = np.dtype( - [ - ("rec_id", "S256"), - ("snippet_idx", np.int32), - ("modulation", "S32"), - ("snr", np.int32), - ("beta", np.float32), - ("sps", np.int32), - ] -) - -info_dtype = np.dtype( - [ - ("num_records", np.int32), - ("dataset_name", "S64"), # up to 64‐byte UTF-8 strings - ("creator", "S64"), - ] -) - - -def write_hdf5_file(records, output_path, dataset_name="data"): - """ - Writes a list of records to an HDF5 file. - Parameters: - records (list): List of records to be written to the file - output_path (str): Path to the output HDF5 file - dataset_name (str): Name of the dataset in the HDF5 file (default: "data") - Returns: - str: Path to the created HDF5 file - """ - meta_arr = np.empty(len(records), dtype=meta_dtype) - for i, (_, md) in enumerate(records): - meta_arr[i] = ( - md["rec_id"].encode("utf-8"), - md["snippet_idx"], - md["modulation"].encode("utf-8"), - int(md["snr"]), - float(md["beta"]), - int(md["sps"]), - ) - - first_rec, _ = records[0] # records[0] is a tuple of (data, md) - sample = first_rec - shape, dtype = sample.shape, sample.dtype - - with h5py.File(output_path, "w") as hf: - dset = hf.create_dataset( - dataset_name, shape=(len(records),) + shape, dtype=dtype, compression="gzip" - ) - - for idx, (snip, md) in enumerate(records): - dset[idx, ...] = snip - - mg = hf.create_group("metadata") - mg.create_dataset("metadata", data=meta_arr, compression="gzip") - - print(dset.shape, f"snippets created in {dataset_name}") - - info_arr = np.array( - [ - ( - len(records), - dataset_name.encode("utf-8"), - b"generate_dataset.py", # already bytes - ) - ], - dtype=info_dtype, - ) - - mg.create_dataset("dataset_info", data=info_arr) - - return output_path - - -def split_recording(recording_list, num_snippets): - """ - Splits a list of recordings into smaller chunks. - - Parameters: - recording_list (list): List of recordings to be split - - Returns: yeah yeah - list: List of split recordings - """ - snippet_list = [] - - for data, md in recording_list: - C, N = data.shape - L = N // num_snippets - for i in range(num_snippets): - start = i * L - end = (i + 1) * L - snippet = data[:, start:end] - # copy the metadata, adding a snippet index - snippet_md = md.copy() - snippet_md["snippet_idx"] = i - snippet_list.append((snippet, snippet_md)) - return snippet_list - - -def generate_datasets(cfg): - """ - Generates a dataset from a folder of .npy files and saves it to an HDF5 file - - Parameters: - path_to_recordings (str): Path to the folder containing .npy files - output_path (str): Path to the output HDF5 file - dataset_name (str): Name of the dataset in the HDF5 file (default: "data") - - Returns: - dset (h5py.Dataset): The created dataset object - """ - - parent = os.path.dirname(cfg.output_dir) - if not parent: - os.makedirs(cfg.output_dir, exist_ok=True) - - # we assume the recordings are in .npy format - files = os.listdir(cfg.input_dir) - if not files: - raise ValueError("No files found in the specified directory.") - - records = [] - for fname in files: - rec = from_npy(os.path.join(cfg.input_dir, fname)) - - data = rec.data - - md = rec.metadata # pull metadata from the recordinh - md.setdefault("recid", len(records)) - records.append((data, md)) - - # split each recording into 8 snippets each - records = split_recording(records, cfg.num_slices) - - train_records, val_records = split(records, cfg.train_split, cfg.seed) - - train_path = os.path.join(cfg.output_dir, "train.h5") - val_path = os.path.join(cfg.output_dir, "val.h5") - - write_hdf5_file(train_records, train_path, "training_data") - write_hdf5_file(val_records, val_path, "validation_data") - - return train_path, val_path - -def main(): - settings = get_app_settings() - dataset_cfg = settings.dataset - train_path, val_path = generate_datasets(dataset_cfg) - print(f"✅ Train: {train_path}\n✅ Val: {val_path}") - - -if __name__ == "__main__": - main() diff --git a/scripts/split_dataset.py b/scripts/split_dataset.py deleted file mode 100644 index 894512a..0000000 --- a/scripts/split_dataset.py +++ /dev/null @@ -1,43 +0,0 @@ -import random -from collections import defaultdict - - -def split(dataset, train_frac=0.8, seed=42): - """ - Splits a dataset into smaller datasets based on the specified lengths. - - Parameters: - dataset (list): The dataset to be split. - lengths (list): A list of lengths for each split. - - Returns: - list: A list of split datasets. - """ - N = len(dataset) - target = int(N * train_frac) - - by_rec = defaultdict(list) - for i, (_, md) in enumerate(dataset): - by_rec[md["rec_id"]].append(i) - - rec_ids = list(by_rec.keys()) - random.seed(seed) - random.shuffle(rec_ids) - - train_set = set() - count = 0 - for rec_id in rec_ids: - index = by_rec[rec_id] - if count + len(index) <= target: - train_set.update(index) - count += len(index) - - validation_set = set(range(N)) - train_set - - print(f"Train set :{len(train_set)}") - print(f"val set :{len(validation_set)}") - - train_records = [dataset[i] for i in sorted(train_set)] - val_records = [dataset[i] for i in sorted(validation_set)] - - return train_records, val_records