With python os module
Run parasol ascii using python os module:
#!/usr/bin/env python
import os
filename = 'P3L2TRGB071037KL'
command = 'parasolascii -c ' + filename + ' cc > ' + filename + '.ascii'
os.system(command)
to save polder/parasol data in an ascii file.
With python subprocess module
To read a polder/parasol file, it is not necessary to first save the data in an ascii file, one can use the python subprocess module instead, illustration:
#!/usr/bin/env python
import subprocess
filename = 'P3L2TRGB071037KL'
polder_latitude = []
polder_longitude = []
polder_cc = []
command = ['parasolascii', '-g', filename, 'cc']
process = subprocess.Popen(command, stdout=subprocess.PIPE, encoding='utf8')
count = 0
while True:
text = process.stdout.readline()
if text != '':
latitude, longitude, cc = text.split()
polder_latitude.append( latitude )
polder_longitude.append( longitude )
polder_cc.append( cc )
count=count+1
else:
break
for i in range(100):
print(polder_latitude[i],polder_longitude[i],polder_cc[i])
returns:
54.750 -3.323 1
54.750 -3.034 1
54.750 -2.745 1
54.750 -2.456 1
54.750 -2.167 1
54.750 -1.878 1
54.750 -1.589 1
. . .
. . .
. . .
References
Liens | Site |
---|---|
Parasolascii | icare |
Parasol_Level-2_format_latest.pdf | icare |
subprocess | python doc |
subprocess and Type Str doesnt support the buffer API | stackoverflow |
subprocess.Popen stdin read file | stackoverflow |
Why does Popen.communicate() return b'hi\n' instead of 'hi'? | stackoverflow |
subprocess module | bogotobogo |
Python3 subprocess output | stackoverflow |