Пример #1
0
        plants_dictionary[idnr].capacity += unit_capacity
        # todo: average commissioning year calculation

        unit_month = int(rv[COLS_860_3['operating_month']])
        unit_year_raw = int(rv[COLS_860_3['operating_year']])
        unit_year = 1.0 * unit_year_raw + unit_month / 12
        if idnr in commissioning_year_by_unit.keys():
            commissioning_year_by_unit[idnr].append([unit_capacity, unit_year])
        else:
            commissioning_year_by_unit[idnr] = [[unit_capacity, unit_year]]

        for i in COLS_860_3['fuel_type']:
            try:
                if rv[i] == "None":
                    continue
                fuel_type = pw.standardize_fuel(rv[i], fuel_thesaurus)
                plants_dictionary[idnr].fuel.update(fuel_type)
            except:
                continue
    else:
        print("Can't find plant with ID: {0}".format(idnr))

# calculate and save average commissioning year
for idnr, unit_vals in commissioning_year_by_unit.iteritems():
    cap_times_year = 0
    total_cap = 0
    for unit in unit_vals:
        cap_times_year += unit[0] * unit[1]
        total_cap += unit[0]
    plants_dictionary[idnr].commissioning_year = cap_times_year / total_cap
Пример #2
0
    rv = sheet.row_values(i)
    try:
        ref = int(rv[ref_col])
        if not ref:
            print("-Error reading ref from: {0}".format(rv[ref_col]))
            continue
    except:
        continue

    try:
        project_type = pw.format_string(rv[type_col])
        if project_type not in PROJECT_TYPES_TO_READ:  # don't read all project types
            continue

        try:
            fuel = pw.standardize_fuel(project_type, fuel_thesaurus)
        except:
            print("-Error reading fuel: {0}".format(project_type))
            fuel = pw.NO_DATA_SET
    except:
        print(u"-Error: Can't read project type for project {0}.".format(ref))
        continue

    try:
        status = pw.format_string(rv[status_col])
        if status != u"Registered":
            continue
    except:
        print(
            u"-Error: Can't read project status for project {0}.".format(ref))
        continue
Пример #3
0
     if not idnr:  # must have plant ID - don't read plant if not
         print(u"-Error: Null ID for plant {0}.".format(name))
         continue
 except:
     print(u"-Error: Can't read ID for plant {0}.".format(name))
     continue  # must have plant ID - don't read plant if not
 try:
     capacity = float(
         pw.format_string(row[capacity_col].replace(
             ",", "")))  # note: may need to convert to MW
 except:
     print(
         u"-Error: Can't read capacity for plant {0}; value: {1}"
         .format(name, row[capacity_col]))
 try:
     fuel = pw.standardize_fuel(row[fuel_col], fuel_thesaurus)
 except:
     print(
         u"-Error: Can't read fuel type for plant {0}.".format(
             name))
     fuel = pw.NO_DATA_SET
 try:
     latitude = float(row[latitude_col])
     longitude = float(row[longitude_col])
 except:
     latitude, longitude = pw.NO_DATA_NUMERIC, pw.NO_DATA_NUMERIC
 try:
     location = pw.format_string(row[location_col])
 except:
     location = pw.NO_DATA_UNICODE
 try:
Пример #4
0
    datareader = csv.reader(f)
    headers = datareader.next()
    for row in datareader:
        commissioning_years_dictionary[pw.format_string(row[0])] = row[1]

# read data from csv and parse
count = 1

wb = xlrd.open_workbook(RAW_FILE_NAME)
ws = wb.sheet_by_name(TAB)

# treat first data row specially for plant name
rv0 = ws.row_values(START_ROW)
current_plant_name = pw.format_string(rv0[COLS['name']])
current_owner = pw.format_string(rv0[COLS['owner']])
current_fuel_types = pw.standardize_fuel(rv0[COLS['fuel']], fuel_thesaurus)
current_capacity_sum = float(rv0[COLS['capacity']]) * CAPACITY_CONVERSION_TO_MW
current_generation_sum = float(
    rv0[COLS['generation']]) * GENERATION_CONVERSION_TO_GWH

test_print = False
for row_id in range(START_ROW + 1, ws.nrows):
    rv = ws.row_values(row_id)

    row_fuel = pw.format_string(rv[COLS['fuel']], None)
    row_name = pw.format_string(rv[COLS['name']], None)
    row_grid = pw.format_string(rv[COLS['grid']], None)

    if row_grid == u"AISLADO":
        continue  # don't add islanded generators (not grid-connected)
Пример #5
0
        try:
            if rv[generation_col] == u'-':
                generation = pw.PlantGenerationObject()
            else:
                gen_gwh = float(rv[generation_col])
                generation = pw.PlantGenerationObject.create(gen_gwh,
                                                             DATA_YEAR,
                                                             source=SOURCE_URL)
        except:
            print("-Error: Can't read genertaion for plant {0}".format(name))
            generation = pw.PlantGenerationObject()

        try:
            plant_type = pw.format_string(rv[type_col])
            if plant_type == u"HYDRO":
                fuel = pw.standardize_fuel(plant_type, fuel_thesaurus)
            elif plant_type == u"NUCLEAR":
                fuel = pw.standardize_fuel(plant_type, fuel_thesaurus)
            elif plant_type == u"THERMAL":
                fuel = pw.standardize_fuel(rv[fuel1_col], fuel_thesaurus)
                if rv[fuel2_col] and rv[fuel2_col] != 'n/a':
                    fuel2 = pw.standardize_fuel(rv[fuel2_col], fuel_thesaurus)
                    fuel = fuel.union(fuel2)
            else:
                print("Can't identify plant type {0}".format(plant_type))
        except:
            print(u"Can't identify plant type for plant {0}".format(name))

        latitude = pw.NO_DATA_NUMERIC
        longitude = pw.NO_DATA_NUMERIC
Пример #6
0
        try:
            capacity = float(capacity_val)
        except:
            try:
                capacity = eval(capacity_val)
            except:
                print("Could not evaluate {0}".format(capacity_val))

    if year_built_val:
        year_built = int(year_built_val)

    if fuel_type_str:
        if '+' in fuel_type_str:
            fuel_type = None
        else:
            fuel_type = pw.standardize_fuel(fuel_type_str, fuel_thesaurus)

    if name_str:  # if true, this row begins a new plant
        # first process the previous plant unless this is the first entry
        if i > START_ROW:
            print i
            print fuel_type_set
            raw_input()
            total_capacity = sum(capacity_list)
            average_year_built = sum(year_built_list) / len(
                year_built_list)  # TODO: fix this
            new_location = pw.LocationObject(latitude=0.0, longitude=0.0)
            new_plant = pw.PowerPlant(plant_idnr=plant_idnr,
                                      plant_name=name,
                                      plant_country=COUNTRY_NAME,
                                      plant_capacity=total_capacity,
Пример #7
0
 tree = ET.parse(f)
 root = tree.getroot()
 for station in tree.findall("gml:featureMember", ns):
     plant = station.find(
         "Electricity_Infrastructure:National_Major_Power_Stations", ns)
     name = pw.format_string(
         plant.find("Electricity_Infrastructure:NAME", ns).text)
     plant_id = int(
         plant.find("Electricity_Infrastructure:OBJECTID", ns).text)
     try:
         owner = pw.format_string(
             plant.find("Electricity_Infrastructure:OWNER", ns).text)
     except:
         owner = pw.NO_DATA_UNICODE
     fuel = pw.standardize_fuel(
         plant.find("Electricity_Infrastructure:PRIMARYFUELTYPE", ns).text,
         fuel_thesaurus)
     try:
         capacity = plant.find("Electricity_Infrastructure:GENERATIONMW",
                               ns).text
         capacity = float(capacity)
     except:
         print(u"Error: Can't read capacity for plant {0}.".format(name))
         capacity = pw.NO_DATA_NUMERIC
     coords = plant.find(
         "Electricity_Infrastructure:SHAPE/gml:Point/gml:pos",
         ns).text.split(" ")
     try:
         latitude = float(coords[0])
         longitude = float(coords[1])
     except:
Пример #8
0
 except:
     print(u"-Error: Can't read plant name.")
     continue  # must have plant name - don't read plant if not
 try:
     idnr = int(row[id_col])
 except:
     print(u"-Error: Can't read ref id.")
     continue  # must have ID number
 try:
     capacity = float(pw.format_string(
         row[capacity_col]))  # note: may need to convert to MW
 except:
     print(u"-Error: Can't read capacity for plant {0}.".format(name))
     capacity = 0.0
 try:
     fuel_type = pw.standardize_fuel(row[fuel_col], fuel_thesaurus)
     if not fuel_type:
         print("-Error: No fuel type for {0}.".format(row[fuel_col]))
 except:
     print("-Error: Can't read fuel for plant {0}.".format(name))
     fuel_type = set([])
 try:
     x_coordinate = float(row[x_coordinate_col].replace(",", ""))
     y_coordinate = float(row[y_coordinate_col].replace(",", ""))
     longitude, latitude = pyproj.transform(osgb36, wgs84, x_coordinate,
                                            y_coordinate)
 except:
     print(u"-Error: Can't read location for plant {0}.".format(name))
     latitude, longitude = 0.0, 0.0
 coord_source = COUNTRY_NAME + u"national data"
 try:
Пример #9
0
                continue

            try:
                name = pw.format_string(
                    row.get("nombre", row.get("comuna", pw.NO_DATA_UNICODE)))
            except:
                print(u"-Error: Can't read name for ID {0}, skipping.".format(
                    idval))
                continue

            try:
                fuel_string = row.get(
                    "Tipo",
                    row.get("Tipo ", row.get("Combustible",
                                             pw.NO_DATA_UNICODE)))
                fuel = pw.standardize_fuel(fuel_string, fuel_thesaurus)
            except:
                print(u"-Error: Can't read fuel for plant {0}.".format(name))
                fuel = pw.NO_DATA_SET

            # special treament of name for biomass plants (not included in data file)
            if fuel == set(["Biomass"]):
                try:
                    name = pw.format_string(
                        plant_locations["Biomass"][idval][2])
                except:
                    print(
                        "-Error: Can't read name for ID {0} (Biomass).".format(
                            idval))
                    continue