default=DEFAULT_DATABASE_FILE)
    argparser.add_argument('-o',
                           '--output',
                           type=str,
                           default=DEFAULT_SUMMARY_FILE)
    argparser.add_argument(
        '--country',
        type=str,
        nargs='+',
        help="ISO-3 country codes; all countries are processed by default.")
    args = argparser.parse_args()

    # prepare list of country codes
    countries = {
        v.iso_code: k
        for k, v in pw.make_country_dictionary().iteritems()
    }
    if args.country is None:
        args.country = sorted(countries.keys(), key=lambda k: countries[k])
    else:
        args.country = [country_code.upper() for country_code in args.country]
        for iso_code in args.country:
            if iso_code not in countries:
                raise ValueError('iso code <{0}> is invalid'.format(iso_code))

    # make sqlite database
    db_conn = pw.copy_csv_to_sqlite(args.input,
                                    ':memory:',
                                    return_connection=True)

    # summarize country-level data
Esempio n. 2
0
parser = argparse.ArgumentParser()
parser.add_argument("--dump", help="dump all the data", action="store_true")
DATA_DUMP = True if parser.parse_args().dump else False

# open log file
f_log = open(DATABASE_BUILD_LOG_FILE, 'a')
f_log.write('Starting Global Power Plant Database build run at {0}.\n'.format(
    time.ctime()))

# print summary
print(
    "Starting Global Power Plant Database build; minimum plant size: {0} MW.".
    format(MINIMUM_CAPACITY_MW))

# make country dictionary
country_dictionary = pw.make_country_dictionary()

# make powerplants dictionary
core_database = {}
datadump = {}

# make plant condcordance dictionary
plant_concordance = pw.make_plant_concordance()
print("Loaded concordance file with {0} entries.".format(
    len(plant_concordance)))
carma_id_used = []  # Record matched carma_ids

# STEP 0: Read in source databases.
# Identify countries with automated data from .automated flag.
print("Loading source databases...")
country_databases = {}
Esempio n. 3
0
	return summary


### MAIN ###
if __name__ == '__main__':
	argparser = argparse.ArgumentParser(description="Summarize the Global Power Plant Database at the country level.")
	argparser.add_argument('-i', '--input', type=str, default=DEFAULT_DATABASE_FILE)
	argparser.add_argument('-o', '--output', type=str, default=DEFAULT_SUMMARY_FILE)
	argparser.add_argument('--country', type=str, nargs='+',
		help="ISO-3 country codes; all countries are processed by default.")
	args = argparser.parse_args()
	print(args)

	# prepare list of country codes
	countries = {v.iso_code: k for k, v in pw.make_country_dictionary().iteritems()}
	if args.country is None:
		args.country = sorted(countries.keys(), key=lambda k: countries[k])
	else:
		args.country = [country_code.upper() for country_code in args.country]
		for iso_code in args.country:
			if iso_code not in countries:
				raise ValueError('iso code <{0}> is invalid'.format(iso_code))

	# make sqlite database
	db_conn = pw.copy_csv_to_sqlite(args.input, ':memory:', return_connection=True)

	# summarize country-level data
	country_summaries = {}
	for iso_code in args.country:
		country_summaries[iso_code] = country_summary(db_conn, countries[iso_code], iso_code)