Skip to content

Commit ede28fc

Browse files
authored
Merge pull request #175 from NREL/fix-cba
fix cba curtailment calculation
2 parents 8b0cddc + fcdfce5 commit ede28fc

File tree

1 file changed

+14
-18
lines changed

1 file changed

+14
-18
lines changed

disco/cli/cba_post_process.py

+14-18
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,16 @@ def add_curtailment_columns(filename, curtailment_tolerance):
1212
df["PVSystems__Curtailment__residential (kWh)"] = 0.0
1313
columns = ["substation", "feeder", "placement", "sample", "penetration_level"]
1414

15-
def calc_curtailment(pf1, control_mode):
15+
def calc_energy_curtailed(pf1, control_mode):
1616
"""Calculate curtailment."""
1717
if pf1 == 0:
1818
return 0
19-
20-
# We may need to consider using this tolerance in the future.
21-
# if pf1 < curtailment_tolerance:
22-
# return 0
19+
if pf1 < curtailment_tolerance:
20+
return 0
2321
diff = pf1 - control_mode
24-
#if diff < 0 and abs(diff) < curtailment_tolerance:
25-
# return 0
26-
return diff / pf1
22+
if diff < 0 and abs(diff) < curtailment_tolerance:
23+
return 0
24+
return diff
2725

2826
for (substation, feeder, placement, sample, penetration_level), tdf in df.groupby(by=columns):
2927
for customer_type in ("commercial", "residential"):
@@ -33,7 +31,7 @@ def calc_curtailment(pf1, control_mode):
3331
if sim_vals.empty:
3432
continue
3533
pf1 = tdf.query("scenario == 'pf1'")[power_col]
36-
curtailment = pf1.combine(sim_vals, calc_curtailment)
34+
curtailment = pf1.combine(sim_vals, calc_energy_curtailed)
3735
cond = lambda x: (
3836
(x["substation"] == substation)
3937
& (x["feeder"] == feeder)
@@ -50,15 +48,13 @@ def calc_curtailment(pf1, control_mode):
5048

5149
@click.command()
5250
@click.argument("output_dir")
53-
# This is disabled because we don't know the best tolerance for these customer-type
54-
# aggregations. Leaving it in the code in case we need it in the future.
55-
# @click.option(
56-
# "-d", "--curtailment-tolerance",
57-
# default=0.0001,
58-
# show_default=True,
59-
# help="Set curtailment to 0 if the diff is less than this value.",
60-
# )
61-
def cba_post_process(output_dir, curtailment_tolerance=0.0001):
51+
@click.option(
52+
"-d", "--curtailment-tolerance",
53+
default=0.001,
54+
show_default=True,
55+
help="Set curtailment to 0 if the diff is less than this value.",
56+
)
57+
def cba_post_process(output_dir, curtailment_tolerance=0.001):
6258
"""Perform post-processing of CBA tables."""
6359
add_curtailment_columns(output_dir, curtailment_tolerance)
6460

0 commit comments

Comments
 (0)