Skip to content

Commit

Permalink
solve conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
Wan, Hanlong committed Sep 26, 2024
1 parent 9c26f37 commit 6a93cc8
Show file tree
Hide file tree
Showing 10 changed files with 367 additions and 173 deletions.
12 changes: 6 additions & 6 deletions copper/chiller.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ def get_ref_cond_flow_rate(self):

# Retrieve curves
curves = self.get_chiller_curves()
cap_f_t = curves["cap_f_t"]
eir_f_t = curves["eir_f_t"]
cap_f_t = curves["cap-f-t"]
eir_f_t = curves["eir-f-t"]
eir_f_plr = curves["eir_f_plr"]

cap_f_lwt_lct_rated = cap_f_t.evaluate(self.ref_lwt, self.ref_lct)
Expand Down Expand Up @@ -255,8 +255,8 @@ def calc_rated_eff(self, eff_type, unit="kW/ton", output_report=False, alt=False

# Retrieve curves
curves = self.get_chiller_curves()
cap_f_t = curves["cap_f_t"]
eir_f_t = curves["eir_f_t"]
cap_f_t = curves["cap-f-t"]
eir_f_t = curves["eir-f-t"]
eir_f_plr = curves["eir_f_plr"]

try:
Expand Down Expand Up @@ -413,9 +413,9 @@ def get_chiller_curves(self):
curves = {}
for curve in self.set_of_curves:
if curve.out_var == "cap-f-t":
curves["cap_f_t"] = curve
curves["cap-f-t"] = curve
elif curve.out_var == "eir-f-t":
curves["eir_f_t"] = curve
curves["eir-f-t"] = curve
else:
curves["eir_f_plr"] = curve

Expand Down
16 changes: 8 additions & 8 deletions copper/curves.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ def __init__(self, eqp, sets):
self.sets_of_curves = sets

def get_aggregated_set_of_curves(
self, method="weighted-average", N=None, ranges={}, misc_attr={}
self, method="weighted_average", N=None, ranges={}, misc_attr={}
):
"""Determine sets of curves based on aggregation.
:param str method: Type of aggregation, currently supported: 'average', 'median', 'weighted-average', and 'NN-weighted-average' as in nearest neighbor weighted average.
:param int N: Number of neighbor used to the aggregation, only used when the method is 'NN-weighted-average'.
:param str method: Type of aggregation, currently supported: 'average', 'median', 'weighted_average', and 'NN_weighted_average' as in nearest neighbor weighted average.
:param int N: Number of neighbor used to the aggregation, only used when the method is 'NN_weighted_average'.
:param dict ranges: Dictionary that defines the ranges of values for each independent variable used to calculate aggregated dependent variable values.
:param dict misc_attr: Dictionary that provides values for the aggregated set of curves.
:return: Aggregated set of curves
Expand Down Expand Up @@ -142,7 +142,7 @@ def get_aggregated_set_of_curves(
y_s = [list(map(lambda x: sum(x) / len(x), zip(*vals)))]
elif method == "median":
y_s = [list(map(lambda x: statistics.median(x), zip(*vals)))]
elif method == "weighted-average":
elif method == "weighted_average":
df, _ = self.nearest_neighbor_sort(target_attr=misc_attr)
sorted_vals = list(
map(vals.__getitem__, df.index.values)
Expand All @@ -152,7 +152,7 @@ def get_aggregated_set_of_curves(
map(lambda x: np.dot(df["score"].values, x), zip(*sorted_vals))
)
]
elif method == "NN-weighted-average":
elif method == "NN_weighted_average":
# first make sure that the user has specified to pick N values
try:
assert N is not None
Expand Down Expand Up @@ -242,7 +242,7 @@ def nearest_neighbor_sort(self, target_attr=None, vars=[], N=None):
:param dict target_attr: Target attributes we want to match
:param list vars: The variables we want to use to compute our l2 score. note COP will be added
:param int N: Indicates the number of nearest neighbors to consider. N=None for weighted-average
:param int N: Indicates the number of nearest neighbors to consider. N=None for weighted_average
:param pandas.DataFrame df: Pandas dataframe with selected chiller names and the associated weightings
:return: Index of set_of_curve that should be the closest fit
:rtype: int
Expand Down Expand Up @@ -319,7 +319,7 @@ def normalize_vars(
:param dict target_attr: Reference targets with respect to which l2 score needs to computed
:param list vars: List of strings for variables we want to normalize
:param list weights: Weights associated with each variable in vars
:param int N: Number of nearest neighbors. It should be none unless method is 'NN-weighted-average'
:param int N: Number of nearest neighbors. It should be none unless method is 'NN_weighted_average'
:return: Dataframe with added columns with normalized variables, dict with added normalized values of var in vars, index of the best curve
:rtype: list
Expand Down Expand Up @@ -467,7 +467,7 @@ def get_data_for_plotting(self, curve, norm):

return [x, y]

def plot(self, out_var=[], axes=[], norm=True, color="Black", alpha=0.3):
def plot(self, out_var=[], axes=[], norm=False, color="Black", alpha=0.3):
"""Plot a set of curves.
:param list out_var: List of the output variables to plot, e.g. `eir-f-t`, `eir-f-plr`, `cap-f-t`.
Expand Down
Loading

0 comments on commit 6a93cc8

Please sign in to comment.