Esempio n. 1
0
        /// <summary>
        /// 单站单天解
        /// </summary>
        public void ResolveSingleStationSingleDay()
        {
            if (string.IsNullOrWhiteSpace(obsFolder))
            {
                FrmIono.MessHelper.Print("\r\n文件夹不存在:" + obsFolder);
                return;
            }

            DirectoryInfo dir   = new DirectoryInfo(obsFolder);
            var           files = dir.GetFiles("*.??o");

            for (int i = 0; i < files.Length; i++)
            {
                FrmIono.MessHelper.Print(string.Format("\r\n{0}:{1}", DateTime.Now, "开始读取文件:" + files[i].Name));
                try
                {
                    OFile of = new OFile(files[i].FullName);
                    if (of.TryRead())
                    {
                        int    year, doy;
                        string stationName;
                        FileName.ParseRinex2(files[i].Name, out stationName, out doy, out year);

                        // 下载星历
                        Dictionary <string, List <DOY> > doys = new Dictionary <string, List <DOY> >();
                        doys.Add(stationName, new List <DOY> {
                            new DOY(year, doy)
                        });
                        if (!Download(doys))
                        {
                            PrintWithTime("下载星历失败!");
                            return;
                        }

                        DOY fileDOY = new DOY(year, doy);
                        DOY start   = fileDOY.AddDays(-1);
                        DOY end     = fileDOY.AddDays(1);

                        // 读取星历
                        PrintWithTime("正在读取星历...");
                        Orbit orb = new Orbit(orbFolder);
                        orb.GetAllSp3Files(orbFolder, start, end);
                        orb.Read(orbFolder);

                        // 计算轨道
                        PrintWithTime("正在计算轨道...");
                        for (int j = 0; j < of.Epoches.Count; j++)
                        {
                            var epo = of.Epoches[j];
                            orb.GetSatPos(ref epo);
                        }

                        //探测粗差
                        PrintWithTime("正在探测粗差...");
                        of.DetectOutlier();

                        // 探测弧段
                        of.DetectAllArcs();

                        // 探测周跳
                        PrintWithTime("正在探测周跳...");
                        of.DetectCycleSlip();

                        // 计算穿刺点
                        of.CalIPP();

                        // 相位平滑伪距
                        PrintWithTime("正在计算VTEC...");
                        of.CalSP4();

                        // 计算VTEC
                        of.CalVTEC();

                        // 多项式拟合
                        Print("正在拟合多项式...");
                        if (FitType == enumFitType.Polynomial)
                        {
                            of.Fit();
                        }
                        else if (FitType == enumFitType.DoubleDifference)
                        {
                            of.DoubleDifference();
                        }
                        else if (FitType == enumFitType.Smooth)
                        {
                            of.Smooth();
                        }

                        // 输出结果
                        PrintWithTime("正在写入文件...");
                        of.WriteTEC(resFolder);
                    }
                    else
                    {
                        FrmIono.MessHelper.Print(string.Format("\r\n{0}:{1}", DateTime.Now, "读取文件失败!"));
                    }
                }
                catch (Exception e)
                {
                    FrmIono.MessHelper.Print(string.Format("\r\n{0}:{1}:{2}", DateTime.Now, "解算失败,原因是", e.ToString()));
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 逐个测站解算,耗内存小
        /// </summary>
        public void ResolveSingleStationMultiDay()
        {
            var staNames = GetStationNames(obsFolder);

            if (staNames.Count <= 0)
            {
                return;
            }
            if (SetProgressMax != null)
            {
                SetProgressMax(staNames.Count);
            }


            for (int i = 0; i < staNames.Count; i++)
            {
                try
                {
                    if (SetProgressValue != null)
                    {
                        SetProgressValue(i + 1);
                    }

                    var staName = staNames[i];
                    Print(string.Format("\r\n\r\n开始解算第{0}个测站,共{1}个:{2}", i + 1, staNames.Count, staName));
                    PrintWithTime("正在搜索观测文件...");

                    OStation sta = new OStation(staName);
                    sta.SearchAllOFiles(obsFolder);
                    PrintWithTime(string.Format("共找到{0}个文件:", sta.FileNum));
                    for (int j = 0; j < sta.OFiles.Count; j++)
                    {
                        Print(string.Format("\r\n    {0} {1}", j + 1, sta.OFiles[j].Path));
                    }
                    if (sta.FileNum <= 0)
                    {
                        return;
                    }

                    if (!sta.CheckDataConsist())
                    {
                        PrintWithTime("错误!本站数据不连续");
                        continue;
                    }

                    PrintWithTime("正在下载辅助文件...");
                    if (!Download(sta.DOYs))
                    {
                        PrintWithTime("错误!下载辅助文件失败");
                    }

                    PrintWithTime("读取星历文件...");
                    Orb = new Orbit(orbFolder);
                    Orb.GetAllSp3Files(orbFolder, sta.StartDOY, sta.EndDOY);
                    Orb.Read(orbFolder);

                    PrintWithTime("读取观测文件...");
                    sta.ReadAllObs();
                    sta.SortObs();

                    PrintWithTime(string.Format("共读取到{0}个历元", sta.EpochNum));
                    if (sta.EpochNum > 0)
                    {
                        sta.StartTime = sta.Epoches[0].Epoch;
                    }
                    else
                    {
                        return;
                    }

                    PrintWithTime("计算卫星轨道...");
                    for (int j = 0; j < sta.EpochNum; j++)
                    {
                        OEpoch oepo = sta.Epoches[j];
                        Orb.GetSatPos(ref oepo);
                    }
                    PrintWithTime("\r\n穿刺点计算...");
                    sta.CalAzElIPP();

                    PrintWithTime("粗差探测...");
                    sta.DetectOutlier();
                    PrintWithTime("弧段探测...");
                    sta.DetectArcs();
                    PrintWithTime("周跳探测...");
                    sta.DetectCycleSlip();
                    PrintWithTime("相位平滑伪距计算...");
                    sta.SmoothP4();
                    if (FitType == enumFitType.None)
                    {
                        sta.CalVTEC();
                        PrintWithTime(string.Format("{0}观测值写入文件", "sp4"));
                        sta.WriteMeas(resFolder, "SP4");
                    }
                    else if (FitType == enumFitType.Polynomial)
                    {
                        PrintWithTime("VTEC计算...");
                        sta.CalVTEC();
                        PrintWithTime("多项式拟合计算...");
                        sta.Fit();
                        PrintWithTime(string.Format("{0}观测值写入文件", "vtec"));
                        sta.WriteMeas(resFolder, "vtec");
                        PrintWithTime(string.Format("{0}观测值写入文件", "dtec"));
                        sta.WriteMeas(resFolder, "dtec");
                    }
                    else if (FitType == enumFitType.Smooth)
                    {
                        PrintWithTime("VTEC计算...");
                        sta.CalVTEC();
                        PrintWithTime("滑动平均计算...");
                        sta.Smooth();
                        PrintWithTime(string.Format("{0}观测值写入文件", "vtec"));
                        sta.WriteMeas(resFolder, "vtec");
                        PrintWithTime(string.Format("{0}观测值写入文件", "dtec"));
                        sta.WriteMeas(resFolder, "dtec");
                    }
                    else if (FitType == enumFitType.DoubleDifference)
                    {
                        PrintWithTime("二阶差分计算...");
                        sta.DoubleDiff();
                        PrintWithTime(string.Format("{0}观测值写入文件", "l6"));
                        sta.WriteMeas1(resFolder, "L6");
                    }
                    else if (FitType == enumFitType.ROTI)
                    {
                        PrintWithTime("计算ROTI...");
                        sta.ROTI();
                        PrintWithTime(string.Format("{0}观测值写入文件", "l6"));
                        sta.WriteMeas(resFolder, "roti");
                    }
                }
                catch (Exception e)
                {
                    PrintWithTime("未知异常(" + e.ToString() + ")");
                    continue;
                }
            }
        }