def clockDiffByDistance(timeList1, timeList2, gpsTimeList1, gpsTimeList2, delayList, shift): factor1 = clockTimeCalibrate.clockTimeFactor(gpsTimeList1) factor2 = clockTimeCalibrate.clockTimeFactor(gpsTimeList2) list1 = clockTimeCalibrate.timeCalibrate(timeList1, factor1) list2 = clockTimeCalibrate.timeCalibrate(timeList2, factor2) gpsTimeList1 = clockTimeCalibrate.timeCalibrate(gpsTimeList1, factor1) gpsTimeList2 = clockTimeCalibrate.timeCalibrate(gpsTimeList2, factor2) lenght = len(list1) Num = 4 result = [] for index in range(lenght): startNo = int(list1[index][0] / 1000000000000) - 1 delayFun1, delayFun2 = gpsOrbit.gpsLagInterFun(gpsTimeList1, gpsTimeList2, delayList, startNo, Num, shift) delay1 = delayFun1(list1[index][0]) delay2 = delayFun2(list2[index][0]) delay1 = delayFun1(list1[index][0] - delay1) delay2 = delayFun2(list2[index][0] - delay2) delay1 = delayFun1(list1[index][0] - delay1) delay2 = delayFun2(list2[index][0] - delay2) coinDelay = list1[index][0] - delay1 - (list2[index][0] - delay2) result.append( [timeList1[index][0], list1[index][0], coinDelay, delay1, delay2]) print 'clock difference calculated by satellite distance' return result
def timeCalibrate(groPulseList, satPulseList, groGPSList, satGPSList): groFactor = clockTimeCalibrate.clockTimeFactor(groGPSList) satFactor = clockTimeCalibrate.clockTimeFactor(satGPSList) groGPSList = clockTimeCalibrate.timeCalibrate(groGPSList, groFactor) satGPSList = clockTimeCalibrate.timeCalibrate(satGPSList, satFactor) groPulseList = clockTimeCalibrate.timeCalibrate(groPulseList, groFactor) satPulseList = clockTimeCalibrate.timeCalibrate(satPulseList, satFactor) print 'time calibrated!' return groPulseList, satPulseList, groGPSList, satGPSList
def coincidenceDelay(timeList1, timeList2, List2Delay, gpsTimeList1, gpsTimeList2, startSec, endSec, shift, fitNum): # Num=int((endSec-startSec)/2)+5 Num = 4 secCount = 1000000000000 # print Num timeFactor1 = clockTimeCalibrate.clockTimeFactor(gpsTimeList1) timeFactor2 = clockTimeCalibrate.clockTimeFactor(gpsTimeList2) List1 = clockTimeCalibrate.timeCalibrate(timeList1, timeFactor1) List2 = clockTimeCalibrate.timeCalibrate(timeList2, timeFactor2) gpsTimeList1 = clockTimeCalibrate.timeCalibrate(gpsTimeList1, timeFactor1) gpsTimeList2 = clockTimeCalibrate.timeCalibrate(gpsTimeList2, timeFactor2) # delayFun1, delayFun2,delayfunc = gpsOrbit.gpsLagInterFun(gpsTimeList1, gpsTimeList2, List2Delay, 86, Num, shift,sec) # x=[float(i/100.0) for i in range(8600,10500)] # fx=[delayFun2(i) for i in x] # plt.figure("play") # ax1 = plt.subplot(111) # plt.sca(ax1) # #plt.plot(sr_x, sr_fx, linestyle=' ', marker='o', color='b') # plt.plot(x, fx, linestyle='--', color='r') # plt.show() tol = len(List1) gap = int(tol / 1000) for i in range(1, fitNum + 1): sec = int(List1[i * gap][0] / 1000000000000) delayFun1, delayFun2, delayfunc = gpsOrbit.gpsLagInterFun( gpsTimeList1, gpsTimeList2, List2Delay, sec, Num, shift, secCount) # print sec timeBase1 = gpsTimeList1[sec - 1][0] timeBase2 = gpsTimeList2[sec - 1][0] delay1 = delayFun1(List1[i * gap][0] / 1000000000000) delay2 = delayFun2(List2[i * gap][0] / 1000000000000) # print delay1, delay2,List1[i*gap][0]/1000000000000,List2[i*gap][0]/1000000000000,'1' delay1 = delayFun1((List1[i * gap][0] - delay1) / 1000000000000) delay2 = delayFun2((List2[i * gap][0] - delay2) / 1000000000000) delay1 = delayFun1((List1[i * gap][0] - delay1) / 1000000000000) delay2 = delayFun2((List2[i * gap][0] - delay2) / 1000000000000) delay = delayfunc(List1[i * gap][0] / 1000000000000) delay = delayfunc((List1[i * gap][0] - delay) / 1000000000000) delay = delayfunc((List1[i * gap][0] - delay) / 1000000000000) time2 = List2[i * gap][0] - delay2 time1 = List1[i * gap][0] - delay1 detTime = time1 - time2 det = List1[i * gap][0] - List2[i * gap][0] - delay # print delay1,delay2,time1,time2 # print timeBase2-timeBase1 print '%s\t%s\t%s\t%s' % (List1[i * gap][0], detTime, det, delay)
def gpsClock(): gpsTimeFile1=unicode('G:\\时频传输数据处理\\双站数据处理\\3.2\LJ\\recv_fixed_GPSTime.txt','utf8') gpsTimeFile2=unicode('G:\\时频传输数据处理\\双站数据处理\\3.2\DLH\\recv_fixed_GPSTime.txt','utf8') gpsTimeList1=fileToList.fileToList(gpsTimeFile1) gpsTimeList2=fileToList.fileToList(gpsTimeFile2) timeFactor1 = clockTimeCalibrate.clockTimeFactor(gpsTimeList1) timeFactor2 = clockTimeCalibrate.clockTimeFactor(gpsTimeList2) gpsTimeList1 = clockTimeCalibrate.timeCalibrate(gpsTimeList1, timeFactor1) gpsTimeList2 = clockTimeCalibrate.timeCalibrate(gpsTimeList2, timeFactor2) detTime=[] if len(gpsTimeList1)>len(gpsTimeList2): Sec=len(gpsTimeList2) else:Sec=len(gpsTimeList1) for i in range(Sec-1): det=(gpsTimeList1[i+1][0]-gpsTimeList1[i][0])-(gpsTimeList2[i+1][0]-gpsTimeList2[i][0]) detTime.append([i,det]) #print gpsTimeList1[i+1][0]-gpsTimeList1[i][0] #print gpsTimeList2[i+1][0]-gpsTimeList2[i][0] print "the difference between GPS time record by two station"
def GPS_Compare(gpsList1, gpsList2, shift): timeFactor1, offset1 = clockTimeCalibrate.clockTimeFactorFit(gpsList1) timeFactor2, offset2 = clockTimeCalibrate.clockTimeFactorFit(gpsList2) gpsFitList1 = clockTimeCalibrate.timeCalibrate(gpsList1, timeFactor1, -offset1) gpsFitList2 = clockTimeCalibrate.timeCalibrate(gpsList2, timeFactor2, -offset2) N1 = len(gpsFitList1) N2 = len(gpsFitList2) Sec = [] coinList = [] residual = [] if shift >= 0: if N1 - shift >= N2: N = N2 else: N = N1 - shift for i in range(N): residual.append(gpsFitList1[i + shift][0] - (gpsFitList2[i][0] + shift * 1000000000000)) Sec.append(i + 1) coinList.append( [gpsFitList1[i + shift][0], gpsFitList2[i][0], residual[-1]]) else: if N1 + shift >= N2: N = N2 else: N = N1 + shift for i in range(N): residual.append(gpsFitList1[i - shift][0] - (gpsFitList2[i][0] - shift * 1000000000000)) Sec.append(i + 1) coinList.append( [gpsFitList1[i - shift][0], gpsFitList2[i][0], residual[-1]]) rms = np.std(residual, ddof=1) m = np.mean(residual) print 'GPS Compare RMS:%s Mean:%s' % (rms, m) return coinList, rms, m
def groundMoveScan(): # step=[3,3,3,2,2,2] # scanRange=[9,9,9,4,4,6] step = [1, 1, 1, 1, 1, 1] scanRange = [1, 1, 1, 1, 1, 1] offset = [-29, -32, 15, -26, -42, 9] date = '20180121' dataLJ = '20180122014609' dataDLH = '20180122014608' startSec = 120 endSec = 215 gpsShift = -17 tdcShift = 1 groundXYZList = fileToList.fileToList( unicode( 'C:\Users\Levit\Experiment Data\双站数据\\3.10\\groundStationWGS84.txt', 'utf8')) satelliteXYZList = fileToList.fileToList( unicode( 'C:\Users\Levit\Experiment Data\双站数据\\%s\\satelliteWGS84_Sec.txt' % date, 'utf8')) atmosphereList = fileToList.fileToList( unicode('C:\Users\Levit\Experiment Data\双站数据\\%s\\天气参数.txt' % date, 'utf8')) gpsTimeList1 = fileToList.fileToList( unicode( 'C:\Users\Levit\Experiment Data\双站数据\\%s\共视数据\\%s-tdc2_channel_1.txt' % (date, dataLJ), 'utf8')) gpsTimeList2 = fileToList.fileToList( unicode( 'C:\Users\Levit\Experiment Data\双站数据\\%s\共视数据\\%s-tdc13_channel_1.txt' % (date, dataDLH), 'utf8')) dataList = fileToList.fileToList( unicode( 'C:\Users\Levit\Experiment Data\双站数据\\%s\\result\\synCoincidence-120-220--16-1-Coin-紫台WGS84-atm-factor_filtered.txt' % (date), 'utf8')) List1, List2 = dataReduce(dataList, 100) newgpsTimeList2 = [] if tdcShift >= 0: for i in range(tdcShift): newgpsTimeList2.append([gpsTimeList2[i][0]]) for i in range(len(gpsTimeList2)): newgpsTimeList2.append( [gpsTimeList2[i][0] + tdcShift * 1000000000000]) else: for i in range(len(gpsTimeList2)): gpsTime = gpsTimeList2[i][0] + tdcShift * 1000000000000 if gpsTime > 0: newgpsTimeList2.append([gpsTime]) timeFactor1, offset1 = clockTimeCalibrate.clockTimeFactorFit(gpsTimeList1) timeFactor2, offset2 = clockTimeCalibrate.clockTimeFactorFit( newgpsTimeList2) gpsTimeList1 = clockTimeCalibrate.timeCalibrate(gpsTimeList1, timeFactor1, offset1) newgpsTimeList2 = clockTimeCalibrate.timeCalibrate(newgpsTimeList2, timeFactor2, offset2) minSTD = 100000000 for i in range(scanRange[0] / step[0]): for j in range(scanRange[1] / step[1]): for k in range(scanRange[2] / step[2]): for ii in range(scanRange[3] / step[3]): for jj in range(scanRange[4] / step[4]): for kk in range(scanRange[5] / step[5]): move = [ i * step[0] - scanRange[0] / 2 + offset[0], j * step[1] - scanRange[1] / 2 + offset[1], k * step[2] - scanRange[2] / 2 + offset[2], ii * step[3] - scanRange[3] / 2 + offset[3], jj * step[4] - scanRange[4] / 2 + offset[4], kk * step[5] - scanRange[5] / 2 + offset[5] ] info = [date, startSec, endSec, gpsShift, move] groundXYZListMove = ground_move( groundXYZList, move) std = satMoveSimulation(List1, List2, groundXYZListMove, satelliteXYZList, atmosphereList, gpsTimeList1, newgpsTimeList2, info) [x1, y1, z1, x2, y2, z2] = move print '%s\t%s\t%s\t%s\t%s\t%s\t%s' % ( x1, y1, z1, x2, y2, z2, std) if std < minSTD: minSTD = std minMove = move print 'best move: %s, std: %s' % (minMove, minSTD)
def satMoveScan(): step = [1, 1, 1] scanRange = [1, 1, 1] offset = [10, -12, -20] date = '20180109' dataLJ = '20180110012855' dataDLH = '20180110012854' startSec = 137 endSec = 230 gpsShift = -22 tdcShift = 1 groundXYZList = fileToList.fileToList( unicode( 'C:\Users\Levit\Experiment Data\双站数据\\3.10\\groundStationWGS84.txt', 'utf8')) satelliteXYZList = fileToList.fileToList( unicode( 'C:\Users\Levit\Experiment Data\双站数据\\%s\\satelliteWGS84_Sec_new.txt' % date, 'utf8')) atmosphereList = fileToList.fileToList( unicode('C:\Users\Levit\Experiment Data\双站数据\\%s\\天气参数.txt' % date, 'utf8')) gpsTimeList1 = fileToList.fileToList( unicode( 'C:\Users\Levit\Experiment Data\双站数据\\%s\共视数据\\%s-tdc2_channel_1.txt' % (date, dataLJ), 'utf8')) gpsTimeList2 = fileToList.fileToList( unicode( 'C:\Users\Levit\Experiment Data\双站数据\\%s\共视数据\\%s-tdc13_channel_1.txt' % (date, dataDLH), 'utf8')) dataList = fileToList.fileToList( unicode( 'C:\Users\Levit\Experiment Data\双站数据\\%s\\result\\synCoincidence-137-240--21-1-Coin-紫台WGS84-atm-factor-neworbit-0120_filtered.txt' % (date), 'utf8')) List1, List2 = dataReduce(dataList, 100) newgpsTimeList2 = [] if tdcShift >= 0: for i in range(tdcShift): newgpsTimeList2.append([gpsTimeList2[i][0]]) for i in range(len(gpsTimeList2)): newgpsTimeList2.append( [gpsTimeList2[i][0] + tdcShift * 1000000000000]) else: for i in range(len(gpsTimeList2)): gpsTime = gpsTimeList2[i][0] + tdcShift * 1000000000000 if gpsTime > 0: newgpsTimeList2.append([gpsTime]) timeFactor1, offset1 = clockTimeCalibrate.clockTimeFactorFit(gpsTimeList1) timeFactor2, offset2 = clockTimeCalibrate.clockTimeFactorFit( newgpsTimeList2) gpsTimeList1 = clockTimeCalibrate.timeCalibrate(gpsTimeList1, timeFactor1, offset1) newgpsTimeList2 = clockTimeCalibrate.timeCalibrate(newgpsTimeList2, timeFactor2, offset2) for i in range(scanRange[0] / step[0]): for j in range(scanRange[1] / step[1]): for k in range(scanRange[2] / step[2]): move = [ i * step[0] - scanRange[0] / 2 + offset[0], j * step[1] - scanRange[1] / 2 + offset[1], k * step[2] - scanRange[2] / 2 + offset[2] ] info = [date, startSec, endSec, gpsShift, move] satelliteXYZListMove = sat_move(satelliteXYZList, move) std = satMoveSimulation(List1, List2, groundXYZList, satelliteXYZListMove, atmosphereList, gpsTimeList1, newgpsTimeList2, info) [x, y, z] = move print '%s\t%s\t%s\t%s' % (x, y, z, std)
def timeCoincidence(timeList1, timeList2, List2Delay, gpsTimeList1, gpsTimeList2, startSec, endSec, shift, coinfile): SYSD1_LJ = 171628 SYSD2_DLH = 99901 coincidenceList = [] detList = [] tolerate = 2000000 timeCount1 = 0 timeCount2 = 0 coinCount = 0 Num = 5 sec = 1000000000000.0 timeFactor1, offset1 = clockTimeCalibrate.clockTimeFactorFit(gpsTimeList1) timeFactor2, offset2 = clockTimeCalibrate.clockTimeFactorFit(gpsTimeList2) List1 = clockTimeCalibrate.timeCalibrate(timeList1, timeFactor1, offset1) List2 = clockTimeCalibrate.timeCalibrate(timeList2, timeFactor2, offset2) gpsTimeList1 = clockTimeCalibrate.timeCalibrate(gpsTimeList1, timeFactor1, offset1) gpsTimeList2 = clockTimeCalibrate.timeCalibrate(gpsTimeList2, timeFactor2, offset2) # List1=timeList1 # List2=timeList2 for i in range(startSec, endSec): inSec = True timeBase1 = gpsTimeList1[i - 1][0] # timeBase2 = gpsTimeList2[i][0] timeBase2 = gpsTimeList2[i - 1][0] while List2[timeCount2][0] - timeBase2 < 0: timeCount2 += 1 while List1[timeCount1][0] - timeBase1 < 0: timeCount1 += 1 startNo = i delayFun1 = gpsOrbit.gpsLagInterFun(List2Delay, startNo, Num, shift, 0) delayFun2 = gpsOrbit.gpsLagInterFun(List2Delay, startNo, Num, shift, 1) # atmDelayFun1= gpsOrbit.gpsLagInterFun( List2Delay, startNo, Num, shift, 2) # atmDelayFun2= gpsOrbit.gpsLagInterFun( List2Delay, startNo, Num, shift, 3) # print i,delayFun1(i),delayFun2(i) while inSec: delay1 = delayFun1(List1[timeCount1][0] / sec) delay2 = delayFun2(List2[timeCount2][0] / sec) # atmDelay1=atmDelayFun1(List1[timeCount1][0]/sec) # atmDelay2 = atmDelayFun2(List2[timeCount2][0] / sec) # print List1[timeCount1][0]/sec,delay1,List2[timeCount2][0]/sec,delay2 delay1 = delayFun1((List1[timeCount1][0] - delay1) / sec) delay2 = delayFun2((List2[timeCount2][0] - delay2) / sec) delay1 = delayFun1((List1[timeCount1][0] - delay1) / sec) delay2 = delayFun2((List2[timeCount2][0] - delay2) / sec) time1 = List1[timeCount1][0] - timeBase1 - delay1 - SYSD1_LJ time2 = List2[timeCount2][0] - timeBase2 - delay2 - SYSD2_DLH detTime = time1 - time2 det = (List1[timeCount1][0] - delay1 - SYSD1_LJ) - (List2[timeCount2][0] - delay2 - SYSD2_DLH) # print List1[timeCount1][0],delay1,List2[timeCount2][0],delay2,detTime,timeBase1,timeBase2 if abs(detTime) > tolerate: if detTime > 0: timeCount2 += 1 else: timeCount1 += 1 else: coinCount += 1 # coincidenceList.append( # [timeList1[timeCount1][0], timeList2[timeCount2][0], det, detTime, delay1, delay2]) # 正常符合 coincidenceList.append([ List1[timeCount1][0] - SYSD1_LJ, List2[timeCount2][0] - SYSD2_DLH, det, detTime, delay1, delay2 ]) #激光修正计算 # coincidenceList.append( # [List1[timeCount1][0]-SYSD1_LJ-delay1,List2[timeCount2][0]-SYSD2_DLH-delay2,List1[timeCount1][0]-SYSD1_LJ-atmDelay1- (List2[timeCount2][0]-SYSD2_DLH-atmDelay2), delay1, delay2]) detList.append(det) timeCount1 += 1 timeCount2 += 1 if List2[timeCount2][0] > gpsTimeList2[i][0]: inSec = False fileToList.listToFile(coincidenceList, coinfile) # print numpy.std(detList, ddof=1) std = numpy.std(detList, ddof=1) # print 'time coincidence finished ! there are ' + str(coinCount) + ' pairs.' return coincidenceList, std