multi-vector-simulator icon indicating copy to clipboard operation
multi-vector-simulator copied to clipboard

Manage KPI for energy sectors

Open smartie2076 opened this issue 5 years ago • 9 comments

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 avatar Dec 10 '20 11:12 smartie2076

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

smartie2076 avatar Jan 05 '21 10:01 smartie2076

@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 avatar Jan 07 '21 11:01 smartie2076

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.

smartie2076 avatar Jan 07 '21 15:01 smartie2076

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

Bachibouzouk avatar Jan 08 '21 09:01 Bachibouzouk

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:

  • [x] Change "KPI individual sectors" to a pd.DF, adapt functions that write into it f04ff78cce0957a16c7f2b0b536605f609e40637
  • [x] Prepare the pd.DF for being printed into the report c18ebebaa94fba05190879e7503588e333198f08
  • [x] Add a section with the KPI of the sectors to the automated result c18ebebaa94fba05190879e7503588e333198f08
  • [ ] Relocate parameters that are now printed into the KPI of the energy system (so that they would be printed into the report) into the "KPI individual sectors", adapt functions that acessed the data from there. Requires running all pytests for each moved KPI.

smartie2076 avatar Jan 11 '21 11:01 smartie2076

@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?

Bachibouzouk avatar Jan 13 '21 11:01 Bachibouzouk

@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.

smartie2076 avatar Mar 02 '21 10:03 smartie2076

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

SabineHaas avatar Mar 02 '21 11:03 SabineHaas

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.

smartie2076 avatar Mar 03 '21 13:03 smartie2076