|
13 | 13 | import numpy_financial as npf |
14 | 14 | from datetime import datetime |
15 | 15 | 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 |
18 | 18 | import warnings |
19 | 19 | import itertools |
20 | 20 | import pandas as pd |
@@ -5906,14 +5906,15 @@ def out_break_walk_subtr(self, orig_dict, base_val, eff_val, focus_yrs): |
5906 | 5906 | del orig_dict[k] |
5907 | 5907 | return orig_dict |
5908 | 5908 |
|
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, |
5910 | 5910 | code_comply_res, code_comply_com, bps_comply_res, bps_comply_com): |
5911 | 5911 | """Read in and apply the effects of codes/BPS to measure stock/energy/carbon/energy costs. |
5912 | 5912 |
|
5913 | 5913 | Args: |
5914 | 5914 | adopt_scheme (string): Assumed consumer adoption scenario. |
5915 | 5915 | msegs: Baseline stock, energy, and square footage data for building microsegments. |
5916 | 5916 | handyvars (object): Global variables useful across class methods. |
| 5917 | + verboseprint (function): Print verbose messages with user option. |
5917 | 5918 | trim_yrs (list): Optional list of years to focus results on. |
5918 | 5919 | code_comply_res (float): Compliance rate to assume for residential codes. |
5919 | 5920 | 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, |
6115 | 6116 | "electric"][var].keys()} for var in [ |
6116 | 6117 | "stock", "energy", "carbon", "cost"]} |
6117 | 6118 | 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. ")) |
6124 | 6123 | # Adjust onsite reduction frac. times apply frac. to account for overlaps |
6125 | 6124 | onsite_frac_already_in_place, onsite_times_apply_fracs = self.stack_impacts( |
6126 | 6125 | code_std_flag, reg, bldg, regu_type, onsite_frac_already_in_place, |
@@ -7366,6 +7365,9 @@ def main(opts: argparse.NameSpace): # noqa: F821 |
7366 | 7365 | of key results to an output JSON. |
7367 | 7366 | """ |
7368 | 7367 |
|
| 7368 | + # Set function that only prints message when in verbose mode |
| 7369 | + verboseprint = print if opts.verbose else lambda *a, **k: None |
| 7370 | + |
7369 | 7371 | # Raise numpy errors as exceptions |
7370 | 7372 | numpy.seterr('raise') |
7371 | 7373 | # Initialize user opts variable (elements: S-S calculation method; |
@@ -7632,7 +7634,7 @@ def main(opts: argparse.NameSpace): # noqa: F821 |
7632 | 7634 | m.markets["Technical potential"]["uncompeted"]["mseg_adjust"] = \ |
7633 | 7635 | meas_comp_data["Technical potential"] |
7634 | 7636 | # 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") |
7636 | 7638 |
|
7637 | 7639 | # Import total absolute heating and cooling energy use data, used in |
7638 | 7640 | # removing overlaps between supply-side and demand-side heating/cooling |
@@ -7697,7 +7699,7 @@ def main(opts: argparse.NameSpace): # noqa: F821 |
7697 | 7699 | print("Post-processing impacts of state-level codes and/or performance standards...", |
7698 | 7700 | end="", flush=True) |
7699 | 7701 | cbpslist = a_run.process_codes_bps( |
7700 | | - opts, adopt_scheme, msegs, handyvars, trim_yrs, |
| 7702 | + adopt_scheme, msegs, handyvars, verboseprint, trim_yrs, |
7701 | 7703 | code_comply_res, code_comply_com, bps_comply_res, bps_comply_com) |
7702 | 7704 | print("Calculations complete") |
7703 | 7705 | 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 |
7769 | 7771 | try: |
7770 | 7772 | elec_carb = elec_cost_carb['CO2 intensity of electricity']['data'] |
7771 | 7773 | 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 |
7773 | 7775 | except KeyError: |
7774 | 7776 | # Data are structured as in the site_source_co2_conversions files |
7775 | 7777 | elec_carb = elec_cost_carb['electricity']['CO2 intensity']['data'] |
7776 | 7778 | elec_cost = elec_cost_carb['electricity']['price']['data'] |
7777 | | - format_data = False |
| 7779 | + fmt = False |
7778 | 7780 |
|
7779 | 7781 | # Determine regions and building types used by active measures for |
7780 | 7782 | # aggregating onsite generation data |
@@ -7814,7 +7816,7 @@ def variable_depth_dict(): return defaultdict(variable_depth_dict) |
7814 | 7816 | else: |
7815 | 7817 | bt_bin = 'commercial' |
7816 | 7818 | # 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 |
7818 | 7820 | # Convert Mt/TWh to Mt/MMBtu |
7819 | 7821 | carbtmp = {k: elec_carb[cz].get(k, 0)/3.41214e6 |
7820 | 7822 | for k in elec_carb[cz].keys()} |
|
0 commit comments