cpmodel / FTT_StandAlone

Future Technology Transformation models
GNU General Public License v3.0
9 stars 1 forks source link

Masterfile error for Industrial Heat #143

Closed rhayward1 closed 3 weeks ago

rhayward1 commented 4 weeks ago

The master files for FTT-IH are not up to date, so the model cannot run from them and needs to read in the csv files. Comments in the code suggest csv files should be taken if no masterfile exists, but an error is returned instead. Is there still a code which can write/update master files based on the csv files? If so, that would be a big time saver!

Femkemilene commented 3 weeks ago

I'm unaware of code that writes Masterfiles from csv files. What error are you getting? I can think of two:

rhayward1 commented 3 weeks ago

The error is due to the model not working with csv files only I believe:

File "/opt/homebrew/Caskroom/miniforge/base/envs/FTT_env/lib/python3.12/site-packages/pandas/io/excel/_base.py", line 624, in raise_if_bad_sheet_by_name raise ValueError(f"Worksheet named '{name}' not found") ValueError: Worksheet named 'FTT-IH-CHI' not found (FTT_env) rosiehayward@Rosies-Laptop FTT_StandAlone %

There's some sort of masterfile error. Is there a way I can copy the fix from main over? Thanks, Femke.

Femkemilene commented 3 weeks ago

You can cherry pick a single commit from GitHub Desktop, by going to the branch with the change, to history on the left, and then right click the commit and click cherry pick.

If that doesn't fix the error, let me know. I don't quite recognize the error message you get, so it may be something new. A work-around may be to remove the masterfiles for now. With the bug fix above, it should then completely rely on csv files.

rhayward1 commented 3 weeks ago

I've just checked and I should be up to date with that commit so not sure what the problem is. I've moved the master files into an 'old' folder but now I have a new bug to do with scenarios. I'll try to fix it, thanks, Femke!

rhayward1 commented 3 weeks ago

Hi Femke, so the function def generate_model_list(ftt_modules, scenarios) won't work at the moment without a masterfile:

`def generate_model_list(ftt_modules, scenarios): """ Using the models and scenarios from the settings.ini file, put these into a dictionary.

Remove the pseudo-scenario gamma, as this should not be initialised separately
"""
# Remove Gamma pseudo-scenario for initialisation
scenarios = [item for item in scenarios if item != "Gamma"]

models = {}

for module in ftt_modules:
    module_scenarios = []
    for scenario in scenarios:
        matching_file, file_root = get_masterfile(module, scenario)
        if matching_file:
            # TODO: rewrite this and other code to allow for other types of scenario names
            module_scenarios.append(int(scenario[1:]))
    if module_scenarios:
        models[module] = [module_scenarios, file_root]
return models`
rhayward1 commented 3 weeks ago

I've found the problem. The file FTT_Variables.xlsx is missing in FTT-IH-UPDATE, but it is needed in the latest model version. I'm creating this file which should resolve these issues.