-
Notifications
You must be signed in to change notification settings - Fork 1
/
generateNetwork.py
81 lines (62 loc) · 2.5 KB
/
generateNetwork.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# -*- coding: utf-8 -*-
"""
Created on Tue Oct 3 08:56:12 2017
@author: isaac
"""
from argparse import ArgumentParser
import os
import numpy as np
from toil.common import Toil
from toil.job import Job
from module_SN import computeSN
from module_IN import computeIN
from module_F import joinSNIN
from module_Net import runNetwork
#python generateNetwork.py file:jobStore --pathGPX /Users/isaac/IdeaProjects/QGISphase/src/cimas/cimasData/Massanella/ --pathNPY /Users/isaac/IdeaProjects/QGISphase/src/cimas/cimasData/rutas_on_Massanella_Summer.npy
#
#rutas = np.load("cimasData/rutas_on_Teide_Spring.npy")
#rutas = np.load("cimasData/rutas_on_Teide_Winter.npy")
#rutas = np.load("cimasData/rutas_on_Massanella_Spring.npy")
# rutas = np.load("cimasData/rutas_on_Massanella_Summer.npy")
#==============================================================================
# DAG of jobs
#==============================================================================
def generateNetwork(job,options):
# outComputeSN = None
j1 = Job.wrapJobFn(computeSN,options)
j2 = Job.wrapJobFn(computeIN,options)
j3 = Job.wrapJobFn(joinSNIN,options)
j4 = Job.wrapJobFn(runNetwork, options)
job.addChild(j1)
job.addChild(j2)
job.addFollowOn(j3)
j3.addFollowOn(j4)
#defaultOutPath = "tmp"
def main(options=None):
if not options:
parser = ArgumentParser()
Job.Runner.addToilOptions(parser)
parser.add_argument('--pathGPX',help='The absolute path where all GPX file are.')
parser.add_argument('--pathNPY', help='A npy file (np.array stored) with the path of each file to be analysed')
# parser.add_argument("--O", help="Output destination path ",default=defaultOutPath)
options = parser.parse_args()
#some checks
npyFile = options.pathNPY
if not os.path.exists(npyFile):
print("the npy file [fileNameGPX1,fileNameGPX2,...] does not exists.")
exit()
try:
codes = np.load(npyFile)
if len(codes)==0:
raise RuntimeError("Invalid values of npy file: %s" % options.pathNPY)
except:
raise RuntimeError("Invalid format of npy file: %s" % options.pathNPY)
#Run workflow
with Toil(options) as workflow:
if not workflow.options.restart:
workflow.start(Job.wrapJobFn(generateNetwork,options=options))
else:
workflow.restart()
# workflow.exportFile(sortedFileID, sortedFileURL)
if __name__ == '__main__':
main()