Ejemplo n.º 1
0
        private PolynomialFitResult PolynomialFit(long Number_Obs, double Time_First_JD, double[] SecondsFromTimeFirstJD,
		                             double[] Variable_Star_DN, double[] Variable_Sky_DN, double[] Comparison_Star_DN,
		                             double[] Comparison_Sky_DN,
                                     int firstObsIndex, int lastObsIndex, double kweeVanWoerdenT0)
        {
            // http://var2.astro.cz/library/1350745528_ebfit.pdf
            //
            // Mag(t) = M0 + C1 * F(t, t0, d, G)
            // F(t, t0, d, G) = 1 - {1 - Exp[1 - cosh((t - t0 / d))] } ^ G;
            // t0 - time of minimum
            // d > 0 is the minimum width
            // G > 0 - the pointedness, G > 1 corresponds to flat minima (total eclipse)
            //
            // -----------------------------------------------------------------------------
            //
            // We use a simplified model:
            //
            // Mag(t) = M0 - C * {1 - Exp[1 - cosh((t - T0 / D))] } ^ G
            //
            // Where M0 is a constrant and we don't fit for it
            // C has been fixed to +1
            // t0 is taken from the KweeVanWoerden solution
            // ------------------------------------------------------------------------------

            var rv = new PolynomialFitResult();
            rv.TimePoints = new List<double>();

            var dataPointsVar = new List<double>();
            var dataPointsComp = new List<double>();

            for (int i = 0; i < Number_Obs; i++)
            {
                double y = (Variable_Star_DN[i] - Variable_Sky_DN[i]) / (Comparison_Star_DN[i] - Comparison_Sky_DN[i]);
                if (i >= firstObsIndex && i < lastObsIndex)
                {
                    double x = SecondsFromTimeFirstJD[i] / (24 * 3600);
                    rv.TimePoints.Add(x);
                    dataPointsVar.Add(Variable_Star_DN[i] - Variable_Sky_DN[i]);
                    dataPointsComp.Add(Comparison_Star_DN[i] - Comparison_Sky_DN[i]);
                }

                rv.DataPoints.Add(y);
            }

            var fitter = new ModelFitter(rv.TimePoints.Count, rv.TimePoints.ToArray(), dataPointsVar.ToArray(), dataPointsComp.ToArray());
            fitter.Solve(true, kweeVanWoerdenT0);

            for (int i = 0; i < Number_Obs; i++)
            {
                if (i >= firstObsIndex && i < lastObsIndex)
                    rv.FittedValues.Add(fitter.NormIntensities[i - firstObsIndex]);
                else
                    rv.FittedValues.Add(double.NaN);
            }

            rv.G = fitter.G;
            rv.M0 = fitter.M0;
            rv.C = fitter.C;
            rv.D = fitter.D;
            rv.T0 = fitter.T0;

            rv.StartIndex = firstObsIndex;
            rv.StopIndex = lastObsIndex;

            rv.Time_Of_Minimum_JD = Time_First_JD + fitter.T0;
            rv.Time_Of_Minimum_Uncertainty = 0; // Math.Sqrt((4.0 * rv.A * rv.C - rv.B * rv.B) / (4.0 * rv.A * rv.A) / ((float)(rv.TimePoints.Count / 4.0 - 1.0)));

            return rv;
        }
Ejemplo n.º 2
0
        private PolynomialFitResult PolynomialFit(long Number_Obs, double Time_First_JD, double[] SecondsFromTimeFirstJD,
                                                  double[] Variable_Star_DN, double[] Variable_Sky_DN, double[] Comparison_Star_DN,
                                                  double[] Comparison_Sky_DN,
                                                  int firstObsIndex, int lastObsIndex, double kweeVanWoerdenT0)
        {
            // http://var2.astro.cz/library/1350745528_ebfit.pdf
            //
            // Mag(t) = M0 + C1 * F(t, t0, d, G)
            // F(t, t0, d, G) = 1 - {1 - Exp[1 - cosh((t - t0 / d))] } ^ G;
            // t0 - time of minimum
            // d > 0 is the minimum width
            // G > 0 - the pointedness, G > 1 corresponds to flat minima (total eclipse)
            //
            // -----------------------------------------------------------------------------
            //
            // We use a simplified model:
            //
            // Mag(t) = M0 - C * {1 - Exp[1 - cosh((t - T0 / D))] } ^ G
            //
            // Where M0 is a constrant and we don't fit for it
            // C has been fixed to +1
            // t0 is taken from the KweeVanWoerden solution
            // ------------------------------------------------------------------------------

            var rv = new PolynomialFitResult();

            rv.TimePoints = new List <double>();


            var dataPointsVar  = new List <double>();
            var dataPointsComp = new List <double>();

            for (int i = 0; i < Number_Obs; i++)
            {
                double y = (Variable_Star_DN[i] - Variable_Sky_DN[i]) / (Comparison_Star_DN[i] - Comparison_Sky_DN[i]);
                if (i >= firstObsIndex && i < lastObsIndex)
                {
                    double x = SecondsFromTimeFirstJD[i] / (24 * 3600);
                    rv.TimePoints.Add(x);
                    dataPointsVar.Add(Variable_Star_DN[i] - Variable_Sky_DN[i]);
                    dataPointsComp.Add(Comparison_Star_DN[i] - Comparison_Sky_DN[i]);
                }

                rv.DataPoints.Add(y);
            }

            var fitter = new ModelFitter(rv.TimePoints.Count, rv.TimePoints.ToArray(), dataPointsVar.ToArray(), dataPointsComp.ToArray());

            fitter.Solve(true, kweeVanWoerdenT0);

            for (int i = 0; i < Number_Obs; i++)
            {
                if (i >= firstObsIndex && i < lastObsIndex)
                {
                    rv.FittedValues.Add(fitter.NormIntensities[i - firstObsIndex]);
                }
                else
                {
                    rv.FittedValues.Add(double.NaN);
                }
            }

            rv.G  = fitter.G;
            rv.M0 = fitter.M0;
            rv.C  = fitter.C;
            rv.D  = fitter.D;
            rv.T0 = fitter.T0;

            rv.StartIndex = firstObsIndex;
            rv.StopIndex  = lastObsIndex;

            rv.Time_Of_Minimum_JD          = Time_First_JD + fitter.T0;
            rv.Time_Of_Minimum_Uncertainty = 0;         // Math.Sqrt((4.0 * rv.A * rv.C - rv.B * rv.B) / (4.0 * rv.A * rv.A) / ((float)(rv.TimePoints.Count / 4.0 - 1.0)));

            return(rv);
        }