rl-institut / multi-vector-simulator

Multi-vector Simulation Tool assessing and optimizing Local Energy Systems (LES) for the E-LAND project
GNU General Public License v2.0
21 stars 10 forks source link

Manage KPI for energy sectors #703

Open smartie2076 opened 3 years ago

smartie2076 commented 3 years ago

Currently, the attributed costs are in data[KPI][KPI_SCALARS_DICT]:

        "scalars": {
            "Attributed costsElectricity": 6325876.92136,
            "Degree of autonomy": 0.25960818577078226,
            "Levelized costs of electricity equivalent": 0.2800016253040174,
            "Levelized costs of electricity equivalentElectricity": 0.2800016253040174,
            "Onsite energy fraction": 0.9790092690915841,
            "Onsite energy matching": 0.12801451335599984,
            "Renewable factor": 0.3000000000420336,
            "Renewable share of local generation": 0.9999762956574617,
            "Total internal generation": 511349.8499467013,
            "Total internal non-renewable generation": 12.121212,
            "Total internal renewable generation": 511337.7287347013,
            "Total non-renewable energy use": 1610709.6026548704,
            "Total renewable energy use": 690304.1155616869,
            "Total_demandElectricity": 1969698.4840000041,
            "Total_demandElectricity_electricity_equivalent": 1969698.4840000041,
            "Total_demand_electricity_equivalent": 1969698.4840000041,
            "Total_excessElectricity": 248466.24995910013,
            "Total_excessElectricity_electricity_equivalent": 248466.24995910013,
            "Total_excess_electricity_equivalent": 248466.24995910013,
            "Total_feedinElectricity": 10733.607100290017,
            "Total_feedinElectricity_electricity_equivalent": 10733.607100290017,
            "Total_feedin_electricity_equivalent": 10733.607100290017,
            "annuity_om": 299923.27217999997,
            "annuity_total": 551518.7768799999,
            "costs_cost_om": 1387892.5351200001,
            "costs_dispatch": 2052203.7683199998,
            "costs_investment_over_lifetime": 2885780.61792,
            "costs_om_total": 3440096.30344,
            "costs_total": 6325876.92136,
            "costs_upfront_in_year_zero": 3088890.3465
        }

They should however be in here for a better overview:

    "kpi": {
        "KPI individual sectors": {
            "Renewable factor": {
                "Electricity": 0.3000000000420336
            },
            "Renewable share of local generation": {
                "Electricity": 0.9999762956574617
            },
            "Total internal non-renewable generation": {
                "Electricity": 12.121212
            },
            "Total internal non-renewable generation_electricity_equivalent": {
                "Electricity": 12.121212
            },
            "Total internal renewable generation": {
                "Electricity": 511337.7287347013
            },
            "Total internal renewable generation_electricity_equivalent": {
                "Electricity": 511337.7287347013
            },
            "Total non-renewable energy use": {
                "Electricity": 1610709.6026548704
            },
            "Total non-renewable energy use_electricity_equivalent": {
                "Electricity": 1610709.6026548704
            },
            "Total renewable energy use": {
                "Electricity": 690304.1155616869
            },
            "Total renewable energy use_electricity_equivalent": {
                "Electricity": 690304.1155616869
            }

Also, the KPI individual sectors should be adapted to the structure of kpi scalars so that its easier to print them in the pdf report.

Originally posted by @smartie2076 in https://github.com/rl-institut/multi-vector-simulator/issues/549#issuecomment-742474854

smartie2076 commented 3 years ago

This is something we should discuss in our call with ICOM, when fixing the output of the simulation.

smartie2076 commented 3 years ago

@Bachibouzouk so, I realized that the discussion with Dimitris was maybe rather about the parser but not how I should do it within the MVS. We should look at our current parser again and see if it already does what he wants, and if I have free range for what I am doing.

smartie2076 commented 3 years ago
def convert_from_special_types_to_json(o):
    if isinstance(o, np.int64):
        answer = int(o)
    ...
    elif isinstance(o, pd.DataFrame):
        answer = {DATA_TYPE_JSON_KEY: TYPE_DATAFRAME}
        answer.update(json.loads(o.to_json(orient="split")))

Resulting in

        "cost_matrix": {
            "columns": [
                "label",
                "costs_total",
                "costs_om_total",
            ],
            "data": [
                [
                    "battery storage capacity",
                    3068972.69526,
                    0.0,
                ],
                [
                    "battery input power",
                    0.0,
                    0.0,
                ],
            ],
            "data_type": "pandas_Dataframe",
            "index": [
                0,
                0,
            ]

So, this is not exactly what Dimitris explained to us. It is pd.DataFrame. But we anyway provide them with the cost_matrix, right, so he should be able to read it?

For me, it really does not matter what I do - keep it as json, make a pd.DF. But I would like to have this in the report, and ideally in the EPA.

Bachibouzouk commented 3 years ago

For the report it is best that this is a pd.DF, I will make the parser to provide the right json format we discussed :). For the report we should just make sure we have our pd.DF following the tidy data standard

smartie2076 commented 3 years ago

For the report it is best that this is a pd.DF, I will make the parser to provide the right json format we discussed :). For the report we should just make sure we have our pd.DF following the tidy data standard

Great! Then the todos here are:

Bachibouzouk commented 3 years ago

@smartie2076 - the last point can be addressed in a subsequent PR, if I understand it well you want to move the relevant values from "scalars" into "KPI individual sectors", or is it the reverse?

smartie2076 commented 3 years ago

@SabineHaas @Bachibouzouk @ciaradunks this is actually something that may be important to do before the release. I will try to do it tomorrow and ask @Bachibouzouk to do a dummy EPA integration, to see if anything fails.

SabineHaas commented 3 years ago

Ah, I've also noticed that some of the units are missing in KPI_SCALARS_DICT

smartie2076 commented 3 years ago

Yeah, that as well. As the EPA currently already has some issues to parse the MVS results, I will not add onto that and pause this issue. We can address it when there are better/more interactive error messages displayed in the EPA.