Skip to content

Commit 21193fe

Browse files
committed
Revert branch contents to eaaa063
1 parent de73019 commit 21193fe

30 files changed

Lines changed: 1760188 additions & 1689866 deletions

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ jobs:
6363
- name: Set up Python
6464
uses: actions/setup-python@v5
6565
with:
66-
python-version: '3.12'
66+
python-version: '3.x'
6767
- name: Install scout package
6868
run: |
6969
python -m pip install --upgrade pip

pyproject.toml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,25 @@ authors = [
2020
requires-python = ">=3.10"
2121
license = {file = "LICENSE.md"}
2222
dependencies = [
23-
"pandas == 2.3.3",
24-
"numpy == 1.26.4",
25-
"scipy == 1.15.3",
26-
"requests == 2.32.5",
27-
"numpy-financial == 1.0.0",
28-
"xlsxwriter == 3.2.9",
29-
"matplotlib == 3.10.8",
30-
"backoff == 2.2.1",
31-
"python-dotenv == 1.2.1",
32-
"pyyaml == 6.0.3",
33-
"jsonschema == 4.25.1",
34-
"pytest == 9.0.2"
23+
"pandas >= 2.0",
24+
"numpy >= 1.16, <2.0",
25+
"scipy",
26+
"requests",
27+
"numpy-financial",
28+
"xlsxwriter",
29+
"matplotlib",
30+
"backoff",
31+
"python-dotenv",
32+
"pyyaml",
33+
"jsonschema",
34+
"pytest"
3535
]
3636

3737
[tool.setuptools_scm]
3838

3939
[project.optional-dependencies]
4040
dev = [
41-
"openpyxl == 3.1.5",
42-
"flake8 == 7.3.0",
43-
"tabulate == 0.9.0",
41+
"openpyxl",
42+
"flake8 >= 7.0",
43+
"tabulate",
4444
]

scout/config.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010

1111

1212
class LogConfig:
13-
"""Configure the logger"""
13+
"""Configure the logger
14+
"""
1415

1516
@staticmethod
1617
def configure_logging():

scout/ecm_prep.py

Lines changed: 4040 additions & 1076 deletions
Large diffs are not rendered by default.

scout/ecm_prep_vars.py

Lines changed: 0 additions & 2284 deletions
This file was deleted.

scout/run.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
import numpy_financial as npf
1414
from datetime import datetime
1515
from scout.plots import run_plot
16-
from scout.config import Config, FilePaths as fp
17-
from scout.utils import PrintFormat as fmt
16+
from scout.config import FilePaths as fp
17+
from scout.config import Config
1818
import warnings
1919
import itertools
2020
import pandas as pd
@@ -5906,14 +5906,15 @@ def out_break_walk_subtr(self, orig_dict, base_val, eff_val, focus_yrs):
59065906
del orig_dict[k]
59075907
return orig_dict
59085908

5909-
def process_codes_bps(self, opts, adopt_scheme, msegs, handyvars, trim_yrs,
5909+
def process_codes_bps(self, adopt_scheme, msegs, handyvars, verboseprint, trim_yrs,
59105910
code_comply_res, code_comply_com, bps_comply_res, bps_comply_com):
59115911
"""Read in and apply the effects of codes/BPS to measure stock/energy/carbon/energy costs.
59125912
59135913
Args:
59145914
adopt_scheme (string): Assumed consumer adoption scenario.
59155915
msegs: Baseline stock, energy, and square footage data for building microsegments.
59165916
handyvars (object): Global variables useful across class methods.
5917+
verboseprint (function): Print verbose messages with user option.
59175918
trim_yrs (list): Optional list of years to focus results on.
59185919
code_comply_res (float): Compliance rate to assume for residential codes.
59195920
code_comply_com (float): Compliance rate to assume for commercial codes.
@@ -6115,12 +6116,10 @@ def process_codes_bps(self, opts, adopt_scheme, msegs, handyvars, trim_yrs,
61156116
"electric"][var].keys()} for var in [
61166117
"stock", "energy", "carbon", "cost"]}
61176118
except ValueError:
6118-
fmt.verboseprint(opts.verbose,
6119-
("No measures flagged as basis for setting relative "
6120-
"efficiency of electric equipment for current region and "
6121-
"building type. Setting relative efficiency of conversion "
6122-
"to 1 across end uses and proceeding."),
6123-
"warning")
6119+
verboseprint(
6120+
("WARNING: No measures flagged as basis for setting relative efficiency of "
6121+
"electric equipment for current region and building type. Setting "
6122+
"relative efficiency of conversion to 1 across end uses and proceeding. "))
61246123
# Adjust onsite reduction frac. times apply frac. to account for overlaps
61256124
onsite_frac_already_in_place, onsite_times_apply_fracs = self.stack_impacts(
61266125
code_std_flag, reg, bldg, regu_type, onsite_frac_already_in_place,
@@ -7366,6 +7365,9 @@ def main(opts: argparse.NameSpace): # noqa: F821
73667365
of key results to an output JSON.
73677366
"""
73687367

7368+
# Set function that only prints message when in verbose mode
7369+
verboseprint = print if opts.verbose else lambda *a, **k: None
7370+
73697371
# Raise numpy errors as exceptions
73707372
numpy.seterr('raise')
73717373
# Initialize user opts variable (elements: S-S calculation method;
@@ -7632,7 +7634,7 @@ def main(opts: argparse.NameSpace): # noqa: F821
76327634
m.markets["Technical potential"]["uncompeted"]["mseg_adjust"] = \
76337635
meas_comp_data["Technical potential"]
76347636
# Print data import message for each ECM if in verbose mode
7635-
fmt.verboseprint(opts.verbose, f"Imported ECM {m.name} competition data", "info")
7637+
verboseprint("Imported ECM '" + m.name + "' competition data")
76367638

76377639
# Import total absolute heating and cooling energy use data, used in
76387640
# removing overlaps between supply-side and demand-side heating/cooling
@@ -7697,7 +7699,7 @@ def main(opts: argparse.NameSpace): # noqa: F821
76977699
print("Post-processing impacts of state-level codes and/or performance standards...",
76987700
end="", flush=True)
76997701
cbpslist = a_run.process_codes_bps(
7700-
opts, adopt_scheme, msegs, handyvars, trim_yrs,
7702+
adopt_scheme, msegs, handyvars, verboseprint, trim_yrs,
77017703
code_comply_res, code_comply_com, bps_comply_res, bps_comply_com)
77027704
print("Calculations complete")
77037705
elif any([x is not None and len(x) != 0 for x in [codes, bps]]):
@@ -7769,12 +7771,12 @@ def main(opts: argparse.NameSpace): # noqa: F821
77697771
try:
77707772
elec_carb = elec_cost_carb['CO2 intensity of electricity']['data']
77717773
elec_cost = elec_cost_carb['End-use electricity price']['data']
7772-
format_data = True # Boolean for indicating data key substructure
7774+
fmt = True # Boolean for indicating data key substructure
77737775
except KeyError:
77747776
# Data are structured as in the site_source_co2_conversions files
77757777
elec_carb = elec_cost_carb['electricity']['CO2 intensity']['data']
77767778
elec_cost = elec_cost_carb['electricity']['price']['data']
7777-
format_data = False
7779+
fmt = False
77787780

77797781
# Determine regions and building types used by active measures for
77807782
# aggregating onsite generation data
@@ -7814,7 +7816,7 @@ def variable_depth_dict(): return defaultdict(variable_depth_dict)
78147816
else:
78157817
bt_bin = 'commercial'
78167818
# Get CO2 intensity and electricity cost data and convert units
7817-
if format_data: # Data (and data structure) from emm_region files
7819+
if fmt: # Data (and data structure) from emm_region files
78187820
# Convert Mt/TWh to Mt/MMBtu
78197821
carbtmp = {k: elec_carb[cz].get(k, 0)/3.41214e6
78207822
for k in elec_carb[cz].keys()}

scout/run_batch.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
from pathlib import Path
33
from scout.config import LogConfig, Config, FilePaths as fp
44
from scout.ecm_prep_args import ecm_args
5-
from scout.ecm_prep import ECMPrepHelper, main as ecm_prep_main
6-
from scout.utils import JsonIO
5+
from scout.ecm_prep import Utils, main as ecm_prep_main
76
from scout import run
87
from argparse import ArgumentParser
98
import logging
@@ -123,23 +122,20 @@ def run_batch(self):
123122
ecm_prep_main(ecm_prep_opts)
124123

125124
# Run run.main() for each yml in the group, set custom results directories
126-
run_setup = JsonIO.load_json(fp.GENERATED / "run_setup.json")
125+
run_setup = Utils.load_json(fp.GENERATED / "run_setup.json")
127126
# Find subset of ECMs that were set to inactive or skipped in the prep run
128127
inactive_skipped_ecms = run_setup["inactive"] + run_setup["skipped"]
129128
ecm_files_list = self.get_ecm_files(yml_grp)
130129
for ct, config in enumerate(yml_grp):
131130
# Set all ECMs inactive
132-
run_setup = ECMPrepHelper.update_active_measures(
133-
run_setup,
134-
to_inactive=ecm_prep_opts.ecm_files
135-
)
136-
# Set yml-specific ECMs active
131+
run_setup = Utils.update_active_measures(run_setup,
132+
to_inactive=ecm_prep_opts.ecm_files)
137133
# Find yml-specific individual ECMs not marked inactive or skipped
138134
active_ecms = [ecm for ecm in ecm_files_list[ct] if
139135
ecm not in inactive_skipped_ecms]
140136
# Set yml-specific ECMs not marked inactive or skipped active
141-
run_setup = ECMPrepHelper.update_active_measures(run_setup, to_active=active_ecms)
142-
JsonIO.dump_json(run_setup, fp.GENERATED / "run_setup.json")
137+
run_setup = Utils.update_active_measures(run_setup, to_active=active_ecms)
138+
Utils.dump_json(run_setup, fp.GENERATED / "run_setup.json")
143139
run_opts = self.get_run_opts(config)
144140
logger.info(f"Running run.py for {config}")
145141
run.main(run_opts)

scout/utils.py

Lines changed: 0 additions & 84 deletions
This file was deleted.

0 commit comments

Comments
 (0)