Ejemplo n.º 1
0
from umbmid import get_proj_path, verify_path, get_script_logger
from umbmid.loadsave import save_pickle, save_mat, load_pickle
from umbmid.content import get_class_labels
from umbmid.ai.traintestsplit import split_to_train_test

###############################################################################

# Define the directory where the clean dataset is located
__DATA_DIR = os.path.join(get_proj_path(), 'datasets/gen-one/clean/')

###############################################################################

# Define the output directory where the train/test set files will
# be saved
__OUTPUT_DIR = os.path.join(get_proj_path(), 'datasets/gen-one/clean/')
verify_path(__OUTPUT_DIR)

###############################################################################

if __name__ == '__main__':

    logger = get_script_logger(__file__)  # Get logger

    # Load the dataset to be split and its metadata
    fd_data = load_pickle(os.path.join(__DATA_DIR, 'fd_data_s11_emp.pickle'))
    metadata = load_pickle(os.path.join(__DATA_DIR, 'md_list_s11_emp.pickle'))
    labels = get_class_labels(metadata)  # Get the class labels

    # Split into the train and test sets, and return the random seed
    # NOTE: The random seed that was used to make the train/test sets
    #       that produced the results presented in the EuCAP2020 paper
Ejemplo n.º 2
0
def make_clean_files(gen='one',
                     cal_type='emp',
                     sparams='s11',
                     logger=null_logger):
    """Makes and saves the clean .mat and .pickle files

    Parameters
    ----------
    gen : str
        The generation of data to be used, must be in ['one', 'two']
    cal_type : str
        The type of calibration to be performed, must be in
        ['emp', 'adi'
    sparams : str
        The type of sparam to save, must be in ['s11', 's21']
    logger :
        A logger for logging progress
    """

    assert gen in ['one', 'two', 'three'], \
        "Error: gen must be in ['one', 'two', 'three']"

    assert sparams in ['s11', 's21'], \
        "Error: sparams must be in ['s11', 's21']"

    # Load the frequency-domain dataset
    logger.info('\tImporting FD data and metadata...')
    fd_data, fd_md = import_fd_cal_dataset(cal_type=cal_type,
                                           prune=True,
                                           gen=gen,
                                           sparams=sparams,
                                           logger=logger)

    logger.info('\tImport complete. Saving to .pickle and .mat files...')

    # Define an output dir for this generation of dataset
    this_output_dir = os.path.join(__OUTPUT_DIR, 'gen-%s/clean/' % gen)
    verify_path(this_output_dir)  # Verify that this dir exists

    logger.info('Num data samples:\t\t%s' % np.size(fd_data, axis=0))
    logger.info('Length of metadata:\t\t%s' % len(fd_md))

    # Save the frequency-domain data and metadata
    save_pickle(
        fd_md,
        os.path.join(this_output_dir,
                     'md_list_%s_%s.pickle' % (sparams, cal_type)))
    save_pickle(
        fd_data,
        os.path.join(this_output_dir,
                     'fd_data_%s_%s.pickle' % (sparams, cal_type)))
    save_mat(
        fd_data, 'fd_data_%s' % sparams,
        os.path.join(this_output_dir,
                     'fd_data_%s_%s.mat' % (sparams, cal_type)))
    save_mat(
        fd_md, 'md_%s' % sparams,
        os.path.join(this_output_dir,
                     'md_list_%s_%s.mat' % (sparams, cal_type)))

    logger.info('\tComplete saving clean data files.')
Ejemplo n.º 3
0
University of Manitoba
October 21st, 2019
"""

import os
import numpy as np

from umbmid import get_proj_path, verify_path, get_script_logger
from umbmid.loadsave import save_pickle, save_mat
from umbmid.build import (import_fd_dataset, import_metadata,
                          import_metadata_df)

###############################################################################

__OUTPUT_DIR = os.path.join(get_proj_path(), 'datasets/')
verify_path(__OUTPUT_DIR)

__DATA_DIR = os.path.join(get_proj_path(), 'datasets/')

###############################################################################

# The possible sparams for each generation of dataset
possible_sparams = {
    'one': ['s11'],
    'two': ['s11', 's21'],
}

###############################################################################

if __name__ == '__main__':
University of Manitoba
October 21st, 2019
"""

import os
import numpy as np

from umbmid import get_proj_path, verify_path, get_script_logger
from umbmid.loadsave import save_pickle, save_mat
from umbmid.build import (import_fd_dataset, import_metadata,
                          import_metadata_df)

###############################################################################

__OUTPUT_DIR = os.path.join(get_proj_path(), 'datasets/')
verify_path(__OUTPUT_DIR)

__DATA_DIR = os.path.join(get_proj_path(), 'datasets/')

###############################################################################

# The possible sparams for each generation of dataset
possible_sparams = {
    'one': ['s11'],
    'two': ['s11', 's21'],
    'three': ['s11', 's21'],
}

###############################################################################

if __name__ == '__main__':