def delayCalJ2000(groundXYZList, satelliteXYZList, detTime, Num): delayList = [] lenght = len(satelliteXYZList) for i in range(Num): distance1 = math.sqrt( (groundXYZList[i][1] - satelliteXYZList[i][1]) ** 2 + (groundXYZList[i][2] - satelliteXYZList[i][2]) ** 2 \ + (groundXYZList[i][3] - satelliteXYZList[i][3]) ** 2) distance2 = math.sqrt( (groundXYZList[i][4] - satelliteXYZList[i][1]) ** 2 + (groundXYZList[i][5] - satelliteXYZList[i][2]) ** 2 \ + (groundXYZList[i][6] - satelliteXYZList[i][3]) ** 2) delay1 = 1000000000000.0 * distance1 / 299792458 delay2 = 1000000000000.0 * distance2 / 299792458 delayList.append([delay1, delay2, delay1 - delay2]) # print distance1,distance2 for i in range(Num, lenght - Num): sec = [float(i + j - Num) for j in range(2 * Num + 1)] satelliteFx = [ satelliteXYZList[i + j - Num][1] for j in range(2 * Num + 1) ] satelliteFy = [ satelliteXYZList[i + j - Num][2] for j in range(2 * Num + 1) ] satelliteFz = [ satelliteXYZList[i + j - Num][3] for j in range(2 * Num + 1) ] satelliteFuncX = lagInterpolation.get_Lxfunc(sec, satelliteFx) satelliteFuncY = lagInterpolation.get_Lxfunc(sec, satelliteFy) satelliteFuncZ = lagInterpolation.get_Lxfunc(sec, satelliteFz) delay1 = 0.0 delay2 = 0.0 for ii in range(3): satelliteX1 = satelliteFuncX(i + detTime - delay1) satelliteY1 = satelliteFuncY(i + detTime - delay1) satelliteZ1 = satelliteFuncZ(i + detTime - delay1) satelliteX2 = satelliteFuncX(i + detTime - delay2) satelliteY2 = satelliteFuncY(i + detTime - delay2) satelliteZ2 = satelliteFuncZ(i + detTime - delay2) distance1 = math.sqrt( (groundXYZList[i][1] - satelliteX1) ** 2 + (groundXYZList[i][2] - satelliteY1) ** 2 \ + (groundXYZList[i][3] - satelliteZ1) ** 2) distance2 = math.sqrt( (groundXYZList[i][4] - satelliteX2) ** 2 + (groundXYZList[i][5] - satelliteY2) ** 2 \ + (groundXYZList[i][6] - satelliteZ2) ** 2) delay1 = distance1 / 299792458 delay2 = distance2 / 299792458 # print ii,delay1,delay2,distance1,distance2 delayList.append([ 1000000000000.0 * delay1, 1000000000000.0 * delay2, 1000000000000.0 * (delay1 - delay2) ]) # print distance1,distance2 return delayList
def groundStationSec(groundList, startTime, passSec, interNum): year, month, day, hour, minute, sec = startTime jd = jdutil.date_to_jd(year, month, day) mjd = jdutil.jd_to_mjd(jd) print jd, mjd J = len(groundList[0]) silde = [] groundSecList = [] groundfun = range(J) index = 0 found = False while not found: if int(groundList[index][0]) == int(mjd): found = True else: index += 1 for j in range(1, J): x = [ float(groundList[index + i - interNum][0]) for i in range(2 * interNum + 1) ] fx = [ groundList[index + ii - interNum][j] for ii in range(2 * interNum + 1) ] groundfun[j] = lagInterpolation.get_Lxfunc(x, fx) for i in range(passSec): time = mjd + hour / 24. + minute / (24 * 60.) + (sec + i) / (24 * 60 * 60.) silde.append(i) for j in range(1, J): silde.append(groundfun[j](time)) groundSecList.append(silde[i * J:]) print 'ground station position interpolation calculated by second !' return groundSecList
def gpsLagInter(gpsTimeList1, gpsTimeList2, gpsDelList, interNum): N = len(gpsDelList) interGpsDel = [] for i in range(N - 2): x = [i, i + 1, i + 2] fx = [gpsDelList[i][2], gpsDelList[i + 1][2], gpsDelList[i + 2][2]] gpsfun = lagInterpolation.get_Lxfunc(x, fx) for j in range(interNum): t1 = gpsTimeList1[i][0] + 1000000000000.0 * j / interNum t2 = gpsTimeList2[i][0] + 1000000000000.0 * j / interNum delay = gpsfun(i + float(j) / interNum) interGpsDel.append([t1, t2, delay]) print 'gps delay have interpolation %s times' % interNum return interGpsDel
def gpsLagInterFun(disDelayList, startNo, Num, shift, channel): if startNo < Num: print 'startNo should bigger than Num' # x1 = [float(gpsTimeList1[i + startNo - Num][0] / sec) for i in range(2 * Num + 1)] x1 = [float(i + startNo - Num) for i in range(2 * Num + 1)] fx1 = [ float(disDelayList[i + startNo - Num + shift][channel]) for i in range(2 * Num + 1) ] # x2 = [float(gpsTimeList2[i + startNo - Num][0] / sec) for i in range(2 * Num + 1)] # x2 = [float(i + startNo - Num) for i in range(2 * Num + 1)] # fx2 = [float(disDelayList[i + startNo - Num+shift][1]) for i in range(2 * Num + 1)] # print x1,fx1 # delayX = [float(i + 1) for i in range(startNo - Num, startNo + Num + 1)] # delayY = [float(disDelayList[i + startNo - Num + shift][2]) for i in range(2 * Num + 1)] # delayfunc = lagInterpolation.get_Lxfunc(delayX, delayY) gpsfunc1 = lagInterpolation.get_Lxfunc(x1, fx1) # gpsfunc2 = lagInterpolation.get_Lxfunc(x2, fx2) # print gpsfunc1(gpsTimeList1[startNo][0]/sec) # return gpsfunc1,gpsfunc2,delayfunc return gpsfunc1
def delayCalWGS84(groundXYZList, ground1, ground2, satelliteXYZList, detTime, Num, atmosphereList): delayList = [] lenght = len(satelliteXYZList) # print lenght for i in range(Num): distance1 = math.sqrt((groundXYZList[ground1][1] - satelliteXYZList[i][1]) ** 2 + ( groundXYZList[ground1][2] - satelliteXYZList[i][2]) ** 2 \ + (groundXYZList[ground1][3] - satelliteXYZList[i][3]) ** 2) distance2 = math.sqrt((groundXYZList[ground2][1] - satelliteXYZList[i][1]) ** 2 + ( groundXYZList[ground2][2] - satelliteXYZList[i][2]) ** 2 \ + (groundXYZList[ground2][3] - satelliteXYZList[i][3]) ** 2) delay1 = 1000000000000.0 * distance1 / 299792458 delay2 = 1000000000000.0 * distance2 / 299792458 delayList.append([delay1, delay2, 0.0, 0.0, delay1 - delay2]) # print distance1,distance2 for i in range(Num, lenght - Num): sec = [float(i + j - Num) for j in range(2 * Num + 1)] satelliteFx = [ satelliteXYZList[i + j - Num][1] for j in range(2 * Num + 1) ] satelliteFy = [ satelliteXYZList[i + j - Num][2] for j in range(2 * Num + 1) ] satelliteFz = [ satelliteXYZList[i + j - Num][3] for j in range(2 * Num + 1) ] satelliteFuncX = lagInterpolation.get_Lxfunc(sec, satelliteFx) satelliteFuncY = lagInterpolation.get_Lxfunc(sec, satelliteFy) satelliteFuncZ = lagInterpolation.get_Lxfunc(sec, satelliteFz) delay1 = 0.0 delay2 = 0.0 for ii in range(3): satelliteX1 = satelliteFuncX(i + detTime - delay1) satelliteY1 = satelliteFuncY(i + detTime - delay1) satelliteZ1 = satelliteFuncZ(i + detTime - delay1) satelliteX2 = satelliteFuncX(i + detTime - delay2) satelliteY2 = satelliteFuncY(i + detTime - delay2) satelliteZ2 = satelliteFuncZ(i + detTime - delay2) distance1 = math.sqrt( (groundXYZList[ground1][1] - satelliteX1) ** 2 + (groundXYZList[ground1][2] - satelliteY1) ** 2 \ + (groundXYZList[ground1][3] - satelliteZ1) ** 2) distance2 = math.sqrt( (groundXYZList[ground2][1] - satelliteX2) ** 2 + (groundXYZList[ground2][2] - satelliteY2) ** 2 \ + (groundXYZList[ground2][3] - satelliteZ2) ** 2) delay1 = distance1 / 299792458 delay2 = distance2 / 299792458 # print ii,delay1, delay2,delay1-delay2 tmpX1 = ( satelliteX1 + groundXYZList[ground1][2] * satelliteY1 / groundXYZList[ground1][1] + groundXYZList[ground1][3] * satelliteZ1 / groundXYZList[ground1][1] ) / (1.0 + (groundXYZList[ground1][2] / groundXYZList[ground1][1])**2 + (groundXYZList[ground1][3] / groundXYZList[ground1][1])**2) tmpY1 = (groundXYZList[ground1][2] / groundXYZList[ground1][1]) * tmpX1 tmpZ1 = (groundXYZList[ground1][3] / groundXYZList[ground1][1]) * tmpX1 tmpDis1 = math.sqrt((tmpX1 - satelliteX1)**2 + (tmpY1 - satelliteY1)**2 + (tmpZ1 - satelliteZ1)**2) theta1 = math.asin(tmpDis1 / distance1) elevationAngle1 = (math.pi / 2 - theta1) * 180 / math.pi atmDelay1 = atmosphericDelayCorrect.MPAtmDelayModelCal( atmosphereList[ground1][1], atmosphereList[ground1][2], atmosphereList[ground1][3], atmosphereList[ground1][4], atmosphereList[ground1][5], atmosphereList[ground1][6], elevationAngle1) tmpX2 = ( satelliteX2 + groundXYZList[ground2][2] * satelliteY2 / groundXYZList[ground2][1] + groundXYZList[ground2][3] * satelliteZ2 / groundXYZList[ground2][1] ) / (1.0 + (groundXYZList[ground2][2] / groundXYZList[ground2][1])**2 + (groundXYZList[ground2][3] / groundXYZList[ground2][1])**2) tmpY2 = (groundXYZList[ground2][2] / groundXYZList[ground2][1]) * tmpX2 tmpZ2 = (groundXYZList[ground2][3] / groundXYZList[ground2][1]) * tmpX2 tmpDis2 = math.sqrt((tmpX2 - satelliteX2)**2 + (tmpY2 - satelliteY2)**2 + (tmpZ2 - satelliteZ2)**2) theta2 = math.asin(tmpDis2 / distance2) elevationAngle2 = (math.pi / 2 - theta2) * 180 / math.pi atmDelay2 = atmosphericDelayCorrect.MPAtmDelayModelCal( atmosphereList[ground2][1], atmosphereList[ground2][2], atmosphereList[ground2][3], atmosphereList[ground2][4], atmosphereList[ground2][5], atmosphereList[ground2][6], elevationAngle2) atmDelay1 = 1000000000000.0 * atmDelay1 / 299792458 atmDelay2 = 1000000000000.0 * atmDelay2 / 299792458 disDelay1 = 1000000000000.0 * delay1 disDelay2 = 1000000000000.0 * delay2 totDelay = disDelay1 + atmDelay1 - disDelay2 - atmDelay2 delayList.append([ disDelay1 + atmDelay1, disDelay2 + atmDelay2, atmDelay1, atmDelay2, totDelay ]) # print i, disDelay1, disDelay2,atmDelay1,atmDelay2,totDelay return delayList
def satLagInterFun(satList, Num, j, shift): # x = [float(satList[i - Num + shift][0]/1000000.0+satList[i - Num + shift][1]) for i in range(2 * Num + 1)] x = [float(satList[i - Num + shift][0]) for i in range(2 * Num + 1)] fx = [satList[i - Num + shift][j] for i in range(2 * Num + 1)] satfun = lagInterpolation.get_Lxfunc(x, fx) return satfun
def groPulseCoincidence(groPulseList, satPulseList, groGPSList, satGPSList, gpsDisList, groSatShift, startSec, endSec): indexGro = 0 indexSat = 0 Num = 4 coinCount = 0 coinList = [] tolerate = 20000000 windows = 250000 offset = 0 #satShiftTime=groSatShift*1000000000000.0 #时间修正方法1 groGPSFactorList, satGPSFactorList = timeGPSFactor(groGPSList, satGPSList, 5, 50000) #时间修正方法2 # NG = len(groGPSList) # secG = [float(i + 1) for i in range(NG)] # timeG = [groGPSList[i][0] for i in range(NG)] # matG = numpy.polyfit(secG, timeG, 2) # FG = numpy.poly1d(matG) # NS = len(satGPSList) # secS = [float(i + 1) for i in range(NS)] # timeS = [satGPSList[i][0] for i in range(NS)] # matS = numpy.polyfit(secS, timeS, 2) # FS = numpy.poly1d(matS) if startSec - groSatShift - 1 < 0: print 'start sec should be later than ', groSatShift + 1 timeBaseG = groGPSList[startSec - 1][0] timeBaseS = satGPSList[startSec - 1 - groSatShift][0] while groPulseList[indexGro][0] - timeBaseG < 0: indexGro += 1 while satPulseList[indexSat][0] - timeBaseS < 0: indexSat += 1 for i in range(startSec, endSec - 1): inSec = True x = [float(j * 1000000000000.0) for j in range(i - Num, i + Num + 1)] y = [gpsDisList[j][0] for j in range(i - Num, i + Num + 1)] distanceFun = lagInterpolation.get_Lxfunc(x, y) while inSec: #时间修正方法1 groPulseTime = i * 1000000000000.0 + ( groPulseList[indexGro][0] - timeBaseG) / (groGPSFactorList[i - 1] / 1000000000000.0) satPulseTime = i * 1000000000000.0 + ( satPulseList[indexSat][0] - timeBaseS) / ( satGPSFactorList[i - 1 - groSatShift] / 1000000000000.0) #时间修正方法2 # groPulseTime =FG(groPulseList[indexGro][0]/1000000000000.0) # satPulseTime=FS(satPulseList[indexSat][0]/1000000000000.0) delay = distanceFun( groPulseTime) * 1000 * 1000000000000.0 / 299792458 delay = distanceFun(groPulseTime + delay) * 1000 * 1000000000000.0 / 299792458 # detTime=groPulseTime+delay-satPulseTime-(timeBaseG-timeBaseS) detTime = groPulseTime + delay - satPulseTime # print detTime,delay,groPulseTime,groPulseList[indexGro][0],satPulseTime,satPulseList[indexSat][0] if abs(detTime - offset) > tolerate: if detTime > 0: indexSat += 1 else: indexGro += 1 else: # print detTime, offset, detTime - offset coinCount += 1 coinList.append([ groPulseList[indexGro][0], satPulseList[indexSat][0], groPulseTime, satPulseTime, detTime ]) tolerate = abs(detTime - offset) + windows offset = detTime indexGro += 1 indexSat += 1 if satPulseList[indexSat][0] > satGPSList[i - groSatShift][ 0] and groPulseList[indexGro][0] > groGPSList[i][0]: timeBaseS = satGPSList[i - groSatShift][0] timeBaseG = groGPSList[i][0] inSec = False print 'time coincidence finished ! there are ' + str(coinCount) + ' pairs.' return coinList
def satPulseCoincidence(groPulseList, satPulseList, groGPSList, satGPSList, gpsDisList, groSatShift, startSec, endSec): indexGro = 0 indexSat = 0 Num = 4 coinCount = 0 coinList = [] tolerate = 20000000 windows = 250000 offset = 0 groGPSFactorList, satGPSFactorList = timeGPSFactor(groGPSList, satGPSList, 5, 50000) if startSec - groSatShift - 1 < 0: print 'start sec should be later than ', groSatShift + 1 timeBaseG = groGPSList[startSec - 1][0] timeBaseS = satGPSList[startSec - 1 - groSatShift][0] while groPulseList[indexGro][0] - timeBaseG < 0: indexGro += 1 while satPulseList[indexSat][0] - timeBaseS < 0: indexSat += 1 for i in range(startSec, endSec - 1): inSec = True x = [float(j) for j in range(i - Num, i + Num + 1)] y = [gpsDisList[j][0] for j in range(i - Num, i + Num + 1)] distanceFun = lagInterpolation.get_Lxfunc(x, y) while inSec: groPulseTime = i * 1000000000000.0 + ( groPulseList[indexGro][0] - timeBaseG) / (groGPSFactorList[i - 1] / 1000000000000.0) satPulseTime = i * 1000000000000.0 + ( satPulseList[indexSat][0] - timeBaseS) / ( satGPSFactorList[i - 1 - groSatShift] / 1000000000000.0) delay = distanceFun( satPulseTime / 1000000000000.0) * 1000 * 1000000000000.0 / 299792458 delay = distanceFun( (satPulseTime + delay) / 1000000000000.0) * 1000 * 1000000000000.0 / 299792458 detTime = satPulseTime + delay - groPulseTime # print detTime,delay,groPulseTime,satPulseTime if abs(detTime - offset) > tolerate: if detTime > 0: indexGro += 1 else: indexSat += 1 else: coinCount += 1 coinList.append([ satPulseList[indexSat][0], groPulseList[indexGro][0], satPulseTime, groPulseTime, detTime ]) tolerate = abs(detTime - offset) + windows offset = detTime indexGro += 1 indexSat += 1 #print coinList[-1],detTime if satPulseList[indexSat][0] > satGPSList[i - groSatShift][ 0] and groPulseList[indexGro][0] > groGPSList[i][0]: timeBaseS = satGPSList[i - groSatShift][0] timeBaseG = groGPSList[i][0] inSec = False print 'time coincidence finished ! there are ' + str(coinCount) + ' pairs.' return coinList