def test_if_pie_charts_of_costs_is_stored(self):
     F1.create_plotly_piechart_fig(
         title_of_plot="a_title",
         names=["costs1", "costs2"],
         values=[0.2, 0.8],
         file_name="filename.png",
         file_path=OUTPUT_PATH,
     )
     assert os.path.exists(os.path.join(OUTPUT_PATH, "filename.png")) is True
Beispiel #2
0
def test_fixed_width_text_smaller_than_limit_returns_text():
    txt = "12345"
    assert F1.fixed_width_text(txt, char_num=2) == "12\n34\n5"
Beispiel #3
0
def test_fixed_width_text_smaller_than_limit_returns_text():
    txt = "12345"
    assert txt == F1.fixed_width_text(txt, char_num=10)
Beispiel #4
0
def test_get_color_is_cyclic():
    colors = [1, 2, 3]
    assert F1.get_color(3, colors) == colors[0]
def evaluate_dict(dict_values, path_pdf_report=None, path_png_figs=None):
    """This is the main function of F0. It calls all functions that prepare the simulation output, ie. Storing all simulation output into excellent files, bar charts, and graphs.

    Parameters
    ----------
    dict_values :
        dict Of all input and output parameters up to F0

    path_pdf_report : (str)
        if provided, generate a pdf report of the simulation to the given path

    path_png_figs : (str)
        if provided, generate png figures of the simulation's results to the given path

    Returns
    -------
    type
        NA

    """

    logging.info(
        "Summarizing simulation results to results_timeseries and results_scalars_assets."
    )

    parse_simulation_log(
        path_log_file=os.path.join(
            dict_values[SIMULATION_SETTINGS][PATH_OUTPUT_FOLDER], LOGFILE),
        dict_values=dict_values,
    )

    # storing all flows to exel.
    store_timeseries_all_busses_to_excel(dict_values)

    # Write everything to file with multiple tabs
    store_scalars_to_excel(dict_values)

    store_as_json(
        dict_values,
        dict_values[SIMULATION_SETTINGS][PATH_OUTPUT_FOLDER],
        JSON_WITH_RESULTS,
    )

    # generate png figures
    if path_png_figs is not None:
        # plot demand timeseries
        F1_plots.plot_timeseries(dict_values,
                                 data_type=DEMANDS,
                                 file_path=path_png_figs)
        # plot demand timeseries for the first 2 weeks only
        F1_plots.plot_timeseries(dict_values,
                                 data_type=DEMANDS,
                                 max_days=14,
                                 file_path=path_png_figs)

        # plot supply timeseries
        F1_plots.plot_timeseries(dict_values,
                                 data_type=RESOURCES,
                                 file_path=path_png_figs)
        # plot supply timeseries for the first 2 weeks only
        F1_plots.plot_timeseries(dict_values,
                                 data_type=RESOURCES,
                                 max_days=14,
                                 file_path=path_png_figs)

        # plot power flows in the energy system
        F1_plots.plot_instant_power(dict_values, file_path=path_png_figs)

        # plot optimal capacities if there are optimized assets
        F1_plots.plot_optimized_capacities(dict_values,
                                           file_path=path_png_figs)

        # plot annuity, first-investment and om costs
        F1_plots.plot_piecharts_of_costs(dict_values, file_path=path_png_figs)

    # generate a pdf report
    if path_pdf_report is not None:
        app = autoreport.create_app(dict_values)
        autoreport.print_pdf(app, path_pdf_report=path_pdf_report)
        logging.info("Generating PDF report of the simulation: {}".format(
            path_pdf_report))