コード例 #1
0
ファイル: common.py プロジェクト: sonya/eea
def iogen_for_year(year,
                   is_hybrid=False,
                   allow_imports=True,
                   adjust_for_inflation=False):

    if is_hybrid:
        transaction_table = "hybrid_transactions_%d" % year
        value_column_name = "expenditure"
    else:
        transaction_table = "%s.transact_view_%d" % (config.IO_SCHEMA, year)
        value_column_name = "fob"

    fd_codes = fd_sectors_for_year(year, is_hybrid)

    iogen = IOMatrixGenerator(
        transaction_table=transaction_table,
        from_sector_name="from_sector",
        to_sector_name="to_sector",
        value_column_name=value_column_name,
        final_demand_sectors=fd_codes)
    iogen.set_pce_col(bea.fd_sectors[year]["pce"])
    iogen.set_export_col(bea.fd_sectors[year]["exports"])

    from_blacklist = [bea.tourism_adjustment_codes[year]]
    to_blacklist = [bea.tourism_adjustment_codes[year]]
    if year in (1972, 1977, 1982):
        from_blacklist.append("780300")
        to_blacklist.append("780300")

    if not allow_imports:
        to_blacklist.append(bea.fd_sectors[year]["imports"])

    iogen.blacklist_from_sectors(from_blacklist)
    iogen.blacklist_to_sectors(to_blacklist)

    if adjust_for_inflation:
        iogen.set_exchange_rate(deflators.get_gdp_deflator(year))

    return iogen
コード例 #2
0
def iogen_for_year(year,
                   is_hybrid=False,
                   allow_imports=True,
                   adjust_for_inflation=False):

    if is_hybrid:
        transaction_table = "hybrid_transactions_%d" % year
        value_column_name = "expenditure"
    else:
        transaction_table = "%s.transact_view_%d" % (config.IO_SCHEMA, year)
        value_column_name = "fob"

    fd_codes = fd_sectors_for_year(year, is_hybrid)

    iogen = IOMatrixGenerator(transaction_table=transaction_table,
                              from_sector_name="from_sector",
                              to_sector_name="to_sector",
                              value_column_name=value_column_name,
                              final_demand_sectors=fd_codes)
    iogen.set_pce_col(bea.fd_sectors[year]["pce"])
    iogen.set_export_col(bea.fd_sectors[year]["exports"])

    from_blacklist = [bea.tourism_adjustment_codes[year]]
    to_blacklist = [bea.tourism_adjustment_codes[year]]
    if year in (1972, 1977, 1982):
        from_blacklist.append("780300")
        to_blacklist.append("780300")

    if not allow_imports:
        to_blacklist.append(bea.fd_sectors[year]["imports"])

    iogen.blacklist_from_sectors(from_blacklist)
    iogen.blacklist_to_sectors(to_blacklist)

    if adjust_for_inflation:
        iogen.set_exchange_rate(deflators.get_gdp_deflator(year))

    return iogen
コード例 #3
0
ファイル: counterfact.py プロジェクト: sonya/eea
stmt = db.prepare("select distinct harmonized, description" +
                  "  from jp.io_map_1990 order by harmonized")
for row in stmt():
    sector_titles[row[0]] = row[1]

cfgen = CounterfactGenerator(iogen, envgen)

for series_code in config.env_series.keys():
    cfgen.set_series_code(series_code)

    for year in config.STUDY_YEARS:
        iogen = cfgen.get_iogen()
        iogen.set_table("%s.ixi_%d" % (config.SCHEMA, year))
        iogen.set_fd_sectors(config.fd_sectors[year])
        iogen.blacklist_from_sectors(config.from_blacklists[year])
        iogen.blacklist_to_sectors(config.to_blacklists[year])
        iogen.set_pce_col(config.pce_sector[year])
        iogen.set_export_col(config.export_sector[year])

        exchange_rate = wiod.common.get_exchange_rate("JPN", year)
        if exchange_rate is None:
            exchange_rate = 1 / exrate.get_rate("jp", year)

        # tons co2 / (M jpy * exchange rate) = tons co2 / M usd
        # GJ / (M jpy * exchange rate) = GJ / M usd
        # exchange_rate * 1000 gives us kilotons and terrajoules
        iogen.set_exchange_rate(exchange_rate * 1000)

        envgen = cfgen.get_envgen()
        envgen.set_table("%s.env_%d" % (config.SCHEMA, year))
コード例 #4
0
ファイル: counterfact.py プロジェクト: sonya/eea
stmt = db.prepare("select distinct harmonized, description" +
                  "  from jp.io_map_1990 order by harmonized")
for row in stmt():
    sector_titles[row[0]] = row[1]

cfgen = CounterfactGenerator(iogen, envgen)

for series_code in config.env_series.keys():
    cfgen.set_series_code(series_code)
    
    for year in config.STUDY_YEARS:
        iogen = cfgen.get_iogen()
        iogen.set_table("%s.ixi_%d" % (config.SCHEMA, year))
        iogen.set_fd_sectors(config.fd_sectors[year])
        iogen.blacklist_from_sectors(config.from_blacklists[year])
        iogen.blacklist_to_sectors(config.to_blacklists[year])
        iogen.set_pce_col(config.pce_sector[year])
        iogen.set_export_col(config.export_sector[year])
    
        exchange_rate = wiod.common.get_exchange_rate("JPN", year)
        if exchange_rate is None:
            exchange_rate = 1 / exrate.get_rate("jp", year)

        # tons co2 / (M jpy * exchange rate) = tons co2 / M usd
        # GJ / (M jpy * exchange rate) = GJ / M usd
        # exchange_rate * 1000 gives us kilotons and terrajoules
        iogen.set_exchange_rate(exchange_rate * 1000)
    
        envgen = cfgen.get_envgen()
        envgen.set_table("%s.env_%d" % (config.SCHEMA, year))