umbmid/build.py
def import_fd_dataset(gen='one', sparams='s11', logger=null_logger):
    """Load the freq-domain s-params of each sample in the dataset

    Loads the .txt raw data files of the measured S-parameters in the
    frequency domain for each scan, and returns as an array.

    Parameters
    ----------
    gen : str
        The generation of dataset to use, must be in ['one', 'two']
    sparams : str
        Must be in ['s11', 's21'], indicates which type of s-param to
        import
    logger :
        Logging object for recording progress

    Returns
    -------
    fd_dataset : array_like
        The S-parameters in the frequency-domain for each scan
    """

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

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

    this_data_dir = os.path.join(__DATA_DIR, 'gen-%s/raw/' % gen)

    if sparams in ['s11']:
        sparam_str = 'Mono'
    else:
        sparam_str = 'Multi'

    # Init list for storing the S-parameters for each scan
    fd_dataset = []

    # For each experimental session in the dataset
    for expt_session in os.listdir(this_data_dir):

        # If the expt_session is a directory
        if os.path.isdir(os.path.join(this_data_dir, expt_session)):

            logger.info('Working on:\t%s...' % expt_session)

            # Get the path to the -metadata.csv file for this
            # expt_session
            metadata_path = os.path.join(this_data_dir, expt_session,
                                         expt_session + '-metadata.csv')

            # Load the -metadata.csv file for this expt_session
            session_metadata = np.genfromtxt(metadata_path, delimiter=',',
                                             dtype=str)

            # Get the identifying strings for each experiment in
            # this session as described in the -metadata.csv file
            expt_strs = ['expt%2d' % int(ii) for ii in session_metadata[1:, 0]]

            # Use format 'expt01', 'expt02', etc.
            expt_strs = [ii.replace(' ', '0') for ii in expt_strs]

            # Find the files that are possible experiments
            potential_expts = os.listdir(os.path.join(this_data_dir,
                                                      expt_session))

            # For each potential experiment (file in the session folder)
            for expt in potential_expts:

                # If this is not the -metadata.csv file, and if
                # the file is of the target sparam  ('s11' or 's21')
                if '-metadata.csv' not in expt and sparam_str in expt:

                    logger.info('\t\tLoading expt:\t%s' % expt)

                    # Find the expt name from the .txt file name
                    expt_name = expt.split('_')[1].lower()

                    # Assert that the expt_name matches one of the expts
                    # described in the -metadata.csv file
                    assert expt_name in expt_strs, \
                        'Error: file %s not expected experiment for ' \
                        'session %s' % (expt, expt_session)

                    # If the scan was performed counterclockwise, it
                    # has the identifier string '(foC'
                    if '(foC' in expt.split('_'):

                        # For any counterclockwise scans, convert them
                        # to being clockwise
                        fd_dataset.append(
                            np.flip(load_fd_data(
                                os.path.join(this_data_dir, expt_session,
                                             expt)), axis=1))

                    else:  # If the scan was performed clockwise
                        fd_dataset.append(
                            load_fd_data(os.path.join(this_data_dir,
                                                      expt_session, expt)))

    # Convert the frequency-domain dataset to an np array
    fd_dataset = np.reshape(fd_dataset,
                            [len(fd_dataset), fd_dataset[0].shape[0],
                             fd_dataset[0].shape[1]])

    return fd_dataset
Load the freq-domain s-params of each sample in the dataset

    Loads the .txt raw data files of the measured S-parameters in the
    frequency domain for each scan, and returns as an array.

    Parameters
    ----------
    gen : str
        The generation of dataset to use, must be in ['one', 'two']
    sparams : str
        Must be in ['s11', 's21'], indicates which type of s-param to
        import
    logger :
        Logging object for recording progress

    Returns
    -------
    fd_dataset : array_like
        The S-parameters in the frequency-domain for each scan
    
Load the freq-domain s-params of each sample in the dataset
Loads the .txt raw data files of the measured S-parameters in the
frequency domain for each scan, and returns as an array.
Load the freq - domain s - params of each sample in the dataset Loads the . txt raw data files of the measured S - parameters in the frequency domain for each scan and returns as an array .
def import_fd_dataset(gen='one', sparams='s11', logger=null_logger):
    assert sparams in ['s11', 's21'], \
        "Error: sparams must be in ['s11', 's21']"
    assert gen in ['one', 'two', 'three'], \
        "Error: gen must be in ['one', 'two', 'three']"
    this_data_dir = os.path.join(__DATA_DIR, 'gen-%s/raw/' % gen)
    if sparams in ['s11']:
        sparam_str = 'Mono'
    else:
        sparam_str = 'Multi'
    fd_dataset = []
    for expt_session in os.listdir(this_data_dir):
        if os.path.isdir(os.path.join(this_data_dir, expt_session)):
            logger.info('Working on:\t%s...' % expt_session)
            metadata_path = os.path.join(this_data_dir, expt_session,
                                         expt_session + '-metadata.csv')
            session_metadata = np.genfromtxt(metadata_path, delimiter=',',
                                             dtype=str)
            expt_strs = ['expt%2d' % int(ii) for ii in session_metadata[1:, 0]]
            expt_strs = [ii.replace(' ', '0') for ii in expt_strs]
            potential_expts = os.listdir(os.path.join(this_data_dir,
                                                      expt_session))
            for expt in potential_expts:
                if '-metadata.csv' not in expt and sparam_str in expt:
                    logger.info('\t\tLoading expt:\t%s' % expt)
                    expt_name = expt.split('_')[1].lower()
                    assert expt_name in expt_strs, \
                        'Error: file %s not expected experiment for ' \
                        'session %s' % (expt, expt_session)
                    if '(foC' in expt.split('_'):
                        fd_dataset.append(
                            np.flip(load_fd_data(
                                os.path.join(this_data_dir, expt_session,
                                             expt)), axis=1))
                    else:  
                        fd_dataset.append(
                            load_fd_data(os.path.join(this_data_dir,
                                                      expt_session, expt)))
    fd_dataset = np.reshape(fd_dataset,
                            [len(fd_dataset), fd_dataset[0].shape[0],
                             fd_dataset[0].shape[1]])
    return fd_dataset
def import_fd_dataset ( gen = 'one' , sparams = 's11' , logger = null_logger ) : assert sparams in [ 's11' , 's21' ] , "Error: sparams must be in ['s11', 's21']" assert gen in [ 'one' , 'two' , 'three' ] , "Error: gen must be in ['one', 'two', 'three']" this_data_dir = os . path . join ( __DATA_DIR , 'gen-%s/raw/' % gen ) if sparams in [ 's11' ] : sparam_str = 'Mono' else : sparam_str = 'Multi' fd_dataset = [ ] for expt_session in os . listdir ( this_data_dir ) : if os . path . isdir ( os . path . join ( this_data_dir , expt_session ) ) : logger . info ( 'Working on:\t%s...' % expt_session ) metadata_path = os . path . join ( this_data_dir , expt_session , expt_session + '-metadata.csv' ) session_metadata = np . genfromtxt ( metadata_path , delimiter = ',' , dtype = str ) expt_strs = [ 'expt%2d' % int ( ii ) for ii in session_metadata [ 1 : , 0 ] ] expt_strs = [ ii . replace ( ' ' , '0' ) for ii in expt_strs ] potential_expts = os . listdir ( os . path . join ( this_data_dir , expt_session ) ) for expt in potential_expts : if '-metadata.csv' not in expt and sparam_str in expt : logger . info ( '\t\tLoading expt:\t%s' % expt ) expt_name = expt . split ( '_' ) [ 1 ] . lower ( ) assert expt_name in expt_strs , 'Error: file %s not expected experiment for ' 'session %s' % ( expt , expt_session ) if '(foC' in expt . split ( '_' ) : fd_dataset . append ( np . flip ( load_fd_data ( os . path . join ( this_data_dir , expt_session , expt ) ) , axis = 1 ) ) else : fd_dataset . append ( load_fd_data ( os . path . join ( this_data_dir , expt_session , expt ) ) ) fd_dataset = np . reshape ( fd_dataset , [ len ( fd_dataset ) , fd_dataset [ 0 ] . shape [ 0 ] , fd_dataset [ 0 ] . shape [ 1 ] ] ) return fd_dataset
Load the freq-domain s-params of each sample in the dataset
Loads the .txt raw data files of the measured S-parameters in the
frequency domain for each scan, and returns as an array.
Load the freq - domain s - params of each sample in the dataset Loads the . txt raw data files of the measured S - parameters in the frequency domain for each scan and returns as an array .
"""Load the freq-domain s-params of each sample in the dataset

    Loads the .txt raw data files of the measured S-parameters in the
    frequency domain for each scan, and returns as an array.

    Parameters
    ----------
    gen : str
        The generation of dataset to use, must be in ['one', 'two']
    sparams : str
        Must be in ['s11', 's21'], indicates which type of s-param to
        import
    logger :
        Logging object for recording progress

    Returns
    -------
    fd_dataset : array_like
        The S-parameters in the frequency-domain for each scan
    """ # Init list for storing the S-parameters for each scan
 # For each experimental session in the dataset
 # If the expt_session is a directory
 # Get the path to the -metadata.csv file for this
 # expt_session
 # Load the -metadata.csv file for this expt_session
 # Get the identifying strings for each experiment in
 # this session as described in the -metadata.csv file
 # Use format 'expt01', 'expt02', etc.
 # Find the files that are possible experiments
 # For each potential experiment (file in the session folder)
 # If this is not the -metadata.csv file, and if
 # the file is of the target sparam  ('s11' or 's21')
 # Find the expt name from the .txt file name
 # Assert that the expt_name matches one of the expts
 # described in the -metadata.csv file
 # If the scan was performed counterclockwise, it
 # has the identifier string '(foC'
 # For any counterclockwise scans, convert them
 # to being clockwise
 # If the scan was performed clockwise
 # Convert the frequency-domain dataset to an np array

The S-parameters in the frequency-domain for each scan
The S - parameters in the frequency - domain for each scan
array_like

gen
The generation of dataset to use, must be in ['one', 'two']
The generation of dataset to use must be in [ ' one ' ' two ' ]
sparams
Must be in ['s11', 's21'], indicates which type of s-param to
import
Must be in [ ' s11 ' ' s21 ' ] indicates which type of s - param to import
logger
Logging object for recording progress
Logging object for recording progress