#!/usr/bin/env python

from numpy import *
import numpy as np
import sys
import subprocess
import glob
import os

print 'Number of arguments:', len(sys.argv), 'arguments.'
print 'Argument List:', str(sys.argv)

print sys.argv[0], sys.argv[1]
polder_file_name = sys.argv[1]

command = 'parasolascii -g ' + polder_file_name + ' phase > ' + polder_file_name + '.txt'
os.system(command)

hour = []
i=0
command = ['parasolascii', polder_file_name, 'utc_hour']
process = subprocess.Popen(command, stdout=subprocess.PIPE)
while True:
	text = process.stdout.readline()
	if text != '':
		hour.append( int(text) )
		#print hour[i],i
		i=i+1
	else:
		break

minute = []
i=0
command = ['parasolascii', polder_file_name, 'utc_minute']
process = subprocess.Popen(command, stdout=subprocess.PIPE)
while True:
	text = process.stdout.readline()
	if text != '':
		minute.append( int(text) )
		#print minute[i],i
		i=i+1
	else:
		break
print len(hour),len(minute)
time = []
for i in range(len(hour)):
	time.append( hour[i] * 60.0 + minute[i]	)
start_time = min(time)
end_time = max(time)
if (end_time-start_time)>60.0:		
	print 'hello', alen(hour)
	for j in np.arange(alen(hour)):
		if(hour[j]<12.0): 
			time[j] = 24.0*60.0+hour[i]*60.0+minute[j]	
			start_time = min(time)
			end_time = max(time) - 24*60
start_hour = int( start_time / 60 )
start_minute = int( start_time - start_hour * 60.0 )
end_hour = int( end_time / 60 )
end_minute = int( end_time - end_hour * 60.0 )	
print start_hour, start_minute, end_hour, end_minute
if start_hour < 10:
	str_start_hour = '0' + str( start_hour )	
else:
	str_start_hour = str( start_hour )
if start_minute < 10:
	str_start_minute = '0' + str( start_minute )
else:
	str_start_minute = str( start_minute )		
if end_hour < 10:
	str_end_hour = '0' + str( end_hour )	
else:
	str_end_hour = str( end_hour )		
if end_minute < 10:
	str_end_minute = '0' + str( end_minute )
else:
	str_end_minute = str( end_minute )		
command = 'mv ' + polder_file_name + '.txt' + ' ' + polder_file_name + '_' + str_start_hour + str_start_minute + '_' + str_end_hour + str_end_minute +  '.txt'
os.system(command)

About / Au sujet de

Ben
Created:
30 octobre 2016 03:55:12

Updated:
30 octobre 2016 03:55:12

License / Licence

MIT License

Abstract / Résumé