Ejemplo n.º 1
0
        public static void tidedisp(time tutc, rtktime utc, double[] rr, erp_t erp, double[] disp)
        {
            time    tut = new time();
            rtktime ut  = new rtktime();

            double[] pos  = new double[2], E = new double[9], erpv = new double[5], rs = new double[3], rm = new double[3];
            double[] gmst = new double[1], drt = new double[3];
            double   r;

            if (erp != null)
            {
                pppcmn.geterp(tutc, utc, erp, erpv);
            }
            tut.ut1 = tutc.utc + erpv[2];
            ut      = rtklibcmn.timeadd(utc, erpv[2]);
            r       = Math.Sqrt(rr[0] * rr[0] + rr[1] * rr[1] + rr[2] * rr[2]);
            if (r <= 0)
            {
                return;
            }
            pos[0] = Math.Asin(rr[2] / r);
            pos[1] = Math.Atan2(rr[1], rr[0]);
            transcoor.mat_xyz2enu(matrix.Array2matrix(pos), E);

            pppcmn.sunmoonpos(tutc, utc, erpv, rs, rm, gmst);
            pppcmn.tide_solid(rs, rm, pos, E, gmst[0], drt);

            for (int i = 0; i < 3; i++)
            {
                disp[i] += drt[i];
            }
        }
Ejemplo n.º 2
0
        public static double utc2gmst(time t, double ut1_utc)
        {
            double[] ep2000 = new double[6] {
                2000, 1, 1, 12, 0, 0
            }, ep = new double[6];
            double[] tut0 = new double[6];
            double   tut;
            double   ut, t1, t2, t3, gmst0, gmst;


            tut = t.utc + ut1_utc;
            //time.time2calend(t, ep);
            time2calend(tut, ep);
            //ut = t.calend[3] * 3600.0 + t.calend[4] * 60.0 + t.calend[5] + t.utc - t.gpsec;//ut表示秒
            ut      = ep[3] * 3600.0 + ep[4] * 60.0 + ep[5];
            tut0[0] = ep[0]; tut0[1] = ep[1]; tut0[2] = ep[2];
            time tut0_ = new time(tut0);//tu0_将t的 年 月 日化成秒,以GPS时为时间基准
            time tep   = new time(ep2000);

            t1 = (tut0_.gpsec - tep.gpsec) / 86400.0 / 36525.0;

            t2    = t1 * t1; t3 = t2 * t1;
            gmst0 = 24110.54841 + 8640184.812866 * t1 + 0.093104 * t2 - 6.2E-6 * t3;
            gmst  = gmst0 + 1.002737909350795 * ut;

            return((gmst % 86400.0) * Math.PI / 43200.0); /* 0 <= gmst <= 2*PI */
        }
Ejemplo n.º 3
0
        public static int inputobs(obs_t obs, obs_t obss)
        {
            int          n = 0, sat;
            time         t    = new time();
            List <obs_s> obs_ = new List <obs_s>();

            for (int i = 0; i < 32; i++)
            {
                obs_.Add(null);
            }
            obs.obs_b = new List <obs_s>();
            if (0 <= iobss && iobss < obss.n)
            {
                t = obss.obs_b[iobss].t;
            }
            for (int i = 0; i < obss.obs_b.Count; i++)
            {
                if ((iobss + i) >= obss.obs_b.Count)
                {
                    n = i; break;
                }
                if ((obss.obs_b[iobss + i].t.gpsec - t.gpsec) > DT)
                {
                    n = i; break;
                }
            }
            for (int i = 0; i < n; i++)
            {
                sat           = int.Parse(obss.obs_b[iobss + i].sprn.Substring(1, 2));
                obs_[sat - 1] = obss.obs_b[iobss + i];
            }
            foreach (var v in obs_)
            {
                if (v != null)
                {
                    obs.obs_b.Add(v);
                }
            }
            iobss += n;
            return(n);//n为当前历元观测的卫星数
        }
Ejemplo n.º 4
0
        public static double sbstrop(time t, double[] pos, double[] azel, double[] var)
        {
            double k1 = 77.604, k2 = 382000.0, rd = 287.054, gm = 9.784, g = 9.80665;

            double[] pos_ = new double[3], met = new double[10], ep = new double[6];
            double   zh = 0.0, zw = 0.0, c, sinel = Math.Sin(azel[1]), h = pos[2], m, doy = 0.0;
            time     tep;
            int      i;

            ep[0] = t.calend[0];
            ep[1] = ep[2] = 1.0; ep[3] = ep[4] = ep[5] = 0.0;
            tep   = new time(ep);

            doy = (t.gpsec - tep.gpsec) / 86400.0 + 1;
            if (pos[2] < -100.0 || 10000.0 < pos[2] || azel[1] <= 0)
            {
                var[0] = 0.0;
                return(0.0);
            }
            if (zh == 0.0 || Math.Abs(pos[0] - pos_[0]) > 1E-7 || Math.Abs(pos[1] - pos_[1]) > 1E-7 ||
                Math.Abs(pos[2] - pos_[2]) > 1.0)
            {
                getmet(pos[0] * R2D, met);
                c = Math.Cos(2.0 * Math.PI * (doy - (pos[0] >= 0.0 ? 28.0 : 211.0)) / 365.25);
                for (i = 0; i < 5; i++)
                {
                    met[i] -= met[i + 5] * c;
                }
                zh  = 1E-6 * k1 * rd * met[0] / gm;
                zw  = 1E-6 * k2 * rd / (gm * (met[4] + 1.0) - met[3] * rd) * met[2] / met[1];
                zh *= Math.Pow(1.0 - met[3] * h / met[1], g / (rd * met[3]));
                zw *= Math.Pow(1.0 - met[3] * h / met[1], (met[4] + 1.0) * g / (rd * met[3]) - 1.0);
                for (i = 0; i < 3; i++)
                {
                    pos_[i] = pos[i];
                }
            }
            m      = 1.001 / Math.Sqrt(0.002001 + sinel * sinel);
            var[0] = 0.12 * 0.12 * m * m;
            return((zh + zw) * m);
        }
Ejemplo n.º 5
0
        public static double gpst2utc(double t)
        {
            int    i;
            double tu = 0;

            for (i = 0; leaps[i][0] > 0; i++)
            {
                double[] ep = new double[6];
                time     t1 = new time();
                for (int j = 0; j < 6; j++)
                {
                    ep[j] = leaps[i][j];
                }
                t1 = new time(ep);
                tu = t + leaps[i][6];
                if ((tu - t1.gpsec) > 0)
                {
                    break;
                }
            }
            return(tu);
        }
Ejemplo n.º 6
0
        public void gpst2utc()
        {
            int    i;
            double tu = 0;

            for (i = 0; leaps[i][0] > 0; i++)
            {
                double[] ep = new double[6];
                time     t1 = new time();
                for (int j = 0; j < 6; j++)
                {
                    ep[j] = leaps[i][j];
                }
                t1 = new time(ep);
                tu = gpsec + leaps[i][6];
                if ((tu - t1.gpsec) > 0)
                {
                    break;
                }
            }
            utc = tu;
        }
Ejemplo n.º 7
0
        const double CLIGHT = 299792458.0;   /* speed of light (m/s) */

        /*读取观测值文件 支持ver 2.11*/
        public static int readobs(string path, obs_t obs, station sta)
        {
            using (StreamReader sr = new StreamReader(path))
            {
                if (readobsh(sr, obs, sta) == 1 && (sta.ver < 3 && sta.ver > 0))
                {
                    string line = "";
                    while (!sr.EndOfStream)
                    {
                        time    tcurrent = new time(); string[] sprn = new string[64];
                        rtktime rtktcur = new rtktime();
                        int     ns      = 0;                                 //每个历元观测到的卫星数
                        line = sr.ReadLine();
                        if (line != null)                                    //读取含历元时间信息和卫星数的一行
                        {
                            tcurrent = new time(line.Substring(0, 26), "o"); //读取时间信息
                            rtklibcmn.str2time(line.Substring(0, 26), rtktcur);
                            ns   = int.Parse(line.Substring(29, 3));         //读取当前历元观测到的卫星数
                            sprn = new string[ns];                           //卫星prn
                            for (int i = 0, j = 32; i < ns; i++, j += 3)
                            {
                                if (j >= 68)
                                {
                                    line = sr.ReadLine();
                                    j    = 32;
                                }
                                sprn[i] = line.Substring(j, 3);
                            }
                        }

                        for (int i = 0; i < ns; i++)//读取每个卫星相应的观测值
                        {
                            obs_s sat = new obs_s();
                            sat.t    = tcurrent;
                            sat.rtkt = rtktcur;
                            sat.sprn = sprn[i];
                            line     = sr.ReadLine();
                            for (int k = 0, j = 0; k < obs.ntype; k++, j += 16)//读取一颗卫星的所有观测值信息
                            {
                                obssat obsat = new obssat();
                                if (j >= 80)
                                {
                                    line = sr.ReadLine();
                                    j    = 0;
                                }
                                obsat.type = obs.obstype[k];
                                if (j >= line.Length)
                                {
                                    obsat.value = 0;
                                }
                                else
                                {
                                    if (line.Substring(j, 14).Trim() == "")
                                    {
                                        obsat.value = 0;
                                    }
                                    else
                                    {
                                        obsat.value = double.Parse(line.Substring(j, 14));
                                    }
                                }
                                sat.type_value.Add(obsat);
                            }
                            obs.obs_b.Add(sat);
                        }
                        obs.n += ns;
                    }
                    return(1);
                }
                else
                {
                    return(0);
                }
            }
        }
Ejemplo n.º 8
0
 /*读取IGS精密星历*/
 public static int readsp3(string path, sp3_t sp3)
 {
     using (StreamReader sr = new StreamReader(path))
     {
         double   value = 0.0, std = 0.0, ba;
         double[] bfact = new double[2];
         int      flag  = 0;
         string   line  = "";
         for (int i = 0; i < 22; i++)//IGS
         {
             line = sr.ReadLine();
             if (i == 2)
             {
                 sp3.ns = int.Parse(line.Substring(4, 2));
             }
             if (i == 14)
             {
                 bfact[0] = str2num(line, 3, 10);
                 bfact[1] = str2num(line, 14, 12);
             }
         }
         if (sp3.ns == 0)
         {
             return(0);
         }
         while (!sr.EndOfStream)
         {
             time    t1    = new time();
             rtktime rtkt1 = new rtktime();
             line = sr.ReadLine();
             if (line.Contains("EOF"))
             {
                 break;
             }
             if (line.Contains("*"))
             {
                 t1 = new time(line, "sp3");
                 rtklibcmn.str2time(line.Substring(1), rtkt1);
             }
             for (int i = 0; i < sp3.ns; i++)
             {
                 sp3b sb = new sp3b();
                 sb.t    = t1;
                 sb.rtkt = rtkt1;
                 line    = sr.ReadLine();
                 if (line.Substring(1, 1) == "G" && line.Substring(0, 1) == "P")//只读取GPS卫星
                 {
                     sb.prn = line.Substring(1, 3);
                     for (int j = 0; j < 4; j++)
                     {
                         value = str2num(line, 4 + j * 14, 14);
                         std   = str2num(line, 61 + j * 3, j < 3 ? 2 : 3);
                         if (value != 0 && Math.Abs(value - 999999.999999) >= 1E-6)//读取卫星XYZ坐标,单位为米
                         {
                             sb.xyzt[j] = value * (j < 3 ? 1000.0 : 1E-6);
                         }
                         if ((ba = bfact[j < 3 ? 0 : 1]) > 0.0 && std > 0.0)
                         {
                             sb.std[j] = Math.Pow(ba, std) * (j < 3 ? 1E-3 : 1E-12);
                         }
                     }
                 }
                 sp3.sp3_b.Add(sb);
             }
         }
         return(flag);
     }
 }
Ejemplo n.º 9
0
 /*对流层改正用于标准单点定位*/
 public static int tropcorr(time t, double[] pos, double[] azel, double[] trop)
 {
     trop[0] = pppcmn.tropmodel(t, pos, azel, REL_HUMI);
     trop[1] = Math.Pow(ERR_SAAS / (Math.Sin(azel[1]) + 0.1), 2);
     return(1);
 }
Ejemplo n.º 10
0
        /*由广播星历计算的电离层模型,克布罗歇模型*/
        public static double ionmodel(time t, rtktime rtkt, double[] alpha, double[] bela, double[] pos, double[] azel)//由广播星历计算的电离层模型,克布罗歇模型
        {
            double[] ion_default = new double[8] {
                0.1118E-07, -0.7451E-08, -0.5961E-07, 0.1192E-06,
                0.1167E+06, -0.2294E+06, -0.1311E+06, 0.1049E+07
            };
            double tt, f, psi, phi, lam, amp, per, x;
            int    i;

            if (pos[2] < -1E3 || azel[1] <= 0)
            {
                return(0.0);
            }
            for (i = 0; i < 4; i++)
            {
                if (alpha[i] != 0 || bela[i] != 0)
                {
                    break;
                }
            }
            if (i < 4)
            {
                for (int j = 0; j < 4; j++)
                {
                    ion_default[j]     = alpha[j];
                    ion_default[j + 4] = bela[j];
                }
            }
            /* earth centered angle (semi-circle) */
            psi = 0.0137 / (azel[1] / Math.PI + 0.11) - 0.022;
            /* subionospheric latitude/longitude (semi-circle) */
            phi = pos[0] / Math.PI + psi * Math.Cos(azel[0]);
            if (phi > 0.416)
            {
                phi = 0.416;
            }
            else if (phi < -0.416)
            {
                phi = -0.416;
            }
            lam = pos[1] / Math.PI + psi * Math.Sin(azel[0]) / Math.Cos(phi * Math.PI);
            /* geomagnetic latitude (semi-circle) */
            phi += 0.064 * Math.Cos((lam - 1.617) * Math.PI);

            /* local time (s) */
            //tt = 43200.0 * lam + time2gpst(t, &week);
            tt  = 43200.0 * lam + rtklibcmn.time2gpst(rtkt, null);
            tt -= Math.Floor(tt / 86400.0) * 86400.0; /* 0<=tt<86400 */

            /* slant factor */
            f = 1.0 + 16.0 * Math.Pow(0.53 - azel[1] / Math.PI, 3.0);

            /* ionospheric delay */
            amp = ion_default[0] + phi * (ion_default[1] + phi * (ion_default[2] + phi * ion_default[3]));
            per = ion_default[4] + phi * (ion_default[5] + phi * (ion_default[6] + phi * ion_default[7]));
            amp = amp < 0.0 ? 0.0 : amp;
            per = per < 72000.0 ? 72000.0 : per;
            x   = 2.0 * Math.PI * (tt - 50400.0) / per;

            return(CLIGHT * f * (Math.Abs(x) < 1.57 ? 5E-9 + amp * (1.0 + x * x * (-0.5 + x * x / 24.0)) : 5E-9));
        }
Ejemplo n.º 11
0
 /*电离层改正用于标准单点定位*/
 public static int ioncorr(time t, rtktime rtkt, nav_t nav, double[] pos, double[] azel, double[] ion)
 {
     ion[0] = ionmodel(t, rtkt, nav.alpha, nav.beta, pos, azel);
     ion[1] = Math.Pow(ion[0] * ERR_BRDCI, 2);
     return(1);
 }