#! /usr/bin/env python # -*- coding: cp1252 -*- ''' *************************************************************************************** S M O L A - 2 0 0 6 S U R V E Y S h o t p o i n t t i m e r e c o n s t r u c t i o n - - - - - - - - - - - - - - - - - - - - - - - - - - - DESCRIPTION: This Python script extracts position and time from automatic logging computer data files. This computer logs time and position every minute, independent of any survey line. Both time and position are GPS based. In order to reconstruct shotpoint times fram the Smøla-2006 Survey we first need to interpolate the minute-files so we can obtain time of an arbitrary point along the survey line (subject to size of interpolation step). Combining shotpoint positions with interpolated position/time values we can determine interpolated time of shotpoint. A brief time offset must be added to the interpolated shotpoint values to account for the delay between the EIVA Survey computer actually issuing the shot command, and the Gun Controller firing time. (This is performed in a later processing stage). INPUT FILE: File from automatic logging computer, containing minute reading of date, time and position. Filename: See constant declaration section below. OUTPUT FILES: Two files generated (as later interpolation deals with Easting/Northing separately): a) Time and Easting b) Time and Northing Names of output files: See constant declaration section below. OTHER ASSUMPTIONS: This program file must be placed "above" input file directory called "logs". EXTERNAL LIBRARY USED: UTM to Lat/Long conversion - download library from: http://www.pygps.org/#LatLongUTMconversion Either: a) On Linux: Unpack it, and run "python setup.py install" as root. In order to build Python modules you must first install 'python-devel'. b) Windows/Linux: Put "LatLongUTMconversion.py" in the same directory as this file. VERSION: Ver Date By Description ---------------------------------------------------------------------------------- 0.1 14 Aug 2007 O.Meyer Initial version ---------------------------------------------------------------------------------- Dept. of Earth Science University of Bergen N O R W A Y *************************************************************************************** ''' import LatLongUTMconversion from string import split from os.path import join from datetime import datetime from time import strptime WGS84 = 23 # Datum constant, see LatLongUTMconversion file #----- Directory, file names DataDirectory = './logs' DataFile = 'toktlogger-24-25-okt-2006.txt' TimeEastingFile = 'time_easting.txt' TimeNorthingFile = 'time_northing.txt' #--------------------------------------------------------------------- #----- S t a r t o f p r o g r a m #--------------------------------------------------------------------- #----- Example format line in input file: #----- 1,2006622,24.10.2006,134210.21,3100,000,000,-1,-1,-1,-1, 170.358,6327.44758 N,00706.58098 E, 264.93,-1,-1,-1, 7.90, 11.90, 8.70, 37.95, 994.80, 57,2,8,3,0,-1, 5.00, 267,,*5c #--- We need to output all positions with a time value in seconds, since a reference point in time #--- This reference point is set in the next statement, to 24/10/2006, 00:00:00.000000 BaseTime = datetime(2006,10,24,0,0,0,0) #---- One input file, two output files f_in = open(join(DataDirectory,DataFile)) f_E = open(TimeEastingFile, "w") f_N = open(TimeNorthingFile, "w") for line in f_in: #<<<<<<-- Loop throgh all lines in input file s = line.split(',') Day = s[2].split('.')[0] Month = s[2].split('.')[1] Year = s[2].split('.')[2] Hour = s[3][0:2] Minute = s[3][2:4] Seconds = s[3][4:6] Microsec = int(s[3].split('.')[1]) * 10000 Latitude = s[12].split()[0] # s[12] holds string like '6324.99468 N' Longitude = s[13].split()[0] # s[13] holds string like '00706.58098 E' #--- Convert lat/long to decimal degrees, and then to UTM Easting/Northing Latitude = int(Latitude[0:2]) + (float(Latitude[2:])/60.0) Longitude = int(Longitude[0:3]) + (float(Longitude[3:])/60.0) (z, e, n) = LatLongUTMconversion.LLtoUTM(WGS84, Latitude, Longitude) #--- Create Datetime object from current time values #print '%s-%s-%s %02s:%02s:%02s.%06d' % (Day, Month, Year, Hour, Minute, Seconds, Microsec) TimeStamp = datetime( int(Year), int(Month), int(Day), int(Hour), int(Minute), int(Seconds), Microsec ) #--- Calculate time delta: Difference between time in current line, and base time at midnight 24. Oct. TimeDelta = TimeStamp - BaseTime #--- Convert this time delta to number of seconds, with fractional part TimeDeltaAsFloat = (TimeDelta.days * 86400) + TimeDelta.seconds + (TimeDelta.microseconds/1000000.0) #--- Write to output files f_E.write('%1.3f %1.1f\n' % (TimeDeltaAsFloat, e)) f_N.write('%1.3f %1.1f\n' % (TimeDeltaAsFloat, n)) f_E.close() f_N.close() f_in.close()