{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", " Renewable power plants: Validation and output notebook\n", " \n", "
This notebook is part of the Renewable power plants Data Package of Open Power System Data.\n", "
" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Part 1 of the script (Download and process Notebook) has downloaded and merged the original data. This Notebook subsequently checks, validates the list of renewable power plants and creates CSV/XLSX/SQLite files. It also generates a daily time series of cumulated installed capacities by energy source.\n", "\n", "*(Before running this script make sure you ran Part 1, so that the renewables.pickle files for each country exist in the same folder as the scripts)*\n" ] }, { "cell_type": "markdown", "metadata": { "toc": true }, "source": [ "

Table of Contents

\n", "
" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Initialization" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "settings = {\n", " 'version': '2018-03-08',\n", " 'changes': 'Fixing incorrect coordinates in previous version.'\n", "}" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Script setup" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": true }, "outputs": [], "source": [ "import json\n", "import logging\n", "import os\n", "import urllib.parse\n", "import re\n", "import zipfile\n", "\n", "import pandas as pd\n", "import numpy as np\n", "import requests\n", "import sqlalchemy\n", "import yaml\n", "import hashlib\n", "import os\n", "\n", "%matplotlib inline\n", "\n", "# Option to make pandas display 40 columns max per dataframe (default is 20)\n", "pd.options.display.max_columns = 40\n", "\n", "# Create input and output folders if they don't exist\n", "os.makedirs(os.path.join('input', 'original_data'), exist_ok=True)\n", "\n", "os.makedirs('output', exist_ok=True)\n", "os.makedirs(os.path.join('output', 'renewable_power_plants'), exist_ok=True)\n", "package_path = os.path.join('output', 'renewable_power_plants',settings['version'])\n", "os.makedirs(package_path, exist_ok=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Load data" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "countries = set(['DE', 'DK','FR','PL','CH'])\n", "countries_non_DE = countries - set(['DE'])\n", "countries_dirty = set(['DE_outvalidated_plants', 'FR_overseas_territories'])\n", "countries_including_dirty = countries | countries_dirty\n", "\n", "# Read data from script Part 1 download_and_process\n", "\n", "dfs = {}\n", "for country in countries:\n", " dfs[country] = pd.read_pickle('intermediate/'+country+'_renewables.pickle')" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true }, "source": [ "# Validation Markers\n", "\n", "This section checks the DataFrame for a set of pre-defined criteria and adds markers to the entries in an additional column. The marked data will be included in the output files, but marked, so that they can be easiliy filtered out. For creating the validation plots and the time series, suspect data is skipped." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Germany DE" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Add marker to data according to criteria (see validation_marker above)**" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "mark_rows = {}\n", "validation_marker = {}\n", "\n", "key = 'R_1'\n", "mark_rows[key] = (\n", " (dfs['DE']['commissioning_date'] <= '2016-12-31') \n", " & (dfs['DE']['data_source'] == 'BNetzA')\n", " ) | (\n", " (dfs['DE']['commissioning_date'] <= '2016-12-31')\n", " & (dfs['DE']['data_source'] == 'BNetzA_PV')\n", " ) | (\n", " (dfs['DE']['commissioning_date'] <= '2016-12-31')\n", " & (dfs['DE']['data_source'] == 'BNetzA_PV_historic')\n", " )\n", "validation_marker[key] = {\n", " \"Short explanation\": \"data_source = BNetzA and commissioning_date < 2016-12-31\",\n", " \"Long explanation\": \"This powerplant is probably also represented by an entry from the TSO data and should therefore be filtered out.\"\n", "}\n", "\n", "key = 'R_2'\n", "mark_rows[key] = ((dfs['DE']['notification_reason'] != 'Inbetriebnahme') &\n", " (dfs['DE']['data_source'] == 'BNetzA'))\n", "validation_marker[key] = {\n", " \"Short explanation\": \"notification_reason other than commissioning (Inbetriebnahme)\",\n", " \"Long explanation\": \"This powerplant is probably represented by an earlier entry already (possibly also from the TSO data) and should therefore be filtered out.\"\n", "}\n", "\n", "key = 'R_3'\n", "mark_rows[key] = (dfs['DE']['commissioning_date'].isnull())\n", "validation_marker[key] = {\n", " \"Short explanation\": \"commissioning_date not specified\",\n", " \"Long explanation\": \"\"\n", "}\n", "\n", "key = 'R_4'\n", "mark_rows[key] = dfs['DE'].electrical_capacity <= 0.0\n", "validation_marker[key] = {\n", " \"Short explanation\": \"electrical_capacity not specified\",\n", " \"Long explanation\": \"\"\n", "}\n", "\n", "key = 'R_5'\n", "mark_rows[key] = dfs['DE']['grid_decommissioning_date'].isnull() == False # Just the entry which is not double should be kept, thus the other one is marked\n", "validation_marker[key] = {\n", " \"Short explanation\": \"decommissioned from the grid\",\n", " \"Long explanation\": \"This powerplant is probably commissioned again to the grid of another grid operator and therefore this doubled entry should be filtered out.\"\n", "}\n", "\n", "key = 'R_6'\n", "mark_rows[key] = dfs['DE']['decommissioning_date'].isnull() == False\n", "validation_marker[key] = {\n", " \"Short explanation\": \"decommissioned\",\n", " \"Long explanation\": \"This powerplant is completely decommissioned.\"\n", "}\n", "\n", "key = 'R_8' # note that we skip R7 here as R7 is used for frech oversees power plants below (we never change meanings of R markers, so R7 stays reserved for that)\n", "mark_rows[key] = (dfs['DE'].duplicated(['eeg_id'],keep='first') # note that this depends on BNetzA items to be last in list, because we want to keep the TSO items\n", " & (dfs['DE']['eeg_id'].isnull() == False)) \n", "validation_marker[key] = {\n", " \"Short explanation\": \"duplicate_eeg_id\",\n", " \"Long explanation\": \"This power plant is twice in the data (e.g. through BNetzA and TSOs).\"\n", "}\n", "\n", "\n", "\n", "dfs['DE']['comment'] = ''\n", "for key, rows_to_mark in mark_rows.items():\n", " dfs['DE'].loc[rows_to_mark, 'comment'] += key+\"|\"\n", "\n", "del mark_rows, key, rows_to_mark # free variables no longer needed" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": true }, "outputs": [], "source": [ "# Summarize capacity of suspect data by data_source\n", "dfs['DE'].groupby(['comment', 'data_source'])['electrical_capacity'].sum().to_frame()\n", "\n", "# Summarize capacity of suspect data by energy source\n", "dfs['DE'].groupby(['comment', 'energy_source_level_2'])['electrical_capacity'].sum().to_frame()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Create cleaned DataFrame**\n", "\n", "All marked entries are deleted for the cleaned version of the DataFrame that is utilized for creating time series of installation and for the validation plots." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## France FR" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Create empty marker column\n", "dfs['FR']['comment'] = \"\"\n", "\n", "key = 'R_7'\n", "mark_rows_FR_not_in_Europe = dfs['FR'][((dfs['FR']['lat'] < 41) |\n", " (dfs['FR']['lon'] < -6) |\n", " (dfs['FR']['lon'] > 10))].index\n", "validation_marker[key] = {\n", "\t\"Short explanation\": \"not connected to the European grid\",\n", "\t\"Long explanation\": \"This powerplant is located in regions belonging to France but not located in Europe (e.g. Guadeloupe).\"\n", "}\n", "\n", "dfs['FR'].loc[mark_rows_FR_not_in_Europe, 'comment'] += key+\"|\"\n", "\n", "del mark_rows_FR_not_in_Europe" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Harmonization" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Harmonizing column order" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "field_lists = {\n", "\t'DE': ['commissioning_date', 'decommissioning_date', 'energy_source_level_1', 'energy_source_level_2', 'energy_source_level_3', 'technology', 'electrical_capacity', 'thermal_capacity', 'voltage_level', 'tso', 'dso', 'dso_id', 'eeg_id', 'bnetza_id', 'federal_state', 'postcode', 'municipality_code', 'municipality', 'address', 'address_number', 'utm_zone', 'utm_east', 'utm_north', 'lat', 'lon', 'data_source', 'comment'],\n", "\t'DK': ['commissioning_date', 'energy_source_level_1', 'energy_source_level_2', 'technology', 'electrical_capacity', 'dso', 'gsrn_id', 'postcode', 'municipality_code', 'municipality', 'address', 'address_number', 'utm_east', 'utm_north', 'lat', 'lon', 'hub_height', 'rotor_diameter', 'manufacturer', 'model', 'data_source'],\n", "\t'FR': ['municipality_code', 'municipality', 'energy_source_level_1', 'energy_source_level_2', 'energy_source_level_3', 'technology', 'electrical_capacity', 'number_of_installations', 'lat', 'lon', 'data_source', 'comment'],\n", "\t'PL': ['district', 'energy_source_level_1', 'energy_source_level_2', 'energy_source_level_3', 'technology', 'electrical_capacity', 'number_of_installations', 'lat', 'lon', 'data_source'],\n", "\t'CH': ['commissioning_date', 'municipality', 'energy_source_level_1', 'energy_source_level_2', 'energy_source_level_3', 'technology', 'electrical_capacity', 'municipality_code', 'project_name', 'production', 'tariff', 'notification_date', 'contract_period_end', 'street', 'canton', 'company', 'lat', 'lon', 'data_source']\n", "}\n", "\n", "for country in countries:\n", " dfs[country] = dfs[country].loc[:, field_lists[country]]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Cleaning fields\n", "\n", "Five digits behind the decimal point for decimal fields. Dates should be without timestamp." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "cleaning_specs = {\n", " 'decimal' : {\n", " 'DE': ['electrical_capacity','lat','lon','utm_east','utm_north','thermal_capacity'],\n", " 'DK': ['electrical_capacity','lat','lon','utm_east','utm_north'],\n", " 'CH': ['electrical_capacity','lat','lon'],\n", " 'FR': ['electrical_capacity','lat','lon'],\n", " 'PL': ['electrical_capacity'],\n", " },\n", " 'integer': {\n", " 'DE': ['utm_zone'],\n", " },\n", " 'date': {\n", " 'DE': ['commissioning_date', 'decommissioning_date'],\n", " 'DK': ['commissioning_date'],\n", " 'CH': ['commissioning_date'],\n", " }, \n", "}\n", "\n", "for cleaning_type, cleaning_spec in cleaning_specs.items():\n", " for country, fields in cleaning_spec.items():\n", " for field in fields:\n", " print('Cleaning '+country+'.'+field+' to decimal.')\n", " \n", " if cleaning_type == 'decimal':\n", " dfs[country][field] = dfs[country][field].map(lambda x: round(x, 5))\n", " \n", " if cleaning_type == 'integer':\n", " dfs[country][field] = pd.to_numeric(dfs[country][field], errors='coerce')\n", " dfs[country][field] = dfs[country][field].map(lambda x: '%.0f' % x)\n", " \n", " if cleaning_type == 'date':\n", " dfs[country][field] = dfs[country][field].apply(lambda x: x.date())\n", "\n", "del cleaning_specs" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Sort" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "sort_by = {\n", " 'DE': 'commissioning_date',\n", " 'DK': 'commissioning_date',\n", " 'CH': 'commissioning_date',\n", " 'FR': 'municipality_code',\n", " 'PL': 'district',\n", "}\n", "\n", "for country, sort_by in sort_by.items():\n", " dfs[country] = dfs[country].iloc[dfs[country][sort_by].sort_values().index]\n", " \n", "del sort_by" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Leave unspecified cells blank" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "for country in countries:\n", " dfs[country].fillna('', inplace=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Separate dirty from clean\n", "\n", "We separate all plants which have a validation marker in the comments column into a separate DataFrame and eventually also in a separate CSV file, so the main country files only contain \"clean\" plants, i.e. those without any special comment. This is useful since all our comments denote that most people would probably not like to include them in their calculations." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": true }, "outputs": [], "source": [ "for country in ['DE','FR']:\n", " idx_dirty = dfs[country][dfs[country].comment.str.len() > 1].index\n", " dirty_key = 'DE_outvalidated_plants' if country=='DE' else 'FR_overseas_territories'\n", " dfs[dirty_key] = dfs[country].loc[idx_dirty]\n", " dfs[country] = dfs[country].drop(idx_dirty)\n", "\n", "del idx_dirty, dirty_key" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Capacity time series\n", "\n", "This section creates a daily and yearly time series of the cumulated installed capacity by energy source. This data will be part of the output and will be compared in a plot for validation in the next section." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Additional column for chosing energy sources for time series\n", "dfs['DE']['temp_energy_source'] = dfs['DE']['energy_source_level_2']\n", "\n", "# Time series for on- and offshore wind should be separated, for hydro subtype\n", "# should be used because all is run-of-river\n", "idx_subtype = dfs['DE'][(dfs['DE'].energy_source_level_2 == 'Wind') |\n", " (dfs['DE'].energy_source_level_2 == 'Hydro')].index\n", "\n", "dfs['DE'].loc[idx_subtype, 'temp_energy_source'] = dfs['DE'].loc[\n", " idx_subtype, 'technology']\n", "\n", "# Set energy source for which time series should be generated\n", "energy_sources = ['Solar', 'Onshore', 'Offshore', 'Bioenergy',\n", " 'Geothermal', 'Run-of-river']\n", "\n", "# Set range of time series as index\n", "timeseries_yearly = pd.DataFrame(index=pd.date_range(start='1990-01-01', end='2017-12-31', freq='A'))\n", "timeseries_daily = pd.DataFrame(index=pd.date_range(start='2005-01-01', end='2017-12-31', freq='D'))\n", "\n", "del idx_subtype" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Create cumulated time series per energy source for both yearly and daily time series\n", "for gtype in energy_sources:\n", " temp = (dfs['DE'][['commissioning_date', 'electrical_capacity']]\n", " .loc[dfs['DE']['temp_energy_source'].isin([gtype])])\n", "\n", " temp_timeseries = temp.set_index('commissioning_date')\n", " temp_timeseries.index = pd.DatetimeIndex(temp_timeseries.index)\n", "\n", " # Create cumulated time series per energy_source and year\n", " timeseries_yearly['{0}'.format(gtype)] = temp_timeseries.resample('A').sum().cumsum().fillna(method='ffill')\n", "\n", " # Create cumulated time series per energy_source and day\n", " timeseries_daily['{0}'.format(gtype)] = temp_timeseries.resample('D').sum().cumsum().fillna(method='ffill')\n", "\n", "del energy_sources\n", "dfs['DE'].drop('temp_energy_source',axis=1,inplace=True)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Filling a few timeseries with forward-fill, as some did not work in the loop\n", "timeseries_daily.Onshore = timeseries_daily.Onshore.fillna(method='ffill')\n", "timeseries_daily.Offshore = timeseries_daily.Offshore.fillna(method='ffill')\n", "timeseries_daily.Bioenergy = timeseries_daily.Bioenergy.fillna(method='ffill')\n", "timeseries_daily.Geothermal = timeseries_daily.Geothermal.fillna(method='ffill')\n", "timeseries_daily['Run-of-river'] = timeseries_daily['Run-of-river'].fillna(method='ffill')\n", "\n", "# Shorten timestamp to year for the yearly time series \n", "timeseries_yearly.index = pd.to_datetime(timeseries_yearly.index, format=\"%Y\").year\n", "\n", "# Show yearly timeseries of installed capacity in MW per energy source level 2\n", "timeseries_yearly" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Reset index of timeseries.**" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Time index is not required any more\n", "timeseries_yearly = timeseries_yearly.reset_index()\n", "timeseries_daily = timeseries_daily.reset_index()\n", "\n", "# Set index name\n", "timeseries_yearly.rename(columns={'index': 'year'}, inplace=True)\n", "timeseries_daily.rename(columns={'index': 'day'}, inplace=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Output\n", "This section finally writes the Data Package:\n", "* CSV + XLSX + SQLite\n", "* Meta data (JSON)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "os.makedirs(package_path, exist_ok=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Write data files" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "** Write CSV-files**\n", "\n", "One csv-file for each country. This process will take some time depending on you hardware." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "table_names = {}\n", "\n", "for country in countries_including_dirty:\n", " table_names[country] = 'renewable_power_plants_'+country if country not in countries_dirty else 'res_plants_separated_'+country\n", " dfs[country].to_csv(os.path.join(package_path, table_names[country]+'.csv'),\n", " sep=',',\n", " decimal='.',\n", " date_format='%Y-%m-%d',\n", " line_terminator='\\n',\n", " encoding='utf-8',\n", " index=False)\n", "\n", "# Write daily cumulated time series as csv\n", "timeseries_daily.to_csv(os.path.join(package_path, 'renewable_capacity_timeseries_DE.csv'),\n", " sep=',',\n", " float_format='%.3f',\n", " decimal='.',\n", " date_format='%Y-%m-%d',\n", " encoding='utf-8',\n", " index=False)\n", "\n", "# Write csv of Marker Explanations\n", "validation_marker_df = pd.DataFrame(validation_marker).transpose()\n", "validation_marker_df = validation_marker_df.iloc[:, ::-1] # Reverse column order\n", "validation_marker_df.index.name = 'Validation marker'\n", "validation_marker_df.reset_index(inplace=True)\n", "validation_marker_df.to_csv(os.path.join(package_path, 'validation_marker.csv'), \n", " sep=',',\n", " decimal='.',\n", " date_format='%Y-%m-%d',\n", " line_terminator='\\n',\n", " encoding='utf-8',\n", " index=False)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "** Write XLSX-file**\n", "\n", "This process will take some time depending on your hardware.\n", "\n", "All country power plant list will be written in one xlsx-file. Each country power plant list is written in a separate sheet. As the German power plant list has to many entries for one sheet, it will be split in two. An additional sheet includes the explanations of the marker." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": true }, "outputs": [], "source": [ "# Write the results as xlsx file\n", "%time writer = pd.ExcelWriter(os.path.join(package_path, 'renewable_power_plants.xlsx'), engine='xlsxwriter', date_format='yyyy-mm-dd')\n", "\n", "print('Writing DE part 1')\n", "%time dfs['DE'][:1000000].to_excel(writer, index=False, sheet_name='DE part-1')\n", "\n", "print('Writing DE part 2')\n", "%time dfs['DE'][1000000:].to_excel(writer, index=False, sheet_name='DE part-2')\n", "\n", "for country in (countries_non_DE | countries_dirty):\n", " print('Writing '+country)\n", " %time dfs[country].to_excel(writer, index=False, sheet_name=country)\n", "\n", "print('Writing validation marker sheet')\n", "%time validation_marker_df.to_excel(writer, index=False, sheet_name='validation_marker')\n", "\n", "print('Saving...')\n", "%time writer.save()\n", "print('...done!')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Write SQLite**" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# The decommissioning_date column is giving the engine some trouble, therefore cast to string: \n", "#dfs['DE'].decommissioning_date = dfs['DE'].decommissioning_date.astype(str)\n", "#dfs['DE'].commissioning_date = dfs['DE'].commissioning_date.astype(str)\n", "\n", "# Using chunksize parameter is for lower\n", "# memory computers. Removing it might speed things up.\n", "engine = sqlalchemy.create_engine('sqlite:///' + package_path + '/renewable_power_plants.sqlite') \n", "\n", "for country in countries_including_dirty:\n", " % time dfs[country].to_sql(table_names[country],engine,if_exists=\"replace\",chunksize=100000,index=False)\n", "\n", "validation_marker_df.to_sql('validation_marker', engine, if_exists=\"replace\", chunksize=100000, index=False)\n", "timeseries_daily.to_sql('renewable_capacity_timeseries_DE', engine, if_exists=\"replace\", chunksize=100000, index=False)" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true }, "source": [ "## Write meta data\n", "\n", "The Data Packages meta data are created in the specific JSON format as proposed by the Open Knowledge Foundation. Please see the Frictionless Data project by OKFN (http://data.okfn.org/) and the Data Package specifications (http://dataprotocols.org/data-packages/) for more details.\n", "\n", "In order to keep the Jupyter Notebook more readable the metadata is written in the human-readable YAML format using a multi-line string and then parse the string into a Python dictionary and save it as a JSON file." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "metadata = \"\"\"\n", "hide: yes\n", "name: opsd-renewable-power-plants\n", "title: Renewable power plants\n", "description: List of renewable energy power stations\n", "long_description: >-\n", " This Data Package contains a list of renewable energy power plants in lists of \n", " renewable energy-based power plants of Germany, Denmark, France and Poland. \n", " Germany: More than 1.7 million renewable power plant entries, eligible under the \n", " renewable support scheme (EEG). \n", " Denmark: Wind and phovoltaic power plants with a high level of detail. \n", " France: Aggregated capacity and number of installations per energy source per \n", " municipality (Commune). \n", " Poland: Summed capacity and number of installations per energy source \n", " per municipality (Powiat).\n", " Switzerland: Renewable power plants eligible under the Swiss feed in tariff KEV \n", " (Kostendeckende Einspeisevergütung)\n", " Due to different data availability, the power plant lists are of different \n", " accurancy and partly provide different power plant parameter. Due to that, the \n", " lists are provided as seperate csv-files per country and as separate sheets in the\n", " excel file. Suspect data or entries with high probability of duplication are marked\n", " in the column 'comment'. Theses validation markers are explained in the file\n", " validation_marker.csv. Filtering all entries with comments out results in the recommended\n", " data set.\n", " Additionally, the Data Package includes a daily time series of cumulated\n", " installed capacity per energy source type for Germany. All data processing is \n", " conducted in Python and pandas and has been documented in the Jupyter Notebooks \n", " linked below. \n", "keywords: [master data register,power plants,renewables,germany,denmark,france,poland,switzerland,open power system data]\n", "geographical-scope: Germany, Denmark, France, Poland, Switzerland\n", "resources:\n", " - path: renewable_power_plants_DE.csv\n", " format: csv\n", " encoding: UTF-8\n", " missingValue: \"\"\n", " schema: \n", " fields:\n", " - name: commissioning_date\n", " type: date\n", " format: YYYY-MM-DD\n", " description: Date of commissioning of specific unit\n", " - name: decommissioning_date\n", " type: date\n", " format: YYYY-MM-DD\n", " description: Date of decommissioning of specific unit\n", " - name: energy_source_level_1\n", " description: Type of energy source (e.g. Renewable energy)\n", " type: string\n", " - name: energy_source_level_2\n", " description: Type of energy source (e.g. Wind, Solar)\n", " type: string\n", " opsd-contentfilter: \"true\"\n", " - name: energy_source_level_3\n", " description: Subtype of energy source (e.g. Biomass and biogas)\n", " type: string\n", " - name: technology\n", " description: Technology to harvest energy source (e.g. Onshore, Photovoltaics)\n", " type: string\n", " - name: electrical_capacity\n", " description: Installed electrical capacity in MW\n", " type: number\n", " format: float\n", " unit: MW\n", " - name: thermal_capacity\n", " description: Installed thermal capacity in MW\n", " type: number\n", " format: float\n", " unit: MW\n", " - name: voltage_level\n", " description: Voltage level of grid connection\n", " type: string\n", " - name: tso\n", " description: Name of transmission system operator of the area the plant is located\n", " type: string\n", " - name: dso\n", " description: Name of distribution system operator of the region the plant is located in\n", " type: string\n", " - name: dso_id\n", " description: Company number of German distribution grid operator\n", " type: string\n", " - name: eeg_id\n", " description: Power plant EEG (German feed-in tariff law) remuneration number\n", " type: string\n", " - name: bnetza_id\n", " description: Power plant identification number by BNetzA\n", " type: string\n", " - name: federal_state\n", " description: Name of German administrative level 'Bundesland'\n", " type: string\n", " - name: postcode\n", " description: German zip-code\n", " type: string\n", " - name: municipality_code\n", " description: German Gemeindenummer (municipalitiy number)\n", " type: string\n", " - name: municipality\n", " description: Name of German Gemeinde (municipality)\n", " type: string\n", " - name: address\n", " description: Street name or name of land parcel\n", " type: string\n", " - name: address_number\n", " description: House number or number of land parcel\n", " type: string\n", " - name: utm_zone\n", " description: Universal Transverse Mercator zone value\n", " type: \n", " - name: utm_east\n", " description: Coordinate in Universal Transverse Mercator (east)\n", " type: numeric\n", " format: float\n", " - name: utm_north\n", " description: Coordinate in Universal Transverse Mercator (north)\n", " type: numeric\n", " format: float\n", " - name: lat\n", " description: Latitude coordinates\n", " type: geopoint\n", " format: lat\n", " - name: lon\n", " description: Longitude coordinates \n", " type: geopoint\n", " format: lon\n", " - name: data_source\n", " description: Source of database entry\n", " type: string\n", " - name: comment\n", " description: Shortcodes for comments related to this entry, explanation can be looked up in validation_marker.csv\n", " type: string\n", " - path: renewable_power_plants_DK.csv\n", " format: csv\n", " encoding: UTF-8\n", " missingValue: \"\"\n", " schema:\n", " fields:\n", " - name: commissioning_date\n", " type: date\n", " format: YYYY-MM-DD\n", " - name: energy_source_level_1\n", " description: Type of energy source (e.g. Renewable energy)\n", " type: string\n", " - name: energy_source_level_2\n", " description: Type of energy source (e.g. Wind, Solar)\n", " type: string\n", " opsd-contentfilter: \"true\"\n", " - name: technology\n", " description: Technology to harvest energy source (e.g. Onshore, Photovoltaics)\n", " type: string\n", " - name: electrical_capacity\n", " description: Installed electrical capacity in MW\n", " type: number\n", " format: float\n", " - name: dso\n", " description: Name of distribution system operator of the region the plant is located in\n", " type: string\n", " - name: gsrn_id\n", " description: Danish wind turbine identifier number (GSRN)\n", " type: number\n", " format: integer\n", " - name: postcode\n", " description: Danish zip-code\n", " type: string\n", " - name: municipality_code\n", " description: Danish 3-digit Kommune-Nr\n", " type: string\n", " - name: municipality\n", " description: Name of Danish Kommune\n", " type: string\n", " - name: address\n", " description: Street name or name of land parcel\n", " type: string\n", " - name: address_number\n", " description: House number or number of land parcel\n", " type: string\n", " - name: utm_east\n", " description: Coordinate in Universal Transverse Mercator (east)\n", " type: numeric\n", " format: float\n", " - name: utm_north\n", " description: Coordinate in Universal Transverse Mercator (north)\n", " type: numeric\n", " format: float\n", " - name: lat\n", " description: Latitude coordinates\n", " type: geopoint\n", " format: lat\n", " - name: lon\n", " description: Longitude coordinates \n", " type: geopoint\n", " format: lon\n", " - name: hub_height\n", " description: Wind turbine hub heigth in m\n", " type: numeric\n", " format: float\n", " - name: rotor_diameter\n", " description: Wind turbine rotor diameter in m\n", " type: numeric\n", " format: float\n", " - name: manufacturer\n", " description: Company that has built the wind turbine\n", " type: string\n", " - name: model\n", " description: Wind turbind model type\n", " type: string\n", " - name: data_source\n", " description: Source of database entry\n", " type: string\n", " - path: renewable_power_plants_FR.csv\n", " format: csv\n", " encoding: UTF-8\n", " missingValue: \"\"\n", " schema:\n", " fields:\n", " - name: municipality_code\n", " description: French 5-digit INSEE code for Communes\n", " type: string\n", " - name: municipality\n", " description: Name of French Commune\n", " type: string\n", " - name: energy_source_level_1\n", " description: Type of energy source (e.g. Renewable energy)\n", " type: string\n", " - name: energy_source_level_2\n", " description: Type of energy source (e.g. Wind, Solar)\n", " type: string\n", " opsd-contentfilter: \"true\"\n", " - name: energy_source_level_3\n", " description: Subtype of energy source (e.g. Biomass and biogas)\n", " type: string\n", " - name: technology\n", " description: Technology to harvest energy source (e.g. Onshore, Photovoltaics)\n", " type: string\n", " - name: electrical_capacity\n", " description: Installed electrical capacity in MW\n", " type: number\n", " format: float\n", " - name: number_of_installations\n", " description: Number of installations of the energy source subtype in the municipality\n", " type: number\n", " format: integer\n", " - name: lat\n", " description: Latitude coordinates\n", " type: geopoint\n", " format: lat\n", " - name: lon\n", " description: Longitude coordinates \n", " type: geopoint\n", " format: lon\n", " - name: data_source\n", " description: Source of database entry\n", " type: string\n", " - path: renewable_power_plants_PL.csv\n", " format: csv\n", " encoding: UTF-8\n", " missingValue: \"\"\n", " schema:\n", " fields:\n", " - name: district\n", " description: Name of the Polish powiat\n", " type: string\n", " - name: energy_source_level_1\n", " description: Type of energy source (e.g. Renewable energy)\n", " type: string\n", " - name: energy_source_level_2\n", " description: Type of energy source (e.g. Wind, Solar)\n", " type: string\n", " opsd-contentfilter: \"true\"\n", " - name: energy_source_level_3\n", " description: Subtype of energy source (e.g. Biomass and biogas)\n", " type: string\n", " - name: technology\n", " description: Technology to harvest energy source (e.g. Onshore, Photovoltaics)\n", " type: string\n", " - name: electrical_capacity\n", " description: Installed electrical capacity in MW\n", " type: number\n", " format: float\n", " - name: number_of_installations\n", " description: Number of installations of the energy source subtype in the district\n", " type: number\n", " format: integer\n", " - name: data_source\n", " description: Source of database entry\n", " type: string\n", " - path: renewable_power_plants_CH.csv\n", " format: csv\n", " encoding: UTF-8\n", " missingValue: \"\"\n", " schema:\n", " fields:\n", " - name: commissioning_date\n", " type: date\n", " format: YYYY-MM-DD\n", " - name: municipality\n", " type: string\n", " - name: energy_source_level_1\n", " description: Type of energy source (e.g. Renewable energy)\n", " type: string\n", " - name: energy_source_level_2\n", " description: Type of energy source (e.g. Wind, Solar)\n", " type: string\n", " opsd-contentfilter: \"true\"\n", " - name: technology\n", " description: Technology to harvest energy source (e.g. Onshore, Photovoltaics)\n", " type: string\n", " - name: electrical_capacity\n", " description: Installed electrical capacity in MW\n", " type: number\n", " format: float\n", " - name: municipality_code\n", " type: number\n", " format: integer\n", " - name: project_name\n", " description: name of the project\n", " type: string\n", " - name: production\n", " description: yearly production in MWh\n", " type: numeric\n", " format: float\n", " - name: tariff\n", " description: tariff in CHF for 2016\n", " type: numeric\n", " format: float\n", " - name: notification_date\n", " description: date of data entriy at BFE\n", " type: date\n", " format: YYYY-MM-DD HH:MM:SS.SSSSS\n", " - name: street\n", " description: Street name\n", " type: string\n", " - name: canton\n", " description: name of the cantones/ member states of the Swiss conferderation\n", " type: string\n", " - name: company\n", " description: name of the company\n", " type: string\n", " - name: lat\n", " description: Latitude coordinates\n", " type: geopoint\n", " format: lat\n", " - name: lon\n", " description: Longitude coordinates \n", " type: geopoint\n", " format: lon\n", " - name: data_source\n", " description: Source of database entry\n", " type: string\n", " - path: res_plants_separated_DE_outvalidated_plants.csv\n", " format: csv\n", " encoding: UTF-8\n", " missingValue: \"\"\n", " schema: \n", " fields:\n", " - name: commissioning_date\n", " type: date\n", " format: YYYY-MM-DD\n", " description: Date of commissioning of specific unit\n", " - name: decommissioning_date\n", " type: date\n", " format: YYYY-MM-DD\n", " description: Date of decommissioning of specific unit\n", " - name: energy_source_level_1\n", " description: Type of energy source (e.g. Renewable energy)\n", " type: string\n", " - name: energy_source_level_2\n", " description: Type of energy source (e.g. Wind, Solar)\n", " type: string\n", " opsd-contentfilter: \"true\"\n", " - name: energy_source_level_3\n", " description: Subtype of energy source (e.g. Biomass and biogas)\n", " type: string\n", " - name: technology\n", " description: Technology to harvest energy source (e.g. Onshore, Photovoltaics)\n", " type: string\n", " - name: electrical_capacity\n", " description: Installed electrical capacity in MW\n", " type: number\n", " format: float\n", " unit: MW\n", " - name: thermal_capacity\n", " description: Installed thermal capacity in MW\n", " type: number\n", " format: float\n", " unit: MW\n", " - name: voltage_level\n", " description: Voltage level of grid connection\n", " type: string\n", " - name: tso\n", " description: Name of transmission system operator of the area the plant is located\n", " type: string\n", " - name: dso\n", " description: Name of distribution system operator of the region the plant is located in\n", " type: string\n", " - name: dso_id\n", " description: Company number of German distribution grid operator\n", " type: string\n", " - name: eeg_id\n", " description: Power plant EEG (German feed-in tariff law) remuneration number\n", " type: string\n", " - name: bnetza_id\n", " description: Power plant identification number by BNetzA\n", " type: string\n", " - name: federal_state\n", " description: Name of German administrative level 'Bundesland'\n", " type: string\n", " - name: postcode\n", " description: German zip-code\n", " type: string\n", " - name: municipality_code\n", " description: German Gemeindenummer (municipalitiy number)\n", " type: string\n", " - name: municipality\n", " description: Name of German Gemeinde (municipality)\n", " type: string\n", " - name: address\n", " description: Street name or name of land parcel\n", " type: string\n", " - name: address_number\n", " description: House number or number of land parcel\n", " type: string\n", " - name: utm_zone\n", " description: Universal Transverse Mercator zone value\n", " type: \n", " - name: utm_east\n", " description: Coordinate in Universal Transverse Mercator (east)\n", " type: numeric\n", " format: float\n", " - name: utm_north\n", " description: Coordinate in Universal Transverse Mercator (north)\n", " type: numeric\n", " format: float\n", " - name: lat\n", " description: Latitude coordinates\n", " type: geopoint\n", " format: lat\n", " - name: lon\n", " description: Longitude coordinates \n", " type: geopoint\n", " format: lon\n", " - name: data_source\n", " description: Source of database entry\n", " type: string\n", " - name: comment\n", " description: Shortcodes for comments related to this entry, explanation can be looked up in validation_marker.csv\n", " type: string\n", " - path: res_plants_separated_FR_overseas_territories.csv\n", " format: csv\n", " encoding: UTF-8\n", " missingValue: \"\"\n", " schema:\n", " fields:\n", " - name: municipality_code\n", " description: French 5-digit INSEE code for Communes\n", " type: string\n", " - name: municipality\n", " description: Name of French Commune\n", " type: string\n", " - name: energy_source_level_1\n", " description: Type of energy source (e.g. Renewable energy)\n", " type: string\n", " - name: energy_source_level_2\n", " description: Type of energy source (e.g. Wind, Solar)\n", " type: string\n", " opsd-contentfilter: \"true\"\n", " - name: energy_source_level_3\n", " description: Subtype of energy source (e.g. Biomass and biogas)\n", " type: string\n", " - name: technology\n", " description: Technology to harvest energy source (e.g. Onshore, Photovoltaics)\n", " type: string\n", " - name: electrical_capacity\n", " description: Installed electrical capacity in MW\n", " type: number\n", " format: float\n", " - name: number_of_installations\n", " description: Number of installations of the energy source subtype in the municipality\n", " type: number\n", " format: integer\n", " - name: lat\n", " description: Latitude coordinates\n", " type: geopoint\n", " format: lat\n", " - name: lon\n", " description: Longitude coordinates \n", " type: geopoint\n", " format: lon\n", " - name: data_source\n", " description: Source of database entry\n", " type: string\n", " - path: renewable_power_plants.xlsx\n", " format: xlsx\n", " - path: validation_marker.csv\n", " format: csv\n", " encoding: UTF-8\n", " mediatype: text/csv\n", " missingValue: \"\"\n", " schema: \n", " fields:\n", " - name: Validation_Marker\n", " description: Name of validation marker utilized in column comment in the renewable_power_plant_germany.csv\n", " type: string\n", " - name: Explanation\n", " description: Comment explaining meaning of validation marker\n", " type: string\n", " - path: renewable_capacity_timeseries_DE.csv\n", " format: csv\n", " encoding: UTF-8\n", " mediatype: text/csv\n", " missingValue: \"\"\n", " schema: \n", " fields:\n", " - name:\n", " description: Day\n", " type: datetime\n", " format: YYYY-MM-DD\n", " - name: Solar\n", " description: Cumulated electrical solar capacity in MW\n", " type: number\n", " format: float\n", " unit: MW\n", " - name: Onshore\n", " description: Cumulated electrical wind onshore capacity in MW\n", " type: number\n", " format: float\n", " unit: MW\n", " - name: Offshore\n", " description: Cumulated electrical wind offshore capacity in MW\n", " type: number\n", " format: float\n", " unit: MW\n", " - name: Bioenergy and renewable waste\n", " description: Cumulated electrical bioenergy and renewable waste capacity in MW\n", " type: number\n", " format: float\n", " unit: MW\n", " - name: Geothermal\n", " description: Cumulated electrical geothermal capacity in MW\n", " type: number \n", " format: float\n", " unit: MW\n", " - name: Run-of-river\n", " description: Cumulated electrical run-of-river capacity in MW\n", " type: number \n", " format: float\n", " unit: MW\n", "licenses:\n", " - type: MIT license\n", " url: http://www.opensource.org/licenses/MIT\n", "sources:\n", " - name: BNetzA\n", " web: http://www.bundesnetzagentur.de/cln_1422/DE/Sachgebiete/ElektrizitaetundGas/Unternehmen_Institutionen/ErneuerbareEnergien/Anlagenregister/Anlagenregister_Veroeffentlichung/Anlagenregister_Veroeffentlichungen_node.html\n", " source: Bundesnetzagentur register of renewable power plants (excl. PV)\n", " - name: BNetzA_PV\n", " web: http://www.bundesnetzagentur.de/cln_1431/DE/Sachgebiete/ElektrizitaetundGas/Unternehmen_Institutionen/ErneuerbareEnergien/Photovoltaik/DatenMeldgn_EEG-VergSaetze/DatenMeldgn_EEG-VergSaetze_node.html \n", " source: Bundesnetzagentur register of PV power plants\n", " - name: TransnetBW, TenneT, Amprion, 50Hertz, Netztransparenz.de\n", " web: https://www.netztransparenz.de/de/Anlagenstammdaten.htm\n", " source: Netztransparenz.de - information platform of German TSOs (register of renewable power plants in their control area)\n", " - name: Postleitzahlen Deutschland\n", " web: http://www.suche-postleitzahl.org/downloads\n", " source: Zip codes of Germany linked to geo-information\n", " - name: Energinet.dk\n", " web: http://www.energinet.dk/SiteCollectionDocuments/Danske%20dokumenter/El/SolcelleGraf.xlsx\n", " source: register of Danish wind power plants\n", " - name: Energistyrelsen\n", " web: http://www.ens.dk/sites/ens.dk/files/info/tal-kort/statistik-noegletal/oversigt-energisektoren/stamdataregister-vindmoeller/anlaegprodtilnettet.xls \n", " source: ens.dk - register of Danish PV power plants\n", " - name: GeoNames\n", " web: http://download.geonames.org/export/zip/\n", " source: geonames.org\n", " - name: Ministry for the Ecological and Inclusive Transition\n", " web: http://www.statistiques.developpement-durable.gouv.fr/energie-climat/r/differentes-energies-energies-renouvelables.html?tx_ttnews[tt_news]=25029&cHash=005200fdf3c7976410f38ae53cd17e0b\n", " - name: OpenDataSoft\n", " web: http://public.opendatasoft.com/explore/dataset/correspondance-code-insee-code-postal/download/'\\\n", " '?format=csv&refine.statut=Commune%20simple&timezone=Europe/Berlin&use_labels_for_header=true\n", " source: Code Postal - Code INSEE\n", " - name: Urzad Regulacji Energetyki (URE)\n", " web: http://www.ure.gov.pl/uremapoze/mapa.html\n", " source: Energy Regulatory Office of Poland\n", " - name: Bundesamt für Energie (BFE)\n", " web: http://www.bfe.admin.ch/themen/00612/02073/index.html?dossier_id=02166&lang=de\n", " source: Swiss Federal Office of Energy\n", "contributors:\n", " - name: Ingmar Schlecht\n", " email: schlecht@neon-energie.de\n", " web: http://open-power-system-data.org/\n", "views: True\n", "openpowersystemdata-enable-listing: True\n", "\"\"\"\n", "\n", "metadata = yaml.load(metadata)\n", "\n", "metadata['last_changes'] = settings['changes']\n", "metadata['version'] = settings['version']\n", "\n", "metadata['documentation'] = 'https://github.com/Open-Power-System-Data/renewable_power_plants/blob/'+settings['version']+'/main.ipynb'\n", "\n", "datapackage_json = json.dumps(metadata, indent=4, separators=(',', ': '))\n", "\n", "# Write the information of the metadata\n", "with open(os.path.join(package_path, 'datapackage.json'), 'w') as f:\n", " f.write(datapackage_json)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Generate checksums\n", "\n", "Generates checksums.txt" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "def get_sha_hash(path, blocksize=65536):\n", " sha_hasher = hashlib.sha256()\n", " with open(path, 'rb') as f:\n", " buffer = f.read(blocksize)\n", " while len(buffer) > 0:\n", " sha_hasher.update(buffer)\n", " buffer = f.read(blocksize)\n", " return sha_hasher.hexdigest()\n", "\n", "files = [\n", " 'validation_marker.csv', 'renewable_capacity_timeseries_DE.csv',\n", " 'renewable_power_plants.sqlite', 'renewable_power_plants.xlsx',\n", "]\n", "\n", "for country in countries_including_dirty:\n", " files.append(table_names[country]+'.csv')\n", "\n", "with open('checksums.txt', 'w') as f:\n", " for file_name in sorted(files):\n", " file_hash = get_sha_hash(os.path.join(package_path, file_name))\n", " f.write('{},{}\\n'.format(file_name, file_hash))" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "anaconda-cloud": {}, "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.4" }, "latex_envs": { "bibliofile": "biblio.bib", "cite_by": "apalike", "current_citInitial": 1, "eqLabelWithNumbers": true, "eqNumInitial": 0 }, "toc": { "nav_menu": {}, "number_sections": true, "sideBar": true, "skip_h1_title": false, "title_cell": "Table of Contents", "title_sidebar": "Contents", "toc_cell": true, "toc_position": { "height": "716px", "left": "104px", "top": "280px", "width": "231px" }, "toc_section_display": true, "toc_window_display": true }, "varInspector": { "cols": { "lenName": 16, "lenType": 16, "lenVar": 40 }, "kernels_config": { "python": { "delete_cmd_postfix": "", "delete_cmd_prefix": "del ", "library": "var_list.py", "varRefreshCmd": "print(var_dic_list())" }, "r": { "delete_cmd_postfix": ") ", "delete_cmd_prefix": "rm(", "library": "var_list.r", "varRefreshCmd": "cat(var_dic_list()) " } }, "position": { "height": "531px", "left": "1530px", "right": "40px", "top": "273px", "width": "350px" }, "types_to_exclude": [ "module", "function", "builtin_function_or_method", "instance", "_Feature" ], "window_display": true } }, "nbformat": 4, "nbformat_minor": 1 }