Ejemplo n.º 1
0
        internal void GetPosition(double timeOfDay, out double raHours, out double errRACosDEArcSec, out double deDeg, out double errDEArcSec)
        {
            raHours = m_RegressionRA.ComputeYWithError(timeOfDay, out errRACosDEArcSec, m_ErrorMethod) / 15.0;
            deDeg   = m_RegressionDE.ComputeYWithError(timeOfDay, out errDEArcSec, m_ErrorMethod);

            errRACosDEArcSec *= Math.Cos(deDeg * Math.PI / 180) * 3600;
            errDEArcSec      *= 3600;

            if (m_PosUncertaintyMedArcSec.HasValue)
            {
                errRACosDEArcSec = Math.Sqrt(errRACosDEArcSec * errRACosDEArcSec + m_PosUncertaintyMedArcSec.Value * m_PosUncertaintyMedArcSec.Value);
                errDEArcSec      = Math.Sqrt(errDEArcSec * errDEArcSec + m_PosUncertaintyMedArcSec.Value * m_PosUncertaintyMedArcSec.Value);
            }

            if (errRACosDEArcSec < m_SmallestReportedUncertaintyArcSec)
            {
                errRACosDEArcSec = m_SmallestReportedUncertaintyArcSec;
            }
            if (errDEArcSec < m_SmallestReportedUncertaintyArcSec)
            {
                errDEArcSec = m_SmallestReportedUncertaintyArcSec;
            }
        }
Ejemplo n.º 2
0
        public void TestRAUncertainty()
        {
            var regressionRA      = new LinearRegression();
            var regressionRACosDE = new LinearRegression();
            var regressionDE      = new LinearRegression();

            #region DATA

            var data3 = new double[100, 2]
            {
                { 107.739483057629, 23.1727860863356 },
                { 107.739758423225, 23.1725858289442 },
                { 107.739270316112, 23.1727265176296 },
                { 107.740138616241, 23.1726236358575 },
                { 107.739635635855, 23.1720172219518 },
                { 107.739770516897, 23.1729142307849 },
                { 107.73978035157, 23.1724868171702 },
                { 107.7402464908, 23.1722211800014 },
                { 107.740153319844, 23.17248806658 },
                { 107.739638162317, 23.1721297891023 },
                { 107.740152592624, 23.1724840894266 },
                { 107.73958378293, 23.1723613227751 },
                { 107.740253757515, 23.172044928013 },
                { 107.739869281082, 23.1718262300426 },
                { 107.739789179397, 23.1719229687229 },
                { 107.740109562638, 23.1722060231074 },
                { 107.740283891099, 23.1718843884705 },
                { 107.739908616613, 23.1721244581715 },
                { 107.740456941346, 23.171955354053 },
                { 107.739775905586, 23.1718647897894 },
                { 107.739910899659, 23.1717039889273 },
                { 107.740289075343, 23.1716186337573 },
                { 107.739949394724, 23.171506240555 },
                { 107.739932221015, 23.1716027243754 },
                { 107.740295228809, 23.1716475314679 },
                { 107.740110388037, 23.1713426960706 },
                { 107.740000979798, 23.1716693560547 },
                { 107.740683952325, 23.1709681704731 },
                { 107.740203119785, 23.1714519510736 },
                { 107.740273707513, 23.1713702195282 },
                { 107.740715664145, 23.1708006096487 },
                { 107.740242143812, 23.1714449185373 },
                { 107.740687548443, 23.1714370988362 },
                { 107.740393828828, 23.1711679651411 },
                { 107.740547330181, 23.1707733940985 },
                { 107.740304974691, 23.1709983145174 },
                { 107.74034540204, 23.1710469626238 },
                { 107.740904365499, 23.1712337543625 },
                { 107.740271422439, 23.1707876401664 },
                { 107.740473226403, 23.1707728540074 },
                { 107.740636055235, 23.1704881107108 },
                { 107.740425649522, 23.1706972672815 },
                { 107.741075014634, 23.1711886612524 },
                { 107.740786717375, 23.1703917179741 },
                { 107.740612480474, 23.1707997640991 },
                { 107.740513888292, 23.1702033095878 },
                { 107.740861057518, 23.1707917436653 },
                { 107.740431450664, 23.1704962321596 },
                { 107.740894364108, 23.1706460451468 },
                { 107.740737653969, 23.1699454114361 },
                { 107.741167338868, 23.1704390641158 },
                { 107.7413536072, 23.1702117449598 },
                { 107.741086391515, 23.1708025027409 },
                { 107.740817260861, 23.1707126761071 },
                { 107.741221711022, 23.1703529560508 },
                { 107.740861537438, 23.1703420196572 },
                { 107.74133696574, 23.1699266624604 },
                { 107.741008974082, 23.1698332023904 },
                { 107.741330374957, 23.1699747581779 },
                { 107.740956577025, 23.1699971703065 },
                { 107.741383593614, 23.1700614545797 },
                { 107.741111473117, 23.1693429455465 },
                { 107.741121545844, 23.1698626383014 },
                { 107.740820518692, 23.1696821611261 },
                { 107.740916798005, 23.1696481452449 },
                { 107.741407098196, 23.1697794065368 },
                { 107.741287855641, 23.1694896025056 },
                { 107.741231209856, 23.1697278715938 },
                { 107.741571326879, 23.1696485314836 },
                { 107.741256422563, 23.1692796164232 },
                { 107.741083941569, 23.1692085591873 },
                { 107.742137813992, 23.1692501809322 },
                { 107.741681536193, 23.1691250721346 },
                { 107.741303539868, 23.1692497992003 },
                { 107.741635549928, 23.1696783769589 },
                { 107.741659390834, 23.1692018221502 },
                { 107.741519314827, 23.1689582724524 },
                { 107.741584255568, 23.1690406639767 },
                { 107.741457448448, 23.1689571870363 },
                { 107.741598496613, 23.1690963575179 },
                { 107.741640939783, 23.1689548869089 },
                { 107.741369971733, 23.1688034552239 },
                { 107.741859029521, 23.1688553893107 },
                { 107.741963565581, 23.1683666431612 },
                { 107.741666822527, 23.1688987338326 },
                { 107.741641792823, 23.1689634685279 },
                { 107.742023968239, 23.1690510611327 },
                { 107.741962846523, 23.1688076089897 },
                { 107.741683243803, 23.1683235937605 },
                { 107.742121706882, 23.1689619396987 },
                { 107.741538062532, 23.168283426697 },
                { 107.742422013432, 23.1687801621234 },
                { 107.741896618583, 23.1686362544736 },
                { 107.741972513575, 23.1686551496664 },
                { 107.74206679923, 23.168500337937 },
                { 107.742405073144, 23.1684770104653 },
                { 107.742032294448, 23.1683475533958 },
                { 107.742230287337, 23.1682284222132 },
                { 107.742201384546, 23.1682279605208 },
                { 107.741884032454, 23.1682565185304 }
            };

            var data2 = new double[100, 2]
            {
                { 107.739477771965, 69.1728347555165 },
                { 107.73961196667, 69.1726830767986 },
                { 107.739409817125, 69.1725933008645 },
                { 107.74019077671, 69.172494940147 },
                { 107.740585586026, 69.1726077103564 },
                { 107.74059838218, 69.1722819118463 },
                { 107.740208274081, 69.1723120729806 },
                { 107.740712281929, 69.1720791829606 },
                { 107.74033612626, 69.1723780587458 },
                { 107.741242715081, 69.1721192003436 },
                { 107.741266002392, 69.1722343854433 },
                { 107.741105006249, 69.1721003309252 },
                { 107.741363419742, 69.172088671089 },
                { 107.741690798727, 69.1722568414364 },
                { 107.741666861184, 69.17205417308 },
                { 107.741361837266, 69.1720675384819 },
                { 107.742084712903, 69.1718874998462 },
                { 107.742042010619, 69.1719175816475 },
                { 107.742280817921, 69.1719094396275 },
                { 107.742577304285, 69.1717986068223 },
                { 107.741966244595, 69.1718798130166 },
                { 107.742684141694, 69.1718510228511 },
                { 107.742976630078, 69.17157595174 },
                { 107.743352294911, 69.1715857376448 },
                { 107.743061556848, 69.1714241326127 },
                { 107.743090113926, 69.1714458284253 },
                { 107.743275509384, 69.1715522559223 },
                { 107.743176399757, 69.1714823812197 },
                { 107.743814300524, 69.1713901151672 },
                { 107.743767969983, 69.1714428793583 },
                { 107.743858065548, 69.1713035534992 },
                { 107.743822885639, 69.1712307918348 },
                { 107.744334295083, 69.1713055626603 },
                { 107.744427875787, 69.1712388751409 },
                { 107.744340783728, 69.1710928940912 },
                { 107.744805413896, 69.1710055991679 },
                { 107.74502108349, 69.1709137441353 },
                { 107.744828974649, 69.1709496406011 },
                { 107.74512401154, 69.1708573778863 },
                { 107.745281281021, 69.1708161629737 },
                { 107.745576469803, 69.1710203029433 },
                { 107.745740147716, 69.1707075932863 },
                { 107.745502577032, 69.1708074622807 },
                { 107.745623997879, 69.1706684821245 },
                { 107.746509028511, 69.1708362938784 },
                { 107.74602549245, 69.1706568551002 },
                { 107.745897609677, 69.170596921634 },
                { 107.746469521491, 69.1704027875192 },
                { 107.746277468908, 69.1703449453588 },
                { 107.74672857027, 69.1705498632184 },
                { 107.746946720371, 69.1702725215642 },
                { 107.746884661238, 69.1704713141467 },
                { 107.746860604767, 69.1702156222331 },
                { 107.747294089089, 69.1701998357532 },
                { 107.747620144745, 69.1702161529364 },
                { 107.747858455982, 69.170059426359 },
                { 107.747632580795, 69.1700516486805 },
                { 107.747755094573, 69.1698765265442 },
                { 107.747994751954, 69.1701514424405 },
                { 107.748121399878, 69.1700667592208 },
                { 107.748172662863, 69.1698849007696 },
                { 107.748228803142, 69.1699923304849 },
                { 107.749014214424, 69.1697868133965 },
                { 107.748792915115, 69.1700161340914 },
                { 107.748638559821, 69.1698409328545 },
                { 107.748636809009, 69.1697153039492 },
                { 107.749136438823, 69.1697074633957 },
                { 107.749338377121, 69.1697654496001 },
                { 107.749569612206, 69.1697500026688 },
                { 107.749595422398, 69.169419529115 },
                { 107.750383523525, 69.1696656542994 },
                { 107.75048831811, 69.1692035028989 },
                { 107.750352623105, 69.1693815488115 },
                { 107.750761537512, 69.1692866838914 },
                { 107.750685403332, 69.1693024139098 },
                { 107.750705748086, 69.1692717484141 },
                { 107.750843059166, 69.1692580533525 },
                { 107.750716179597, 69.1691529497331 },
                { 107.75072202975, 69.1691168107163 },
                { 107.75108559747, 69.1691834005496 },
                { 107.751493043153, 69.1691522809292 },
                { 107.751596829163, 69.169012841963 },
                { 107.75131727043, 69.1688012714158 },
                { 107.751666922544, 69.1689359714136 },
                { 107.751578388338, 69.1687399323656 },
                { 107.751905351653, 69.1688376229061 },
                { 107.752250104552, 69.1687619831483 },
                { 107.752678677296, 69.1687244251449 },
                { 107.752525957028, 69.1686536798413 },
                { 107.752373714866, 69.1686287601216 },
                { 107.753019411842, 69.1686380478501 },
                { 107.752741905599, 69.1684961094107 },
                { 107.753018243388, 69.1683971436757 },
                { 107.752942371889, 69.1684595315802 },
                { 107.753259742823, 69.1684806579804 },
                { 107.753511849838, 69.168268224757 },
                { 107.75342673874, 69.1685388792275 },
                { 107.753991832751, 69.1681999371544 },
                { 107.753606583523, 69.1682240722345 },
                { 107.753806764198, 69.1682937040626 },
            };

            var data = new double[100, 2]
            {
                { 107.73935730677, 69.172711754819 },
                { 107.739941719805, 69.1725607327368 },
                { 107.739969545763, 69.1728020832412 },
                { 107.739725613496, 69.1724948444009 },
                { 107.739031353708, 69.1726159366499 },
                { 107.739747958109, 69.1721826902977 },
                { 107.74074663056, 69.1722130865804 },
                { 107.739619292955, 69.1724872676585 },
                { 107.739526386824, 69.1723097829692 },
                { 107.7410771233, 69.1725703918204 },
                { 107.740739660076, 69.1724144742981 },
                { 107.740697636644, 69.1721550394849 },
                { 107.741880544558, 69.1719738870443 },
                { 107.741833247397, 69.1721940884685 },
                { 107.742314186337, 69.17193450189 },
                { 107.740926254247, 69.1721384298611 },
                { 107.741970497859, 69.1721455511604 },
                { 107.742119450987, 69.1721636360282 },
                { 107.742132805385, 69.1719603779096 },
                { 107.742777129314, 69.1714210932301 },
                { 107.743075397391, 69.1714527431053 },
                { 107.743768675633, 69.1715943552255 },
                { 107.742542542626, 69.1716645234002 },
                { 107.743524460336, 69.1716088168889 },
                { 107.743350115709, 69.1717882604853 },
                { 107.743489485345, 69.1721692852173 },
                { 107.74401344733, 69.1717430018303 },
                { 107.743001358569, 69.171745750306 },
                { 107.744101155658, 69.1715995718388 },
                { 107.743357827113, 69.1709192593056 },
                { 107.744693317033, 69.1716866797303 },
                { 107.74508962137, 69.1713006067015 },
                { 107.743997983147, 69.1708910615953 },
                { 107.743996491802, 69.1715212096561 },
                { 107.74373222623, 69.1709626863127 },
                { 107.744993875976, 69.1714069871322 },
                { 107.744573043011, 69.1710885783853 },
                { 107.744610440986, 69.1709524781463 },
                { 107.744515880438, 69.171012647055 },
                { 107.745021853434, 69.1706795177817 },
                { 107.745928469586, 69.1709513201446 },
                { 107.746274328526, 69.1709990525173 },
                { 107.746003621776, 69.1703636654999 },
                { 107.746860479622, 69.1707788370646 },
                { 107.746015994963, 69.170532070676 },
                { 107.745308266138, 69.1703833282827 },
                { 107.747434171025, 69.1707583505672 },
                { 107.746380716695, 69.1707477283657 },
                { 107.746322773734, 69.1705759472448 },
                { 107.747195770778, 69.1704783387962 },
                { 107.746726832268, 69.1705445287354 },
                { 107.746479807916, 69.170295182694 },
                { 107.746858852632, 69.170151842435 },
                { 107.748005552167, 69.1701324143026 },
                { 107.746440725163, 69.1702997117708 },
                { 107.747632752596, 69.1699714950714 },
                { 107.746288060495, 69.170247112624 },
                { 107.748643753256, 69.1698662806951 },
                { 107.74881046717, 69.1699979516342 },
                { 107.747535292112, 69.170078645581 },
                { 107.747766333879, 69.1699744718271 },
                { 107.748809227233, 69.1700193921839 },
                { 107.749697498078, 69.1695793718616 },
                { 107.74893998829, 69.1698713857366 },
                { 107.748878487794, 69.1695228880432 },
                { 107.74904534252, 69.1698472549382 },
                { 107.749463140037, 69.1696628177742 },
                { 107.749830174792, 69.1698519550262 },
                { 107.749699649195, 69.1695956041761 },
                { 107.750502343619, 69.1693099555417 },
                { 107.750326261356, 69.1691415029809 },
                { 107.748673873243, 69.1692620977489 },
                { 107.75106313072, 69.1690631812159 },
                { 107.75052688368, 69.1691938573698 },
                { 107.750543324985, 69.1695068538202 },
                { 107.751031016666, 69.1692150774484 },
                { 107.751096804392, 69.1688797213772 },
                { 107.75042386222, 69.1690032179007 },
                { 107.750153005185, 69.169176739356 },
                { 107.751104742713, 69.1687864249361 },
                { 107.751084417858, 69.1690641095538 },
                { 107.751285471877, 69.1690996992436 },
                { 107.751597211541, 69.169157134543 },
                { 107.751909360988, 69.1690350795147 },
                { 107.752462310445, 69.1684796654783 },
                { 107.751635885797, 69.1688208914861 },
                { 107.752428595531, 69.1685312843568 },
                { 107.753169064017, 69.1685892661358 },
                { 107.752228822227, 69.1685323946141 },
                { 107.753263916127, 69.168469632772 },
                { 107.753442528401, 69.1684911064022 },
                { 107.753490171167, 69.168976339076 },
                { 107.753304279553, 69.1685787342008 },
                { 107.75333647205, 69.1683355355218 },
                { 107.753820078749, 69.1683194672346 },
                { 107.753790511111, 69.1683609672304 },
                { 107.754442898298, 69.1681319406902 },
                { 107.753649542414, 69.1683447688382 },
                { 107.754436235939, 69.1684819745314 },
                { 107.754808387808, 69.1680718218884 },
            };
            #endregion

            double SEC_TO_DAY = 1.0 / (24 * 3600);

            for (int i = 0; i < 100; i++)
            {
                var ra = data[i, 0];
                var de = data[i, 1];

                regressionRA.AddDataPoint(i * SEC_TO_DAY, ra);
                regressionDE.AddDataPoint(i * SEC_TO_DAY, de);

                regressionRACosDE.AddDataPoint(i * SEC_TO_DAY, ra * Math.Cos(de * Math.PI / 180.0));
            }

            regressionRA.Solve();
            regressionDE.Solve();
            regressionRACosDE.Solve();

            double      timeOfDay = 50 * SEC_TO_DAY;
            ErrorMethod errMethod = ErrorMethod.HalfStdDev;

            double errRAArcSec;
            double errDEArcSec;

            var raHours = regressionRA.ComputeYWithError(timeOfDay, out errRAArcSec, errMethod) / 15.0;
            var deDeg   = regressionDE.ComputeYWithError(timeOfDay, out errDEArcSec, errMethod);

            double cosDEFactor = Math.Cos(deDeg * Math.PI / 180);


            double errRACosDEArcSec = errRAArcSec * cosDEFactor * 3600;
            errDEArcSec *= 3600;

            Trace.WriteLine(string.Format("RA = {0} +/- {1:0.00}\" StdDev={4:0.000}; DE={2} +/- {3:0.00}\"",
                                          AstroConvert.ToStringValue(raHours, "HH MM SS.TT"), errRACosDEArcSec, AstroConvert.ToStringValue(deDeg, "+DD MM SS.T"), errDEArcSec, regressionRA.StdDevUnscaled * cosDEFactor * 3600));

            double errRA2;
            var    raHoursCosDE = regressionRACosDE.ComputeYWithError(timeOfDay, out errRA2, errMethod) / 15.0;
            raHours = raHoursCosDE / cosDEFactor;
            errRA2 *= 3600;

            Trace.WriteLine(string.Format("RA = {0} +/- {1:0.00}\" StdDev={4:0.000}; DE={2} +/- {3:0.00}\"",
                                          AstroConvert.ToStringValue(raHours, "HH MM SS.TT"), errRA2, AstroConvert.ToStringValue(deDeg, "+DD MM SS.T"), errDEArcSec, regressionRACosDE.StdDevUnscaled * 3600));

            Assert.IsTrue(regressionRA.StdDevUnscaled * cosDEFactor < regressionRACosDE.StdDevUnscaled);

            // NOTE: StdDev in the RA fit appears to be smaller in RA.CosDE terms when the fitting is done in RA, compared to when it is done in RA.CosDE.
            // Therefore we continue to use the RA fitting, rather than RA.CosDE fitting.
            // TODO: This needs to be looked through and proper mathematical evaluation needs to be done for the uncertainties before the RA.CosDE fitting can be used directly
        }