With python os module
Run parasol ascii using python os module:
#!/usr/bin/env pythonimport osfilename = '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 pythonimport subprocessfilename = 'P3L2TRGB071037KL'polder_latitude = []polder_longitude = []polder_cc = []command = ['parasolascii', '-g', filename, 'cc']process = subprocess.Popen(command, stdout=subprocess.PIPE, encoding='utf8')count = 0while 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+1else:breakfor i in range(100):print(polder_latitude[i],polder_longitude[i],polder_cc[i])
returns:
54.750 -3.323 154.750 -3.034 154.750 -2.745 154.750 -2.456 154.750 -2.167 154.750 -1.878 154.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 |
