-
Notifications
You must be signed in to change notification settings - Fork 0
/
pathFinder.py
48 lines (43 loc) · 1.48 KB
/
pathFinder.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import csv
import sys
filename = 'darkskytest'
# Get cloud cover data from CSV file
with open(filename + '.csv', 'r') as f:
reader = csv.reader(f)
data = list(reader)
strs = [i[2:] for i in data[1:]]
cloudCover = [list(map(float, i)) for i in strs]
# Determine the maximum and minimum speed
highSpeed = 20
lowSpeed = 10
speedRange = highSpeed - lowSpeed
lx, lt = len(cloudCover), len(cloudCover[0])
# Initialize two-dimensional list of paths and list of cloud cover sums
paths = [[None]*(lx+1) for i in range(speedRange)]
pathsENet = [None]*speedRange
startPoint = cloudCover[0][0]
# Finding all straight line paths with constant speed between highSpeed and lowSpeed
for deltaX in range(highSpeed, lowSpeed, -1):
distRem = lx - deltaX
currTime = 0
while distRem > 0:
paths[deltaX - speedRange - 1][currTime] = cloudCover[deltaX*(currTime+1)][currTime]
currTime += 1
distRem -= deltaX
if currTime >= 49:
print("Your inputted low speed is too slow!")
sys.exit()
if distRem < 0:
finalPoint = cloudCover[lx-1][currTime]
paths[deltaX - speedRange - 1][currTime] = finalPoint*abs(distRem/deltaX)
# Iterating through each generated path
for i, path in enumerate(paths):
j = 0
ccSum = startPoint
while (j < lx) and (path[j] != None):
ccSum += path[j]
j += 1
ccSum *= (i+1)
pathsENet[i] = ccSum
# A sum of all the cloud cover values along any given straight line path
print(pathsENet)