Exemple #1
0
/*-----------------------------------------------------------------------------
 *
 *                           procedure dsinit
 *
 *  this procedure provides deep space contributions to mean motion dot due
 *    to geopotential resonance with half day and one day orbits.
 *
 *  author        : david vallado                  719-573-2600   28 jun 2005
 *
 *  inputs        :
 *    cosim, sinim-
 *    emsq        - eccentricity squared
 *    argpo       - argument of perigee
 *    s1, s2, s3, s4, s5      -
 *    ss1, ss2, ss3, ss4, ss5 -
 *    sz1, sz3, sz11, sz13, sz21, sz23, sz31, sz33 -
 *    t           - time
 *    tc          -
 *    gsto        - greenwich sidereal time                   rad
 *    mo          - mean anomaly
 *    mdot        - mean anomaly dot (rate)
 *    no          - mean motion
 *    nodeo       - right ascension of ascending node
 *    nodedot     - right ascension of ascending node dot (rate)
 *    xpidot      -
 *    z1, z3, z11, z13, z21, z23, z31, z33 -
 *    eccm        - eccentricity
 *    argpm       - argument of perigee
 *    inclm       - inclination
 *    mm          - mean anomaly
 *    xn          - mean motion
 *    nodem       - right ascension of ascending node
 *
 *  outputs       :
 *    em          - eccentricity
 *    argpm       - argument of perigee
 *    inclm       - inclination
 *    mm          - mean anomaly
 *    nm          - mean motion
 *    nodem       - right ascension of ascending node
 *    irez        - flag for resonance           0-none, 1-one day, 2-half day
 *    atime       -
 *    d2201, d2211, d3210, d3222, d4410, d4422, d5220, d5232, d5421, d5433    -
 *    dedt        -
 *    didt        -
 *    dmdt        -
 *    dndt        -
 *    dnodt       -
 *    domdt       -
 *    del1, del2, del3        -
 *    ses  , sghl , sghs , sgs  , shl  , shs  , sis  , sls
 *    theta       -
 *    xfact       -
 *    xlamo       -
 *    xli         -
 *    xni
 *
 *  locals        :
 *    ainv2       -
 *    aonv        -
 *    cosisq      -
 *    eoc         -
 *    f220, f221, f311, f321, f322, f330, f441, f442, f522, f523, f542, f543  -
 *    g200, g201, g211, g300, g310, g322, g410, g422, g520, g521, g532, g533  -
 *    sini2       -
 *    temp        -
 *    temp1       -
 *    theta       -
 *    xno2        -
 *
 *  coupling      :
 *    getgravconst
 *
 *  references    :
 *    hoots, roehrich, norad spacetrack report #3 1980
 *    hoots, norad spacetrack report #6 1986
 *    hoots, schumacher and glover 2004
 *    vallado, crawford, hujsak, kelso  2006
 * ----------------------------------------------------------------------------*/
        public DsinitResult dsinit(DsinitOptions dsinitOptions)
        {
            Globals globals = new Globals();
            double  pi      = globals.pi;
            double  twoPi   = globals.twoPi;
            double  xke     = globals.xke;
            double  x2o3    = globals.x2o3;

            double cosim   = dsinitOptions.cosim;
            double argpo   = dsinitOptions.argpo;
            double s1      = dsinitOptions.s1;
            double s2      = dsinitOptions.s2;
            double s3      = dsinitOptions.s3;
            double s4      = dsinitOptions.s4;
            double s5      = dsinitOptions.s5;
            double sinim   = dsinitOptions.sinim;
            double ss1     = dsinitOptions.ss1;
            double ss2     = dsinitOptions.ss2;
            double ss3     = dsinitOptions.ss3;
            double ss4     = dsinitOptions.ss4;
            double ss5     = dsinitOptions.ss5;
            double sz1     = dsinitOptions.sz1;
            double sz3     = dsinitOptions.sz3;
            double sz11    = dsinitOptions.sz11;
            double sz13    = dsinitOptions.sz13;
            double sz21    = dsinitOptions.sz21;
            double sz23    = dsinitOptions.sz23;
            double sz31    = dsinitOptions.sz31;
            double sz33    = dsinitOptions.sz33;
            double t       = dsinitOptions.t;
            double tc      = dsinitOptions.tc;
            double gsto    = dsinitOptions.gsto;
            double mo      = dsinitOptions.mo;
            double mdot    = dsinitOptions.mdot;
            double no      = dsinitOptions.no;
            double nodeo   = dsinitOptions.nodeo;
            double nodedot = dsinitOptions.nodedot;
            double xpidot  = dsinitOptions.xpidot;
            double z1      = dsinitOptions.z1;
            double z3      = dsinitOptions.z3;
            double z11     = dsinitOptions.z11;
            double z13     = dsinitOptions.z13;
            double z21     = dsinitOptions.z21;
            double z23     = dsinitOptions.z23;
            double z31     = dsinitOptions.z31;
            double z33     = dsinitOptions.z33;
            double ecco    = dsinitOptions.ecco;
            double eccsq   = dsinitOptions.eccsq;

            double emsq  = dsinitOptions.emsq;
            double em    = dsinitOptions.em;
            double argpm = dsinitOptions.argpm;
            double inclm = dsinitOptions.inclm;
            double mm    = dsinitOptions.mm;
            double nm    = dsinitOptions.nm;
            double nodem = dsinitOptions.nodem;
            double irez  = dsinitOptions.irez;
            double atime = dsinitOptions.atime;
            double d2201 = dsinitOptions.d2201;
            double d2211 = dsinitOptions.d2211;
            double d3210 = dsinitOptions.d3210;
            double d3222 = dsinitOptions.d3222;
            double d4410 = dsinitOptions.d4410;
            double d4422 = dsinitOptions.d4422;
            double d5220 = dsinitOptions.d5220;
            double d5232 = dsinitOptions.d5232;
            double d5421 = dsinitOptions.d5421;
            double d5433 = dsinitOptions.d5433;
            double dedt  = dsinitOptions.dedt;
            double didt  = dsinitOptions.didt;
            double dmdt  = dsinitOptions.dmdt;
            double dnodt = dsinitOptions.dnodt;
            double domdt = dsinitOptions.domdt;
            double del1  = dsinitOptions.del1;
            double del2  = dsinitOptions.del2;
            double del3  = dsinitOptions.del3;
            double xfact = dsinitOptions.xfact;
            double xlamo = dsinitOptions.xlamo;
            double xli   = dsinitOptions.xli;
            double xni   = dsinitOptions.xni;

            double f220   = 0.0;
            double f221   = 0.0;
            double f311   = 0.0;
            double f321   = 0.0;
            double f322   = 0.0;
            double f330   = 0.0;
            double f441   = 0.0;
            double f442   = 0.0;
            double f522   = 0.0;
            double f523   = 0.0;
            double f542   = 0.0;
            double f543   = 0.0;
            double g200   = 0.0;
            double g201   = 0.0;
            double g211   = 0.0;
            double g300   = 0.0;
            double g310   = 0.0;
            double g322   = 0.0;
            double g410   = 0.0;
            double g422   = 0.0;
            double g520   = 0.0;
            double g521   = 0.0;
            double g532   = 0.0;
            double g533   = 0.0;
            double sini2  = 0.0;
            double temp   = 0.0;
            double temp1  = 0.0;
            double xno2   = 0.0;
            double ainv2  = 0.0;
            double aonv   = 0.0;
            double cosisq = 0.0;
            double eoc    = 0.0;

            double q22    = 1.7891679e-6;
            double q31    = 2.1460748e-6;
            double q33    = 2.2123015e-7;
            double root22 = 1.7891679e-6;
            double root44 = 7.3636953e-9;
            double root54 = 2.1765803e-9;
            double rptim  = 4.37526908801129966e-3; // equates to 7.29211514668855e-5 rad/sec
            double root32 = 3.7393792e-7;
            double root52 = 1.1428639e-7;
            double znl    = 1.5835218e-4;
            double zns    = 1.19459e-5;

            // -------------------- deep space initialization ------------
            irez = 0;
            if ((nm < 0.0052359877) && (nm > 0.0034906585))
            {
                irez = 1;
            }
            if ((nm >= 8.26e-3) && (nm <= 9.24e-3) && (em >= 0.5))
            {
                irez = 2;
            }

            // ------------------------ do solar terms -------------------
            double ses  = ss1 * zns * ss5;
            double sis  = ss2 * zns * (sz11 + sz13);
            double sls  = -zns * ss3 * ((sz1 + sz3) - 14.0 - (6.0 * emsq));
            double sghs = ss4 * zns * ((sz31 + sz33) - 6.0);
            double shs  = -zns * ss2 * (sz21 + sz23);

            // sgp4fix for 180 deg incl
            if (inclm < 5.2359877e-2 || inclm > pi - 5.2359877e-2)
            {
                shs = 0.0;
            }
            if (sinim != 0.0)
            {
                shs /= sinim;
            }
            double sgs = sghs - (cosim * shs);

            // ------------------------- do lunar terms ------------------
            dedt = ses + (s1 * znl * s5);
            didt = sis + (s2 * znl * (z11 + z13));
            dmdt = sls - (znl * s3 * ((z1 + z3) - 14.0 - (6.0 * emsq)));
            double sghl = s4 * znl * ((z31 + z33) - 6.0);
            double shll = -znl * s2 * (z21 + z23);


            // sgp4fix for 180 deg incl
            if ((inclm < 5.2359877e-2) || (inclm > (pi - 5.2359877e-2)))
            {
                shll = 0.0;
            }
            domdt = sgs + sghl;
            dnodt = shs;
            if (sinim != 0.0)
            {
                domdt -= (cosim / sinim) * shll;
                dnodt += shll / sinim;
            }

            // ----------- calculate deep space resonance effects --------
            double dndt  = 0.0;
            double theta = (gsto + (tc * rptim)) % twoPi;

            em    += dedt * t;
            inclm += didt * t;
            argpm += domdt * t;
            nodem += dnodt * t;
            mm    += dmdt * t;

            // sgp4fix for negative inclinations
            // the following if statement should be commented out
            // if (inclm < 0.0)
            // {
            //   inclm  = -inclm;
            //   argpm  = argpm - pi;
            //   nodem = nodem + pi;
            // }

            // -------------- initialize the resonance terms -------------
            if (irez != 0)
            {
                aonv = (Math.Pow((nm / xke), x2o3));

                // ---------- geopotential resonance for 12 hour orbits ------
                if (irez == 2)
                {
                    cosisq = cosim * cosim;
                    double emo = em;
                    em = ecco;
                    double emsqo = emsq;
                    emsq = eccsq;
                    eoc  = em * emsq;
                    g201 = -0.306 - ((em - 0.64) * 0.440);

                    if (em <= 0.65)
                    {
                        g211 = (3.616 - (13.2470 * em)) + (16.2900 * emsq);
                        g310 = ((-19.302 + (117.3900 * em)) - (228.4190 * emsq)) + (156.5910 * eoc);
                        g322 = ((-18.9068 + (109.7927 * em)) - (214.6334 * emsq)) + (146.5816 * eoc);
                        g410 = ((-41.122 + (242.6940 * em)) - (471.0940 * emsq)) + (313.9530 * eoc);
                        g422 = ((-146.407 + (841.8800 * em)) - (1629.014 * emsq)) + (1083.4350 * eoc);
                        g520 = ((-532.114 + (3017.977 * em)) - (5740.032 * emsq)) + (3708.2760 * eoc);
                    }
                    else
                    {
                        g211 = ((-72.099 + (331.819 * em)) - (508.738 * emsq)) + (266.724 * eoc);
                        g310 = ((-346.844 + (1582.851 * em)) - (2415.925 * emsq)) + (1246.113 * eoc);
                        g322 = ((-342.585 + (1554.908 * em)) - (2366.899 * emsq)) + (1215.972 * eoc);
                        g410 = ((-1052.797 + (4758.686 * em)) - (7193.992 * emsq)) + (3651.957 * eoc);
                        g422 = ((-3581.690 + (16178.110 * em)) - (24462.770 * emsq)) + (12422.520 * eoc);
                        if (em > 0.715)
                        {
                            g520 = ((-5149.66 + (29936.92 * em)) - (54087.36 * emsq)) + (31324.56 * eoc);
                        }
                        else
                        {
                            g520 = (1464.74 - (4664.75 * em)) + (3763.64 * emsq);
                        }
                    }
                    if (em < 0.7)
                    {
                        g533 = ((-919.22770 + (4988.6100 * em)) - (9064.7700 * emsq)) + (5542.21 * eoc);
                        g521 = ((-822.71072 + (4568.6173 * em)) - (8491.4146 * emsq)) + (5337.524 * eoc);
                        g532 = ((-853.66600 + (4690.2500 * em)) - (8624.7700 * emsq)) + (5341.4 * eoc);
                    }
                    else
                    {
                        g533 = ((-37995.780 + (161616.52 * em)) - (229838.20 * emsq)) + (109377.94 * eoc);
                        g521 = ((-51752.104 + (218913.95 * em)) - (309468.16 * emsq)) + (146349.42 * eoc);
                        g532 = ((-40023.880 + (170470.89 * em)) - (242699.48 * emsq)) + (115605.82 * eoc);
                    }
                    sini2 = sinim * sinim;
                    f220  = 0.75 * (1.0 + (2.0 * cosim) + cosisq);
                    f221  = 1.5 * sini2;
                    f321  = 1.875 * sinim * (1.0 - (2.0 * cosim) - (3.0 * cosisq));
                    f322  = -1.875 * sinim * ((1.0 + (2.0 * cosim)) - (3.0 * cosisq));
                    f441  = 35.0 * sini2 * f220;
                    f442  = 39.3750 * sini2 * sini2;

                    f522 = 9.84375 * sinim * ((sini2 * (1.0 - (2.0 * cosim) - (5.0 * cosisq)))
                                              + (0.33333333 * (-2.0 + (4.0 * cosim) + (6.0 * cosisq))));
                    f523 = sinim * ((4.92187512 * sini2 * ((-2.0 - (4.0 * cosim)) + (10.0 * cosisq)))
                                    + (6.56250012 * ((1.0 + (2.0 * cosim)) - (3.0 * cosisq))));
                    f542 = 29.53125 * sinim * ((2.0 - (8.0 * cosim))
                                               + (cosisq * (-12.0 + (8.0 * cosim) + (10.0 * cosisq))));
                    f543 = 29.53125 * sinim * ((-2.0 - (8.0 * cosim))
                                               + (cosisq * ((12.0 + (8.0 * cosim)) - (10.0 * cosisq))));

                    xno2   = nm * nm;
                    ainv2  = aonv * aonv;
                    temp1  = 3.0 * xno2 * ainv2;
                    temp   = temp1 * root22;
                    d2201  = temp * f220 * g201;
                    d2211  = temp * f221 * g211;
                    temp1 *= aonv;
                    temp   = temp1 * root32;
                    d3210  = temp * f321 * g310;
                    d3222  = temp * f322 * g322;
                    temp1 *= aonv;
                    temp   = 2.0 * temp1 * root44;
                    d4410  = temp * f441 * g410;
                    d4422  = temp * f442 * g422;
                    temp1 *= aonv;
                    temp   = temp1 * root52;
                    d5220  = temp * f522 * g520;
                    d5232  = temp * f523 * g532;
                    temp   = 2.0 * temp1 * root54;
                    d5421  = temp * f542 * g521;
                    d5433  = temp * f543 * g533;
                    xlamo  = ((mo + nodeo + nodeo) - (theta + theta)) % twoPi;
                    xfact  = (mdot + dmdt + (2.0 * ((nodedot + dnodt) - rptim))) - no;
                    em     = emo;
                    emsq   = emsqo;
                }

                //  ---------------- synchronous resonance terms --------------
                if (irez == 1)
                {
                    g200  = 1.0 + (emsq * (-2.5 + (0.8125 * emsq)));
                    g310  = 1.0 + (2.0 * emsq);
                    g300  = 1.0 + (emsq * (-6.0 + (6.60937 * emsq)));
                    f220  = 0.75 * (1.0 + cosim) * (1.0 + cosim);
                    f311  = (0.9375 * sinim * sinim * (1.0 + (3.0 * cosim))) - (0.75 * (1.0 + cosim));
                    f330  = 1.0 + cosim;
                    f330 *= 1.875 * f330 * f330;
                    del1  = 3.0 * nm * nm * aonv * aonv;
                    del2  = 2.0 * del1 * f220 * g200 * q22;
                    del3  = 3.0 * del1 * f330 * g300 * q33 * aonv;
                    del1  = del1 * f311 * g310 * q31 * aonv;
                    xlamo = ((mo + nodeo + argpo) - theta) % twoPi;
                    xfact = (mdot + xpidot + dmdt + domdt + dnodt) - (no + rptim);
                }

                //  ------------ for sgp4, initialize the integrator ----------
                xli   = xlamo;
                xni   = no;
                atime = 0.0;
                nm    = no + dndt;
            }

            DsinitResult dsinitResult = new DsinitResult();

            dsinitResult.em    = em;
            dsinitResult.argpm = argpm;
            dsinitResult.inclm = inclm;
            dsinitResult.mm    = mm;
            dsinitResult.nm    = nm;
            dsinitResult.nodem = nodem;

            dsinitResult.irez  = irez;
            dsinitResult.atime = atime;

            dsinitResult.d2201 = d2201;
            dsinitResult.d2211 = d2211;
            dsinitResult.d3210 = d3210;
            dsinitResult.d3222 = d3222;
            dsinitResult.d4410 = d4410;

            dsinitResult.d4422 = d4422;
            dsinitResult.d5220 = d5220;
            dsinitResult.d5232 = d5232;
            dsinitResult.d5421 = d5421;
            dsinitResult.d5433 = d5433;

            dsinitResult.dedt  = dedt;
            dsinitResult.didt  = didt;
            dsinitResult.dmdt  = dmdt;
            dsinitResult.dndt  = dndt;
            dsinitResult.dnodt = dnodt;
            dsinitResult.domdt = domdt;

            dsinitResult.del1 = del1;
            dsinitResult.del2 = del2;
            dsinitResult.del3 = del3;

            dsinitResult.xfact = xfact;
            dsinitResult.xlamo = xlamo;
            dsinitResult.xli   = xli;
            dsinitResult.xni   = xni;

            return(dsinitResult);
        }
Exemple #2
0
/*-----------------------------------------------------------------------------
 *
 *                             procedure sgp4init
 *
 *  this procedure initializes variables for sgp4.
 *
 *  author        : david vallado                  719-573-2600   28 jun 2005
 *  author        : david vallado                  719-573-2600   28 jun 2005
 *
 *  inputs        :
 *    opsmode     - mode of operation afspc or improved 'a', 'i'
 *    satn        - satellite number
 *    bstar       - sgp4 type drag coefficient              kg/m2er
 *    ecco        - eccentricity
 *    epoch       - epoch time in days from jan 0, 1950. 0 hr
 *    argpo       - argument of perigee (output if ds)
 *    inclo       - inclination
 *    mo          - mean anomaly (output if ds)
 *    no          - mean motion
 *    nodeo       - right ascension of ascending node
 *
 *  outputs       :
 *    rec      - common values for subsequent calls
 *    return code - non-zero on error.
 *                   1 - mean elements, ecc >= 1.0 or ecc < -0.001 or a < 0.95 er
 *                   2 - mean motion less than 0.0
 *                   3 - pert elements, ecc < 0.0  or  ecc > 1.0
 *                   4 - semi-latus rectum < 0.0
 *                   5 - epoch elements are sub-orbital
 *                   6 - satellite has decayed
 *
 *  locals        :
 *    cnodm  , snodm  , cosim  , sinim  , cosomm , sinomm
 *    cc1sq  , cc2    , cc3
 *    coef   , coef1
 *    cosio4      -
 *    day         -
 *    dndt        -
 *    em          - eccentricity
 *    emsq        - eccentricity squared
 *    eeta        -
 *    etasq       -
 *    gam         -
 *    argpm       - argument of perigee
 *    nodem       -
 *    inclm       - inclination
 *    mm          - mean anomaly
 *    nm          - mean motion
 *    perige      - perigee
 *    pinvsq      -
 *    psisq       -
 *    qzms24      -
 *    rtemsq      -
 *    s1, s2, s3, s4, s5, s6, s7          -
 *    sfour       -
 *    ss1, ss2, ss3, ss4, ss5, ss6, ss7         -
 *    sz1, sz2, sz3
 *    sz11, sz12, sz13, sz21, sz22, sz23, sz31, sz32, sz33        -
 *    tc          -
 *    temp        -
 *    temp1, temp2, temp3       -
 *    tsi         -
 *    xpidot      -
 *    xhdot1      -
 *    z1, z2, z3          -
 *    z11, z12, z13, z21, z22, z23, z31, z32, z33         -
 *
 *  coupling      :
 *    getgravconst-
 *    initl       -
 *    dscom       -
 *    dpper       -
 *    dsinit      -
 *    sgp4        -
 *
 *  references    :
 *    hoots, roehrich, norad spacetrack report #3 1980
 *    hoots, norad spacetrack report #6 1986
 *    hoots, schumacher and glover 2004
 *    vallado, crawford, hujsak, kelso  2006
 * ----------------------------------------------------------------------------*/
        public void sgp4init(Satrec satrec, Sgp4initOptions options)
        {
            Globals globals = new Globals();

            double pi          = globals.pi;
            double earthRadius = globals.earthRadius;
            double j2          = globals.j2;
            double j4          = globals.j4;
            double j3oj2       = globals.j3oj2;
            double x2o3        = globals.x2o3;

            char   opsmode = options.opsmode;
            string satn    = options.satn;
            double epoch   = options.epoch;
            double xbstar  = options.xbstar;
            double xecco   = options.xecco;
            double xargpo  = options.xargpo;
            double xinclo  = options.xinclo;
            double xmo     = options.xmo;
            double xno     = options.xno;
            double xnodeo  = options.xnodeo;


            double cosim;
            double sinim;
            double cc1sq;
            double cc2;
            double cc3;
            double coef;
            double coef1;
            double cosio4;
            double em;
            double emsq;
            double eeta;
            double etasq;
            double argpm;
            double nodem;
            double inclm;
            double mm;
            double nm;
            double perige;
            double pinvsq;
            double psisq;
            double qzms24;
            double s1;
            double s2;
            double s3;
            double s4;
            double s5;
            double sfour;
            double ss1;
            double ss2;
            double ss3;
            double ss4;
            double ss5;
            double sz1;
            double sz3;
            double sz11;
            double sz13;
            double sz21;
            double sz23;
            double sz31;
            double sz33;
            double tc;
            double temp;
            double temp1;
            double temp2;
            double temp3;
            double tsi;
            double xpidot;
            double xhdot1;
            double z1;
            double z3;
            double z11;
            double z13;
            double z21;
            double z23;
            double z31;
            double z33;

            /* ------------------------ initialization --------------------- */
            // sgp4fix divisor for divide by zero check on inclination
            // the old check used 1.0 + Math.cos(pi-1.0e-9), but then compared it to
            // 1.5 e-12, so the threshold was changed to 1.5e-12 for consistency
            double temp4 = 1.5e-12;

            // ----------- set all near earth variables to zero ------------
            satrec.isimp   = 0; satrec.method = 'n'; satrec.aycof = 0.0;
            satrec.con41   = 0.0; satrec.cc1 = 0.0; satrec.cc4 = 0.0;
            satrec.cc5     = 0.0; satrec.d2 = 0.0; satrec.d3 = 0.0;
            satrec.d4      = 0.0; satrec.delmo = 0.0; satrec.eta = 0.0;
            satrec.argpdot = 0.0; satrec.omgcof = 0.0; satrec.sinmao = 0.0;
            satrec.t       = 0.0; satrec.t2cof = 0.0; satrec.t3cof = 0.0;
            satrec.t4cof   = 0.0; satrec.t5cof = 0.0; satrec.x1mth2 = 0.0;
            satrec.x7thm1  = 0.0; satrec.mdot = 0.0; satrec.nodedot = 0.0;
            satrec.xlcof   = 0.0; satrec.xmcof = 0.0; satrec.nodecf = 0.0;

            // ----------- set all deep space variables to zero ------------
            satrec.irez  = 0; satrec.d2201 = 0.0; satrec.d2211 = 0.0;
            satrec.d3210 = 0.0; satrec.d3222 = 0.0; satrec.d4410 = 0.0;
            satrec.d4422 = 0.0; satrec.d5220 = 0.0; satrec.d5232 = 0.0;
            satrec.d5421 = 0.0; satrec.d5433 = 0.0; satrec.dedt = 0.0;
            satrec.del1  = 0.0; satrec.del2 = 0.0; satrec.del3 = 0.0;
            satrec.didt  = 0.0; satrec.dmdt = 0.0; satrec.dnodt = 0.0;
            satrec.domdt = 0.0; satrec.e3 = 0.0; satrec.ee2 = 0.0;
            satrec.peo   = 0.0; satrec.pgho = 0.0; satrec.pho = 0.0;
            satrec.pinco = 0.0; satrec.plo = 0.0; satrec.se2 = 0.0;
            satrec.se3   = 0.0; satrec.sgh2 = 0.0; satrec.sgh3 = 0.0;
            satrec.sgh4  = 0.0; satrec.sh2 = 0.0; satrec.sh3 = 0.0;
            satrec.si2   = 0.0; satrec.si3 = 0.0; satrec.sl2 = 0.0;
            satrec.sl3   = 0.0; satrec.sl4 = 0.0; satrec.gsto = 0.0;
            satrec.xfact = 0.0; satrec.xgh2 = 0.0; satrec.xgh3 = 0.0;
            satrec.xgh4  = 0.0; satrec.xh2 = 0.0; satrec.xh3 = 0.0;
            satrec.xi2   = 0.0; satrec.xi3 = 0.0; satrec.xl2 = 0.0;
            satrec.xl3   = 0.0; satrec.xl4 = 0.0; satrec.xlamo = 0.0;
            satrec.zmol  = 0.0; satrec.zmos = 0.0; satrec.atime = 0.0;
            satrec.xli   = 0.0; satrec.xni = 0.0;


            // sgp4fix - note the following variables are also passed directly via satrec.
            // it is possible to streamline the sgp4init call by deleting the "x"
            // variables, but the user would need to set the satrec.* values first. we
            // include the additional assignments in case twoline2rv is not used.

            satrec.bstar = xbstar;
            satrec.ecco  = xecco;
            satrec.argpo = xargpo;
            satrec.inclo = xinclo;
            satrec.mo    = xmo;
            satrec.no    = xno;
            satrec.nodeo = xnodeo;

            //  sgp4fix add opsmode
            satrec.operationmode = opsmode;

            // ------------------------ earth constants -----------------------
            // sgp4fix identify constants and allow alternate values

            double ss = (78.0 / earthRadius) + 1.0;
            // sgp4fix use multiply for speed instead of pow
            double qzms2ttemp = (120.0 - 78.0) / earthRadius;
            double qzms2t     = qzms2ttemp * qzms2ttemp * qzms2ttemp * qzms2ttemp;

            satrec.init = 'y';
            satrec.t    = 0.0;

            InitlOptions initlOptions = new InitlOptions();

            initlOptions.satn    = satn;
            initlOptions.ecco    = satrec.ecco;
            initlOptions.epoch   = epoch;
            initlOptions.inlco   = satrec.inclo;
            initlOptions.no      = satrec.no;
            initlOptions.method  = satrec.method;
            initlOptions.opsmode = satrec.operationmode;

            Initl       initl       = new Initl();
            InitlResult initlResult = new InitlResult();

            initlResult = initl.initl(initlOptions); //TODO: Finish impl

            double ao     = initlResult.ao;
            double con42  = initlResult.con42;
            double cosio  = initlResult.cosio;
            double cosio2 = initlResult.cosio2;
            double eccsq  = initlResult.eccsq;
            double omeosq = initlResult.omeosq;
            double posq   = initlResult.posq;
            double rp     = initlResult.rp;
            double rteosq = initlResult.rteosq;
            double sinio  = initlResult.sinio;

            satrec.no    = initlResult.no;
            satrec.con41 = initlResult.con41;
            satrec.gsto  = initlResult.gsto;
            satrec.error = 0;



            // sgp4fix remove this check as it is unnecessary
            // the mrt check in sgp4 handles decaying satellite cases even if the starting
            // condition is below the surface of te earth
            // if (rp < 1.0)
            // {
            //   printf("// *** satn%d epoch elts sub-orbital ***\n", satn);
            //   satrec.error = 5;
            // }


            if (omeosq >= 0.0 || satrec.no >= 0.0)
            {
                satrec.isimp = 0;
                if (rp < (220.0 / earthRadius + 1.0))
                {
                    satrec.isimp = 1;
                }
                sfour  = ss;
                qzms24 = qzms2t;
                perige = (rp - 1.0) * earthRadius;

                // - for perigees below 156 km, s and qoms2t are altered -
                if (perige < 156.0)
                {
                    sfour = perige - 78.0;
                    if (perige < 98.0)
                    {
                        sfour = 20.0;
                    }

                    // sgp4fix use multiply for speed instead of pow
                    double qzms24temp = (120.0 - sfour) / earthRadius;
                    qzms24 = qzms24temp * qzms24temp * qzms24temp * qzms24temp;
                    sfour  = (sfour / earthRadius) + 1.0;
                }
                pinvsq = 1.0 / posq;

                tsi        = 1.0 / (ao - sfour);
                satrec.eta = ao * satrec.ecco * tsi;
                etasq      = satrec.eta * satrec.eta;
                eeta       = satrec.ecco * satrec.eta;
                psisq      = Math.Abs(1.0 - etasq);
                coef       = qzms24 * Math.Pow(tsi, 4.0);
                coef1      = coef / (Math.Pow(psisq, 3.5));
                cc2        = coef1 * satrec.no * ((ao * (1.0 + (1.5 * etasq) + (eeta * (4.0 + etasq))))
                                                  + (((0.375 * j2 * tsi) / psisq) * satrec.con41
                                                     * (8.0 + (3.0 * etasq * (8.0 + etasq)))));
                satrec.cc1 = satrec.bstar * cc2;
                cc3        = 0.0;
                if (satrec.ecco > 1.0e-4)
                {
                    cc3 = (-2.0 * coef * tsi * j3oj2 * satrec.no * sinio) / satrec.ecco;
                }
                satrec.x1mth2 = 1.0 - cosio2;
                satrec.cc4    = 2.0 * satrec.no * coef1 * ao * omeosq * (
                    ((satrec.eta * (2.0 + (0.5 * etasq)))
                     + (satrec.ecco * (0.5 + (2.0 * etasq))))
                    - (((j2 * tsi) / (ao * psisq))
                       * ((-3.0 * satrec.con41 * ((1.0 - (2.0 * eeta)) + (etasq * (1.5 - (0.5 * eeta)))))
                          + (0.75 * satrec.x1mth2
                             * ((2.0 * etasq) - (eeta * (1.0 + etasq)))
                             * Math.Cos(2.0 * satrec.argpo))))
                    );
                satrec.cc5  = 2.0 * coef1 * ao * omeosq * (1.0 + (2.75 * (etasq + eeta)) + (eeta * etasq));
                cosio4      = cosio2 * cosio2;
                temp1       = 1.5 * j2 * pinvsq * satrec.no;
                temp2       = 0.5 * temp1 * j2 * pinvsq;
                temp3       = -0.46875 * j4 * pinvsq * pinvsq * satrec.no;
                satrec.mdot = satrec.no + (0.5 * temp1 * rteosq * satrec.con41)
                              + (0.0625 * temp2 * rteosq * ((13.0 - (78.0 * cosio2)) + (137.0 * cosio4)));
                satrec.argpdot = (-0.5 * temp1 * con42)
                                 + (0.0625 * temp2 * ((7.0 - (114.0 * cosio2)) + (395.0 * cosio4)))
                                 + (temp3 * ((3.0 - (36.0 * cosio2)) + (49.0 * cosio4)));
                xhdot1         = -temp1 * cosio;
                satrec.nodedot = xhdot1 + (((0.5 * temp2 * (4.0 - (19.0 * cosio2)))
                                            + (2.0 * temp3 * (3.0 - (7.0 * cosio2)))) * cosio);
                xpidot        = satrec.argpdot + satrec.nodedot;
                satrec.omgcof = satrec.bstar * cc3 * Math.Cos(satrec.argpo);
                satrec.xmcof  = 0.0;
                if (satrec.ecco > 1.0e-4)
                {
                    satrec.xmcof = (-x2o3 * coef * satrec.bstar) / eeta;
                }
                satrec.nodecf = 3.5 * omeosq * xhdot1 * satrec.cc1;
                satrec.t2cof  = 1.5 * satrec.cc1;

                // sgp4fix for divide by zero with xinco = 180 deg
                if (Math.Abs(cosio + 1.0) > 1.5e-12)
                {
                    satrec.xlcof = (-0.25 * j3oj2 * sinio * (3.0 + (5.0 * cosio))) / (1.0 + cosio);
                }
                else
                {
                    satrec.xlcof = (-0.25 * j3oj2 * sinio * (3.0 + (5.0 * cosio))) / temp4;
                }
                satrec.aycof = -0.5 * j3oj2 * sinio;

                // sgp4fix use multiply for speed instead of pow
                double delmotemp = 1.0 + (satrec.eta * Math.Cos(satrec.mo));
                satrec.delmo  = delmotemp * delmotemp * delmotemp;
                satrec.sinmao = Math.Sin(satrec.mo);
                satrec.x7thm1 = (7.0 * cosio2) - 1.0;


                // --------------- deep space initialization -------------
                if ((2 * pi) / satrec.no >= 225.0)
                {
                    satrec.method = 'd';
                    satrec.isimp  = 1;
                    tc            = 0.0;
                    inclm         = satrec.inclo;


                    DscomOptions dscomOptions = new DscomOptions();
                    dscomOptions.epoch = epoch;
                    dscomOptions.ep    = satrec.ecco;
                    dscomOptions.argpp = satrec.argpo;
                    dscomOptions.tc    = tc;
                    dscomOptions.inclp = satrec.inclo;
                    dscomOptions.nodep = satrec.nodeo;

                    dscomOptions.np  = satrec.no;
                    dscomOptions.e3  = satrec.e3;
                    dscomOptions.ee2 = satrec.ee2;

                    dscomOptions.peo   = satrec.peo;
                    dscomOptions.pgho  = satrec.pgho;
                    dscomOptions.pho   = satrec.pho;
                    dscomOptions.pinco = satrec.pinco;

                    dscomOptions.plo = satrec.plo;
                    dscomOptions.se2 = satrec.se2;
                    dscomOptions.se3 = satrec.se3;

                    dscomOptions.sgh2 = satrec.sgh2;
                    dscomOptions.sgh3 = satrec.sgh3;
                    dscomOptions.sgh4 = satrec.sgh4;

                    dscomOptions.sh2 = satrec.sh2;
                    dscomOptions.sh3 = satrec.sh3;
                    dscomOptions.si2 = satrec.si2;
                    dscomOptions.si3 = satrec.si3;

                    dscomOptions.sl2 = satrec.sl2;
                    dscomOptions.sl3 = satrec.sl3;
                    dscomOptions.sl4 = satrec.sl4;

                    dscomOptions.xgh2 = satrec.xgh2;
                    dscomOptions.xgh3 = satrec.xgh3;
                    dscomOptions.xgh4 = satrec.xgh4;
                    dscomOptions.xh2  = satrec.xh2;

                    dscomOptions.xh3 = satrec.xh3;
                    dscomOptions.xi2 = satrec.xi2;
                    dscomOptions.xi3 = satrec.xi3;
                    dscomOptions.xl2 = satrec.xl2;

                    dscomOptions.xl3 = satrec.xl3;
                    dscomOptions.xl4 = satrec.xl4;

                    dscomOptions.zmol = satrec.zmol;
                    dscomOptions.zmos = satrec.zmos;



                    Dscom       dscom       = new Dscom();
                    DscomResult dscomResult = new DscomResult();

                    dscomResult = dscom.dscom(dscomOptions);

                    satrec.e3  = dscomResult.e3;
                    satrec.ee2 = dscomResult.ee2;

                    satrec.peo  = dscomResult.peo;
                    satrec.pgho = dscomResult.pgho;
                    satrec.pho  = dscomResult.pho;

                    satrec.pinco = dscomResult.pinco;
                    satrec.plo   = dscomResult.plo;
                    satrec.se2   = dscomResult.se2;
                    satrec.se3   = dscomResult.se3;

                    satrec.sgh2 = dscomResult.sgh2;
                    satrec.sgh3 = dscomResult.sgh3;
                    satrec.sgh4 = dscomResult.sgh4;
                    satrec.sh2  = dscomResult.sh2;
                    satrec.sh3  = dscomResult.sh3;

                    satrec.si2 = dscomResult.si2;
                    satrec.si3 = dscomResult.si3;
                    satrec.sl2 = dscomResult.sl2;
                    satrec.sl3 = dscomResult.sl3;
                    satrec.sl4 = dscomResult.sl4;

                    sinim = dscomResult.sinim;
                    cosim = dscomResult.cosim;
                    em    = dscomResult.em;
                    emsq  = dscomResult.emsq;
                    s1    = dscomResult.s1;
                    s2    = dscomResult.s2;
                    s3    = dscomResult.s3;
                    s4    = dscomResult.s4;
                    s5    = dscomResult.s5;
                    ss1   = dscomResult.ss1;
                    ss2   = dscomResult.ss2;
                    ss3   = dscomResult.ss3;
                    ss4   = dscomResult.ss4;
                    ss5   = dscomResult.ss5;
                    sz1   = dscomResult.sz1;
                    sz3   = dscomResult.sz3;
                    sz11  = dscomResult.sz11;
                    sz13  = dscomResult.sz13;
                    sz21  = dscomResult.sz21;
                    sz23  = dscomResult.sz23;
                    sz31  = dscomResult.sz31;
                    sz33  = dscomResult.sz33;

                    satrec.xgh2 = dscomResult.xgh2;
                    satrec.xgh3 = dscomResult.xgh3;
                    satrec.xgh4 = dscomResult.xgh4;
                    satrec.xh2  = dscomResult.xh2;
                    satrec.xh3  = dscomResult.xh3;
                    satrec.xi2  = dscomResult.xi2;
                    satrec.xi3  = dscomResult.xi3;
                    satrec.xl2  = dscomResult.xl2;
                    satrec.xl3  = dscomResult.xl3;
                    satrec.xl4  = dscomResult.xl4;
                    satrec.zmol = dscomResult.zmol;
                    satrec.zmos = dscomResult.zmos;

                    nm  = dscomResult.nm;
                    z1  = dscomResult.z1;
                    z3  = dscomResult.z3;
                    z11 = dscomResult.z11;
                    z13 = dscomResult.z13;
                    z21 = dscomResult.z21;
                    z23 = dscomResult.z23;
                    z31 = dscomResult.z31;
                    z33 = dscomResult.z33;


                    DpperOptions dpperOptions = new DpperOptions();
                    dpperOptions.inclo   = inclm;
                    dpperOptions.init    = satrec.init;
                    dpperOptions.ep      = satrec.ecco;
                    dpperOptions.inclp   = satrec.inclo;
                    dpperOptions.nodep   = satrec.nodeo;
                    dpperOptions.argpp   = satrec.argpo;
                    dpperOptions.mp      = satrec.mo;
                    dpperOptions.opsmode = satrec.operationmode;


                    Dpper       dpper       = new Dpper();
                    DpperResult dpperResult = new DpperResult();

                    dpperResult = dpper.dpper(satrec, dpperOptions);

                    satrec.ecco  = dpperResult.ep;
                    satrec.inclo = dpperResult.inclp;
                    satrec.nodeo = dpperResult.nodep;
                    satrec.argpo = dpperResult.argpp;
                    satrec.mo    = dpperResult.mp;

                    argpm = 0.0;
                    nodem = 0.0;
                    mm    = 0.0;



                    DsinitOptions dsinitOptions = new DsinitOptions();

                    dsinitOptions.cosim = cosim;
                    dsinitOptions.emsq  = emsq;
                    dsinitOptions.argpo = satrec.argpo;
                    dsinitOptions.s1    = s1;
                    dsinitOptions.s2    = s2;
                    dsinitOptions.s3    = s3;
                    dsinitOptions.s4    = s4;
                    dsinitOptions.s5    = s5;
                    dsinitOptions.sinim = sinim;
                    dsinitOptions.ss1   = ss1;
                    dsinitOptions.ss2   = ss2;
                    dsinitOptions.ss3   = ss3;
                    dsinitOptions.ss4   = ss4;
                    dsinitOptions.ss5   = ss5;
                    dsinitOptions.sz1   = sz1;
                    dsinitOptions.sz3   = sz3;
                    dsinitOptions.sz11  = sz11;
                    dsinitOptions.sz13  = sz13;
                    dsinitOptions.sz21  = sz21;
                    dsinitOptions.sz23  = sz23;
                    dsinitOptions.sz31  = sz31;
                    dsinitOptions.sz33  = sz33;
                    dsinitOptions.t     = satrec.t;

                    dsinitOptions.tc      = tc;
                    dsinitOptions.gsto    = satrec.gsto;
                    dsinitOptions.mo      = satrec.mo;
                    dsinitOptions.mdot    = satrec.mdot;
                    dsinitOptions.no      = satrec.no;
                    dsinitOptions.nodeo   = satrec.nodeo;
                    dsinitOptions.nodedot = satrec.nodedot;

                    dsinitOptions.xpidot = xpidot;
                    dsinitOptions.z1     = z1;
                    dsinitOptions.z3     = z3;
                    dsinitOptions.z11    = z11;
                    dsinitOptions.z13    = z13;
                    dsinitOptions.z21    = z21;
                    dsinitOptions.z23    = z23;
                    dsinitOptions.z31    = z31;
                    dsinitOptions.z33    = z33;
                    dsinitOptions.ecco   = satrec.ecco;

                    dsinitOptions.eccsq = eccsq;
                    dsinitOptions.em    = em;
                    dsinitOptions.argpm = argpm;
                    dsinitOptions.inclm = inclm;
                    dsinitOptions.mm    = mm;
                    dsinitOptions.nm    = nm;
                    dsinitOptions.nodem = nodem;

                    dsinitOptions.irez  = satrec.irez;
                    dsinitOptions.atime = satrec.atime;
                    dsinitOptions.d2201 = satrec.d2201;
                    dsinitOptions.d2211 = satrec.d2211;
                    dsinitOptions.d3210 = satrec.d3210;
                    dsinitOptions.d3222 = satrec.d3222;
                    dsinitOptions.d4410 = satrec.d4410;
                    dsinitOptions.d4422 = satrec.d4422;
                    dsinitOptions.d5220 = satrec.d5220;
                    dsinitOptions.d5232 = satrec.d5232;
                    dsinitOptions.d5421 = satrec.d5421;
                    dsinitOptions.d5433 = satrec.d5433;
                    dsinitOptions.dedt  = satrec.dedt;
                    dsinitOptions.didt  = satrec.didt;
                    dsinitOptions.dmdt  = satrec.dmdt;
                    dsinitOptions.dnodt = satrec.dnodt;
                    dsinitOptions.domdt = satrec.domdt;
                    dsinitOptions.del1  = satrec.del1;
                    dsinitOptions.del2  = satrec.del2;
                    dsinitOptions.del3  = satrec.del3;
                    dsinitOptions.xfact = satrec.xfact;
                    dsinitOptions.xlamo = satrec.xlamo;
                    dsinitOptions.xli   = satrec.xli;
                    dsinitOptions.xni   = satrec.xni;

                    Dsinit       dsinit       = new Dsinit();
                    DsinitResult dsinitResult = new DsinitResult();
                    dsinitResult = dsinit.dsinit(dsinitOptions);

                    satrec.irez  = dsinitResult.irez;
                    satrec.atime = dsinitResult.atime;
                    satrec.d2201 = dsinitResult.d2201;
                    satrec.d2211 = dsinitResult.d2211;

                    satrec.d3210 = dsinitResult.d3210;
                    satrec.d3222 = dsinitResult.d3222;
                    satrec.d4410 = dsinitResult.d4410;
                    satrec.d4422 = dsinitResult.d4422;
                    satrec.d5220 = dsinitResult.d5220;

                    satrec.d5232 = dsinitResult.d5232;
                    satrec.d5421 = dsinitResult.d5421;
                    satrec.d5433 = dsinitResult.d5433;
                    satrec.dedt  = dsinitResult.dedt;
                    satrec.didt  = dsinitResult.didt;

                    satrec.dmdt  = dsinitResult.dmdt;
                    satrec.dnodt = dsinitResult.dnodt;
                    satrec.domdt = dsinitResult.domdt;
                    satrec.del1  = dsinitResult.del1;

                    satrec.del2  = dsinitResult.del2;
                    satrec.del3  = dsinitResult.del3;
                    satrec.xfact = dsinitResult.xfact;
                    satrec.xlamo = dsinitResult.xlamo;
                    satrec.xli   = dsinitResult.xli;

                    satrec.xni = dsinitResult.xni;
                }

                // ----------- set variables if not deep space -----------
                if (satrec.isimp != 1)
                {
                    cc1sq        = satrec.cc1 * satrec.cc1;
                    satrec.d2    = 4.0 * ao * tsi * cc1sq;
                    temp         = (satrec.d2 * tsi * satrec.cc1) / 3.0;
                    satrec.d3    = ((17.0 * ao) + sfour) * temp;
                    satrec.d4    = 0.5 * temp * ao * tsi * ((221.0 * ao) + (31.0 * sfour)) * satrec.cc1;
                    satrec.t3cof = satrec.d2 + (2.0 * cc1sq);
                    satrec.t4cof = 0.25 * ((3.0 * satrec.d3)
                                           + (satrec.cc1 * ((12.0 * satrec.d2) + (10.0 * cc1sq))));
                    satrec.t5cof = 0.2 * (
                        (3.0 * satrec.d4)
                        + (12.0 * satrec.cc1 * satrec.d3)
                        + (6.0 * satrec.d2 * satrec.d2)
                        + (15.0 * cc1sq * ((2.0 * satrec.d2) + cc1sq))
                        );
                }

                /* finally propogate to zero epoch to initialize all others. */
                // sgp4fix take out check to let satellites process until they are actually below earth surface
                // if(satrec.error == 0)
            }

            Sgp4 sgp4 = new Sgp4();

            sgp4.sgp4(satrec, 0);

            satrec.init = 'n';

            /* eslint-enable no-param-reassign */
        }