forked from DSSAT/NASAP_CHIRPS_WTH
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWTH_main.py
39 lines (36 loc) · 1.36 KB
/
WTH_main.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
#!/usr/bin/env python
#-------------------------------------------------------------------------------
# Name: WTH_main.py
# Purpose: To invoke the necessary functions to build weather files for the native DSSAT format (.WTH)
# Author: Oscar Castillo
# Created: 11/01/2020
# Runs in Python 3.8.5
##Columns of the CSV input file:
#ID,Latitude,Longitude,nasapid,LatNP,LonNP
#-------------------------------------------------------------------------------
from multiprocessing import Process
from NP import nasap_gen
from CHIRPS import chirps
from DSSAT_WTH import nasachirps
import os
in_file = "C:\\Work\\Test\\XYpoints.csv"
ID = "ID"
NASAP_ID = "nasapid"
in_chirps = "C:\\Work\\Test\\in_chirps"
sy, sm, sd, ey, em, ed = [2020, 10, 29, 2020, 10, 31]
out_dir = "C:\\Work\\Test\\Output"
if __name__=='__main__':
if not os.path.exists(out_dir):
os.mkdir(out_dir)
p1 = Process(target=nasap_gen, args=(in_file, out_dir, sy, sm, sd, ey, em, ed))
p1.start()
p2 = Process(target=chirps, args=(in_chirps, in_file, out_dir, ID))
p2.start()
p1.join()
p2.join()
nasap_file = out_dir + "\\dfNASAP.pkl"
chirps_file = out_dir + "\\dfCHIRPS.pkl"
p3 = Process(target=nasachirps, args=(in_file, nasap_file, chirps_file, out_dir))
p3.start()
p3.join()