Functions
Maths calculations used in the PyPSA-China workflow.
HVAC_cost_curve(distance)
Calculate the cost of HVAC lines based on distance. Args: distance (float): distance in km Returns: float: cost in currency
Source code in workflow/scripts/functions.py
83 84 85 86 87 88 89 90 91 92 93 94 95 96 | |
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
66 67 68 69 70 71 72 73 74 75 76 77 78 79 | |
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
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | |
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] |
Source code in workflow/scripts/functions.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | |