def prepare_timeboundary(filename): """Converting tide time series to NetCDF tms file. This is a 'throw-away' code taylor made for files like 'Benchmark_2_input.txt' from the LWRU2 benchmark """ print 'Preparing time boundary from %s' %filename from Numeric import array, zeros, Float, asarray fid = open(filename) #Skip first line line = fid.readline() #Read remaining lines lines = fid.readlines() fid.close() N = len(lines) T = zeros(N, Float) #Time Q = zeros(N, Float) #Values Told = 0.0 Sold = ' ' Lold = ' ' for i, line in enumerate(lines): fields = line.split() #print fields l_time = (fields[0]+' '+fields[1])[0:-1] from time import strptime, mktime s_time = strptime(l_time,'%d/%m/%y %H:%M:%S') #print s_time T[i] = float(mktime(s_time)) if i==0: Tstart = T[0] T[i] = T[i] - Tstart #this is specific to this data set. deals with daylight saving if i>3270: T[i] = T[i]+3600 if T[i]