示例#1
0
def incremental_net_import_analysis():
    base_path = Path().cwd() / 'result_data'
    incr_path = base_path / 'incremental setup - sept'

    oemof_baseline = load_oemof_costs(
        get_oemof_results(base_path, 'oemof_baseline_result_pvol.oemof'))
    hal_sim_name = 'hal_baseline_result_pvol'
    hal_baseline = hal_load_import_kwh(base_path / hal_sim_name, hal_sim_name)
    split_24h = load_oemof_costs(
        get_oemof_split_results(incr_path / 'sliced_24h', 30))
    split_12h = load_oemof_costs(
        get_oemof_split_results(incr_path / 'sliced_12h', 60))
    split_6h = load_oemof_costs(
        get_oemof_split_results(incr_path / 'sliced_6h', 120))

    fig, axes = plt.subplots(nrows=2)
    total_hal_baseline = hal_baseline['wh_total'] / 1000
    total_oemof_baseline = oemof_baseline['wh_total'] / 1000
    total_oemof_24h = split_24h['wh_total'] / 1000
    total_oemof_12h = split_12h['wh_total'] / 1000
    total_oemof_6h = split_6h['wh_total'] / 1000

    mixed_costs = pd.DataFrame(
        {
            'BL HAL': total_hal_baseline,
            'BL OEMOF': total_oemof_baseline,
            '24h split': total_oemof_24h,
            '12h split': total_oemof_12h,
            '6h split': total_oemof_6h,
        },
        index=total_oemof_baseline.index)
    mixed_costs.cumsum().plot(ax=axes[0]).set_ylabel('KWh')
    total_plot = mixed_costs.sum().plot.bar(ax=axes[1], grid=True)
    total_plot.set_ylabel('KWh')
    total_plot.set_xlabel('t')
    fig.subplots_adjust(left=0.12,
                        right=0.97,
                        top=0.92,
                        bottom=0.19,
                        hspace=0.53)
    plt.savefig("praktikumsbericht/images/splits_total.pdf")

    fig, axes = plt.subplots(nrows=1)
    mixed_costs.boxplot(grid=True, showfliers=False, ax=axes)
    dataframe_to_stat_table(incr_path / 'stats.csv', mixed_costs)

    fig.subplots_adjust(left=0.12,
                        right=0.96,
                        top=0.93,
                        bottom=0.07,
                        hspace=0.20)
    # plt.show()
    plt.savefig("praktikumsbericht/images/splits_peaks.pdf")
示例#2
0
def real_data_net_import_analysis():
    base_path = Path().cwd() / 'result_data'
    sept_setup_path = base_path / 'schedule vs real - sept'

    oemof_baseline = load_oemof_costs(get_oemof_results(sept_setup_path, 'baseline_pred.oemof', True))
    hal_baseline = hal_load_import_kwh(sept_setup_path / 'baseline_pred', 'baseline_pred')

    oemof_sept = load_oemof_costs(get_oemof_results(sept_setup_path, 'real_data_offline.oemof', True))
    hal_sept = hal_load_import_kwh(sept_setup_path / 'real_data_online', 'real_data_online')

    total_hal_baseline = hal_baseline['wh_total'] / 1000
    total_oemof_baseline = oemof_baseline['wh_total'] / 1000
    total_hal_sept = hal_sept['wh_total'] / 1000
    total_oemof_sept = oemof_sept['wh_total'] / 1000

    mixed_costs = pd.DataFrame({
        'Pred HAL': total_hal_baseline,
        'Pred OEMOF': total_oemof_baseline,
        'Real HAL': total_hal_sept,
        'Real OEMOF': total_oemof_sept,
    }, index=total_oemof_baseline.index)

    fig, axes = plt.subplots(nrows=1)

    mixed_costs.sum().plot.bar(ax=axes, grid=True).set_ylabel('KWh')
    fig.subplots_adjust(left=0.12, right=0.97, top=0.92, bottom=0.19, hspace=0.53)
    plt.savefig("praktikumsbericht/images/sept_real_total.pdf")
    dataframe_to_stat_table(sept_setup_path / 'stats.csv', mixed_costs)

    hal_stor_load = load_hal_storage_df(sept_setup_path / 'real_data_online', 'real_data_online')[0]['power[W]']
    pred_oemof_results = get_oemof_results(sept_setup_path, 'baseline_pred.oemof', exclude_storage=True)
    real_oemof_results = get_oemof_results(sept_setup_path, 'real_data_offline.oemof', exclude_storage=True)
    oemof_stor_load = real_oemof_results['b1_data'][(('b1', 'sink_storage'), 'flow')] - real_oemof_results['b1_data'][(('source_storage', 'b1'), 'flow')]
    pv_pred = pred_oemof_results['b1_data'][(('source_pv', 'b1'), 'flow')]
    pv_real = real_oemof_results['b1_data'][(('source_pv', 'b1'), 'flow')]

    pl = DataFrame({
        'HAL controlled Storage Balance': hal_stor_load,
        'Schedule controlled Storage Balance': oemof_stor_load,
        'Pred PV Output': pv_pred,
        'Actual PV Output': pv_real,
    }, index=real_oemof_results['b1_data'].index)
    corr = pl.corr()
    # print(corr.to_latex())
    print(corr.to_latex(open("praktikumsbericht/images/sept_real_correlation.tex", 'w'),
                        label='t/res/real',
                        header=['HAL', 'Schedule', 'Pred PV', 'Actual PV'],
                        caption='Correlation between PV input and storage consumption',
                        float_format="%.2f"))
    fig, axes = plt.subplots(nrows=1)
    pl["2016-09-01"].plot(ax=axes)
    axes.set_ylabel('W')
    plt.savefig("praktikumsbericht/images/sept_real_example.pdf")

    # Percentiles
    fig, axes = plt.subplots(nrows=1)
    boxplot = mixed_costs.boxplot(grid=True, showfliers=False, ax=axes)
    boxplot.set_ylabel('KWh')
    fig.subplots_adjust(left=0.12, right=0.96, top=0.93, bottom=0.07, hspace=0.20)
    plt.savefig("praktikumsbericht/images/sept_real_peaks.pdf")

    dataframe_to_stat_table(sept_setup_path / 'stats.csv', mixed_costs)
示例#3
0
def real_data_net_import_analysis():
    base_path = Path().cwd() / 'result_data'
    sept_setup_path = base_path / 'schedule vs real - sept'
    dec_setup_path = base_path / 'schedule vs real - dec'

    sept_total_hal_baseline, sept_total_oemof_baseline, sept_total_hal, sept_total_oemof = get_baseline(
        sept_setup_path)
    dec_total_hal_baseline, dec_total_oemof_baseline, dec_total_hal, dec_total_oemof = get_baseline(
        dec_setup_path)

    mixed_costs = pd.DataFrame(
        {
            'Sept Pred HAL': sept_total_hal_baseline,
            'Sept Pred OEMOF': sept_total_oemof_baseline,
            'Sept Real HAL': sept_total_hal,
            'Sept Real OEMOF': sept_total_oemof,
            'Dec Pred HAL': dec_total_hal_baseline,
            'Dec Pred OEMOF': dec_total_oemof_baseline,
            'Dec Real HAL': dec_total_hal,
            'Dec Real OEMOF': dec_total_oemof,
        },
        index=pd.date_range('2016-09-01', '2017-01-01', freq='min'))

    fig, axes = plt.subplots(nrows=1)

    summed = mixed_costs.sum()
    summed.plot.bar(ax=axes, grid=True).set_ylabel('KWh')
    fig.subplots_adjust(left=0.12,
                        right=0.97,
                        top=0.92,
                        bottom=0.19,
                        hspace=0.53)
    plt.savefig("praktikumsbericht/images/dec_real_total.pdf")
    dataframe_to_stat_table(dec_setup_path / 'stats.csv', mixed_costs)

    ratios = DataFrame(
        {
            'HAL Pred/Real': [
                summed['Sept Pred HAL'] / summed['Sept Real HAL'],
                summed['Dec Pred HAL'] / summed['Dec Real HAL']
            ],
            'OEMOF Pred/Real': [
                summed['Sept Pred OEMOF'] / summed['Sept Real OEMOF'],
                summed['Dec Pred OEMOF'] / summed['Dec Real OEMOF']
            ],
            'Pred OEMOF/HAL': [
                summed['Sept Pred OEMOF'] / summed['Sept Pred HAL'],
                summed['Dec Pred OEMOF'] / summed['Dec Pred HAL']
            ],
            'Real OEMOF/HAL': [
                summed['Sept Real OEMOF'] / summed['Sept Real HAL'],
                summed['Dec Real OEMOF'] / summed['Dec Real HAL']
            ],
        },
        index=['September', 'December'])
    dataframe_to_stat_table(dec_setup_path / 'ratios.csv', ratios)

    diff = ratios[['Pred OEMOF/HAL', 'Real OEMOF/HAL']].diff(axis='columns')[[
        'Real OEMOF/HAL'
    ]].rename({'Real OEMOF/HAL': 'Real OEMOF/HAL - PRED OEMOF/HAL'},
              axis='columns')
    dataframe_to_stat_table(dec_setup_path / 'diff.csv', diff)
    diff.to_latex(
        open("praktikumsbericht/images/real_data_diff.tex", 'w'),
        label='t/res/diff',
        caption='Difference between the ratio of HALs and OEMOFs net import ..',
        float_format="%.2f")

    # Percentiles
    fig, axes = plt.subplots(nrows=1)
    boxplot = mixed_costs.boxplot(grid=True, showfliers=False, ax=axes)
    boxplot.set_ylabel('kWh')
    fig.subplots_adjust(left=0.12,
                        right=0.96,
                        top=0.93,
                        bottom=0.07,
                        hspace=0.20)
    plt.savefig("praktikumsbericht/images/dec_real_peaks.pdf")