Skip to content

Commit

Permalink
refactor: scaling factor tolerance adjustable, removed redundant vali…
Browse files Browse the repository at this point in the history
…dation
  • Loading branch information
Daniel Muldrew committed May 4, 2020
1 parent df0c5e6 commit 2b227fd
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions powersimdata/design/clean_capacity_scaling.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,17 @@ def output_capacities_table(self, base_grid=None):
gen_capacity.loc[tar] = pd.Series(row_dict)
return gen_capacity

def create_scale_factor_table(self, base_grid=None, gen_capacity=None):
def create_scale_factor_table(self, base_grid=None, gen_capacity=None,
tolerance=0.001):
"""
Outputs a scaling factor table for targets and resource with
respect to a base grid for creating a change table.
:param base_grid: reference grid to calculate change table scaling
:param gen_capacity: dataframe of next capacities
:param powersimdata.input.grid.Grid base_grid: reference grid to
calculate change table scaling
:param pandas.DataFrame gen_capacity: dataframe of next capacities
factors
:param float tolerance: deviation from 1.0 to be included in change
table
:return: (*dict*) -- nested dictionary of change table scaling values
"""
if base_grid is None:
Expand All @@ -161,10 +165,6 @@ def create_scale_factor_table(self, base_grid=None, gen_capacity=None):
target_loadzones = grid_loadzones.intersection(
set(grid_info.area_to_loadzone(tar)))
for load_zone in target_loadzones:
if load_zone not in base_grid.zone2id:
print('No loadzone %s in grid!' % load_zone)
continue

load_zone_cap = grid_info.get_capacity(res, load_zone)
if load_zone_cap == 0 and row[res] > 0:
warnings.warn('Attempting to scale target area {0} '
Expand All @@ -175,7 +175,7 @@ def create_scale_factor_table(self, base_grid=None, gen_capacity=None):
'and resource {1}'.format(load_zone, res))
else:
scale_factor = row[res] / base_target_resource_cap
if abs(scale_factor - 1.0) > 0.001:
if abs(scale_factor - 1.0) > tolerance:
scale_factor_table[res][load_zone] = scale_factor
return scale_factor_table

Expand Down

0 comments on commit 2b227fd

Please sign in to comment.