Skip to content

Commit dbbcfdc

Browse files
Copilotjmythms
andcommitted
Use metadata aeo_base_year instead of datetime.today().year for deterministic results
Replace dynamic datetime.today().year with aeo_base_year from metadata.json in ecm_prep_vars.py, htcl_totals.py, and run.py to ensure reproducible integration test results across calendar year boundaries. Co-authored-by: jmythms <[email protected]>
1 parent b53de31 commit dbbcfdc

4 files changed

Lines changed: 9 additions & 12 deletions

File tree

inputs/metadata.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
22
"min year": 2020,
3-
"max year": 2050
3+
"max year": 2050,
4+
"aeo_base_year": 2025
45
}

scout/ecm_prep_vars.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import itertools
55
import numpy
66
import pandas as pd
7-
from datetime import datetime
87
from collections import OrderedDict
98
from scout.utils import JsonIO
109
from scout.config import FilePaths as fp
@@ -168,11 +167,11 @@ def __init__(self, base_dir, handyfiles, opts):
168167
self.discount_rate = 0.07
169168
self.nsamples = 100
170169
self.regions = opts.alt_regions
171-
# Shorthand for current year
172-
self.current_yr = datetime.today().year
173170
# Load metadata including AEO year range
174171
aeo_yrs = JsonIO.load_json(handyfiles.metadata)
175-
# Set minimum modeling year to current year
172+
# Shorthand for current year (based on AEO data vintage)
173+
self.current_yr = aeo_yrs["aeo_base_year"]
174+
# Set minimum modeling year to AEO base year
176175
aeo_min = self.current_yr
177176
# Set maximum modeling year
178177
aeo_max = aeo_yrs["max year"]

scout/htcl_totals.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import json
44
from collections import OrderedDict
5-
from datetime import datetime
65
import gzip
76
from scout.config import FilePaths as fp
87

@@ -106,9 +105,8 @@ def __init__(self, handyfiles):
106105
raise ValueError(
107106
"Error reading in '" +
108107
handyfiles.metadata + "': " + str(e)) from None
109-
# Set minimum AEO modeling year
110-
# aeo_min = aeo_yrs["min year"]
111-
aeo_min = datetime.today().year
108+
# Set minimum AEO modeling year to AEO base year
109+
aeo_min = aeo_yrs["aeo_base_year"]
112110
# Set maximum AEO modeling year
113111
aeo_max = aeo_yrs["max year"]
114112
# Derive time horizon from min/max years

scout/run.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import math
1212
from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter
1313
import numpy_financial as npf
14-
from datetime import datetime
1514
from scout.plots import run_plot
1615
from scout.config import Config, FilePaths as fp
1716
from scout.utils import PrintFormat as fmt
@@ -250,8 +249,8 @@ def __init__(self, handyfiles, opts, brkout, regions, state_appl_regs, codes, bp
250249
raise ValueError(
251250
"Error reading in '" +
252251
handyfiles.cpi_data + "': " + str(e)) from None
253-
# Set present year for cost conversions
254-
yr_before_current = str(datetime.today().year - 1)
252+
# Set present year for cost conversions (based on AEO data vintage)
253+
yr_before_current = str(int(self.aeo_years[0]) - 1)
255254
# Years of the baseline stock cost, energy cost, and carbon cost data
256255
# Note that energy cost data are already adjusted to the year before current in ecm_prep.
257256
# *** Note: stock/carbon cost units could eventually be pulled from baseline data files

0 commit comments

Comments
 (0)