forked from AgriculturalModelExchangeInitiative/PyCrop2ML
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_xml2wf.py
40 lines (28 loc) · 1.02 KB
/
test_xml2wf.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
from path import Path
from pycropml import pparse, render_python
from pycropml import composition
from pycropml.xml2wf import XmlToWf
# Fix pb in local path
cwd = Path.getcwd()
if (cwd/'data').isdir():
data = cwd/'data'
elif (cwd/'test'/'data').isdir():
data = cwd/'test'/'data'
else:
print('Data directory not found')
#data=Path
def testXmlwf():
#model_units = data.glob('unit*.xml')
models = pparse.model_parser(data)
# translate cropml model units to python functions and openalea in python_model repository
render_python.Model2Package(models, dir='.',pkg_name="Phenology").run()
# repository of python models generated with wralea
dir = cwd/'python_model'
rep_composite= data/'crop2ml'
# composite file
#print(rep_composite.glob("composition*.xml")[0])
compositionFile = rep_composite.glob("composition*.xml")[0]
xmlwf,= composition.model_parser(compositionFile)
XmlToWf(xmlwf, dir, "Phenology").run()
if __name__=='__main__':
testXmlwf()