/// <summary> /// 获取插值后的 AtomicClock。 /// </summary> /// <param name="PRN"></param> /// <param name="gpsTime"></param> /// <returns></returns> public AtomicClock GetAtomicClock(Time gpsTime) { String name = sortedRecords[0].Name; Data.Rinex.ClockType clkType = sortedRecords[0].ClockType; if (gpsTime < MinAvailableTime || gpsTime > MaxAvailableTime) { throw new ArgumentException("历元在给定的时间段外,不可进行插值。"); } double deltaX = (double)(gpsTime - minDataTime); if (clkType == Data.Rinex.ClockType.Satellite) { return(new AtomicClock() { Name = name, ClockType = clkType, ClockDrift = interpDrift.GetY(deltaX), ClockBias = interpError.GetY(deltaX), Time = gpsTime, Prn = sortedRecords[0].Prn }); } return(new AtomicClock() { Name = name, ClockType = clkType, ClockDrift = interpDrift.GetY(deltaX), ClockBias = interpError.GetY(deltaX), Time = gpsTime }); }
/// <summary> /// 获取插值后的 AtomicClock。 /// </summary> /// <param name="PRN"></param> /// <param name="gpsTime"></param> /// <returns></returns> public SimpleClockBias GetAtomicClock(Time gpsTime) { if (gpsTime < MinAvailableTime || gpsTime > MaxAvailableTime) { throw new ArgumentException("历元在给定的时间段外,不可进行插值。"); } double deltaX = (double)(gpsTime - minDataTime); return(new SimpleClockBias() { ClockBias = interpError.GetY(deltaX), Time = gpsTime }); }
/// <summary> /// 获取插值后的 EphemerisInfo。 /// 注意:不对钟差相对论误差进行改正,此处时间是卫星钟时间,没有相对信息。2014.09.08 /// 失败,如超过时间,则返回null /// 由于一般没有卫星速度的数据,必须通过插值坐标计算速度。2015.03. /// 如果有速度信息,以下的方法就不合适了。 /// </summary> /// <param name="gpsTime">时间</param> /// <returns></returns> public Ephemeris GetEphemerisInfo(Time gpsTime) { SatelliteNumber PRN = Ephemeris.Prn; Time min = Ephemeris.Time; //Time max = sortedRecords[sortedRecords.Count - 1].Time; //double span = (double)(max - min); double gpsSecond = (gpsTime - min); //减去序列中第一个数 ////老是在这里出问题,宽限一点呢??16分钟 //double expand = 60 * 16; //if (gpsSecond + expand < 0 || gpsSecond - expand > span) //{ // //return null; // throw new ArgumentException("历元在给定的时间段外,不可进行插值。"); //} //计算位置 double x = 0, y = 0, z = 0; double dtime = 0; double dx = 0, dy = 0, dz = 0; double ddtime = 0; int count = entities.Count; int order = 10; order = Math.Min(order, count); //czs // List<int> indexes = GetNearstIndexes(sortedRecords, gpsSecond, order); //cy //List<int> indexes = GetNearstIndexes(sortedRecords, gpsTime, order); double[] t = new double[order]; double[] tList = new double[order + 1]; double[] xList = new double[order + 1]; double[] yList = new double[order + 1]; double[] zList = new double[order + 1]; double[] clockList = new double[order + 1]; int i = 0; foreach (var item in this.entities) { Ephemeris record = item; t[i] = (record.Time - gpsTime); //秒。 #region 方案1:顾及地球自转效应 //correction for earth rotation double sinl = Math.Sin(SunMoonPosition.OMGE * t[i]); double cosl = Math.Cos(SunMoonPosition.OMGE * t[i]); xList[i] = cosl * record.XYZ.X - sinl * record.XYZ.Y; yList[i] = sinl * record.XYZ.X + cosl * record.XYZ.Y; zList[i] = record.XYZ.Z; #endregion #region 方案2:不顾及地球自转效应 //xList[time] = record.XYZ.X; //yList[time] = record.XYZ.Y; //zList[time] = record.XYZ.Z; #endregion //tList[i] = (record.Time - sortedRecords[0].Time); //秒。 // clockList[i] = record.ClockBias; i++; } //Lagrange(tList, xList, gpsSecond, ref x, ref dx); //Lagrange(tList, yList, gpsSecond, ref y, ref dy); //Lagrange(tList, zList, gpsSecond, ref z, ref dz); //Lagrange(tList, clockList, gpsSecond, ref dtime, ref ddtime); //int Nhalf = (int)(order / 2) - 1; //int Nmatch = indexes[Nhalf]; x = fitX.GetY(gpsSecond); y = fitY.GetY(gpsSecond); z = fitZ.GetY(gpsSecond); dtime = fitClock.GetY(gpsSecond); XYZ SatXyz = new XYZ(x, y, z); //精度赋值 //XYZ SatXyzSig = sortedRecords[Nmatch].XyzSdev; //double clockSig = sortedRecords[Nmatch].ClockSdev; //XYZ SatXyzDotSig = new Geo.Coordinates.XYZ(0); //计算速度 //double nextSecond = gpsSecond + 0.001; //XYZ xyzNext = new XYZ(fitX.GetY(nextSecond), fitY.GetY(nextSecond), fitZ.GetY(nextSecond)); //XYZ speed = (xyzNext-xyz) / 0.001; XYZ SatSpeed = new XYZ(dx, dy, dz); //Add relativity correction to dtime //This only for consistency with GPSEphemerisInter //dtr=-2*dot(R,V)/(C*C) //dtime +=EphemerisUtil.GetRelativeCorrection(SatXyz, SatSpeed); return(new Ephemeris() { Prn = PRN, XYZ = SatXyz, //XyzSdev=SatXyzSig, // Clock = fitClock.GetY(gpsSecond), ClockBias = dtime, //ClockSdev = clockSig, ClockDrift = ddtime, Time = gpsTime, XyzDot = SatSpeed, //XyzDotSdev=SatXyzDotSig }); }