2017-12-18 19:34:15 +00:00
|
|
|
|
#!/usr/bin/env python
|
2019-08-08 13:02:28 +00:00
|
|
|
|
"""
|
|
|
|
|
Extract capacities for HVDC links from wikipedia
|
2019-08-11 09:40:47 +00:00
|
|
|
|
|
|
|
|
|
Relevant Settings
|
|
|
|
|
-----------------
|
|
|
|
|
|
2019-08-11 11:17:36 +00:00
|
|
|
|
*None*
|
|
|
|
|
|
2019-08-11 09:40:47 +00:00
|
|
|
|
Inputs
|
|
|
|
|
------
|
|
|
|
|
|
|
|
|
|
Outputs
|
|
|
|
|
-------
|
|
|
|
|
|
|
|
|
|
Description
|
|
|
|
|
-----------
|
|
|
|
|
|
2019-08-08 13:02:28 +00:00
|
|
|
|
"""
|
2017-12-18 19:34:15 +00:00
|
|
|
|
|
|
|
|
|
import pandas as pd
|
|
|
|
|
import numpy as np
|
|
|
|
|
|
2019-08-08 13:02:28 +00:00
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
links_p_nom = pd.read_html('https://en.wikipedia.org/wiki/List_of_HVDC_projects', header=0, match="SwePol")[0]
|
2017-12-18 19:34:15 +00:00
|
|
|
|
|
2019-08-08 13:02:28 +00:00
|
|
|
|
def extract_coordinates(s):
|
|
|
|
|
regex = (r"(\d{1,2})°(\d{1,2})′(\d{1,2})″(N|S) "
|
|
|
|
|
r"(\d{1,2})°(\d{1,2})′(\d{1,2})″(E|W)")
|
|
|
|
|
e = s.str.extract(regex, expand=True)
|
|
|
|
|
lat = (e[0].astype(float) + (e[1].astype(float) + e[2].astype(float)/60.)/60.)*e[3].map({'N': +1., 'S': -1.})
|
|
|
|
|
lon = (e[4].astype(float) + (e[5].astype(float) + e[6].astype(float)/60.)/60.)*e[7].map({'E': +1., 'W': -1.})
|
|
|
|
|
return lon, lat
|
2017-12-18 19:34:15 +00:00
|
|
|
|
|
2019-08-08 13:02:28 +00:00
|
|
|
|
m_b = links_p_nom["Power (MW)"].str.contains('x').fillna(False)
|
|
|
|
|
def multiply(s): return s.str[0].astype(float) * s.str[1].astype(float)
|
2017-12-18 19:34:15 +00:00
|
|
|
|
|
2019-08-08 13:02:28 +00:00
|
|
|
|
links_p_nom.loc[m_b, "Power (MW)"] = links_p_nom.loc[m_b, "Power (MW)"].str.split('x').pipe(multiply)
|
|
|
|
|
links_p_nom["Power (MW)"] = links_p_nom["Power (MW)"].str.extract("[-/]?([\d.]+)", expand=False).astype(float)
|
2017-12-18 19:34:15 +00:00
|
|
|
|
|
2019-08-08 13:02:28 +00:00
|
|
|
|
links_p_nom['x1'], links_p_nom['y1'] = extract_coordinates(links_p_nom['Converterstation 1'])
|
|
|
|
|
links_p_nom['x2'], links_p_nom['y2'] = extract_coordinates(links_p_nom['Converterstation 2'])
|
2017-12-18 19:34:15 +00:00
|
|
|
|
|
2019-08-08 13:02:28 +00:00
|
|
|
|
links_p_nom.dropna(subset=['x1', 'y1', 'x2', 'y2']).to_csv(snakemake.output[0], index=False)
|