OSeMOSYS / otoole

OSeMOSYS Tools for Energy
https://otoole.readthedocs.io
MIT License
25 stars 18 forks source link

[Bug]: Config file `calculated` field not working #173

Closed trevorb1 closed 1 year ago

trevorb1 commented 1 year ago

The Issue

If I set the calculated field to False in the config file for a result variable, it is still calculated.

Expected Behavior

If a variable has the field Calculated: False, I would expect the variable not to be calculated. This may be useful if there is a heavy calculation that you dont actually need.

Steps To Reproduce

  1. Set the field shown below in the config file
Demand:
    indices: [REGION, TIMESLICE, FUEL, YEAR]
    type: result
    dtype: float
    default: 0
    calculated: False
  1. Run a results command
  2. View the variable results in the file results/Demand.csv

Log output

na

Operating System

Linux

What version of otoole are you running?

1.0.2

Possible Solution

Should just be able to add in the following loop to the ReadResults.calcualte_results(..) method:

if not self.results_config[name]["calculated"]:
    LOGGER.info(f"{name} not calculated from config file")
    continue

Anything else?

No response

trevorb1 commented 1 year ago

okay, I was wrong, it wasnt that easy haha. If you add in that loop suggested, CBC and Gurobi tests fail as it can't find the variable RateOfActivity. I think this is because by default RateOfActivity is not a calculated variable (as it is directly read in and also set with Calculated: False in the config file), and otoole can't find the data to perform calculations that require RateOfActivity