Example #1
0
def save_regional_summary(summary, res_dir):
    """Saves the summary by region:  __regional_residential_ashp_summary.csv
    
    Parameters
    ----------
    summary : DataFrame
        compiled regional results
    res_dir :  path
        location to save file

    """
    f_name = os.path.join(res_dir, '__regional_' +
                COMPONENT_NAME.lower().replace(' ','_').\
                    replace('(','').replace(')','') + '_summary.csv')
    summary.to_csv(f_name, mode='w', index_label='region')
Example #2
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')
def communities_summary (coms, res_dir):
    """Saves the summary by: community biomass_cordwood_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:
            
           
            biomass = coms[c][COMPONENT_NAME]
            
            
            
            biomass.get_diesel_prices()
            diesel_price = float(biomass.diesel_prices[0].round(2))
            hf_price = diesel_price + biomass.cd['heating fuel premium']   
            
            try:
                break_even = biomass.break_even_cost
            except AttributeError:
                break_even = 0
               
            
            try:
                levelized_cost = biomass.levelized_cost_of_energy
            except AttributeError:
                levelized_cost = 0
            
            name = c
            if name == 'Barrow':
                name = 'Utqiagvik (Barrow)'
            l = [name,  
                 biomass.max_boiler_output,
                 biomass.heat_displaced_sqft,
                 biomass.biomass_fuel_consumed,
                 biomass.fuel_price_per_unit,
                 biomass.comp_specs['energy density'],
                 biomass.heat_diesel_displaced,
                 hf_price,
                 break_even,
                 levelized_cost,
                 biomass.get_NPV_benefits(),
                 biomass.get_NPV_costs(),
                 biomass.get_NPV_net_benefit(),
                 biomass.irr,
                 biomass.get_BC_ratio(),
                 biomass.reason
                ]
            out.append(l)
            
        except (KeyError,AttributeError) as e:
            #~ print e
            pass
    try:
        cols = ['Community',
            'Maximum Biomass Boiler Output [Btu/hr]',
            'Biomass Heat Displacement square footage [Sqft]',
            'Proposed ' + biomass.biomass_type + \
                            " Consumed [" + biomass.units +"]",
            'Price [$/' + biomass.units + ']',
            "Energy Density [Btu/" + biomass.units + "]",
            'Displaced Heating Oil by Biomass [Gal]',
            "Heating Fuel Price - year 1 [$/gal]",
            'Break Even Heating Fuel Price [$/gal]',
            'Levelized Cost Of Energy [$/MMBtu]',
            'Biomass Cordwood NPV benefits [$]',
            'Biomass Cordwood NPV Costs [$]',
            'Biomass Cordwood NPV Net benefit [$]',
            'Biomass Cordwood Internal Rate of Return',
            'Biomass Cordwood Benefit-cost ratio',
            'notes'
                ]
    except UnboundLocalError:
        return
    
    
    data = DataFrame(out,columns = cols).set_index('Community')#.round(2)
    f_name = os.path.join(res_dir,
                COMPONENT_NAME.lower().replace(' ','_').\
                    replace('(','').replace(')','') + '_summary.csv')
    fd = open(f_name,'w')
    fd.write(("# " + COMPONENT_NAME + " summary by community\n"
            '# Maximum Biomass Boiler Output [Btu/hr]:\n'
            '# Biomass Heat Displacement square footage [Sqft]: Non-residential area to heat with biomass\n'
            '# Proposed ' + biomass.biomass_type + ""
                " consumed [" + biomass.units +"]: Proposed biomass fuel consumed\n"
            '# Price [$/' + biomass.units + ']: Price of biomass fuel\n'
            "# Energy Density [Btu/" + biomass.units + "]: Energy Density of fuel\n"
            '# Displaced Heating Oil by Biomass [Gal]: Estimated heating fuel displace by biomass heating\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'
            '# notes: '+ definitions.NOTES +'\n'))
    fd.close()
    data.to_csv(f_name, mode='a')
Example #4
0
def communities_summary(coms, res_dir):
    """Saves the summary by: community non-residential_building_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()):
        if c.find('+') != -1:  # or c.find("_intertie") != -1:
            continue
        try:
            com = coms[c][COMPONENT_NAME]
            savings = (com.baseline_HF_consumption -\
                      com.proposed_HF_consumption ) * constants.mmbtu_to_gal_HF

            name = c
            if name == 'Barrow':
                name = 'Utqiagvik (Barrow)'

            out.append([
                name,
                com.get_NPV_benefits(),
                com.get_NPV_costs(),
                com.get_NPV_net_benefit(), com.irr,
                com.get_BC_ratio(), com.hoil_price[0], com.elec_price[0],
                com.num_buildings, com.total_sqft_to_retrofit,
                com.break_even_cost, com.levelized_cost_of_energy['MMBtu'],
                com.levelized_cost_of_energy['kWh'],
                com.baseline_HF_consumption * constants.mmbtu_to_gal_HF,
                com.baseline_kWh_consumption, savings,
                com.baseline_kWh_consumption - com.proposed_kWh_consumption
            ])
        except (KeyError, AttributeError) as e:
            #~ print c +":"+ str(e)
            pass

    cols = [
        'Community', 'Non-residential Efficiency NPV Benefit',
        'Non-residential Efficiency NPV Cost',
        'Non-residential Efficiency NPV Net Benefit',
        'Non-residential Internal Rate of Return',
        'Non-residential Efficiency B/C Ratio', 'Heating Oil Price - year 1',
        '$ per kWh - year 1', 'Number Non-residential Buildings',
        'Non-residential Total Square Footage',
        'Breakeven Heating Fuel Price [$/gal heating oil equiv.]',
        'Levelized Cost of Energy [$/MMBtu]',
        'Levelized Cost of Energy [$/kWh]',
        'Non-residential Heating oil equiv. Consumed(gal) - year 1',
        'Non-residential Electricity Consumed (kWh) - year 1',
        'Non-residential Efficiency Heating oil equiv. Saved[gal/year]',
        'Non-residential Efficiency Electricity Saved [kWh/year]'
    ]

    data = DataFrame(out, columns=cols).set_index('Community').round(2)
    f_name = os.path.join(
        res_dir,
        COMPONENT_NAME.lower().replace(' ', '_') + '_summary.csv')
    fd = open(f_name, 'w')
    fd.write((
        "# non residential building component summary by community\n"
        '# Community: ' + definitions.COMMUNITY + '\n'
        '# Non-residential Efficiency NPV Benefit: ' +
        definitions.NPV_BENEFITS + '\n'
        '# Non-residential Efficiency NPV Cost: ' + definitions.NPV_COSTS +
        '\n'
        '# Non-residential Efficiency NPV Net Benefit: ' +
        definitions.NPV_NET_BENEFITS + '\n'
        '# Non-residential Internal Rate of Return: ' + definitions.IRR + '\n'
        '# Non-residential Efficiency B/C Ratio: ' + definitions.NPV_BC_RATIO +
        '\n'
        '# Heating Oil Price - year 1: ' + definitions.PRICE_HF + '\n'
        '# $ per kWh - year 1: ' + definitions.PRICE_ELECTRICITY + '\n'
        '# Number Non-residential Buildings: Number of buildings in the community.\n'
        '# Non-residential Total Square Footage: Total Square footage from buildings.\n'
        '# Breakeven Heating Fuel Price [$/gal heating oil equiv.]: ' +
        definitions.BREAK_EVEN_COST_HF + '\n'
        '# Levelized Cost of Energy [$/MMBtu]: ' + definitions.LCOE + '\n'
        '# Levelized Cost of Energy [$/kWh]: ' + definitions.LCOE + '\n'
        '# Non-residential Heating Oil equiv. Consumed(gal) - year 1: Heating energy consumed in a community with out improvements.\n'
        '# Non-residential Electricity Consumed (kWh) - year 1: Electricity consumed in a community without improvements.\n'
        '# Non-residential Efficiency Heating oil equiv. Saved[gal/year]: Heating energy saved in a community with improvements.\n'
        '# Non-residential Efficiency Electricity Saved [kWh/year]: Electricity consumed in a community with improvements.\n'
    ))
    fd.close()
    data.to_csv(f_name, mode='a')
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')
Example #6
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()):
        if c.find('+') != -1 or c.find("_intertie") != -1:
            continue
        try:
            www = coms[c][COMPONENT_NAME]
            try:
                oil_p, elec_p = www.hoil_price[0], www.elec_price[0]
            except AttributeError:
                oil_p, elec_p = 0, 0

            savings = (www.baseline_HF_consumption -\
                      www.proposed_HF_consumption) * constants.mmbtu_to_gal_HF

            name = c
            if name == 'Barrow':
                name = 'Utqiagvik (Barrow)'

            out.append([
                name,
                www.get_NPV_benefits(),
                www.get_NPV_costs(),
                www.get_NPV_net_benefit(),
                www.irr,
                www.get_BC_ratio(),
                oil_p,
                elec_p,
                #~ www.num_buildings , www.refit_sqft_total,
                www.break_even_cost,
                www.levelized_cost_of_energy['MMBtu'],
                www.levelized_cost_of_energy['kWh'],
                www.baseline_HF_consumption[0] * constants.mmbtu_to_gal_HF,
                www.baseline_kWh_consumption[0],
                savings[0],
                (www.baseline_kWh_consumption -
                 www.proposed_kWh_consumption)[0]
            ])
        except (KeyError, AttributeError) as e:
            #~ print c +":"+ str(e)
            pass

    cols = [
        'Community',
        'Water/Wastewater Efficiency NPV Benefit',
        'Water/Wastewater Efficiency NPV Cost',
        'Water/Wastewater Efficiency NPV Net Benefit',
        'Water/Wastewater Internal Rate of Return',
        'Water/Wastewater Efficiency B/C Ratio',
        'Heating Oil Price - year 1',
        '$ per kWh - year 1',
        #~ 'Number Water/Wastewater Buildings',
        #~ 'Water/Wastewater Total Square Footage',
        'Break Even Diesel Price [$/gal heating oil equiv.]',
        'Levelized Cost of Energy [$/MMBtu]',
        'Levelized Cost of Energy [$/kWh]',
        'Water/Wastewater Heating Oil Equiv. Consumed (gal) - year 1',
        'Water/Wastewater Electricity Consumed (kWh) - year 1',
        'Water/Wastewater Efficiency Heating Oil Equiv. Saved [gal/year]',
        '# Water/Wastewater Efficiency Electricity Saved [kWh/year]'
    ]

    data = DataFrame(out, columns=cols).set_index('Community').round(2)
    f_name = os.path.join(res_dir,
                    COMPONENT_NAME.lower().replace(' ','_').\
                    replace('&','and') + '_summary.csv')
    fd = open(f_name, 'w')
    fd.write(
        ("# non residential building component summary by community\n"
         '# \n'
         '# Community: ' + definitions.COMMUNITY + '\n'
         '# Water/Wastewater Efficiency NPV Benefit: ' +
         definitions.NPV_BENEFITS + '\n'
         '# Water/Wastewater Efficiency NPV Cost: ' + definitions.NPV_COSTS +
         '\n'
         '# Water/Wastewater Efficiency NPV Net Benefit: ' +
         definitions.NPV_NET_BENEFITS + '\n'
         '# Water/Wastewater Internal Rate of Return: ' + definitions.IRR +
         '\n'
         '# Water/Wastewater Efficiency B/C Ratio: ' +
         definitions.NPV_BC_RATIO + '\n'
         '# Heating Oil Price - year 1:'
         ' Heating Oil Price year one of project\n'
         '# $ per kWh - year 1: Electricity Price year one of project\n'
         '# Break Even Diesel Price [$/gal heating oil equiv.]: ' +
         definitions.BREAK_EVEN_COST_DIESEL + '\n'
         '# Levelized Cost of Energy [$/MMBtu]: \n'
         '# Levelized Cost of Energy [$/kWh]: \n'
         '# Water/Wastewater Heating Oil Equiv. Consumed (gal) - year 1:'
         ' heating oil equivalent consumed by water wastewater system\n'
         '# Water/Wastewater Electricity Consumed (kWh) - year 1:'
         ' Electricity consumed by water wastewater system\n'
         '# Water/Wastewater Efficiency Heating Oil Equiv. Saved [gal/year]:\n'
         '# Water/Wastewater Efficiency Electricity Saved [kWh/year]:\n'))
    fd.close()
    data.to_csv(f_name, mode='a')
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')
Example #8
0
def communities_summary (coms, res_dir):
    """Saves the summary by: community residential_building_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()):
        if c.find('+') != -1 or c.find("_intertie") != -1:
            continue
        try:
            res = coms[c][COMPONENT_NAME]

            name = c
            if name == 'Barrow':
                name = 'Utqiagvik (Barrow)'
            out.append([name,
                res.get_NPV_benefits(),res.get_NPV_costs(),
                res.get_NPV_net_benefit(),res.irr,res.get_BC_ratio(),
                res.hoil_price[0], res.init_HH, res.opportunity_HH,
                res.break_even_cost, res.levelized_cost_of_energy,
                res.baseline_fuel_Hoil_consumption[0]/constants.mmbtu_to_gal_HF,
                (res.baseline_fuel_Hoil_consumption[0] - \
                    res.proposed_fuel_Hoil_consumption[0])/\
                        constants.mmbtu_to_gal_HF,
                round(float(res.fuel_oil_percent)*100,2),
                res.baseline_HF_consumption[0],
                res.baseline_HF_consumption[0] - \
                        res.proposed_HF_consumption[0],
                ])
        except (KeyError,AttributeError) as e :
            #~ print e
            pass

    cols = ['Community',
           'Residential Efficiency NPV Benefit',
           'Residential Efficiency NPV Cost',
           'Residential Efficiency NPV Net Benefit',
           'Residential Internal Rate of Return',
           'Residential Efficiency B/C Ratio',
           'Heating Oil Price - year 1',
           'Occupied Houses',
           'Houses to Retrofit',
           'Breakeven Heating Fuel Price [$/gal heating oil equiv.]',
           'Levelized Cost of Energy [$/MMBtu]',
           'Residential Heating Oil Consumed (MMBtu) - year 1',
           'Residential Efficiency Heating Oil Saved (MMBtu/year)',
           'Residential Heating Oil as percent of Total Heating Fuels',
           'Total Residential Heating Fuels (MMBtu) - year 1',
           'Residential Efficiency Total Heating Fuels Saved (MMBtu/year)',
            ]
    data = DataFrame(out,columns = cols).set_index('Community').round(2)
    f_name = os.path.join(res_dir,
                COMPONENT_NAME.lower().replace(' ','_') + '_summary.csv')
    fd = open(f_name,'w')
    fd.write(("# resident building component summary by community\n"
           '# community: '+ definitions.COMMUNITY + '\n'
           '# Residential Efficiency NPV Benefit: ' + definitions.NPV_BENEFITS + '\n'
           '# Residential Efficiency NPV Cost: ' + definitions.NPV_COSTS + '\n'
           '# Residential Efficiency NPV Net Benefit: ' + definitions.NPV_NET_BENEFITS + '\n'
           '# Residential Internal Rate of Return: ' + definitions.IRR +'\n'
           '# Residential Efficiency B/C Ratio: ' + definitions.NPV_BC_RATIO + '\n'
           '# Heating Oil Price - year 1: ' + definitions.PRICE_HF + '\n'
           '# Occupied Houses: Occupied homes in communities.\n'
           '# Houses to Retrofit: Houses that are to be retrofit.\n'
           '# Breakeven Heating Fuel Price [$/gal heating oil equiv.]: ' + definitions.BREAK_EVEN_COST_HF + '\n'
           '# Levelized Cost of Energy [$/MMBtu]: ' + definitions.LCOE + '\n'
           '# Residential Heating Oil Consumed (MMBtu) - year 1: Heating oil consumed by current systems.\n'
           '# Residential Efficiency Heating Oil Saved (MMBtu/year): Heating oil saved by retrofit systems.\n'
           '# Residential Heating Oil as percent of Total Heating Fuels: Percentage of heating fuels that is heating oil.\n'
           '# Total Residential Heating Fuels (MMBtu) - year 1: Heating fuel consumed by current systems.\n'
           '# Residential Efficiency Total Heating Fuels Saved (MMBtu/year): Heating fuel consumed by current systems.\n'
        ))
    fd.close()
    data.to_csv(f_name, mode='a')
def communities_summary(coms, res_dir):
    """Saves the summary by: community Solar_power_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:
            solar = coms[c][COMPONENT_NAME]

            start_yr = solar.comp_specs['start year']
            solar.get_diesel_prices()
            diesel_price = float(solar.diesel_prices[0].round(2))
            assumed_out = solar.comp_specs['output per 10kW solar PV']
            average_load = solar.average_load
            proposed_capacity = solar.proposed_load + 0
            existing_capacity = solar.cd['solar capacity']
            wind_capacity = solar.cd['wind capacity']

            try:
                net_gen = solar.generation_proposed[0]
                loss_heat = solar.fuel_displaced[0]
                hr_op = solar.cd['heat recovery operational']
                net_heating = -1 * loss_heat
                eff = solar.cd["diesel generation efficiency"]
                red_per_year = solar.generation_fuel_used[0]
            except AttributeError:
                net_gen = 0
                loss_heat = 0
                hr_op = solar.cd['heat recovery operational']
                net_heating = 0
                eff = solar.cd["diesel generation efficiency"]
                red_per_year = 0

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

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

            name = c
            if name == 'Barrow':
                name = 'Utqiagvik (Barrow)'
            l = [
                name, assumed_out, average_load, proposed_capacity,
                existing_capacity, wind_capacity, net_gen, loss_heat, hr_op,
                net_heating, red_per_year, eff, diesel_price, break_even,
                levelized_cost,
                solar.get_NPV_benefits(),
                solar.get_NPV_costs(),
                solar.get_NPV_net_benefit(), solar.irr,
                solar.get_BC_ratio(), solar.reason
            ]
            out.append(l)

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

    cols = [
        'Community', 'Assumed  Output per 10kW Solar PV Array',
        'Average Diesel Load [kw]', 'Solar Capacity Proposed [kW]',
        'Existing Solar Capacity [kW]', 'Existing Wind Capacity [kW]',
        'Net Proposed Solar Generation [kWh]',
        'Loss of Recovered Heat from Proposed Solar [gal]',
        'Heat Recovery Operational',
        'Net in Heating Oil Consumption from Proposed Solar [gal]',
        'Proposed Solar 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]',
        'Solar NPV benefits [$]', 'Solar NPV Costs [$]',
        'Solar NPV Net benefit [$]', 'Solar Internal Rate of Return',
        'Solar Benefit-cost ratio', 'notes'
    ]

    data = DataFrame(out, columns=cols).set_index('Community')  #.round(2)
    f_name = os.path.join(res_dir,
                COMPONENT_NAME.lower().replace(' ','_').\
                    replace('&','and') + '_summary.csv')
    fd = open(f_name, 'w')
    fd.write((
        "# solar summary\n"
        '# Community: name of community/project.\n'
        '# Assumed  Output per 10kW Solar PV Array: '
        'Assumed power output of 10 kW solar panel\n'
        '# Average Diesel Load [kw]: ' + definitions.DIESEL_LOAD + '\n'
        '# Solar Capacity Proposed [kW]: '
        'Proposed generation offset by solar system\n'
        '# Existing Solar Capacity [kW]: '
        'Generation capacity of existing solar systems in community\n'
        '# Existing Wind Capacity [kW]: '
        'Generation capacity of existing wind systems in community\n'
        '# Net Proposed Solar Generation [kWh]: '
        'Net electric generation from new systems in kilowatt-hours\n'
        '# Loss of Recovered Heat from Proposed Solar [gal]: '
        'Loss in heat recovery caused by new solar systems.\n'
        '# Heat Recovery Operational: ' + definitions.HR_OP + '\n'
        '# Net Change in Heating Oil Consumption from Proposed Solar [gal]:'
        ' Change in heating oil consumption that would be caused by improvements\n'
        '# Proposed Solar Reduction in Utility Diesel Consumed per year: '
        'Reduction in generation diesel from proposed solar system.\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'
        '# Wind power NPV benefits [$]: ' + definitions.NPV_BENEFITS + '\n'
        '# Wind power NPV Costs [$]: ' + definitions.NPV_COSTS + '\n'
        '# Wind power NPV Net benefit [$]: ' + definitions.NPV_NET_BENEFITS +
        '\n'
        '# Wind power Internal Rate of Return: ' + definitions.IRR + '\n'
        '# Wind power Benefit-cost ratio: ' + definitions.NPV_BC_RATIO + '\n'
        '# notes: ' + definitions.NOTES + '\n'))
    fd.close()
    data.to_csv(f_name, mode='a')
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
    """
    #~ return
    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
            wind = coms[c][COMPONENT_NAME]

            start_yr = wind.comp_specs['start year']
            wind.get_diesel_prices()
            diesel_price = float(wind.diesel_prices[0].round(2))
            phase = wind.comp_specs['phase']
            average_load = wind.average_load
            existing_load = wind.cd['wind capacity']
            existing_solar = wind.cd['solar capacity']
            wind_class = float(wind.comp_specs['wind class'])
            proposed_load = wind.load_offset_proposed
            cap_fac = float(wind.comp_specs['capacity factor'])
            heat_rec_opp = wind.cd['heat recovery operational']
            try:
                #~ offset = wind.load_offset_proposed
                net_gen_wind = wind.net_generation_wind
                decbb = wind.diesel_equiv_captured

                loss_heat = wind.loss_heat_recovery
                electric_diesel_reduction = wind.electric_diesel_reduction

                diesel_red = wind.reduction_diesel_used
                levelized_cost = wind.levelized_cost_of_energy
                break_even = wind.break_even_cost
                eff = wind.cd["diesel generation efficiency"]

            except AttributeError:
                offset = 0
                net_gen_wind = 0
                decbb = 0
                electric_diesel_reduction = 0
                loss_heat = 0

                diesel_red = 0
                levelized_cost = 0
                break_even = 0
                eff = wind.cd["diesel generation efficiency"]

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

            name = c
            if name == 'Barrow':
                name = 'Utqiagvik (Barrow)'
            l = [
                name, start_yr, phase, wind_class, average_load, proposed_load,
                existing_load, existing_solar, cap_fac, net_gen_wind, decbb,
                loss_heat, heat_rec_opp, diesel_red, electric_diesel_reduction,
                eff, diesel_price, break_even, levelized_cost,
                wind.get_NPV_benefits(),
                wind.get_NPV_costs(),
                wind.get_NPV_net_benefit(), wind.irr,
                wind.get_BC_ratio(), wind.reason
            ]
            out.append(l)
        except (KeyError, AttributeError) as e:
            #~ print e
            pass

    cols = [
        'Community', 'Start Year', 'Project phase', 'Assumed Wind Class',
        'Average Diesel Load [kW]', 'Wind Capacity Proposed [kW]',
        'Existing Wind Capacity [kW]', 'Existing Solar Capacity [kW]',
        'Assumed Wind Class Capacity Factor [%]',
        'Net Proposed Wind Generation [kWh]',
        'Heating Oil Equivalent Captured by Secondary Load [gal]',
        'Loss of Recovered Heat from Genset [gal]',
        'Heat Recovery Operational', 'Net in Heating Oil Consumption [gal]',
        'Wind Power Reduction in Utility Diesel Consumed per year [gal]',
        'Diesel Generator Efficiency', 'Diesel Price - year 1 [$/gal]',
        'Breakeven Diesel Price [$/gal]', 'Levelized Cost Of Energy [$/kWh]',
        'Wind NPV benefits [$]', 'Wind NPV Costs [$]',
        'Wind NPV Net benefit [$]', 'Wind Internal Rate of Return',
        'Wind Benefit-cost ratio', 'notes'
    ]

    data = DataFrame(out, columns=cols).set_index('Community')  #.round(2)
    f_name = os.path.join(
        res_dir,
        COMPONENT_NAME.lower().replace(' ', '_') + '_summary.csv')
    fd = open(f_name, 'w')
    fd.write((
        "# wind summary\n"
        '# Breakdown by community of potential wind power improvements'
        '# \n'
        '# Community: ' + definitions.COMMUNITY + '\n'
        '# Start Year: ' + definitions.START_YEAR + '\n'
        '# Project phase: ' + definitions.PHASE + '\n'
        '# Assumed Wind Class: Wind power density class\n'
        '# Average Diesel Load [kW]: ' + definitions.DIESEL_LOAD + '\n'
        '# Wind Capacity Proposed [kW]: Proposed additional capacity for wind'
        ' generation in kilowatts.\n'
        '# Existing Wind Capacity [kW]: Existing wind generation capacity'
        ' in kilowatts.\n'
        '# Existing Solar Capacity [kW]: Existing solar generation capacity'
        ' in kilowatts.\n'
        '# Assumed Wind Class Capacity Factor [%]:\n'
        '# Net Proposed Wind Generation [kWh]: Proposed wind net generation'
        ' in kilowatt-hours.\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 in Heating Oil Consumption [gal]: \n'
        '# Wind Power Reduction in Utility Diesel Consumed per year [gal]: Estimated '
        'Reduction in utility diesel if wind power system is '
        'installed/upgraded. In gallons per year\n'
        '# Diesel Generator Efficiency: ' + definitions.GEN_EFF + ' \n'
        '# Diesel Price - year 1 [$\gal]: ' + definitions.PRICE_DIESEL + '\n'
        '# Breakeven Diesel Price [$/gal]: ' +
        definitions.BREAK_EVEN_COST_DIESEL + '\n'
        '# Levelized Cost Of Energy [$/kWh]:' + definitions.LCOE + '\n'
        '# Wind power NPV benefits [$]: ' + definitions.NPV_BENEFITS + '\n'
        '# Wind power NPV Costs [$]: ' + definitions.NPV_COSTS + '\n'
        '# Wind power NPV Net benefit [$]: ' + definitions.NPV_NET_BENEFITS +
        '\n'
        '# Wind power Internal Rate of Return: ' + definitions.IRR + '\n'
        '# Wind power Benefit-cost ratio: ' + definitions.NPV_BC_RATIO + '\n'
        '# notes: ' + definitions.NOTES + '\n'))

    fd.close()
    data.to_csv(f_name, mode='a')
Example #11
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')
Example #12
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')