Functions
Maths calculations used in the PyPSA-China workflow.
HVAC_cost_curve(distance)
Calculate the cost of HVAC lines based on distance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
distance
|
float
|
distance in km |
required |
Returns: float: cost in currency
Source code in workflow/scripts/functions.py
area_from_lon_lat_poly(geometry)
For shapely geometry in lon-lat coordinates, returns area in km^2.
Source code in workflow/scripts/functions.py
cartesian(s1, s2)
Compute the Cartesian product of two pandas Series.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
s1
|
Series
|
first series |
required |
s2
|
Series
|
second series |
required |
Returns: pd.DataFrame: A DataFrame representing the Cartesian product of s1 and s2.
Examples:
>>> s1 = pd.Series([1, 2, 3], index=["a", "b", "c"])
>>> s2 = pd.Series([4, 5, 6], index=["d", "e", "f"])
>>> cartesian(s1, s2)
d e f
a 4 5 6
b 8 10 12
c 12 15 18
Source code in workflow/scripts/functions.py
get_poly_center(poly)
haversine(p1, p2)
Calculate the great circle distance in km between two points on the earth (specified in decimal degrees)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
p1
|
Point
|
location 1 in decimal deg |
required |
p2
|
Point
|
location 2 in decimal deg |
required |
Returns:
Name | Type | Description |
---|---|---|
float |
float
|
great circle distance in [km] |