示例#1
0
文件: food_sector.py 项目: sonya/eea
    fh = open(path, "r")
    csvf = csv.reader(fh)
    io_codes = common.io_codes_for_year(year)

    data = {}
    row = next(csvf)
    for row in csvf:
        if len(row) == 6:
            sector = row[0]
            btu = row[1]  # total
            #btu = row[2] # coal
            #btu = row[3] # natural gas
            #btu = row[5] # PA-nontrans
            data[sector] = float(btu)

    pce_vector = common.pce_bridge_vector(
        year, "Food and beverages purchased for off-premises consumption")
    #pce_vector = common.pce_bridge_vector(
    #    year, "Clothing and footwear")

    total_expenditure = 0
    meat_expenditure = 0

    energy_data = {}
    for row in pce_vector.get_rows():
        expenditure = pce_vector.get_element(row)
        if expenditure != 0:
            intensity = data[row]
            if row in combined_meat_codes:
                sector = io_codes[row]
                print(row, sector, intensity)
示例#2
0
文件: matrices.py 项目: sonya/eea
    for sector in bea.scrap_used_codes[year]:
        imp_to_cons.set_element(sector, colname, 0)

    # create matrix to collapse split petroleum sectors when multiplying
    # by the import ratio
    rows = iogen_standard.get_sectors()
    cols = iogen.get_sectors()
    pa_collapser = NamedMatrix(False, None, rows, cols)
    for col in cols:
        if col in rows:
            pa_collapser.set_element(col, col, 1)
        elif col == eia.source_naics_map["PA-trans"][year] or \
                col == eia.source_naics_map["PA-nontrans"][year]:
            pa_collapser.set_element(eia.source_naics_map["PA"][year], col, 1)

    conven_pce = common.pce_bridge_vector(year) # all in dollars
    conversions = {} # get btu per dollar which we will use to convert subvectors
    for code in energy_codes:
        conversions[code] = hybrid_pce.get_element(code) / \
            conven_pce.get_element(code)

    for group in bea.nipa_groups:
        Y = common.pce_bridge_vector(year, group)

        deflator = deflators.get_pce_deflator(year)
        pce = Y.sum() * deflator

        if group not in pce_imports:
            pce_imports[group] = {}

        # pce gets /1000 and /1000 again in "is_intensity" version
示例#3
0
文件: food_sector.py 项目: sonya/eea
    fh = open(path, "r")
    csvf = csv.reader(fh)
    io_codes = common.io_codes_for_year(year)

    data = {}
    row = next(csvf)
    for row in csvf:
        if len(row) == 6:
            sector = row[0]
            btu = row[1] # total
            #btu = row[2] # coal
            #btu = row[3] # natural gas
            #btu = row[5] # PA-nontrans
            data[sector] = float(btu)

    pce_vector = common.pce_bridge_vector(
        year, "Food and beverages purchased for off-premises consumption")
    #pce_vector = common.pce_bridge_vector(
    #    year, "Clothing and footwear")

    total_expenditure = 0
    meat_expenditure = 0

    energy_data = {}
    for row in pce_vector.get_rows():
        expenditure = pce_vector.get_element(row)
        if expenditure != 0:
            intensity = data[row]
            if row in combined_meat_codes:
                sector = io_codes[row]
                print(row, sector, intensity)