Skip to content

Commit

Permalink
Moving LLDC config to model.dd
Browse files Browse the repository at this point in the history
  • Loading branch information
Sunishchal committed Sep 26, 2020
1 parent e2a64df commit f99b4ee
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
12 changes: 12 additions & 0 deletions model/dd.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,15 @@
# time ranges
CORE_START_YEAR = 2015
CORE_END_YEAR = 2060

# Config for health & education solution
# Regions included as Least & Less Developed Countries & high Net Reproducitve Rate:
LLDC_HIGH_NRR_CONFIG = {
'OECD90': 'N',
'Eastern Europe': 'N',
'Asia (Sans Japan)': 'Y',
'Middle East and Africa': 'Y',
'Latin America': 'N'
}
LLDC_HIGH_NRR_REGION_Y = dict(filter(lambda x: x[1] == 'Y', LLDC_HIGH_NRR_CONFIG.items())).keys()
LLDC_HIGH_NRR_REGION_N = dict(filter(lambda x: x[1] == 'N', LLDC_HIGH_NRR_CONFIG.items())).keys()
28 changes: 9 additions & 19 deletions solution/health_and_education/clusters/electricity_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,6 @@
use_fixed_weight = 'N'
## TODO: Move above block to advanced_controls.py after we figure out if it varies by scenario

# Regions included as LLDC+HighNRR:
lldc_high_nrr_config = {
'OECD90': 'N',
'Eastern Europe': 'N',
'Asia (Sans Japan)': 'Y',
'Middle East and Africa': 'Y',
'Latin America': 'N'
}
lldc_high_nrr_regions_y = dict(filter(lambda x: x[1] == 'Y', lldc_high_nrr_config.items())).keys()
lldc_high_nrr_regions_n = dict(filter(lambda x: x[1] == 'N', lldc_high_nrr_config.items())).keys()

# TABLE 1: Current TAM Mix
current_tam_mix_list = [
Expand Down Expand Up @@ -125,10 +115,10 @@ def __init__(self, scenario=None):
columns=['LLDC+HighNRR', 'China', 'MDC + LAC + EE', 'Total Electricity Demand in Countries with Higher Educational Attainment (TWh)', 'Total Electricity Demand in Countries with Higher Educational Attainment (TWh) % LLDC'],
index=list(range(2014, 2061)), dtype=np.float64)

ref2_elec_gen.loc[:, 'LLDC+HighNRR'] = self.ref2_tam.loc[:, lldc_high_nrr_regions_y].sum(axis=1) - self.ref2_tam.loc[:, 'China']
ref2_elec_gen.loc[:, 'LLDC+HighNRR'] = self.ref2_tam.loc[:, dd.LLDC_HIGH_NRR_REGION_Y].sum(axis=1) - self.ref2_tam.loc[:, 'China']
ref2_elec_gen.loc[:, 'China'] = self.ref2_tam.loc[:, 'China']
ref2_elec_gen.loc[:, 'MDC + LAC + EE'] = self.ref2_tam.loc[:, lldc_high_nrr_regions_n].sum(axis=1)
if lldc_high_nrr_config['Asia (Sans Japan)'] == 'N':
ref2_elec_gen.loc[:, 'MDC + LAC + EE'] = self.ref2_tam.loc[:, dd.LLDC_HIGH_NRR_REGION_N].sum(axis=1)
if dd.LLDC_HIGH_NRR_CONFIG['Asia (Sans Japan)'] == 'N':
ref2_elec_gen.loc[:, 'MDC + LAC + EE'] = ref2_elec_gen.loc[:, 'MDC + LAC + EE'] - self.ref2_tam.loc[:, 'China']
ref2_elec_gen.loc[:, 'Total Electricity Demand in Countries with Higher Educational Attainment (TWh)'] = ref2_elec_gen.loc[:, ['LLDC+HighNRR', 'China', 'MDC + LAC + EE']].sum(axis=1)
ref2_elec_gen.loc[:, 'Total Electricity Demand in Countries with Higher Educational Attainment (TWh) % LLDC'] = ref2_elec_gen.loc[:, 'LLDC+HighNRR'] / ref2_elec_gen.loc[:, 'Total Electricity Demand in Countries with Higher Educational Attainment (TWh)']
Expand All @@ -141,15 +131,15 @@ def __init__(self, scenario=None):
columns=['LLDC with low educational attainment, excluding China', 'MDC + EE + LAC with low educational attainment, excluding China', 'China', 'LLDC with higher educational attainment, excluding China', 'MDC + EE + LAC with higher educational attainment', 'Total Electricity Demand in Countries with Low Educational Attainment (TWh), exluding China', 'Total Electricity Demand in Countries with Low Educational Attainment (TWh), exluding China % LLDC', 'Total Electricity Demand in Countries with Higher Educational Attainment (TWh)', 'Total Electricity Demand in Countries with Higher Educational Attainment (TWh) % LLDC', 'Total Electricity Demand (TWh)', 'Total Electricity Demand (TWh) % LLDC'],
index=list(range(2014, 2061)), dtype=np.float64)

ref1_elec_gen.loc[:, 'LLDC with low educational attainment, excluding China'] = ref1_tam_low_edu.loc[:, lldc_high_nrr_regions_y].sum(axis=1) - ref1_tam_low_edu.loc[:, 'China']
ref1_elec_gen.loc[:, 'MDC + EE + LAC with low educational attainment, excluding China'] = ref1_tam_low_edu.loc[:, lldc_high_nrr_regions_n].sum(axis=1)
if lldc_high_nrr_config['Asia (Sans Japan)'] == 'N':
ref1_elec_gen.loc[:, 'LLDC with low educational attainment, excluding China'] = ref1_tam_low_edu.loc[:, dd.LLDC_HIGH_NRR_REGION_Y].sum(axis=1) - ref1_tam_low_edu.loc[:, 'China']
ref1_elec_gen.loc[:, 'MDC + EE + LAC with low educational attainment, excluding China'] = ref1_tam_low_edu.loc[:, dd.LLDC_HIGH_NRR_REGION_N].sum(axis=1)
if dd.LLDC_HIGH_NRR_CONFIG['Asia (Sans Japan)'] == 'N':
ref1_elec_gen.loc[:, 'MDC + LAC + EE'] = ref1_elec_gen.loc[:, 'MDC + LAC + EE'] - self.ref1_tam_low_edu.loc[:, 'China']
ref1_elec_gen.loc[:, 'China'] = ref1_tam_high_edu.loc[:, 'China']

ref1_elec_gen.loc[:, 'LLDC with higher educational attainment, excluding China'] = ref1_tam_high_edu.loc[:, lldc_high_nrr_regions_y].sum(axis=1) - ref1_tam_high_edu.loc[:, 'China']
ref1_elec_gen.loc[:, 'MDC + EE + LAC with higher educational attainment'] = ref1_tam_high_edu.loc[:, lldc_high_nrr_regions_n].sum(axis=1)
if lldc_high_nrr_config['Asia (Sans Japan)'] == 'N':
ref1_elec_gen.loc[:, 'LLDC with higher educational attainment, excluding China'] = ref1_tam_high_edu.loc[:, dd.LLDC_HIGH_NRR_REGION_Y].sum(axis=1) - ref1_tam_high_edu.loc[:, 'China']
ref1_elec_gen.loc[:, 'MDC + EE + LAC with higher educational attainment'] = ref1_tam_high_edu.loc[:, dd.LLDC_HIGH_NRR_REGION_N].sum(axis=1)
if dd.LLDC_HIGH_NRR_CONFIG['Asia (Sans Japan)'] == 'N':
ref1_elec_gen.loc[:, 'MDC + EE + LAC with higher educational attainment'] = ref1_elec_gen.loc[:, 'MDC + EE + LAC with higher educational attainment'] - self.ref1_tam_high_edu.loc[:, 'China']

ref1_elec_gen.loc[:, 'Total Electricity Demand in Countries with Low Educational Attainment (TWh), exluding China'] = ref1_elec_gen.loc[:, 'LLDC with low educational attainment, excluding China'] + ref1_elec_gen.loc[:, 'MDC + EE + LAC with low educational attainment, excluding China']
Expand Down

0 comments on commit f99b4ee

Please sign in to comment.