Exemplo n.º 1
0
def DateToMJD(d):
	
	if (re.match('^\d{5}$',d)): # just check the format
		return int(d)
	match = re.match('^\d{4}-\d{1,3}$',d)
	if (match): # YYYY-DOY
		utctod = time.strptime(d,'%Y-%j')
		return ottplib.MJD(calendar.timegm(utctod))
	match = re.match('^\d{4}-\d{1,2}-\d{1,2}$',d) # YYYY-MM-DD
	if (match): 
		utctod = time.strptime(d,'%Y-%m-%d')
		return ottplib.MJD(calendar.timegm(utctod))
	return -1
Exemplo n.º 2
0
def LoadRxLogFile(fname):
    Debug('Opening ' + fname)

    restarts = []

    try:
        fin = open(fname, 'r')
    except:
        Warn('Unable to load ' + fname)
        return restarts

    for l in fin:
        match = re.match(
            '^(\d{2}/\d{2}/\d{2})\s+(\d{2}):(\d{2}):(\d{2})\s+.+\s+restarted',
            l)
        if (match):
            tod = int(match.group(2)) * 3600 + int(match.group(3)) * 60 + int(
                match.group(4))
            mjd = ottplib.MJD(
                calendar.timegm(time.strptime(match.group(1), "%d/%m/%y")))
            restarts.append(mjd + tod / 86400.0)

    fin.close()

    return restarts
Exemplo n.º 3
0
nbad = 0

# Can get some buffered stuff at the beginning if already running so toss it
for i in xrange(20):
    try:
        l = ser.readline()
    except select.error as (code, msg):  # CTRL-C returns code=4
        print msg
        break

while (not killed):

    # Check whether we need to create a new log file
    tt = time.time()
    mjd = ottplib.MJD(tt)
    if (not (mjd == oldmjd)):
        oldmjd = mjd
        if (tic_mode == TIC_MODE_TI):
            fnoutA = dataPath + str(mjd) + ctrExt
        elif (tic_mode == TIC_MODE_TS):
            fnoutA = dataPath + str(mjd) + '.A' + ctrExt
            fnoutB = dataPath + str(mjd) + '.B' + ctrExt
        if (not os.path.isfile(fnoutA)):
            foutA = open(fnoutA, 'w', 0)
            if (os.path.isfile(headerGen) and os.access(headerGen, os.X_OK)):
                header = subprocess.check_output([headerGen, '-c', configFile])
                foutA.write(header.rstrip() +
                            '\n')  # make sure there is just one linefeed
            foutA.write(ctrcfg)  # Configuration after the header
        else:
Exemplo n.º 4
0
	for c in centres:
		print c, cfg[c.lower() + ':base url']
	sys.exit(0)

dataCentre = args.centre.lower()
# Check that we've got this
found = False
for c in centres:
	if (c.lower() == dataCentre):
		found=True
		break
if (not found):
	ErrorExit('The data centre ' + dataCentre + ' is not defined in ' + configFile)
	
today = time.time() # save this in case the day rolls over while the script is running
mjdToday = ottplib.MJD(today)
start = mjdToday
stop  = mjdToday

if (args.start):
	start = DateToMJD(args.start)
	stop = start
	
if (args.stop):
	stop = DateToMJD(args.stop)

outputdir = args.outputdir

Debug('start = {},stop = {} '.format(start,stop))

# Daily data
Exemplo n.º 5
0
# ------------------------------------------
def DecodeUBX_TIM_TP(msg):
	if not(len(msg)==(16+2)*2):
		return ['']
	packed=binascii.unhexlify(msg)
	unpacked=struct.unpack('IIiH4B',packed)
	return unpacked

# ------------------------------------------
# Main 
# ------------------------------------------

home =os.environ['HOME'] + '/'
configFile = os.path.join(home,'etc/gpscv.conf')
tt = time.time()
mjd = ottplib.MJD(tt) - 1 # previous day
compress=False

parser = argparse.ArgumentParser(description='Extract messages from a ublox data file')
parser.add_argument('--config','-c',help='use an alternate configuration file',default=configFile)
parser.add_argument('--debug','-d',help='debug',action='store_true')
parser.add_argument('--mjd','-m',help='mjd',default=mjd)
parser.add_argument('--uniqid',help='chip id',action='store_true')
parser.add_argument('--monver',help='hardware and software versions',action='store_true')
parser.add_argument('--navclock',help='nav-clock',action='store_true')
parser.add_argument('--navsat',help='nav-sat',action='store_true')
parser.add_argument('--navtimeutc',help='nav-timeutc',action='store_true')
parser.add_argument('--rawx',help='raw measurement data',action='store_true')
parser.add_argument('--timtp',help='sawtooth correction',action='store_true')
parser.add_argument('--version','-v',help='show version and exit',action='store_true')
args = parser.parse_args()