def import_medusa_data(mat_filename, config_file):
    """Import measurement data (a .mat file) of the FZJ EIT160 system. This
    data format is identified as 'FZJ-EZ-2017'.

    Parameters
    ----------
    mat_filename: string
        filename to the .mat data file. Note that only MNU0 single-potentials
        are supported!
    config_file: string
        filename for configuration file. The configuration file contains N rows
        with 4 columns each (a, b, m, n)

    Returns
    -------

    """
    df_emd, df_md = _read_mat_mnu0(mat_filename)

    # 'configs' can be a numpy array or a filename
    if not isinstance(config_file, np.ndarray):
        configs = np.loadtxt(config_file).astype(int)
    else:
        configs = config_file

    # construct four-point measurements via superposition
    print('constructing four-point measurements')
    quadpole_list = []

    if df_emd is not None:
        index = 0
        for Ar, Br, M, N in configs:
            # print('constructing', Ar, Br, M, N)
            # the order of A and B doesn't concern us
            A = np.min((Ar, Br))
            B = np.max((Ar, Br))

            # first choice: correct ordering
            query_M = df_emd.query('a=={0} and b=={1} and p=={2}'.format(
                A, B, M
            ))
            query_N = df_emd.query('a=={0} and b=={1} and p=={2}'.format(
                A, B, N
            ))

            if query_M.size == 0 or query_N.size == 0:
                continue

            index += 1

            # keep these columns as they are (no subtracting)
            keep_cols = [
                'datetime',
                'frequency',
                'a', 'b',
                'Zg1', 'Zg2', 'Zg3',
                'Is',
                'Il',
                'Zg',
                'Iab',
            ]

            df4 = pd.DataFrame()
            diff_cols = ['Zt', ]
            df4[keep_cols] = query_M[keep_cols]
            for col in diff_cols:
                df4[col] = query_M[col].values - query_N[col].values
            df4['m'] = query_M['p'].values
            df4['n'] = query_N['p'].values

            quadpole_list.append(df4)

    if quadpole_list:
        dfn = pd.concat(quadpole_list)
        Rsign = np.sign(dfn['Zt'].real)
        dfn['r'] = Rsign * np.abs(dfn['Zt'])
        dfn['Vmn'] = dfn['r'] * dfn['Iab']
        dfn['rpha'] = np.arctan2(
            np.imag(dfn['Zt'].values),
            np.real(dfn['Zt'].values)
        ) * 1e3
    else:
        dfn = pd.DataFrame()

    return dfn, df_md
def import_medusa_data ( mat_filename , config_file ) : df_emd , df_md = _read_mat_mnu0 ( mat_filename ) if not isinstance ( config_file , np . ndarray ) : configs = np . loadtxt ( config_file ) . astype ( int ) else : configs = config_file print ( 'constructing four-point measurements' ) quadpole_list = [ ] if df_emd is not None : index = 0 for Ar , Br , M , N in configs : A = np . min ( ( Ar , Br ) ) B = np . max ( ( Ar , Br ) ) query_M = df_emd . query ( 'a=={0} and b=={1} and p=={2}' . format ( A , B , M ) ) query_N = df_emd . query ( 'a=={0} and b=={1} and p=={2}' . format ( A , B , N ) ) if query_M . size == 0 or query_N . size == 0 : continue index += 1 keep_cols = [ 'datetime' , 'frequency' , 'a' , 'b' , 'Zg1' , 'Zg2' , 'Zg3' , 'Is' , 'Il' , 'Zg' , 'Iab' , ] df4 = pd . DataFrame ( ) diff_cols = [ 'Zt' , ] df4 [ keep_cols ] = query_M [ keep_cols ] for col in diff_cols : df4 [ col ] = query_M [ col ] . values - query_N [ col ] . values df4 [ 'm' ] = query_M [ 'p' ] . values df4 [ 'n' ] = query_N [ 'p' ] . values quadpole_list . append ( df4 ) if quadpole_list : dfn = pd . concat ( quadpole_list ) Rsign = np . sign ( dfn [ 'Zt' ] . real ) dfn [ 'r' ] = Rsign * np . abs ( dfn [ 'Zt' ] ) dfn [ 'Vmn' ] = dfn [ 'r' ] * dfn [ 'Iab' ] dfn [ 'rpha' ] = np . arctan2 ( np . imag ( dfn [ 'Zt' ] . values ) , np . real ( dfn [ 'Zt' ] . values ) ) * 1e3 else : dfn = pd . DataFrame ( ) return dfn , df_md
Import measurement data (a .mat file) of the FZJ EIT160 system. This
    data format is identified as 'FZJ-EZ-2017'.

    Parameters
    ----------
    mat_filename: string
        filename to the .mat data file. Note that only MNU0 single-potentials
        are supported!
    config_file: string
        filename for configuration file. The configuration file contains N rows
        with 4 columns each (a, b, m, n)

    Returns
    -------