def main(args):
    data_file_list = tl.get_data_file_list(args.library)
    if args.list:
        tl.print_list(data_file_list)
        sys.exit(0)
    data = tl.load_data_file(data_file_list, args.select)

    if not args.static:
        logging.debug('Remove zero velocity samples')
        data = ntp.remove_non_positive_velocity_samples(data)

    if args.ue == 'e398':
        # Rename MAC downlink throughput in Application downlink throughput if need be
        ntp.process_data(data, ntp.process_lte_rename_mac_to_app)

    # Get basic data
    ntp.process_data(data, ntp.process_lte_app_throughput)
    ntp.process_data(data, ntp.process_lte_pdcp_throughput)

    column_list = [
        'PDCP downlink throughput', 'Application throughput downlink'
    ]
    if args.select is None:
        df = tl.concat_pandas_data([df[column_list] for df in data])
    else:
        df = data

    print(df['PDCP downlink throughput'].describe())
    print(df['Application throughput downlink'].describe())

    # Normalize
    f_norm = lambda x: x / 1e6

    plt.ion()
    plt.figure()
    plt.subplot2grid((2, 2), (0, 0), colspan=2)
    x = np.arange(0, 120, 1)
    dpl.plot_ecdf_pair(
        df['Application throughput downlink'].dropna().apply(f_norm),
        df['PDCP downlink throughput'].dropna().apply(f_norm), x,
        'Application th.', 'PDCP th.', 'Mbit/s')
    plt.legend(loc=0)
    plt.subplot2grid((2, 2), (1, 0), colspan=1)
    dpl.plot_density(
        df['Application throughput downlink'].dropna().apply(f_norm), x,
        'App. th.', 'Mbit/s')
    plt.subplot2grid((2, 2), (1, 1), colspan=1)
    dpl.plot_density(df['PDCP downlink throughput'].dropna().apply(f_norm), x,
                     'PDCP th.', 'Mbit/s')

    if args.print:
        plt.savefig(args.print, dpi=300, bbox_inches='tight')

    input('Press any key')
def main(args):
    data_file_list = tl.get_data_file_list(args.library)
    if args.list:
        tl.print_list(data_file_list)
        sys.exit(0)
    data = tl.load_data_file(data_file_list, args.select)

    if not args.static:
        logging.debug("Remove zero velocity samples")
        data = ntp.remove_non_positive_velocity_samples(data)

    if args.ue == "e398":
        # Rename MAC downlink throughput in Application downlink throughput if need be
        ntp.process_data(data, ntp.process_lte_rename_mac_to_app)

    # Get basic data
    ntp.process_data(data, ntp.process_lte_app_throughput)
    ntp.process_data(data, ntp.process_lte_pdcp_throughput)

    column_list = ["PDCP downlink throughput", "Application throughput downlink"]
    if args.select is None:
        df = tl.concat_pandas_data([df[column_list] for df in data])
    else:
        df = data

    print(df["PDCP downlink throughput"].describe())
    print(df["Application throughput downlink"].describe())

    # Normalize
    f_norm = lambda x: x / 1e6

    plt.ion()
    plt.figure()
    plt.subplot2grid((2, 2), (0, 0), colspan=2)
    x = np.arange(0, 120, 1)
    dpl.plot_ecdf_pair(
        df["Application throughput downlink"].dropna().apply(f_norm),
        df["PDCP downlink throughput"].dropna().apply(f_norm),
        x,
        "Application th.",
        "PDCP th.",
        "Mbit/s",
    )
    plt.legend(loc=0)
    plt.subplot2grid((2, 2), (1, 0), colspan=1)
    dpl.plot_density(df["Application throughput downlink"].dropna().apply(f_norm), x, "App. th.", "Mbit/s")
    plt.subplot2grid((2, 2), (1, 1), colspan=1)
    dpl.plot_density(df["PDCP downlink throughput"].dropna().apply(f_norm), x, "PDCP th.", "Mbit/s")

    if args.print:
        plt.savefig(args.print, dpi=300, bbox_inches="tight")

    input("Press any key")
def main(args):
    data_file_list = tl.get_data_file_list(args.library)
    if args.list:
        tl.print_list(data_file_list)
        sys.exit(0)
    data = tl.load_data_file(data_file_list, args.select)

    if not args.static:
        logging.debug('Remove zero velocity samples')
        data = ntp.remove_non_positive_velocity_samples(data)

    if args.ue == 'e398':
        # Rename MAC downlink throughput in Application downlink throughput if need be
        ntp.process_data(data, ntp.process_lte_rename_mac_to_app)

    # Get basic data
    ntp.process_data(data, ntp.process_lte_app_bw_prb_util)
    ntp.process_data(data, ntp.process_lte_app_bw_prb_util_bw20)
    ntp.process_data(data, ntp.process_lte_app_bw_prb_util_bw10)
    ntp.process_data(data, ntp.process_lte_app_bw_prb_util_bw15)

    # Spectral efficiency
    ntp.process_data(data, ntp.process_se_bw_norm)

    column_list = [
        'DL bandwidth', 'DL bandwidth full', 'PRB utilization DL',
        'PRB utilization DL full', 'PRB utilization DL 10',
        'PRB utilization DL 15', 'PRB utilization DL 20', 'SE', 'SE norm',
        'SE 10 norm', 'SE 15 norm', 'SE 20 norm'
    ]
    if args.select is None:
        df = tl.concat_pandas_data([df[column_list] for df in data])
    else:
        df = data

    print(df['SE'].describe())
    print(df['SE norm'].describe())

    # Remove outliers because of bandwidth normalization issues
    df['SE norm'][df['SE norm'] > 7.5] = np.nan

    print('90% percentile for SE norm: {:.1f} bit/s/Hz'.format(
        np.percentile(df['SE norm'].dropna(), 90)))
    print('95% percentile for SE norm: {:.1f} bit/s/Hz'.format(
        np.percentile(df['SE norm'].dropna(), 95)))
    print('99% percentile for SE norm: {:.1f} bit/s/Hz'.format(
        np.percentile(df['SE norm'].dropna(), 99)))

    print(df['SE 10 norm'].describe())
    print(df['SE 15 norm'].describe())
    print(df['SE 20 norm'].describe())
    plt.ion()

    plt.figure()
    plt.subplot2grid((2, 2), (0, 0), colspan=2)
    x = np.arange(0, 8.1, 0.1)
    dpl.plot_ecdf_pair(df['SE norm'].dropna(), df['SE'].dropna(), x,
                       'Spectral efficiency (PRB norm.)',
                       'Spectral efficiency', 'bit/s/Hz')
    plt.legend(loc=0)
    plt.subplot2grid((2, 2), (1, 0), colspan=1)
    dpl.plot_density(df['SE'].replace([np.inf, -np.inf], np.nan).dropna(), x,
                     'Spectral efficiency', 'bit/s/Hz')
    plt.subplot2grid((2, 2), (1, 1), colspan=1)
    dpl.plot_density(
        df['SE norm'].where(df['SE norm'] < 8).replace([np.inf, -np.inf],
                                                       np.nan).dropna(), x,
        'Spectral efficiency (PRB norm.)', 'bit/s/Hz')

    if args.print:
        plt.savefig(args.print[0], dpi=300, bbox_inches='tight')

    plt.figure()
    if len(df['SE 15 norm'].dropna()) > 0:
        dpl.plot_ecdf_triplet(df['SE 10 norm'].dropna(),
                              df['SE norm'].dropna(),
                              df['SE 15 norm'].dropna(), x,
                              'Spectral efficiency 10 MHz (PRB norm.)\n',
                              'Spectral efficiency (PRB norm.)\n',
                              'Spectral efficiency 15 MHz (PRB norm.)',
                              'bit/s/Hz')
    else:
        dpl.plot_ecdf_pair(df['SE 10 norm'].dropna(), df['SE norm'].dropna(),
                           x, 'Spectral efficiency 10 MHz (PRB norm.)\n',
                           'Spectral efficiency (PRB norm.)\n', 'bit/s/Hz')
    plt.legend(loc=0)
    if args.print:
        plt.savefig(args.print[1], dpi=300, bbox_inches='tight')

    plt.figure()
    if len(df['SE 15 norm'].dropna()) > 0:
        dpl.plot_ecdf_quad(df['SE 10 norm'].dropna(), df['SE norm'].dropna(),
                           df['SE 15 norm'].dropna(), df['SE'].dropna(), x,
                           'SE 10 MHz (PRB norm.)', 'SE (PRB norm.)',
                           'SE 15 MHz (PRB norm.)', 'SE', 'bit/s/Hz')
        plt.xlabel('[bit/s/Hz]')
    else:
        dpl.plot_ecdf_triplet(df['SE 10 norm'].dropna(),
                              df['SE norm'].dropna(), df['SE'].dropna(), x,
                              'Spectral efficiency 10 MHz (PRB norm.)\n',
                              'Spectral efficiency (PRB norm.)\n',
                              'Spectral efficiency', 'bit/s/Hz')
    plt.legend(loc='best')
    plt.tight_layout()
    if args.print:
        plt.savefig(args.print[2], dpi=300, bbox_inches='tight')

    input('Press any key')
def main(args):
    data_file_list = tl.get_data_file_list(args.library)
    if args.list:
        tl.print_list(data_file_list)
        sys.exit(0)
    data = tl.load_data_file(data_file_list,args.select)

    if not args.static:
        logging.debug('Remove zero velocity samples')
        data = ntp.remove_non_positive_velocity_samples(data)

    if args.ue == 'e398':
        # Rename MAC downlink throughput in Application downlink throughput if need be
        ntp.process_data(data,ntp.process_lte_rename_mac_to_app)

    # Get basic data
    ntp.process_data(data,ntp.process_lte_app_bw_prb_util)
    ntp.process_data(data,ntp.process_lte_app_bw_prb_util_bw20)
    ntp.process_data(data,ntp.process_lte_app_bw_prb_util_bw10)
    ntp.process_data(data,ntp.process_lte_app_bw_prb_util_bw15)

    column_list = ['Application throughput downlink',
                   'Application throughput downlink 10',
                   'Application throughput downlink 15',
                   'Application throughput downlink 20']
    if args.select is None:
        df = tl.concat_pandas_data([df[column_list] for df in data ])
    else:
        df = data

    print(df['Application throughput downlink'].describe())
    print(df['Application throughput downlink 10'].describe())
    print(df['Application throughput downlink 15'].describe())
    print(df['Application throughput downlink 20'].describe())

    # Normalize
    f_norm = lambda x: x/1e6

    plt.ion()
    plt.figure()
    plt.subplot2grid((2,3), (0,0),colspan=3)
    x = np.arange(0,120,1)
    dpl.plot_ecdf_triplet(df['Application throughput downlink 10'].dropna().apply(f_norm),
                          df['Application throughput downlink'].dropna().apply(f_norm),
                          df['Application throughput downlink 15'].dropna().apply(f_norm),x,
                          'Application th. (10 MHz)',
                          'Application th.',
                          'Application th. (15 MHz)',
                          'Mbit/s')
    plt.legend(loc=0)
    plt.subplot2grid((2,3), (1,0),colspan=1)
    dpl.plot_density(df['Application throughput downlink'].dropna().apply(f_norm),x,
                     'App. th.','Mbit/s')
    plt.subplot2grid((2,3), (1,1),colspan=1)
    dpl.plot_density(df['Application throughput downlink 10'].dropna().apply(f_norm),x,
                     'App. th. 10 MHz','Mbit/s')
    plt.subplot2grid((2,3), (1,2),colspan=1)
    dpl.plot_density(df['Application throughput downlink 15'].dropna().apply(f_norm),x,
                     'App. th. 15 MHz','Mbit/s')

    if args.print:
        plt.savefig(args.print,dpi=300,bbox_inches='tight')

    input('Press any key')
def main(args):
    data_file_list = tl.get_data_file_list(args.library)
    if args.list:
        tl.print_list(data_file_list)
        sys.exit(0)
    data = tl.load_data_file(data_file_list,args.select)

    if not args.static:
        logging.debug('Remove zero velocity samples')
        data = ntp.remove_non_positive_velocity_samples(data)

    if args.ue == 'e398':
        # Rename MAC downlink throughput in Application downlink throughput if need be
        ntp.process_data(data,ntp.process_lte_rename_mac_to_app)

    # Get basic data
    ntp.process_data(data,ntp.process_lte_app_bw_prb_util)
    ntp.process_data(data,ntp.process_lte_app_bw_prb_util_bw20)
    ntp.process_data(data,ntp.process_lte_app_bw_prb_util_bw10)
    ntp.process_data(data,ntp.process_lte_app_bw_prb_util_bw15)

    # Spectral efficiency
    ntp.process_data(data,ntp.process_se_bw_norm)

    column_list = ['DL bandwidth','DL bandwidth full',
                   'PRB utilization DL','PRB utilization DL full',
                   'PRB utilization DL 10','PRB utilization DL 15','PRB utilization DL 20',
                   'SE','SE norm','SE 10 norm','SE 15 norm','SE 20 norm']
    if args.select is None:
        df = tl.concat_pandas_data([df[column_list] for df in data ])
    else:
        df = data


    print(df['SE'].describe())
    print(df['SE norm'].describe())

    # Remove outliers because of bandwidth normalization issues
    df['SE norm'][df['SE norm'] > 7.5] = np.nan

    print('90% percentile for SE norm: {:.1f} bit/s/Hz'.format(np.percentile(df['SE norm'].dropna(),90)))
    print('95% percentile for SE norm: {:.1f} bit/s/Hz'.format(np.percentile(df['SE norm'].dropna(),95)))
    print('99% percentile for SE norm: {:.1f} bit/s/Hz'.format(np.percentile(df['SE norm'].dropna(),99)))

    print(df['SE 10 norm'].describe())
    print(df['SE 15 norm'].describe())
    print(df['SE 20 norm'].describe())
    plt.ion()

    plt.figure()
    plt.subplot2grid((2,2), (0,0),colspan=2)
    x = np.arange(0,8.1,0.1)
    dpl.plot_ecdf_pair(df['SE norm'].dropna(),
                       df['SE'].dropna(),x,
                       'Spectral efficiency (PRB norm.)',
                       'Spectral efficiency',
                       'bit/s/Hz')
    plt.legend(loc=0)
    plt.subplot2grid((2,2), (1,0),colspan=1)
    dpl.plot_density(df['SE'].replace([np.inf, -np.inf], np.nan).dropna(),x,
                     'Spectral efficiency','bit/s/Hz')
    plt.subplot2grid((2,2), (1,1),colspan=1)
    dpl.plot_density(df['SE norm'].where(df['SE norm'] < 8).replace([np.inf, -np.inf], np.nan).dropna(),x,
                     'Spectral efficiency (PRB norm.)','bit/s/Hz')

    if args.print:
        plt.savefig(args.print[0],dpi=300,bbox_inches='tight')

    plt.figure()
    if len(df['SE 15 norm'].dropna()) > 0:
        dpl.plot_ecdf_triplet(df['SE 10 norm'].dropna(),
                              df['SE norm'].dropna(),
                              df['SE 15 norm'].dropna(),x,
                              'Spectral efficiency 10 MHz (PRB norm.)\n',
                              'Spectral efficiency (PRB norm.)\n',
                              'Spectral efficiency 15 MHz (PRB norm.)',
                              'bit/s/Hz')
    else:
        dpl.plot_ecdf_pair(df['SE 10 norm'].dropna(),
                           df['SE norm'].dropna(),x,
                           'Spectral efficiency 10 MHz (PRB norm.)\n',
                           'Spectral efficiency (PRB norm.)\n',
                           'bit/s/Hz')
    plt.legend(loc=0)
    if args.print:
        plt.savefig(args.print[1],dpi=300,bbox_inches='tight')

    plt.figure()
    if len(df['SE 15 norm'].dropna()) > 0:
        dpl.plot_ecdf_quad(df['SE 10 norm'].dropna(),
                           df['SE norm'].dropna(),
                           df['SE 15 norm'].dropna(),
                           df['SE'].dropna(),x,
                           'SE 10 MHz (PRB norm.)',
                           'SE (PRB norm.)',
                           'SE 15 MHz (PRB norm.)','SE',
                           'bit/s/Hz')
        plt.xlabel('[bit/s/Hz]')
    else:
        dpl.plot_ecdf_triplet(df['SE 10 norm'].dropna(),
                              df['SE norm'].dropna(),df['SE'].dropna(),x,
                              'Spectral efficiency 10 MHz (PRB norm.)\n',
                              'Spectral efficiency (PRB norm.)\n','Spectral efficiency',
                              'bit/s/Hz')
    plt.legend (loc='best')
    plt.tight_layout ()
    if args.print:
        plt.savefig(args.print[2],dpi=300,bbox_inches='tight')

    input('Press any key')
def main(args):
    data_file_list = tl.get_data_file_list(args.library)
    if args.list:
        tl.print_list(data_file_list)
        sys.exit(0)
    data = tl.load_data_file(data_file_list, args.select)

    if not args.static:
        logging.debug("Remove zero velocity samples")
        data = ntp.remove_non_positive_velocity_samples(data)

    if args.ue == "e398":
        # Rename MAC downlink throughput in Application downlink throughput if need be
        ntp.process_data(data, ntp.process_lte_rename_mac_to_app)

    # Get basic data
    ntp.process_data(data, ntp.process_lte_app_bw_prb_util)
    ntp.process_data(data, ntp.process_lte_app_bw_prb_util_bw20)
    ntp.process_data(data, ntp.process_lte_app_bw_prb_util_bw10)
    ntp.process_data(data, ntp.process_lte_app_bw_prb_util_bw15)

    # Spectral efficiency
    ntp.process_data(data, ntp.process_se_bw_norm)
    # Alternate version
    ntp.process_data(data, ntp.process_lte_se_rb)

    column_list = [
        "DL bandwidth",
        "DL bandwidth full",
        "PRB utilization DL",
        "PRB utilization DL full",
        "PRB utilization DL 10",
        "PRB utilization DL 15",
        "PRB utilization DL 20",
        "SE",
        "SE norm",
        "SE 10 norm",
        "SE 15 norm",
        "SE 20 norm",
        "SE RB",
        "SE RB norm",
    ]
    if args.select is None:
        df = tl.concat_pandas_data([df[column_list] for df in data])
    else:
        df = data

    print(df["SE"].describe())
    print(df["SE norm"].describe())
    print(df["SE 10 norm"].describe())
    print(df["SE 15 norm"].describe())
    print(df["SE 20 norm"].describe())
    print(df["SE RB"].describe())
    print(df["SE RB norm"].describe())
    plt.ion()

    plt.figure()
    plt.subplot2grid((2, 2), (0, 0), colspan=2)
    x = np.arange(0, 8.1, 0.1)
    dpl.plot_ecdf_pair(
        df["SE norm"].dropna(),
        df["SE"].dropna(),
        x,
        "Spectral efficiency (PRB norm.)",
        "Spectral efficiency",
        "bit/s/Hz",
    )
    plt.legend(loc=0)
    plt.subplot2grid((2, 2), (1, 0), colspan=1)
    dpl.plot_density(df["SE"].replace([np.inf, -np.inf], np.nan).dropna(), x, "Spectral efficiency", "bit/s/Hz")
    plt.subplot2grid((2, 2), (1, 1), colspan=1)
    dpl.plot_density(
        df["SE norm"].where(df["SE norm"] < 8).replace([np.inf, -np.inf], np.nan).dropna(),
        x,
        "Spectral efficiency (PRB norm.)",
        "bit/s/Hz",
    )

    if args.print:
        plt.savefig(args.print[0], dpi=300, bbox_inches="tight")

    plt.figure()
    if len(df["SE 15 norm"].dropna()) > 0:
        dpl.plot_ecdf_triplet(
            df["SE 10 norm"].dropna(),
            df["SE norm"].dropna(),
            df["SE 15 norm"].dropna(),
            x,
            "Spectral efficiency 10 MHz (PRB util. norm.)\n",
            "Spectral efficiency (PRB util. norm.)\n",
            "Spectral efficiency 15 MHz (PRB util. norm.)",
            "bit/s/Hz",
        )
    else:
        dpl.plot_ecdf_pair(
            df["SE 10 norm"].dropna(),
            df["SE norm"].dropna(),
            x,
            "Spectral efficiency 10 MHz (PRB util. norm.)\n",
            "Spectral efficiency (PRB util. norm.)\n",
            "bit/s/Hz",
        )
    plt.legend(loc=0)
    if args.print:
        plt.savefig(args.print[1], dpi=300, bbox_inches="tight")

    plt.figure()
    plt.subplot2grid((2, 2), (0, 0), colspan=2)
    dpl.plot_ecdf_pair(
        df["SE norm"].dropna(),
        df["SE RB norm"].dropna(),
        x,
        "Spectral efficiency (PRB util. norm.)\n",
        "Spectral efficiency (RB norm.)",
        "bit/s/Hz",
    )
    plt.legend(loc=0)
    plt.subplot2grid((2, 2), (1, 0), colspan=1)
    dpl.plot_density(df["SE"].replace([np.inf, -np.inf], np.nan).dropna(), x, "Spectral efficiency", "bit/s/Hz")
    plt.subplot2grid((2, 2), (1, 1), colspan=1)
    dpl.plot_density(df["SE RB norm"].dropna(), x, "Spectral efficiency (RB norm.)", "bit/s/Hz")

    input("Press any key")