est = model_data['model'] params = model_data['params'] num_folds = model_data['num_folds'] fuel_types = model_data['fuel_types'] print("Loaded trained generation estimation model from {0}.".format( args.model_filename)) for k, v in params.iteritems(): print(" - {0}: {1}".format(k, v)) print(" - num_folds: {0}".format(num_folds)) print("Fuel types: {0}".format(fuel_types)) # load powerplant database if args.powerplant_database.endswith('.csv'): plants = pw.read_csv_file_to_dict(args.powerplant_database) else: plants = pw.load_database(args.powerplant_database) print("Loaded {0} plants from file {1}.".format(len(plants), args.powerplant_database)) # set up arrays fuel_type_list = [] capacity_by_country_by_fuel = { } # will hold total capacity by country and fuel feature_name_list = [ 'fuel_type', 'capacity_mw', 'commissioning_year', 'fuel_avg_cf', 'cap_sh_country', 'cap_sh_country_fuel' ] # read data from plant database count_full_data = 0
powerwatch_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 .has_api flag. print("Loading source databases...") country_databases = {} for country_name,country in country_dictionary.iteritems(): if country.has_api == 1: country_code = country.iso_code database_filename = COUNTRY_DATABASE_FILE.replace("COUNTRY", country_code) country_databases[country_name] = pw.load_database(database_filename) print("Loaded {0} plants from {1} database.".format(len(country_databases[country_name]),country_name)) # Load multi-country databases. wri_database = pw.load_database(WRI_DATABASE_FILE) print("Loaded {0} plants from WRI database.".format(len(wri_database))) geo_database = pw.load_database(GEO_DATABASE_FILE) print("Loaded {0} plants from GEO database.".format(len(geo_database))) carma_database = pw.load_database(CARMA_DATABASE_FILE) print("Loaded {0} plants from CARMA database.".format(len(carma_database))) sourcewatch_database = pw.load_database(SOURCEWATCH_DATABASE_FILE) print("Loaded {0} plants from SourceWatch database.".format(len(sourcewatch_database))) # Track counts using a dict with keys corresponding to each data source db_sources = country_databases.keys() db_sources.extend(["WRI","GEO","SourceWatch","WRI with GEO lat/long data","WRI with CARMA lat/long data"])
# True if specified --download, otherwise False FILES = {RAW_FILE_NAME_REPD: URL_REPD, RAW_FILE_NAME_DUKES: URL_DUKES} DOWNLOAD_FILES = pw.download( u"UK Renewable Energy Planning Database and DUKES", FILES) # set up fuel type thesaurus fuel_thesaurus = pw.make_fuel_thesaurus() # set up country name thesaurus country_thesaurus = pw.make_country_names_thesaurus() # create dictionary for power plant objects plants_dictionary = {} # load GEO and CARMA for matching coordinates geo_database = pw.load_database(GEO_DATABASE_FILE) print("Loaded {0} plants from GEO database.".format(len(geo_database))) carma_database = pw.load_database(CARMA_DATABASE_FILE) print("Loaded {0} plants from CARMA database.".format(len(carma_database))) # read in plant matches file with open(PLANT_MATCHES, "rbU") as f: f.readline() # skip headers csvreader = csv.reader(f) plant_matches = {} for row in csvreader: dukes_name = str(row[0]) geo_id = pw.make_id(SAVE_CODE_GEO, int(row[1])) if row[1] else "" carma_id = pw.make_id(SAVE_CODE_CARMA, int(row[2])) if row[2] else "" repd_id = int(row[3]) if row[3] else "" plant_matches[dukes_name] = {