Skip to content
Closed
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
37 changes: 24 additions & 13 deletions hourlize/resource.py

@patrickbrown4 patrickbrown4 Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about this one; we save one set of supply curves that are meant to work for all supported region resolutions, but this approach would bake the regions into the supply curves.

And we want to make the classes user-adjustable at runtime anyway (#59), so I think the direction we're going is to stop writing the classes from hourlize and instead determine them dynamically during the run.

Original file line number Diff line number Diff line change
Expand Up @@ -459,24 +459,35 @@ def add_classes(df_sc, class_path, class_bin, class_bin_col, class_bin_method, c
#In this case, class names in class_path must be numbered, starting at 1
df_sc = df_sc.rename(columns={'class':'class_orig'})
df_sc['class_orig'] = df_sc['class_orig'].astype(int)
df_sc = (
df_sc
.groupby(['class_orig'], sort=False)
.apply(
reeds.inputs.get_bin,
bin_col=class_bin_col,
bin_out_col='class_bin',
weight_col='capacity',
bin_num=class_bin_num,
bin_method=class_bin_method,
national = 1 if 'region' not in df_sc.columns else 0
if national:
df_sc['region'] = 'CONUS'
else:
import reeds
dfreg = pd.DataFrame()
for r in df_sc['region'].unique():
df_noclass = df_sc.loc[df_sc['region']==r].copy()
df_noclass = (
df_sc
.groupby(['class_orig'], sort=False)
.apply(
reeds.inputs.get_bin,
bin_col=class_bin_col,
bin_out_col='class_bin',
weight_col='capacity',
bin_num=class_bin_num,
bin_method=class_bin_method.split('_')[0],
)
.reset_index(drop=True)
)
.reset_index()
)
dfreg = pd.concat([dfreg,df_noclass])
if national:
dfreg = dfreg.drop(columns=['region'])
df_sc = dfreg.copy()
df_sc['class'] = (df_sc['class_orig'] - 1) * class_bin_num + df_sc['class_bin']
print('Done adding classes: '+ str(datetime.datetime.now() - startTime))
return df_sc


def add_cost(df_sc, tech):
"""
Calculate capital cost adders.
Expand Down
Loading