Prototype Solar Mini Grid Layout (1st Implementation)




Pay Notebook Creator: Roy Hyunjin Han250
Set Container: Numerical CPU with TINY Memory for 10 Minutes 0
Total0

Log

20171111-0345 - 20171111-0415: 30 minutes

In [4]:
from shapely.geometry import LineString

line = LineString([(0, 0), (1, 1), (2, 0)])
line
Out[4]:
<shapely.geometry.linestring.LineString at 0x7f3ef007a080>
In [5]:
line1 = LineString([(0, 0), (1, 1)])
line2 = LineString([(1, 1), (2, 0)])
In [10]:
from shapely.geometry import Point
print(line1.interpolate(line1.project(Point(2, 0))))
POINT (1 1)
In [13]:
from shapely.geometry import MultiLineString
line1 = LineString([(0, 0), (2, 0)])
line2 = LineString([(0, 0), (1, 1)])
MultiLineString([line1, line2])
Out[13]:
<shapely.geometry.multilinestring.MultiLineString at 0x7f3ef00c76d8>
In [16]:
list(line2.coords)
Out[16]:
[(0.0, 0.0), (1.0, 1.0)]
In [19]:
print(line1.interpolate(line1.project(Point(1, 1))))
POINT (1 0)
In [5]:
# Create angle that is greater than 90 degrees
from shapely.geometry import LineString, MultiLineString
line1 = LineString([(0, 0), (2, 0)])
line2 = LineString([(0, 0), (-1, 1)])
MultiLineString([line1, line2])
Out[5]:
<shapely.geometry.multilinestring.MultiLineString at 0x7f0b30e10518>
In [10]:
# Create right triangle
from shapely.geometry import Point
point = Point(set(line2.coords) - set(line1.coords))
print(point)
POINT (-1 1)
In [11]:
p1 = 2, 0
p2 = -1, 1
In [13]:
import numpy as np
p1[::-1]
Out[13]:
(0, 2)
In [14]:
p2[::-1]
Out[14]:
(1, -1)
In [15]:
angle1 = np.arctan2(*p1[::-1])
angle2 = np.arctan2(*p2[::-1])
In [16]:
np.rad2deg((angle1 - angle2) % (2 * np.pi))
Out[16]:
225.0
In [24]:
a_xy = 2, 0
b_xy = 0, 0
c_xy = -1, 1
np.array(a_xy) - b_xy
a_xy - np.array(b_xy)
Out[24]:
array([2, 0])
In [27]:
import numpy as np

def compute_angle(a_xy, b_xy, c_xy):
    # https://stackoverflow.com/a/31735642/192092
    b_xy = np.array(b_xy)
    angle1 = np.arctan2(*(a_xy - b_xy)[::-1])
    angle2 = np.arctan2(*(c_xy - b_xy)[::-1])
    angle_in_degrees = np.rad2deg((angle1 - angle2) % (2 * np.pi))
    if angle_in_degrees > 180:
        angle_in_degrees = 360 - angle_in_degrees
    return angle_in_degrees

print(compute_angle((2, 0), (0, 0), (-1, 1)))
print(compute_angle((2, 0), (0, 0), (1, 1)))
print(compute_angle((3, 1), (1, 1), (0, 2)))
135.0
45.0
135.0
+ Define linestring with point
+ Compute the angle of incoming vs outgoing line

20171111-0730 - 20171111-0800: 30 minutes

+ Create a tool that computes the angle

20171117-2215 - 20171117-2245: 30 minutes

In [2]:
import numpy as np

def compute_angle(a_xy, b_xy, c_xy):
    # https://stackoverflow.com/a/31735642/192092
    b_xy = np.array(b_xy)
    angle1 = np.arctan2(*(a_xy - b_xy)[::-1])
    angle2 = np.arctan2(*(c_xy - b_xy)[::-1])
    angle_in_degrees = np.rad2deg(angle1 - angle2)
    if angle_in_degrees < 0:
        angle_in_degrees *= -1
    return angle_in_degrees

print(compute_angle((2, 0), (0, 0), (-1, 1)))
print(compute_angle((2, 0), (0, 0), (1, 1)))
print(compute_angle((3, 1), (1, 1), (0, 2)))
135.0
45.0
135.0

20171128-2300 - 20171128-2315: 15 minutes

+ Use pole type A when the angle of the incoming and outcoming distribution line is smaller than X degrees.
+ Use pole type A for solar panel poles.
+ Use pole type B otherwise.