def env_sectors_for_year(year, include_hh=False): if include_hh: blacklist = config.env_sector_blacklist_hh else: blacklist = config.env_sector_blacklist envgen = EnvMatrixGenerator( envtable="%s.env_%d" % (config.WIOD_SCHEMA, year), ind_col_name="industry", series_col_name="measurement", value_col_name="value", universal_conditions=[ "industry NOT IN " + sqlhelper.set_repr(blacklist), ]) return envgen.get_sectors()
def envgen_for_year(year, additional_sectors=[]): blacklist = list(config.env_sector_blacklist) for sector in additional_sectors: blacklist.remove(sector) env_sector_blacklist = sqlhelper.set_repr(blacklist) return EnvMatrixGenerator( envtable="%s.env_%d" % (config.WIOD_SCHEMA, year), ind_col_name="industry", series_col_name="measurement", value_col_name="value", universal_conditions=[ "industry NOT IN " + env_sector_blacklist, "country = $1" ])
import wiod.common from ca import config from common import matrixutils, sqlhelper from common.dbconnect import db from common.matrixutils import NamedMatrix from common.ioutils import IOMatrixGenerator, EnvMatrixGenerator from common.counterfact import CounterfactGenerator iogen = IOMatrixGenerator(transaction_table="%s.ixi_%d" % (config.SCHEMA, config.STUDY_YEARS[0]), final_demand_sectors=config.fd_sectors) iogen.set_pce_col(config.pce_sector) iogen.set_export_col(config.export_sector) envgen = EnvMatrixGenerator( envtable="%s.emissions_quantity" % config.SCHEMA, ind_col_name="industry", series_col_name="1") # we just have emissions, no series, need hack cfgen = CounterfactGenerator(iogen, envgen) cfgen.set_series_code(["1"], "emissions") for year in config.STUDY_YEARS: print(year) iogen = cfgen.get_iogen() iogen.set_table("%s.ixi_%d" % (config.SCHEMA, year)) exchange_rate = wiod.common.get_exchange_rate("CAN", year) if exchange_rate is None: exchange_rate = exrate.get_rate("ca", year)
import wiod.common import common.more_exchange_rates as exrate from jp import config from common import matrixutils, sqlhelper from common.dbconnect import db from common.ioutils import IOMatrixGenerator, EnvMatrixGenerator from common.counterfact import CounterfactGenerator iogen = IOMatrixGenerator(transaction_table=None, from_sector_name="from_sector", to_sector_name="to_sector", value_column_name="value") envgen = EnvMatrixGenerator(envtable=None, ind_col_name="sector", series_col_name="series", value_col_name="value") sector_titles = {} 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()
import wiod.common from ca import config from common import matrixutils, sqlhelper from common.dbconnect import db from common.matrixutils import NamedMatrix from common.ioutils import IOMatrixGenerator, EnvMatrixGenerator from common.counterfact import CounterfactGenerator iogen = IOMatrixGenerator( transaction_table="%s.ixi_%d" % (config.SCHEMA, config.STUDY_YEARS[0]), final_demand_sectors=config.fd_sectors) iogen.set_pce_col(config.pce_sector) iogen.set_export_col(config.export_sector) envgen = EnvMatrixGenerator( envtable="%s.emissions_quantity" % config.SCHEMA, ind_col_name="industry", series_col_name="1") # we just have emissions, no series, need hack cfgen = CounterfactGenerator(iogen, envgen) cfgen.set_series_code(["1"], "emissions") for year in config.STUDY_YEARS: print(year) iogen = cfgen.get_iogen() iogen.set_table("%s.ixi_%d" % (config.SCHEMA, year)) exchange_rate = wiod.common.get_exchange_rate("CAN", year) if exchange_rate is None: exchange_rate = exrate.get_rate("ca", year)
transaction_table="%s.ixi_view_%d" % (config.SCHEMA, config.STUDY_YEARS[0]), from_sector_name="from_sector", to_sector_name="to_sector", value_column_name="value", final_demand_sectors=config.fd_sectors) iogen.set_pce_col(config.pce_sector) iogen.set_export_col(config.export_sector) io_harmonizer = matrixutils.generate_selector_matrix( "%s.code_map" % config.SCHEMA, iogen.get_sectors(), "to_code", "harmonized", ["to_code is not null"]) envgen = EnvMatrixGenerator( envtable="%s.env_%d" % (config.SCHEMA, config.STUDY_YEARS[0]), ind_col_name="sector", series_col_name="series", value_col_name="value") cfgen = CounterfactGenerator(iogen, envgen) for env_series_code in config.env_series: cfgen.set_series_code(env_series_code) for year in config.STUDY_YEARS: iogen = cfgen.get_iogen() iogen.set_table("%s.ixi_view_%d" % (config.SCHEMA, year)) exchange_rate = wiod.common.get_exchange_rate("GBR", year) if exchange_rate is None: exchange_rate = exrate.get_rate("uk", year)
import wiod.common from tw import config from common import matrixutils, sqlhelper from common.ioutils import IOMatrixGenerator, EnvMatrixGenerator from common.counterfact import CounterfactGenerator iogen = IOMatrixGenerator( transaction_table=None, from_sector_name="from_sector", to_sector_name="to_sector", value_column_name="millions") envgen = EnvMatrixGenerator( envtable=None, ind_col_name="sector", series_col_name="series", value_col_name="value") cfgen = CounterfactGenerator(iogen, envgen) for series_code in config.env_series.keys(): cfgen.set_series_code(series_code) for year in config.STUDY_YEARS: iotable = "%s.io_%d" % (config.SCHEMA, year) if year > 2006: # use fake IxI table iotable = "%s.io_view_%d" % (config.SCHEMA, year) iogen = cfgen.get_iogen() iogen.set_table(iotable)