def do_kuznets_plot(): minyear = min(config.STUDY_YEARS) maxyear = max(config.STUDY_YEARS) plot = ScatterPlot("gdp vs emissions change", None, "wiod") for country in config.countries: gdp_pop = common.get_national_value(country, minyear, "ppppc") (env_i, denom_i, intensity_i) = common.get_efficiency( country, minyear, "env", "gdp") (env_f, denom_f, intensity_f) = common.get_efficiency( country, maxyear, "env", "gdp") # numbers are just for sorting which goes on x axis plot.set_value("1 ppp per capita", country, gdp_pop) plot.set_value("2 emiss change", country, intensity_f - intensity_i) plot.write_tables() plot.generate_plot() for year in (minyear, maxyear): plot = ScatterPlot("gdp vs emissions %d" % year, None, "wiod") for country in config.countries: gdp_pop = common.get_national_value(country, year, "ppppc") env_pop = common.get_efficiency(country, year, "env", "gdp") plot.set_value("1 gdp per capita", country, gdp_pop) plot.set_value("2 emissions per capita", country, env_pop[2]) plot.write_tables() plot.generate_plot()
def describe_balance_intensity(): export_total = export_balance.sum(0) import_total = import_balance.sum(0) all_total = all_E.sum(0) balance = export_total.subtract(import_total) balance_ratio = balance.divide(all_total) country_name = config.countries[base_country] years = [str(minyear), str(maxyear)] fields = [] for y in years: balance_val = balance.get_element("sum", y) ratio_val = balance_ratio.get_element("sum", y) (gdp_val, env_val, intensity) = \ common.get_efficiency(base_country, int(y)) if int(y) in balance_plots: plot = balance_plots[int(y)] # ratio = exports to imports plot.set_value("2 ratio", base_country, ratio_val) plot.set_value("1 intensity", base_country, intensity) if int(y) in worldmap: worldmap[int(y)].set_country_value(base_country, balance_val) fields.append(utils.add_commas(balance_val)) fields.append("%.2f" % ratio_val) fields.append("%.2f" % intensity) print(country_name.ljust(15) + " & " + " & ".join(fields) + " \\NN")
def do_overview_table(sortby): minyear = min(config.STUDY_YEARS) maxyear = max(config.STUDY_YEARS) data = {} reverse_data = {} for (country, name) in config.countries.items(): (env_i, gdp_i, intensity_i) = common.get_efficiency( country, minyear, "env", "gdp") (env_f, gdp_f, intensity_f) = common.get_efficiency( country, maxyear, "env", "gdp") if sortby == "growth": pop_i = common.get_national_value(country, minyear, "pop") pop_f = common.get_national_value(country, maxyear, "pop") ppp_i = common.get_national_value(country, minyear, "ppppc") ppp_f = common.get_national_value(country, maxyear, "ppppc") percap_i = env_i / pop_i * 1000 percap_f = env_f / pop_f * 1000 growth = intensity_f - intensity_i pgrowth = percap_f - percap_i reverse_data[ppp_i] = name data[name] = [ utils.add_commas(val).rjust(10) for val in (ppp_i, ppp_f)] data[name] += [ "%.2f" % val for val in (intensity_i, intensity_f, growth, percap_i, percap_f, pgrowth)] else: # end year intensity reverse_data[intensity_f] = name data[name] = [ utils.add_commas(val).rjust(10) for val in (gdp_i, gdp_f, env_i, env_f)] data[name] += ["%.2f" % val for val in (intensity_i, intensity_f)] for key in sorted(reverse_data.keys()): country = reverse_data[key] vals = data[country] print(country.ljust(18) + " & " + " & ".join(vals) + " \\NN")