コード例 #1
0
def communities_summary(coms, res_dir):
    """Saves the summary by: community residential_ashp_summary.csv
    
    Parameters
    ----------
    coms : dictionary
        results from the model, dictionary with each community or project as key
            
    res_dir : path
        location to save file
    
    """
    out = []
    for c in sorted(coms.keys()):
        #~ it = coms[c]['community data'].intertie
        #~ if it is None:
        #~ it = 'parent'
        #~ if it == 'child':
        #~ continue
        if c.find("_intertie") != -1:
            continue
        try:

            ashp = coms[c][COMPONENT_NAME]

            kw_excess = ashp.monthly_value_table['kWh consumed'].max()/\
                                (24 * 31)
            try:
                peak_monthly_btu_hr_hh = ashp.peak_monthly_btu_hr_hh
            except AttributeError:
                peak_monthly_btu_hr_hh = 0

            try:
                #~ ashp.get_electricity_prices()
                price = ashp.electricity_prices[0]
                #~ print float(ashp.electricity_prices.ix[ashp.start_year])
            except AttributeError:

                price = 0

            intertie = ashp.cd['intertie']
            if type(intertie) is list:
                intertie = intertie[0]
            else:
                intertie = ashp.cd['name']

            try:
                levelized_cost = ashp.levelized_cost_of_energy
            except AttributeError:
                levelized_cost = 0

            try:
                break_even = ashp.break_even_cost
            except AttributeError:
                break_even = 0

            ashp.get_diesel_prices()
            diesel_price = float(ashp.diesel_prices[0].round(2))
            hf_price = diesel_price + ashp.cd['heating fuel premium']

            name = c
            if name == 'Barrow':
                name = 'Utqiagvik (Barrow)'
            l = [
                name, ashp.average_cop, ashp.num_houses,
                peak_monthly_btu_hr_hh, price, ashp.electric_consumption,
                kw_excess, ashp.heating_oil_saved,
                ashp.electric_heat_energy_reduction, diesel_price, hf_price,
                break_even, levelized_cost,
                ashp.get_NPV_benefits(),
                ashp.get_NPV_costs(),
                ashp.get_NPV_net_benefit(), ashp.irr,
                ashp.get_BC_ratio(), intertie, ashp.reason
            ]
            out.append(l)

        except (KeyError, AttributeError) as e:
            #~ print c
            #~ print e
            pass

    cols = [
        'Community',
        "ASHP Residential Average Coefficient of Performance (COP)",
        'Number Houses', 'ASHP Residential Peak Household Monthly Btu/hr',
        'Electricity Price [$/kWh]', 'ASHP Residential kWh consumed per year',
        "ASHP Residential Excess Generation Capacity"
        " Needed for Peak Monthly Load (kW)",
        "ASHP Residential Displaced Heating Oil [Gal]",
        "ASHP Residential Displaced Electricity [kWh]",
        "Diesel Price - year 1 [$/gal]", "Heating Fuel Price - year 1 [$/gal]",
        'Break Even Heating Fuel Price [$/gal]',
        'Levelized Cost Of Energy [$/MMBtu]',
        'ASHP Residential NPV benefits [$]', 'ASHP Residential NPV Costs [$]',
        'ASHP Residential NPV Net benefit [$]',
        'ASHP Residential Internal Rate of Return',
        'ASHP Residential Benefit-cost ratio', 'Intertie', 'notes'
    ]

    data = DataFrame(out, columns=cols).set_index('Community')  #.round(2)
    f_name = os.path.join(
        res_dir,
        COMPONENT_NAME.replace(" ", "_").lower() + '_summary.csv')
    fd = open(f_name, 'w')
    fd.write(
        ("# " + COMPONENT_NAME + " summary by community\n"
         '# Community: ' + definitions.COMMUNITY + '\n'
         '# ASHP Residential Average Coefficient of Performance (COP): '
         'ratio of useful heating provided to work required\n'
         '# Number Houses: '
         'Estimated count of homes that would be heated by ASHP\n'
         '# ASHP Residential Peak Household Monthly Btu/hr: \n'
         '# Electricity Price [$/kWh]: ' + definitions.PRICE_ELECTRICITY + '\n'
         '# ASHP Residential kWh consumed per year: electricity consumed\n'
         '# ASHP Residential Excess Generation Capacity '
         ' Needed for Peak Monthly Load (kW): \n'
         '# ASHP Residential Displaced Heating Oil [Gal]:'
         ' Fuel that would be displaced by ASHP\n'
         '# Diesel Price - year 1 [$/gal]: ' + definitions.PRICE_DIESEL + '\n'
         '# Heating Fuel Price - year 1 [$/gal]:' + definitions.PRICE_HF + '\n'
         '# Break Even Heating Fuel Price [$/gal]: ' +
         definitions.BREAK_EVEN_COST_HF + '\n'
         '# Levelized Cost Of Energy [$/kWh]:' + definitions.LCOE + '\n'
         '# ' + COMPONENT_NAME + ' NPV benefits [$]: ' +
         definitions.NPV_BENEFITS + '\n'
         '# ' + COMPONENT_NAME + ' NPV Costs [$]: ' + definitions.NPV_COSTS +
         '\n'
         '# ' + COMPONENT_NAME + ' NPV Net benefit [$]: ' +
         definitions.NPV_NET_BENEFITS + '\n'
         '# ' + COMPONENT_NAME + ' Internal Rate of Return: ' +
         definitions.IRR + '\n'
         '# ' + COMPONENT_NAME + ' Benefit-cost ratio: ' +
         definitions.NPV_BC_RATIO + '\n'
         '# Intertie: Intertie community is part of \n'
         '# notes: ' + definitions.NOTES + '\n'))

    fd.close()
    data.to_csv(f_name, mode='a')
コード例 #2
0
def communities_summary(coms, res_dir):
    """Saves the summary by: community heat_recovery_summary.csv
    
    Parameters
    ----------
    coms : dictionary
        results from the model, dictionary with each community or project 
        as key
    res_dir :  path
        location to save file
    
    """
    out = []
    for c in sorted(coms.keys()):
        #~ it = coms[c]['community data'].intertie
        #~ if it is None:
        #~ it = 'parent'
        #~ if it == 'child':
        #~ continue
        if c.find("_intertie") != -1:
            continue
        try:

            comp = coms[c][COMPONENT_NAME]

            comp.get_diesel_prices()
            diesel_price = float(comp.diesel_prices[0].round(2))
            hfp = comp.cd['heating fuel premium']

            proposed_hr = comp.proposed_heat_recovery
            #~ eff = comp.cd["diesel generation efficiency"]

            try:
                break_even_cost = comp.break_even_cost
                levelized_cost_of_energy = comp.levelized_cost_of_energy
            except AttributeError:
                break_even_cost = np.nan
                levelized_cost_of_energy = np.nan

            name = c
            if name == 'Barrow':
                name = 'Utqiagvik (Barrow)'
            l = [
                name,
                proposed_hr,
                diesel_price,
                hfp,
                diesel_price + hfp,
                #~ eff,
                break_even_cost,
                levelized_cost_of_energy,
                comp.get_NPV_benefits(),
                comp.get_NPV_costs(),
                comp.get_NPV_net_benefit(),
                comp.irr,
                comp.get_BC_ratio(),
                comp.reason
            ]
            out.append(l)

        except (KeyError, AttributeError) as e:
            #~ print e
            pass

    cols = [
        'Community', 'Proposed Heat Recovery [gallons]',
        'Diesel price - year 1 [$/gal]', 'Heating Fuel Premium [$/gal]',
        'Heating Fuel Price - year 1 [$/gal]',
        'Break Even Heating Fuel Price [$/gal]',
        'Levelized Cost of Energy [$/MMBtu]', 'Heat Recovery NPV benefits [$]',
        'Heat Recovery NPV Costs [$]', 'Heat Recovery NPV Net benefit [$]',
        'Heat Recovery Internal Rate of Return',
        'Heat Recovery Benefit-cost ratio', 'notes'
    ]

    data = DataFrame(out, columns=cols).set_index('Community')  #.round(2)
    f_name = os.path.join(
        res_dir,
        COMPONENT_NAME.replace(" ", "_").lower() + '_summary.csv')
    fd = open(f_name, 'w')
    fd.write((
        "# " + COMPONENT_NAME + " summary by community\n"
        '# Community: ' + definitions.COMMUNITY + '\n'
        '# Proposed Heat Recovery [gallons]: Proposed gallons of diesel saved \n'
        '# Diesel price - year 1 [$/gal]: ' + definitions.PRICE_DIESEL + '\n'
        '# Heating Fuel Premium [$/gal]: ' + definitions.PREMIUM + '\n'
        '# Heating Fuel Price - year 1 [$/gal]: ' + definitions.PRICE_HF + '\n'
        '# Break Even Heating Fuel Price [$/gal]: ' +
        definitions.BREAK_EVEN_COST_HF + '\n'
        '# Levelized Cost Of Energy [$/kWh]:' + definitions.LCOE + '\n'
        '# Heat Recovery NPV benefits [$]: ' + definitions.NPV_BENEFITS + '\n'
        '# Heat Recovery NPV Costs [$]: ' + definitions.NPV_COSTS + '\n'
        '# Heat Recovery NPV Net benefit [$]: ' +
        definitions.NPV_NET_BENEFITS + '\n'
        '# Heat Recovery Internal Rate of Return: ' + definitions.IRR + '\n'
        '# Heat Recovery Benefit-cost ratio: ' + definitions.NPV_BC_RATIO +
        '\n'
        '# notes: ' + definitions.NOTES + '\n'))

    fd.close()
    data.to_csv(f_name, mode='a')
コード例 #3
0
def communities_summary(coms, res_dir):
    """Saves the summary by: community hydropower_summary.csv
    
    Parameters
    ----------
    coms : dictionary
        results from the model, dictionary with each community or project 
        as key
    res_dir :  path
        location to save file
    
    """
    out = []
    for c in sorted(coms.keys()):
        it = coms[c]['community data'].intertie
        if it is None:
            it = 'parent'
        if it == 'child':
            continue
        try:
            # ??? NPV or year one
            hydro = coms[c]['Hydropower']

            start_yr = hydro.comp_specs['start year']
            hydro.get_diesel_prices()
            diesel_price = float(hydro.diesel_prices[0].round(2))
            #~ print hydro.diesel_prices[0]
            if hydro.comp_specs["name"] == 'none':
                phase = hydro.comp_specs['phase']
            else:
                phase = "Reconnaissance"

            name = hydro.comp_specs['name']

            average_load = hydro.average_load
            proposed_load = hydro.load_offset_proposed

            heat_rec_opp = hydro.cd['heat recovery operational']

            net_gen_hydro = hydro.net_generation_proposed

            captured_energy = hydro.captured_energy

            lost_heat = hydro.lost_heat_recovery
            electric_diesel_reduction = hydro.generation_diesel_reduction

            diesel_red = hydro.captured_energy - hydro.lost_heat_recovery

            eff = hydro.cd["diesel generation efficiency"]

            levelized_cost = hydro.levelized_cost_of_energy
            break_even = hydro.break_even_cost
            #~ except AttributeError:
            #~ offset = 0
            #~ net_gen_hydro = 0
            #~ decbb = 0
            #~ electric_diesel_reduction=0
            #~ loss_heat = 0

            #~ diesel_red = 0
            #~ eff = hydro.cd["diesel generation efficiency"]

            #~ try:
            #~ red_per_year = net_gen_hydro / eff
            #~ except ZeroDivisionError:
            #~ red_per_year = 0

            community = c
            if community == 'Barrow':
                community = 'Utqiagvik (Barrow)'
            l = [
                name, name, start_yr, phase, average_load, proposed_load,
                net_gen_hydro, captured_energy, lost_heat, heat_rec_opp,
                diesel_red, electric_diesel_reduction, eff, diesel_price,
                break_even, levelized_cost,
                hydro.get_NPV_benefits(),
                hydro.get_NPV_costs(),
                hydro.get_NPV_net_benefit(), hydro.irr,
                hydro.get_BC_ratio(), hydro.reason
            ]
            out.append(l)
        except (KeyError, AttributeError, TypeError) as e:
            #~ print e
            pass

    cols = [
        'Community', 'Project Name', 'Start Year', 'project phase',
        'Average Diesel Load [kw]', 'Hydro Capacity Proposed [kW]:',
        'Net Proposed Hydro Generation [kWh]',
        'Heating Oil Equivalent Captured by Secondary Load [gal]',
        'Loss of Recovered Heat from Genset [gal]',
        'Heat Recovery Operational',
        'Net Reduction in Heating Oil Consumption [gal]',
        'Hydropower Reduction in Utility Diesel Consumed per year',
        'Diesel Generator Efficiency', 'Diesel Price - year 1 [$/gal]',
        'Break Even Diesel Price [$/gal]', 'Levelized Cost Of Energy [$/kWh]',
        'Hydro NPV benefits [$]', 'Hydro NPV Costs [$]',
        'Hydro NPV Net benefit [$]', 'Hydro Internal Rate of Return',
        'Hydro Benefit-cost ratio', 'notes'
    ]

    data = DataFrame(out, columns=cols).set_index('Community')  #.round(2)
    f_name = os.path.join(
        res_dir,
        COMPONENT_NAME.replace(" ", "_").lower() + '_summary.csv')
    with open(f_name, 'w') as summary:
        summary.write((
            '# Hydropower summary by community.\n'
            '# Community: ' + definitions.COMMUNITY + '\n'
            '# Project Name: Name of proposed hydropower project \n'
            '# Start Year: ' + definitions.START_YEAR + '\n'
            '# project phase: ' + definitions.PHASE + '\n'
            '# Average Diesel Load [kw]: ' + definitions.DIESEL_LOAD + '\n'
            '# Hydro Capacity Proposed [kW]: Proposed generation capacity from Hydropower.\n'
            '# Net Proposed Hydro Generation [kWh]: Net generation from proposed hydropower system.\n'
            '# Heating Oil Equivalent Captured by Secondary Load [gal]: \n'
            '# Loss of Recovered Heat from Genset [gal]: \n'
            '# Heat Recovery Operational' + definitions.HR_OP + '\n'
            '# Net Reduction in Heating Oil Consumption [gal]: Change in '
            'heating oil consumed between base and proposed systems\n'
            '# Hydropower Reduction in Utility Diesel Consumed per year: '
            'Reduction in diesel used from generation from hydropower project\n'
            '# Diesel Generator Efficiency: ' + definitions.GEN_EFF + ' \n'
            '# Diesel Price - year 1 [$\gal]: ' + definitions.PRICE_DIESEL +
            '\n'
            '# Break Even Diesel Price [$/gal]: ' +
            definitions.BREAK_EVEN_COST_DIESEL + '\n'
            '# Levelized Cost Of Energy [$/kWh]:' + definitions.LCOE + '\n'
            '# Hydropower NPV benefits [$]: ' + definitions.NPV_BENEFITS + '\n'
            '# Hydropower NPV Costs [$]: ' + definitions.NPV_COSTS + '\n'
            '# Hydropower NPV Net benefit [$]: ' +
            definitions.NPV_NET_BENEFITS + '\n'
            '# Hydropower Internal Rate of Return: ' + definitions.IRR + '\n'
            '# Hydropower Benefit-cost ratio: ' + definitions.NPV_BC_RATIO +
            '\n'
            '# notes: ' + definitions.NOTES + '\n'))

    data.to_csv(f_name, mode='a')
コード例 #4
0
def communities_summary(coms, res_dir):
    """Saves the component summary by community
    
    Parameters
    ----------
    coms : dictionary
        results from the model, dictionary with each community or project 
        as key
    res_dir :  path
        location to save file
    """
    out = []
    for c in sorted(coms.keys()):
        it = coms[c]['community data'].intertie
        if it is None:
            it = 'parent'
        if it == 'child':
            continue
        try:
            # ??? NPV or year one
            it = coms[c][COMPONENT_NAME]
            connect_to = it.comp_specs['nearest community with lower price']

            if it.reason == 'Not a transmission project.':
                continue
            try:
                if it.connect_to_intertie:
                    connect_to += 'intertie'
            except AttributeError:
                pass

            start_yr = it.comp_specs['start year']

            dist = it.comp_specs['distance to community']

            it.get_diesel_prices()
            diesel_price = float(it.diesel_prices[0].round(2))

            try:
                diesel_price_it = float(it.intertie_diesel_prices[0].round(2))
            except AttributeError:
                diesel_price_it = np.nan

            #~ if not it.comp_specs["project details"] is None:
            #~ phase = it.comp_specs["project details"]['phase']
            #~ else:
            phase = "Reconnaissance"

            heat_rec_opp = it.cd['heat recovery operational']

            try:
                generation_displaced = it.pre_intertie_generation[0]
            except AttributeError:
                generation_displaced = np.nan

            try:
                generation_conserved = it.intertie_offset_generation[0]
            except AttributeError:
                generation_conserved = np.nan

            try:
                lost_heat = it.lost_heat_recovery[0]
            except AttributeError:
                lost_heat = np.nan

            try:
                levelized_cost = it.levelized_cost_of_energy
            except AttributeError:
                levelized_cost = 0

            try:
                break_even = it.break_even_cost
            except AttributeError:
                break_even = 0

            eff = it.cd["diesel generation efficiency"]
            try:
                pre_price = it.pre_intertie_generation_fuel_used[0] * \
                            diesel_price
            except AttributeError:
                pre_price = np.nan

            try:
                post_price = it.intertie_offset_generation_fuel_used[0] * \
                            diesel_price_it
            except AttributeError:
                post_price = np.nan

            try:
                eff_it = it.intertie_generation_efficiency
            except AttributeError:
                eff_it = np.nan

            try:
                losses = it.annual_transmission_loss
            except AttributeError:
                losses = np.nan

            name = c
            if name == 'Barrow':
                name = 'Utqiagvik (Barrow)'
            l = [
                name, connect_to, start_yr, phase, dist, generation_displaced,
                generation_conserved, lost_heat, heat_rec_opp, eff, eff_it,
                diesel_price, diesel_price_it, break_even, losses,
                levelized_cost, pre_price, post_price, pre_price - post_price,
                it.get_NPV_benefits(),
                it.get_NPV_costs(),
                it.get_NPV_net_benefit(), it.irr,
                it.get_BC_ratio(), it.reason
            ]
            out.append(l)
        except (KeyError, AttributeError) as e:
            print e
            pass

    cols = [
        'Community to connect', 'Community/Intertie to connect to',
        'Start Year', 'Project Phase', 'Miles of Transmission Line',
        'Generation Displaced in community to connect [kWh]',
        'Electricity Generated, Conserved, or transmitted [kWh]',
        'Loss of Recovered Heat from Genset in community to connect  [gal]',
        'Heat Recovery Operational in community to connect',
        'Diesel Generator Efficiency in community to connect',
        'Diesel Generator Efficiency in community to connect to',
        'Diesel Price - year 1 [$/gal] in community to connect',
        'Diesel Price - year 1 [$/gal] in community to connect to',
        'Breakeven Diesel Price [$/gal]',
        'Annual Transmission loss percentage',
        'Levelized Cost Of Energy [$/kWh]',
        'Status Quo generation Cost (Year 1)',
        'Proposed generation cost (Year 1)',
        'Benefit from reduced generation cost (year 1)',
        'Transmission NPV benefits [$]', 'Transmission NPV Costs [$]',
        'Transmission NPV Net benefit [$]',
        'Transmission Internal Rate of Return',
        'Transmission Benefit-cost ratio', 'notes'
    ]

    data = DataFrame(out, columns=cols).set_index('Community to connect')
    f_name = os.path.join(
        res_dir,
        COMPONENT_NAME.replace(" ", "_").lower() + '_summary.csv')

    fd = open(f_name, 'w')
    fd.write((
        "# Transmission component summary by community\n"
        '# Community to connect: name of main community.\n'
        '# Community/Intertie to connect to: name of secondary community.\n'
        '# Start Year: ' + definitions.START_YEAR + '\n'
        '# project phase: ' + definitions.PHASE + '\n'
        '# Miles of Transmission Line:'
        ' Distance transmission line needs to be.\n'
        '# Generation Displaced in community to connect [kWh]: Diesel '
        'generation displaced in community\n'
        '# Electricity Generated, Conserved, or transmitted [kWh]: \n'
        '# Loss of Recovered Heat from Genset in community to connect [gal]: \n'
        '# Heat Recovery Operational in community to connect: \n'
        '# Diesel Generator Efficiency in community to connect: Estimated '
        'efficiency of diesel generator in community in kilowatt-'
        'hours per gallon.\n'
        '# Diesel Generator Efficiency in community to connect to: Estimated '
        'efficiency of diesel generator in community connected to in '
        'kilowatt-hours per gallon.\n'
        '# Diesel Price - year 1 [$/gal] in community to connect: '
        'Diesel fuel price in the community during the first year of'
        ' project operation.\n'
        '# Diesel Price - year 1 [$/gal] in community to connect to: '
        'Diesel fuel price in the community to connect to during the'
        ' first year of project operation.\n'
        '# Breakeven Diesel Price [$/gal]: ' +
        definitions.BREAK_EVEN_COST_DIESEL + '\n'
        '# Annual Transmission loss percentage: Estimated transmission loss percent.\n'
        '# Levelized Cost Of Energy [$/kWh]:' + definitions.LCOE + '\n'
        '# Status Quo generation Cost (Year 1): Estimated cost of generation in community if nothing changes\n'
        '# Proposed generation cost (Year 1): Estimated cost of generation in community with improvements.\n'
        '# Benefit from reduced generation cost (year 1): Difference in base and proposed cost of generation \n'
        '# Transmission NPV benefits [$]: ' + definitions.NPV_BENEFITS + '\n'
        '# Transmission NPV Costs [$]: ' + definitions.NPV_COSTS + '\n'
        '# Transmission NPV Net benefit [$]: ' + definitions.NPV_NET_BENEFITS +
        '\n'
        '# Transmission Internal Rate of Return: ' + definitions.IRR + '\n'
        '# Transmission Benefit-cost ratio: ' + definitions.NPV_BC_RATIO + '\n'
        '# notes: ' + definitions.NOTES + '\n'))
    fd.close()

    data.to_csv(f_name, mode='a')
コード例 #5
0
def communities_summary(coms, res_dir):
    """Saves the summary by: community diesel_efficiency_summary.csv
    
    Parameters
    ----------
    coms : dictionary
        results from the model, dictionary with each community or project 
        as key
    res_dir :  path
        location to save file
    
    """
    out = []
    for c in sorted(coms.keys()):
        it = coms[c]['community data'].intertie
        if it is None:
            it = 'parent'
        if it == 'child' or c.find("+") != -1:
            continue
        #~ if c.find("_intertie") != -1:
        #~ continue
        try:
            comp = coms[c][COMPONENT_NAME]

            comp.get_diesel_prices()
            diesel_price = float(comp.diesel_prices[0].round(2))
            try:
                average_load = comp.average_load
            except AttributeError:
                average_load = np.nan
            try:
                current_capacity = comp.cd['total capacity']
            except AttributeError:
                current_capacity = np.nan
            try:
                max_capacity = comp.max_capacity
            except AttributeError:
                max_capacity = np.nan
            try:
                generation = comp.generation[0]
            except AttributeError:
                generation = np.nan
            try:
                baseline_eff = comp.baseline_diesel_efficiency
            except AttributeError:
                baseline_eff = np.nan
            try:
                proposed_eff = comp.proposed_diesel_efficiency
            except AttributeError:
                proposed_eff = np.nan
            try:
                baseline_fuel = comp.baseline_generation_fuel_use[0]
            except AttributeError:
                baseline_fuel = np.nan
            try:
                proposed_fuel = comp.proposed_generation_fuel_use[0]
            except AttributeError:
                proposed_fuel = np.nan

            try:
                break_even_cost = comp.break_even_cost
                levelized_cost_of_energy = comp.levelized_cost_of_energy
            except AttributeError:
                break_even_cost = np.nan
                levelized_cost_of_energy = np.nan

            name = c
            if name == 'Barrow':
                name = 'Utqiagvik (Barrow)'
            l = [
                name, average_load, current_capacity, max_capacity, generation,
                baseline_eff, proposed_eff, baseline_fuel, proposed_fuel,
                diesel_price, break_even_cost, levelized_cost_of_energy,
                comp.get_NPV_benefits(),
                comp.get_NPV_costs(),
                comp.get_NPV_net_benefit(), comp.irr,
                comp.get_BC_ratio(), comp.reason
            ]
            out.append(l)

        except (KeyError, AttributeError) as e:
            print e
            pass

    cols = [
        'Community', 'Average Load [kW]', 'Current Capacity [kW]',
        'Proposed Capacity [kW]', 'Generation - year 1[kWh]',
        'Baseline Diesel Generator Efficiency [kWh/gal]',
        'Proposed Diesel Generator Efficiency [kWh/gal]',
        'Baseline Generation Fuel Consumption [Gal]',
        'Proposed Generation Fuel Consumption [Gal]',
        'Diesel price - year 1 [$/gal]', 'Break Even Diesel Price [$/gal]',
        'Levelized Cost of Energy [$/MMBtu]',
        'Diesel Efficiency NPV benefits [$]',
        'Diesel Efficiency NPV Costs [$]',
        'Diesel Efficiency NPV Net benefit [$]',
        'Diesel Efficiency Internal Rate of Return',
        'Diesel Efficiency Benefit-cost ratio', 'notes'
    ]

    data = DataFrame(out, columns=cols).set_index('Community')  #.round(2)
    f_name = os.path.join(
        res_dir,
        COMPONENT_NAME.replace(" ", "_").lower() + '_summary.csv')
    fd = open(f_name, 'w')
    fd.write((
        "# " + COMPONENT_NAME + " summary by community\n"
        '# Community: ' + definitions.COMMUNITY + '\n'
        '# Average Load [kW]: ' + definitions.DIESEL_LOAD + '\n'
        '# Current Capacity [kW]: \n'
        '# Proposed Capacity [kW]: \n'
        '# Generation - year 1[kWh]: \n'
        '# Baseline Diesel Generator Efficiency [kWh/gal]: Current diesel generator efficiency\n'
        '# Proposed Diesel Generator Efficiency [kWh/gal]: Proposed diesel generator efficiency\n'
        '# Baseline Generation Fuel Consumption [Gal]: Current diesel used for generation\n'
        '# Proposed Generation Fuel Consumption [Gal]: Proposed diesel used for generation\n'
        '# Diesel price - year 1 [$/gal]: ' + definitions.PRICE_DIESEL + '\n'
        '# Break Even Diesel Price [$/gal]: ' +
        definitions.BREAK_EVEN_COST_HF + '\n'
        '# Levelized Cost Of Energy [$/kWh]:' + definitions.LCOE + '\n'
        '# Diesel Efficiency NPV benefits [$]: ' + definitions.NPV_BENEFITS +
        '\n'
        '# Diesel Efficiency NPV Costs [$]: ' + definitions.NPV_COSTS + '\n'
        '# Diesel Efficiency NPV Net benefit [$]: ' +
        definitions.NPV_NET_BENEFITS + '\n'
        '# Diesel Efficiency Internal Rate of Return: ' + definitions.IRR +
        '\n'
        '# Diesel Efficiency Benefit-cost ratio: ' + definitions.NPV_BC_RATIO +
        '\n'
        '# notes: ' + definitions.NOTES + '\n'))
    fd.close()
    data.to_csv(f_name, mode='a')