trynthink / scout

A tool for estimating the future energy use, carbon emissions, and capital and operating cost impacts of energy efficiency and demand flexibility technologies in the U.S. residential and commercial building sectors.
https://scout.energy.gov
Other
61 stars 23 forks source link

Breaking Error in run.py #272

Closed dewittpe closed 2 years ago

dewittpe commented 2 years ago

After making the edits to the ecm definition to address #270 I have attempted to run the full pipeline and have run into another error:

$ git rev-parse HEAD; python ecm_prep.py; python run.py
77ea5ba64bc5b5125a65d86a0772f954420097a7

Importing supporting data...No new ECM updates available
--- Runtime: 00:00:01.15 (HH:MM:SS.mm) ---
ECM attributes data load complete
Importing ECM competition data...Data load complete
Calculating uncompeted 'Technical potential' savings/metrics...Calculations complete
Competing ECMs for 'Technical potential' scenario...Traceback (most recent call last):
  File "/Users/peterdewitt/NREL/scout/run.py", line 4746, in <module>
    main(base_dir)
  File "/Users/peterdewitt/NREL/scout/run.py", line 4459, in main
    a_run.compete_measures(adopt_scheme, htcl_totals)
  File "/Users/peterdewitt/NREL/scout/run.py", line 1170, in compete_measures
    self.compete_com_primary(measures_adj, msu, adopt_scheme)
  File "/Users/peterdewitt/NREL/scout/run.py", line 1661, in compete_com_primary
    self.compete_adj(
  File "/Users/peterdewitt/NREL/scout/run.py", line 3260, in compete_adj
    adj_out_break["base fuel"][var][var_sub][yr] - (
KeyError: '2022'
dewittpe commented 2 years ago

After injecting a few print calls I got the following. I appears that the code is expecting years to following [var_sub] but instead the "All Fuels" key is present.

$ git rev-parse HEAD; python ecm_prep.py; python run.py
77ea5ba64bc5b5125a65d86a0772f954420097a7

Importing supporting data...No new ECM updates available
--- Runtime: 00:00:01.16 (HH:MM:SS.mm) ---
ECM attributes data load complete
Importing ECM competition data...Data load complete
Calculating uncompeted 'Technical potential' savings/metrics...Calculations complete
Competing ECMs for 'Technical potential' scenario...

  In else clause at line 3258 of run.py
  Value of `var` is energy
  Value of `var_sub` is baseline
  adj_out_break["base fuel"][var][var_sub].keys() are: dict_keys(['All Fuels'])
Traceback (most recent call last):
  File "/Users/peterdewitt/NREL/scout/run.py", line 4750, in <module>
    main(base_dir)
  File "/Users/peterdewitt/NREL/scout/run.py", line 4463, in main
    a_run.compete_measures(adopt_scheme, htcl_totals)
  File "/Users/peterdewitt/NREL/scout/run.py", line 1170, in compete_measures
    self.compete_com_primary(measures_adj, msu, adopt_scheme)
  File "/Users/peterdewitt/NREL/scout/run.py", line 1661, in compete_com_primary
    self.compete_adj(
  File "/Users/peterdewitt/NREL/scout/run.py", line 3264, in compete_adj
    adj_out_break["base fuel"][var][var_sub][yr] - (
KeyError: '2022'
dewittpe commented 2 years ago

Error was generated by having a ecm_prep.json file with "All Fuels" in it from a prior run on a different branch in the repo. Despite having touched ecm_prep.py and all the ecm definitions the remnants of the prior run were retained in ecm_prep.json.

I'll modify my workflow to delete my local copy of ecm_prep.json when testing the whole pipeline.