@@ -4529,7 +4529,7 @@ def fill_mkts(self, msegs, msegs_cpl, convert_data, tsv_data_init, opts,
45294529 if self.handyvars.full_dat_out[adopt_scheme]:
45304530 # Populate detailed breakout information for measure
45314531 self.breakout_mseg(
4532- self, mskeys, contrib_mseg_key, adopt_scheme, opts, brk_in_dat)
4532+ mskeys, contrib_mseg_key, adopt_scheme, opts, brk_in_dat)
45334533
45344534 # Record contributing microsegment data needed for ECM
45354535 # competition in the analysis engine
@@ -9765,159 +9765,6 @@ def rand_list_gen(self, distrib_info, nsamples):
97659765
97669766 return rand_list
97679767
9768- def create_perf_dict(self, msegs):
9769- """Create dict to fill with updated measure performance information.
9770-
9771- Note:
9772- Given a measure's applicable climate zone, building type,
9773- structure type, fuel type, and end use, create a dict of zeros
9774- with a hierarchy that is defined by these measure properties.
9775-
9776- Args:
9777- msegs (dict): Baseline microsegment stock and energy use
9778- information to use in validating categorization of
9779- measure performance information.
9780-
9781- Returns:
9782- Empty dictionary to fill with EnergyPlus-based performance
9783- information broken down by climate zone, building type/vintage,
9784- fuel type, and end use.
9785- """
9786- # Initialize performance dict
9787- perf_dict_empty = {"primary": None, "secondary": None}
9788- # Create primary dict structure from baseline market properties
9789- perf_dict_empty["primary"] = self.create_nested_dict(
9790- msegs, "primary")
9791-
9792- # Create secondary dict structure from baseline market properties
9793- # (if needed)
9794- if isinstance(self.end_use, dict):
9795- perf_dict_empty["secondary"] = self.create_nested_dict(
9796- msegs, "secondary")
9797-
9798- return perf_dict_empty
9799-
9800- def create_nested_dict(self, msegs, mseg_type):
9801- """Create a nested dictionary based on a pre-defined branch structure.
9802-
9803- Note:
9804- Create a nested dictionary with a structure that is defined by a
9805- measure's applicable baseline market, with end leaf node values set
9806- to zero.
9807-
9808- Args:
9809- msegs (dict): Baseline microsegment stock and energy use
9810- information to use in validating categorization of
9811- measure performance information.
9812- mseg_type (string): Primary or secondary microsegment type flag.
9813-
9814- Returns:
9815- Nested dictionary of zeros with desired branch structure.
9816- """
9817- # Initialize output dictionary
9818- output_dict = {}
9819- # Establish levels of the dictionary key hierarchy from measure's
9820- # applicable baseline market information
9821- keylevels = [
9822- self.climate_zone, self.bldg_type, self.fuel_type[mseg_type],
9823- self.end_use[mseg_type], self.structure_type]
9824- # Find all possible dictionary key chains from the above key level
9825- # info.
9826- dict_keys = list(itertools.product(*keylevels))
9827- # Remove all natural gas cooling key chains (EnergyPlus output
9828- # files do not include a column for natural gas cooling)
9829- dict_keys = [x for x in dict_keys if not (
9830- 'natural gas' in x and 'cooling' in x)]
9831-
9832- # Use an input dictionary with valid baseline microsegment information
9833- # to check that each of the microsegment key chains generated above is
9834- # valid for the current measure; if not, remove each invalid key chain
9835- # from further operations
9836-
9837- # Initialize a list of valid baseline microsegment key chains for the
9838- # measure
9839- dict_keys_fin = []
9840- # Loop through the initial set of candidate key chains generated above
9841- for kc in dict_keys:
9842- # Copy the input dictionary containing valid key chains
9843- dict_check = copy.deepcopy(msegs)
9844- # Loop through all keys in the candidate key chain and move down
9845- # successive levels of the input dict until either the end of the
9846- # key chain is reached or a key is not found in the list of valid
9847- # keys for the current input dict level. In the former case, the
9848- # resultant dict will point to all technologies associated with the
9849- # current key chain (e.g., ASHP, LFL, etc.) If none of these
9850- # technologies are found in the list of technologies covered by the
9851- # measure, the key chain is deemed invalid
9852- for ind, key in enumerate(kc):
9853- # If key is found in the list of valid keys for the current
9854- # input microsegment dict level, move on to next level in the
9855- # dict; otherwise, break the current loop
9856- if key in dict_check.keys():
9857- dict_check = dict_check[key]
9858- # In the case of heating or cooling end uses, an additional
9859- # 'technology type' key must be accounted for ('supply' or
9860- # 'demand')
9861- if key in ['heating', 'cooling']:
9862- dict_check = \
9863- dict_check[self.technology_type[mseg_type]]
9864- else:
9865- break
9866-
9867- # If any of the technology types listed in the measure definition
9868- # are found in the keys of the dictionary yielded by the above
9869- # loop, add the key chain to the list that is used to define the
9870- # final nested dictionary output (e.g., the key chain is valid)
9871- if any([x in self.technology[mseg_type]
9872- for x in dict_check.keys()]):
9873- dict_keys_fin.append(kc)
9874-
9875- # Loop through each of the valid key chains and create an
9876- # associated path in the dictionary, terminating with a zero value
9877- # to be updated in a subsequent routine with EnergyPlus output data
9878- for kc in dict_keys_fin:
9879- current_level = output_dict
9880- for ind, elem in enumerate(kc):
9881- if elem not in current_level and (ind + 1) != len(kc):
9882- current_level[elem] = {}
9883- elif elem not in current_level and (ind + 1) == len(kc):
9884- current_level[elem] = 0
9885- current_level = current_level[elem]
9886-
9887- return output_dict
9888-
9889- def build_array(self, eplus_coltyp, files_to_build):
9890- """Assemble EnergyPlus data from one or more CSVs into a record array.
9891-
9892- Args:
9893- eplus_coltypes (list): Expected EnergyPlus variable data types.
9894- files_to_build (CSV objects): CSV files of EnergyPlus energy
9895- consumption information under measure and baseline cases.
9896-
9897- Returns:
9898- Structured array of EnergyPlus energy savings information for the
9899- Measure.
9900- """
9901- # Loop through CSV file objects and import/add to record array
9902- for ind, f in enumerate(files_to_build):
9903- # Read in CSV file to array
9904- eplus_file = numpy.genfromtxt(f, names=True, dtype=eplus_coltyp,
9905- delimiter=",", missing_values='')
9906- # Find only those rows in the array that represent
9907- # completed simulation runs for the measure of interest
9908- eplus_file = eplus_file[(eplus_file[
9909- 'measure'] == self.energy_efficiency['EnergyPlus file']) |
9910- (eplus_file['measure'] == 'none') &
9911- (eplus_file['status'] == 'completed normal')]
9912- # Initialize or add to a master array that covers all CSV data
9913- if ind == 0:
9914- eplus_perf_array = eplus_file
9915- else:
9916- eplus_perf_array = \
9917- numpy.concatenate((eplus_perf_array, eplus_file))
9918-
9919- return eplus_perf_array
9920-
99219768 def breakout_mseg(self, mskeys, contrib_mseg_key, adopt_scheme, opts, input_data):
99229769 """Record mseg contributions to breakouts by region/bldg/end use/fuel.
99239770
@@ -12817,9 +12664,6 @@ def prepare_measures(measures, convert_data, msegs, msegs_cpl, handyvars,
1281712664 base_dir, handyvars, handyfiles, opts_dict, **m) for m in measures]
1281812665 logger.info("Measure initialization complete")
1281912666
12820- # Fill in EnergyPlus-based performance information for Measure objects
12821- # with a 'From EnergyPlus' flag in their 'energy_efficiency' attribute
12822-
1282312667 # Handle a superfluous 'undefined' key in the ECM performance field that is
1282412668 # generated by the 'Add ECM' web form in certain cases *** NOTE: WILL
1282512669 # FIX IN FUTURE UI VERSION ***
0 commit comments