Beispiel #1
0
 def calc_and_format_embodied_costs(self):
     #calculate and format embodied supply costs
     embodied_costs_list = [Output.clean_df(x) for x in self.demand.outputs.demand_embodied_energy_costs]
     cost_unit = cfg.getParam('currency_year') + " " + cfg.getParam('currency_name')
     for embodied_costs in embodied_costs_list: embodied_costs.columns = [cost_unit.upper()]
     embodied_costs_list = [util.add_to_df_index(x, names=['EXPORT/DOMESTIC', "SUPPLY/DEMAND"], keys=["DOMESTIC","SUPPLY"]) for x in embodied_costs_list]
     return embodied_costs_list
Beispiel #2
0
 def calc_and_format_export_energy(self):
     if self.supply.export_energy is None:
         return None
     export_energy = GeoMapper.geo_map(self.supply.export_energy.copy(), GeoMapper.supply_primary_geography, GeoMapper.combined_outputs_geography, 'total')
     export_energy = Output.clean_df(export_energy)
     util.replace_index_name(export_energy, 'FINAL_ENERGY','SUPPLY_NODE_EXPORT')
     export_energy = util.add_to_df_index(export_energy, names=['EXPORT/DOMESTIC', "ENERGY ACCOUNTING"], keys=["EXPORT", "EMBODIED"])
     for x in cfg.output_combined_levels:
         if x not in export_energy.index.names:
             export_energy = util.add_and_set_index(export_energy,[x],["N/A"])
     return export_energy
Beispiel #3
0
 def calc_and_format_direct_demand_costs(self):
     #calculte and format direct demand costs
     if self.demand.outputs.d_levelized_costs is None:
         return None
     direct_costs = GeoMapper.geo_map(self.demand.outputs.d_levelized_costs.copy(), GeoMapper.demand_primary_geography, GeoMapper.combined_outputs_geography, 'total')
     direct_costs = direct_costs[direct_costs.index.get_level_values('year').isin(cfg.combined_years_subset)]
     levels_to_keep = [x for x in cfg.output_combined_levels if x in direct_costs.index.names]
     direct_costs = direct_costs.groupby(level=levels_to_keep).sum()
     direct_costs = Output.clean_df(direct_costs)
     direct_costs = util.add_to_df_index(direct_costs, names=['EXPORT/DOMESTIC', "SUPPLY/DEMAND"], keys=["DOMESTIC","DEMAND"])
     return direct_costs
Beispiel #4
0
 def calc_and_format_export_costs(self):
     #calculate and format export costs
     if self.supply.export_costs is None:
         return None
     export_costs = GeoMapper.geo_map(self.supply.export_costs.copy(), GeoMapper.supply_primary_geography, GeoMapper.combined_outputs_geography, 'total')
     export_costs = Output.clean_df(export_costs)
     util.replace_index_name(export_costs, 'FINAL_ENERGY', 'SUPPLY_NODE_EXPORT')
     export_costs = util.add_to_df_index(export_costs, names=['EXPORT/DOMESTIC', "SUPPLY/DEMAND"], keys=["EXPORT", "SUPPLY"])
     cost_unit = cfg.getParam('currency_year') + " " + cfg.getParam('currency_name')
     export_costs.columns = [cost_unit.upper()]
     return export_costs
Beispiel #5
0
    def calc_and_format_direct_demand_emissions(self):
        #calculte and format direct demand emissions
        direct_emissions_list = [Output.clean_df(x) for x in self.demand.outputs.demand_direct_emissions]
        direct_emissions_list = [util.add_to_df_index(x, names=['EXPORT/DOMESTIC', "SUPPLY/DEMAND"], keys=["DOMESTIC", "DEMAND"]) for x in direct_emissions_list]
        if GeoMapper.combined_outputs_geography + '_supply' in cfg.output_combined_levels:
             keys = direct_emissions_list[0].index.get_level_values(GeoMapper.combined_outputs_geography.upper()).values
             names = GeoMapper.combined_outputs_geography.upper() + '_SUPPLY'
             for x in direct_emissions_list:
                x[names] = keys

             direct_emissions_list = [x.set_index(names, append=True, inplace=True) for x in direct_emissions_list]
        return direct_emissions_list
Beispiel #6
0
 def calc_and_format_export_emissions(self):
     #calculate and format export emissions
     if self.supply.export_emissions is None:
         return None
     export_emissions = GeoMapper.geo_map(self.supply.export_emissions.copy(), GeoMapper.supply_primary_geography, GeoMapper.combined_outputs_geography, 'total')
     if 'supply_geography' not in cfg.output_combined_levels:
         util.remove_df_levels(export_emissions, GeoMapper.supply_primary_geography +'_supply')
     export_emissions = Output.clean_df(export_emissions)
     util.replace_index_name(export_emissions, 'FINAL_ENERGY','SUPPLY_NODE_EXPORT')
     index_names = export_emissions.index.names
     export_emissions = export_emissions.reset_index()
     export_emissions['FINAL_ENERGY'] = 'export ' + export_emissions['FINAL_ENERGY']
     export_emissions = export_emissions.set_index(index_names).sort_index()
     export_emissions = util.add_to_df_index(export_emissions, names=['EXPORT/DOMESTIC', "SUPPLY/DEMAND"], keys=["EXPORT", "SUPPLY"])
     return export_emissions
Beispiel #7
0
 def calc_and_format_direct_demand_energy(self):
     demand_energy = GeoMapper.geo_map(self.demand.outputs.d_energy.copy(), GeoMapper.demand_primary_geography, GeoMapper.combined_outputs_geography, 'total')
     demand_energy = Output.clean_df(demand_energy)
     demand_energy = demand_energy[demand_energy.index.get_level_values('YEAR')>=cfg.getParamAsInt('current_year')]
     demand_energy = util.add_to_df_index(demand_energy, names=['EXPORT/DOMESTIC', "ENERGY ACCOUNTING"], keys=['DOMESTIC','FINAL'])
     return demand_energy
Beispiel #8
0
 def calc_and_format_embodied_supply_energy(self):
     embodied_energy_list = [Output.clean_df(x) for x in self.demand.outputs.demand_embodied_energy]
     embodied_energy_list = [x[x['VALUE']!=0] for x in embodied_energy_list]
     embodied_energy_list = [util.add_to_df_index(x, names=['EXPORT/DOMESTIC', "ENERGY ACCOUNTING"], keys=['DOMESTIC','EMBODIED']) for x in embodied_energy_list]
     return embodied_energy_list
Beispiel #9
0
 def calc_and_format_embodied_supply_emissions(self):
     # calculate and format embodied supply emissions
     embodied_emissions_list = [Output.clean_df(x) for x in self.demand.outputs.demand_embodied_emissions]
     embodied_emissions_list = [util.add_to_df_index(x, names=['EXPORT/DOMESTIC', "SUPPLY/DEMAND"], keys=["DOMESTIC", "SUPPLY"]) for x in embodied_emissions_list]
     return embodied_emissions_list