Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions hourlize/write_site_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,23 @@
import reeds


def check_negative_values(df, cost_cols):
neg_vals_all = {}
for cc in cost_cols.values():
if cc in df.columns:
neg_vals = sum(df[cc] < 0)
if neg_vals:
neg_vals_all[cc] = neg_vals

if neg_vals_all:
message = "\n".join(
f"{cc} -> {count}" for cc, count in neg_vals_all.items()
)
raise ValueError(
f"The following cost columns have negative values:\n{message}\n"
"Check reV data to confirm these."
)

#%%### Fixed inputs
if reeds.io.hpc:
remotepath = '/kfs2/shared-projects/reeds'
Expand Down Expand Up @@ -116,8 +133,23 @@
_diff = len(outcols) - dfland.shape[1]
assert _diff == 0, len(_diff)

# drop ac suffix for cost columns
cost_cols = {
'cost_spur_usd_per_mw_ac': 'cost_spur_usd_per_mw',
'cost_poi_usd_per_mw_ac': 'cost_poi_usd_per_mw',
'cost_reinforcement_usd_per_mw_ac': 'cost_reinforcement_usd_per_mw',
'cost_total_trans_usd_per_mw_ac': 'cost_total_trans_usd_per_mw',
'cost_export_usd_per_mw_ac': 'cost_export_usd_per_mw'
}
dfland = dfland.rename(columns=cost_cols)

# subset to outcols
dfland = dfland[list(outcols.keys())].astype(outcols)

# check for negative values
check_negative_values(dfland, cost_cols)


#%% Write it
drop = ['trans_gid', 'trans_type']
drop = []
Expand Down Expand Up @@ -188,6 +220,14 @@
columns_meshed = {'Zone_ReEDS':'ba'}

#%% Make combined dataframe
for offshoretype in ['radial', 'meshed']:
cost_cols_sub = {
k: v for k, v in cost_cols.items()
if v not in dictin[f'offshore_{offshoretype}'].columns
}
dictin[f'offshore_{offshoretype}'] = dictin[f'offshore_{offshoretype}'].rename(columns=cost_cols_sub)
check_negative_values(dictin[f'offshore_{offshoretype}'], cost_cols)

dfwrite = dictin['offshore_radial'][columns_same].copy()
for col in columns_different:
for offshoretype in ['radial', 'meshed']:
Expand Down
9 changes: 0 additions & 9 deletions reeds/input_processing/writesupplycurves.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
numbins_other = 5
### Rounding precision
decimals = 7
### spur_cutoff [$/MW]: Cutoff for spur line costs; clip cost for sites with larger costs
spur_cutoff = 1e7

# %% ===========================================================================
### --- FUNCTIONS ---
Expand Down Expand Up @@ -89,7 +87,6 @@ def agg_supplycurve(
numbins_tech,
bin_method='equal_cap_cut',
bin_col='supply_curve_cost_per_mw',
spur_cutoff=1e7,
deflate=None,
):
"""
Expand Down Expand Up @@ -129,8 +126,6 @@ def agg_supplycurve(
)
### Aggregate it
dfout = dfin.groupby(index_cols).agg(aggs)
### Clip negative costs and costs above cutoff
dfout.supply_curve_cost_per_mw = dfout.supply_curve_cost_per_mw.clip(lower=0, upper=spur_cutoff)

return dfin, dfout

Expand Down Expand Up @@ -226,7 +221,6 @@ def main(
scpath=os.path.join(inputs_case,f'supplycurve_wind-{s}.csv'),
inputs_case=inputs_case,
numbins_tech=numbins[f'wind-{s}'],
spur_cutoff=spur_cutoff,
deflate=deflate,
)

Expand Down Expand Up @@ -328,7 +322,6 @@ def main(
scpath=os.path.join(inputs_case, 'supplycurve_upv.csv'),
inputs_case=inputs_case,
numbins_tech=numbins['upv'],
spur_cutoff=spur_cutoff,
deflate=deflate,
)

Expand Down Expand Up @@ -411,7 +404,6 @@ def main(
scpath=os.path.join(inputs_case, 'supplycurve_csp.csv'),
inputs_case=inputs_case,
numbins_tech=numbins['csp'],
spur_cutoff=spur_cutoff,
deflate=deflate,
)

Expand Down Expand Up @@ -492,7 +484,6 @@ def main(
),
numbins_tech=numbins[s],
inputs_case=inputs_case,
spur_cutoff=spur_cutoff,
deflate=deflate
)
spurout_list.append(
Expand Down
Loading