def _generate_exogenous_transport_costs_values(data_wrapper: dw.DataWrapper, cost_type: str): logging.info('Executing: generate_transport_capital_costs_values') map_capacity_technology = dr.loadmap_from_csv( 'capacity_transport_technologies') map_units_technology = dr.loadmap_from_csv('units_transport_technologies') cost_values = data_wrapper.cost_values.copy() cost_values = cost_values[cost_values['type'] == cost_type] cost_values = cost_values[cost_values['technology'].isin( map_capacity_technology.keys())] convert_eur_to2010_dollar = 1 / 1.08 * 1.17 cost_values['unit'] = 'Gvkm' for entry in map_capacity_technology: cost_values = cost_values.replace({'technology': entry}, cost_type[:-1] + '|' + map_capacity_technology[entry]) for entry in map_units_technology: cost_values.loc[(cost_values['technology'] == cost_type[:-1] + '|' + entry), 'unit'] = map_units_technology[entry][1:-3] if cost_type == "Capital Costs": cost_values['unit'] = 'US$2010/' + cost_values['unit'] cost_values['value'] = abs( cost_values['value']) * convert_eur_to2010_dollar elif cost_type == "Fixed Costs": cost_values['unit'] = 'US$2010/' + cost_values['unit'] + '/yr' cost_values['value'] = abs( cost_values['value']) * convert_eur_to2010_dollar else: cost_values['unit'] = 'n/a' cost_values['model'] = DEF_MODEL_AND_VERSION for entry in map_units_technology: cost_values = cost_values.replace({'unit': entry}, map_units_technology[entry]) cost_values['value'] = abs(cost_values['value']) cost_values['subannual'] = 'Year' cost_values['scenario'] = DEF_MAP_FILE_SCENARIOS[data_wrapper.input_file] cost_values = cost_values.groupby([ 'model', 'scenario', 'region', 'technology', 'unit', 'subannual', 'year' ]).mean().reset_index() cost_values.columns = [ 'Model', 'Scenario', 'Region', 'Variable', 'Unit', 'Subannual', 'Year', 'Value' ] data_wrapper.transformed_data['ex_transport ' + str(cost_type)] = cost_values return cost_values
def generate_storage_capacity_values(data_wrapper: dw.DataWrapper): logging.info('Executing: generate_transport_capacity_values') map_capacity_technology = dr.loadmap_from_csv('storages') map_e2p_ratios = dr.loadmap_from_csv('storages_e2p_ratios') capacity_values = data_wrapper.capacity_values.copy() capacity_values = capacity_values[capacity_values['type'] == 'TotalCapacity'] combines = [] for entry in map_capacity_technology: capacity_value = capacity_values[capacity_values['technology'] == entry].copy() capacity_value = capacity_value.replace({'technology': entry}, map_capacity_technology[entry]) if map_capacity_technology[ entry] == 'Maximum Storage|Electricity|Hydro|Pumped Storage': capacity_value['unit'] = 'MWh' capacity_value['value'] = abs( capacity_value['value']) * map_e2p_ratios[ map_capacity_technology[entry]] * 1000 else: capacity_value['unit'] = 'GWh' capacity_value['value'] = abs( capacity_value['value']) * map_e2p_ratios[ map_capacity_technology[entry]] capacity_value['model'] = DEF_MODEL_AND_VERSION capacity_value['subannual'] = 'Year' combines.append(capacity_value) capacity_values = pd.concat(combines) capacity_values = _set_scenarios(capacity_values) capacity_values = capacity_values.groupby([ 'model', 'scenario', 'region', 'technology', 'unit', 'subannual', 'year' ]).sum().reset_index() capacity_values.columns = [ 'Model', 'Scenario', 'Region', 'Variable', 'Unit', 'Subannual', 'Year', 'Value' ] data_wrapper.transformed_data['capacity_storage'] = capacity_values return capacity_values
def generate_additional_emissions_values(data_wrapper: dw.DataWrapper): logging.info('Executing: generate_additional_emissions_values') map_capacity_technology = dr.loadmap_from_csv('capacity_technologies') emission_values = data_wrapper.emission_values.copy() emission_values = emission_values[emission_values['technology'].isin( map_capacity_technology.keys())] for entry in map_capacity_technology: emission_values = emission_values.replace( {'technology': entry}, 'Emissions|CO2|' + map_capacity_technology[entry]) emission_values['model'] = DEF_MODEL_AND_VERSION emission_values['unit'] = 'Mt CO2/yr' emission_values['subannual'] = 'Year' emission_values = _set_scenarios(emission_values) emission_values = emission_values.groupby([ 'model', 'scenario', 'region', 'technology', 'unit', 'subannual', 'year' ]).sum().reset_index() emission_values.columns = [ 'Model', 'Scenario', 'Region', 'Variable', 'Unit', 'Subannual', 'Year', 'Value' ] data_wrapper.transformed_data['emissions2'] = emission_values return emission_values
def generate_capacity_values(data_wrapper: dw.DataWrapper): logging.info('Executing: generate_capacity_values') map_capacity_technology = dr.loadmap_from_csv('capacity_technologies') capacity_values = data_wrapper.capacity_values.copy() capacity_values = capacity_values[capacity_values['type'] == 'TotalCapacity'] capacity_values = capacity_values[capacity_values['technology'].isin( map_capacity_technology.keys())] for entry in map_capacity_technology: capacity_values = capacity_values.replace( {'technology': entry}, 'Capacity|' + map_capacity_technology[entry]) capacity_values['model'] = DEF_MODEL_AND_VERSION capacity_values['unit'] = 'GW' capacity_values['value'] = abs(capacity_values['value']) capacity_values['subannual'] = 'Year' capacity_values = _set_scenarios(capacity_values) capacity_values = capacity_values.groupby([ 'model', 'scenario', 'region', 'technology', 'unit', 'subannual', 'year' ]).sum().reset_index() capacity_values.columns = [ 'Model', 'Scenario', 'Region', 'Variable', 'Unit', 'Subannual', 'Year', 'Value' ] data_wrapper.transformed_data['capacity'] = capacity_values return capacity_values
def generate_final_energy_values(data_wrapper: dw.DataWrapper): logging.info('Executing: generate_final_energy_values') use_values = data_wrapper.usage_values.copy() map_final_sector = dr.loadmap_from_csv('final_energy_sector') map_final_fuel = dr.loadmap_from_csv('final_energy_fuel') use_values = use_values[use_values['technology'].isin( map_final_sector.keys())] for entry in map_final_sector: use_values = use_values.replace({'technology': entry}, map_final_sector[entry]) for entry in map_final_fuel: use_values = use_values.replace({'fuel': entry}, map_final_fuel[entry]) use_values[ 'techfuel'] = use_values['technology'] + '|' + use_values['fuel'] use_values['fuel'] = use_values['techfuel'] use_electricity_values = data_wrapper.usage_values.copy() use_electricity_values = use_electricity_values[ use_electricity_values['fuel'] == 'Power'] use_electricity_values = use_electricity_values[ use_electricity_values['technology'] == 'Power_Demand'] use_electricity_values['fuel'] = 'Final Energy|ElectricityDummy' use_heat_values = _extract_final_energy_heat(data_wrapper) final_energy = pd.concat( [use_values, use_electricity_values, use_heat_values]) final_energy['model'] = DEF_MODEL_AND_VERSION final_energy['unit'] = 'EJ/yr' final_energy['value'] = final_energy['value'] / 1000 final_energy['value'] = abs(final_energy['value']) final_energy = _set_scenarios(final_energy) final_energy = _set_timeslices(final_energy, data_wrapper) final_energy = _transform_columns(final_energy, 'fuel') data_wrapper.transformed_data['final_energy'] = final_energy return final_energy
def generate_secondary_energy(data_wrapper: dw.DataWrapper): logging.info('Executing: generate_secondary_energy') map_secondary_energy_power = dr.loadmap_from_csv('secondary_energy_power') prod_values = data_wrapper.production_values.copy() power_values = prod_values[prod_values['technology'].isin( map_secondary_energy_power.keys())].copy() power_values = power_values[power_values['fuel'] == 'Power'] for entry in map_secondary_energy_power: power_values = power_values.replace({'technology': entry}, 'Secondary Energy|' + map_secondary_energy_power[entry]) power_values['unit'] = 'EJ/yr' map_secondary_energy_heat = dr.loadmap_from_csv('secondary_energy_heat') heat_values = prod_values[prod_values['technology'].isin( map_secondary_energy_heat.keys())].copy() heat_values = heat_values[(heat_values['fuel'] == 'Heat_Low_Residual') | (heat_values['fuel'] == 'Heat_Low_Industrial') | (heat_values['fuel'] == 'Heat_Medium_Industrial') | (heat_values['fuel'] == 'Heat_High_Industrial')] for entry in map_secondary_energy_heat: heat_values = heat_values.replace({'technology': entry}, 'Secondary Energy|' + map_secondary_energy_heat[entry]) heat_values['unit'] = 'EJ/yr' # map_secondary_energy_transport = dr.loadmap_from_csv('secondary_energy_transport') # transport_values = prod_values[prod_values['technology'].isin(map_secondary_energy_transport.keys())].copy() # transport_values = transport_values[(transport_values['fuel'] == 'Mobility_Freight') | # (transport_values['fuel'] == 'Mobility_Passenger')] # map_units_technology = dr.loadmap_from_csv('units_transport_technologies') # transport_values['unit'] = 'EJ/yr' # for entry in map_units_technology: # transport_values = transport_values.replace({'unit': entry}, map_units_technology[entry] + "/yr") # for entry in map_secondary_energy_transport: # transport_values = transport_values.replace({'technology': entry}, # 'Secondary Energy|' + map_secondary_energy_transport[entry]) map_secondary_energy_other = dr.loadmap_from_csv('secondary_energy_other') other_values = prod_values[prod_values['technology'].isin( map_secondary_energy_other.keys())].copy() for entry in map_secondary_energy_other: other_values = other_values.replace({'technology': entry}, 'Secondary Energy|' + map_secondary_energy_other[entry]) other_values['unit'] = 'EJ/yr' secondary_energy = pd.concat([power_values, heat_values, other_values]) secondary_energy['model'] = DEF_MODEL_AND_VERSION secondary_energy['value'] = secondary_energy['value'] / 1000 secondary_energy['value'] = abs(secondary_energy['value']) secondary_energy = _set_scenarios(secondary_energy) secondary_energy = _set_timeslices(secondary_energy, data_wrapper) secondary_energy = _transform_columns(secondary_energy, 'technology') data_wrapper.transformed_data['secondary_energy'] = secondary_energy return secondary_energy