Пример #1
0
        /// <summary>
        /// this will move date to the nearest conjunction
        /// whether it is in future or in the past
        /// </summary>
        /// <returns></returns>
        protected GPGregorianTime movePosition()
        {
            double position = 0;
            double diff;
            double seconds     = 0.5 / 86400.0;
            double prevSeconds = -1;

            for (int i = 0; i < 10; i++)
            {
                position = calculatePosition() / 360;
                if (Math.Abs(pJulianDate - prevSeconds) < seconds)
                {
                    break;
                }

                prevSeconds = pJulianDate;

                diff         = position * 30;
                pJulianDate -= diff;
                pStartDate.addDayHours(diff);
            }

            GPGregorianTime nt = new GPGregorianTime(pStartDate.getLocation());

            nt.setJulianGreenwichTime(new GPJulianTime(GPAstroEngine.ConvertDynamicToUniversal(pJulianDate), 0.0));
            return(nt);
        }
Пример #2
0
        public static void TestSunCoordinates()
        {
            GPObserver obs = new GPObserver();

            obs.setLatitudeNorthPositive(defLatitude).setLongitudeEastPositive(defLongitude);
            GPJulianTime dp = new GPJulianTime();

            dp.setLocalJulianDay(2456710.500000);
            for (int k = 0; k < 26; k++)
            {
                //dp = MA.GPMeeusEngine.GetNextMoonEvent(dp, obs, out kind);
                GPCelestialBodyCoordinates crd = GPAstroEngine.sun_coordinate(dp.getGreenwichJulianEphemerisDay());
                //srt = MA.GPMeeusEngine.GetSiderealTime(dp.GetJulianDay(), out deltaphi, out epsilon);
                //crd = MA.GPMeeusEngine.moon_coordinate(2448724.5);
                crd.makeTopocentric(obs);
                GPAstroEngine.calcHorizontal(crd, obs);
                //Log("time {0}   deltaphi {1}  epsilon {2} sidereal {3}", dp, deltaphi, epsilon, srt/15);
                //Log("time {0}   altitude {1}  azimuth {2}", dp, crd.elevation, crd.azimuth);
                //Log("time {0}   ra {1}  dec {2}", dp, crd.right_ascession, crd.declination);
                //Log("RA={0} DEC={1}", crd.right_ascession, crd.elevation);
                //Log("AZ={0} EL={1} RA", crd.azimuth, crd.elevation);
                Log("{0}", crd.elevation);
                //                Log("next event = {0}, {1}, {2}\n", dp, kind, crd.elevation);
                dp.AddHours(1);
            }
        }
Пример #3
0
        public static void CalcMoonTimes(GPLocationProvider e, GPGregorianTime vc, out GPGregorianTime rise, out GPGregorianTime set)
        {
            double UT;

            rise = null;
            set  = null;

            // inicializacia prvej hodnoty ELEVATION
            vc.setDayHours(0.0);
            vc.normalizeValues();
            UT = vc.getJulianGreenwichTime();
            GPJulianTime start = new GPJulianTime();
            GPJulianTime time;

            start.setLocalJulianDay(vc.getJulianGreenwichTime());
            TRiseSet rs;

            set  = null;
            rise = null;
            time = GPAstroEngine.GetNextMoonEvent(start, e, out rs);
            while (time.getLocalJulianDay() < UT + 1)
            {
                GPGregorianTime gt = new GPGregorianTime(e, time);
                if (rs == TRiseSet.RISE && rise == null)
                {
                    rise = gt;
                }
                else if (rs == TRiseSet.SET && set == null)
                {
                    set = gt;
                }
                time = GPAstroEngine.GetNextMoonEvent(time, e, out rs);
            }
        }
Пример #4
0
 public void MoonCalc(double jdate)
 {
     coord           = GPAstroEngine.moon_coordinate(jdate);
     radius          = coord.distanceFromEarth;
     longitude_deg   = coord.eclipticalLongitude;
     latitude_deg    = coord.eclipticalLatitude;
     declination     = coord.declination;
     right_ascession = coord.right_ascession;
 }
Пример #5
0
        public GPGregorianTime movePosition(int dir)
        {
            double unitLength = getUnitAverageLength();
            int    unitCount  = getUnitCount();

            double lowerLimit = 0.5;
            double upperLimit = unitCount - 0.5;
            double position   = 0;
            bool   over       = false;
            bool   under      = false;
            double nextTithi  = getCurrentPosition() + dir;
            double diff;
            double seconds     = 0.5 / 86400.0;
            double prevSeconds = -1;

            if (dir > 0)
            {
                over  = (nextTithi > upperLimit);
                under = (currentPosition < lowerLimit);
            }
            else
            {
                over  = (currentPosition > upperLimit);
                under = (nextTithi < lowerLimit);
            }
            for (int i = 0; i < 10; i++)
            {
                position = calculatePosition();
                //seconds = Convert.ToInt32((pJulianDate - Math.Floor(pJulianDate)) * 86400);
                if (Math.Abs(pJulianDate - prevSeconds) < seconds)
                {
                    break;
                }
                if (over && position < lowerLimit)
                {
                    position += unitCount;
                }
                else if (under && position > upperLimit)
                {
                    position -= unitCount;
                }

                prevSeconds = pJulianDate;

                diff         = (nextTithi - position) * unitLength;
                pJulianDate += diff;
                pStartDate.addDayHours(diff);
            }

            currentPosition = Convert.ToInt32(nextTithi) % unitCount;

            GPGregorianTime nt = new GPGregorianTime(pStartDate.getLocation());

            nt.setJulianGreenwichTime(new GPJulianTime(GPAstroEngine.ConvertDynamicToUniversal(pJulianDate), 0.0));
            return(nt);
        }
Пример #6
0
 // tithi at sunset
 public int getTithiAtSunset()
 {
     if (p_tithi_sunset < 0)
     {
         GPCelestialBodyCoordinates moonCoord = GPAstroEngine.moon_coordinate(sun.set.getJulianGreenwichTime());
         double d = GPMath.putIn360(moonCoord.eclipticalLongitude - sun.longitude_set_deg - 180) / 12.0;
         p_tithi_sunset = Convert.ToInt32(Math.Floor(d));
     }
     return(p_tithi_sunset);
 }
Пример #7
0
        public void calculateCoordinatesMethodM(double julian)
        {
            double DG  = GPMath.rads;
            double RAD = 180 / GPMath.pi;

            double t  = (julian - 2451545.0) / 36525;
            double t2 = t * t;
            double t3 = t2 * t;
            double t4 = t2 * t2;

            // mean ecliptic longitude of the sun
            double L0 = 280.4664567 + 36000.76982779 * t + 0.0003032028 * t2 + t3 / 49931000;

            // mean anomaly of the sun
            double M = 357.5291 + 35999.05030 * t - 0.0001559 * t2 - 0.00000048 * t3;

            L0             = GPMath.putIn360(L0);
            M              = GPMath.putIn360(M);
            sunMeanAnomaly = M;

            double C = (1.9146 - 0.004817 * t - 0.000014 * t2) * GPMath.sinDeg(M)
                       + (0.019993 - 0.000101 * t) * GPMath.sinDeg(2 * M)
                       + 0.00029 * GPMath.sinDeg(3 * M);

            sunEquationCenter = C;

            // ecliptic longitude of the sun
            //double els = 0;
            eclipticalLongitude = GPMath.putIn360(L0 + C);

            double e           = 0.016708617 - 0.000042037 * t - 0.0000001236 * t2;
            double trueAnomaly = M + C;


//            double epsilon;
//            double deltaPhi;

//            GPAstroEngine.calc_epsilon_phi(julianDay, out deltaPhi, out epsilon);
//            = 23.4391 - 0.013 * t - t2/6101694;
            double omega    = 125.04 - 1934.136 * t;
            double lambda   = eclipticalLongitude - 0.00569 - 0.00478 * GPMath.sinDeg(omega);
            double epsilon0 = 23.4392911 - 0.01300416 * t - 1.638e-7 * t2;
            double epsilon1 = epsilon0 + 0.00256 * GPMath.cosDeg(omega);

            // right ascension of the sun
            this.rightAscession = RAD * Math.Atan2(GPMath.cosDeg(epsilon1) * GPMath.sinDeg(lambda), GPMath.cosDeg(lambda));
            this.rightAscession = GPMath.putIn360(rightAscession);

            // declination of the sun
            this.declination = GPMath.arcsinDeg(GPMath.sinDeg(epsilon1) * GPMath.sinDeg(lambda));

            // equation of time
            equationOfTime = GPAstroEngine.getEquationOfTime(julian, this.rightAscession);
        }
Пример #8
0
 /// <summary>
 /// This can be used only after calculating sunrise and sunset time
 /// using functions calculateRise and calculateSet
 /// </summary>
 /// <param name="vct"></param>
 /// <param name="earth"></param>
 private void updateNoonTimes(GPGregorianTime vct, GPLocationProvider earth)
 {
     noon = new GPGregorianTime(vct);
     if (sunPosMethod == SUNPOSMETHOD_CALCULATOR)
     {
         noon.setDayHours(SetDegTime((sunset_deg + sunrise_deg) / 2 + earth.getTimeZoneOffsetHours() * 15.0));
     }
     else
     {
         noon.setJulianGreenwichTime(GPAstroEngine.ConvertDynamicToUniversal(julianDayNoon));
     }
 }
Пример #9
0
        /// <summary>
        /// Calculates sidereal time at Greenwich.
        /// Based on Chapter 11 of Astronomical Algorithms.
        /// </summary>
        /// <param name="date">Julian Ephemeris Day</param>
        /// <returns>Sidereal time in degrees.</returns>
        public void SetSiderealTime(double date)
        {
            double t;

            //date = 2446896.30625;
            //jd = date;
            t = (date - GPAstroEngine.J2000) / 36525.0;
            GPAstroEngine.calc_epsilon_phi(date, out delta_phi, out epsilon);

            // 11.2
            mean_sidereal_time = GPMath.putIn360(280.46061837 + 360.98564736629 * (date - GPAstroEngine.J2000) +
                                                 t * t * (0.000387933 - t / 38710000));

            apparent_sidereal_time = GPMath.putIn360(mean_sidereal_time + delta_phi * GPMath.cosDeg(epsilon));
        }
Пример #10
0
        public static void TestSiderealTime()
        {
            GPObserver obs = new GPObserver();

            obs.setLatitudeNorthPositive(defLatitude).setLongitudeEastPositive(defLongitude);
            GPJulianTime dp = new GPJulianTime();

            dp.setLocalJulianDay(2456710.500000);
            for (int k = 0; k < 26; k++)
            {
                GPCelestialBodyCoordinates crd = GPAstroEngine.sun_coordinate(dp.getGreenwichJulianEphemerisDay());
                Log("{0}", crd.apparent_sidereal_time / 15);
                dp.AddHours(1);
            }
        }
Пример #11
0
        // return values are in sun.arunodaya, sun.rise, sun.set, sun.noon, sun.length
        // if values are less than zero, that means, no sunrise, no sunset in that day
        //
        // brahma 1 = calculation at brahma muhurta begining
        // brahma 0 = calculation at sunrise



        public void SunCalc(GPGregorianTime vct, GPLocationProvider earth)
        {
            if (sunPosMethod == SUNPOSMETHOD_CALCULATOR)
            {
                GPSun s_rise = new GPSun();
                GPSun s_set  = new GPSun();

                // first calculation
                // for 12:00 universal time
                s_rise.calculateRise(vct, earth);

                // first calculation
                // for 12:00 universal time
                s_set.calculateSet(vct, earth);

                // calculate times
                longitude_arun_deg  = s_rise.eclipticalLongitude - (24.0 / 365.25);
                eclipticalLongitude = s_rise.eclipticalLongitude;
                rightAscession      = s_rise.rightAscession;
                longitude_set_deg   = s_set.eclipticalLongitude;

                sunrise_deg = s_rise.sunrise_deg;
                sunset_deg  = s_set.sunset_deg;
            }
            else
            {
                calculateRiseSet(vct, earth, 180);
                double gmt = vct.getJulianGreenwichNoon();

                longitude_arun_deg  = GPAstroEngine.sunLongitudeMethodM(julianDayRise - 96 / 1440.0);
                eclipticalLongitude = GPAstroEngine.sunLongitudeMethodM(julianDayRise);
                longitude_set_deg   = GPAstroEngine.sunLongitudeMethodM(julianDaySet);
            }

            updateSunriseTimes(vct, earth);
            updateNoonTimes(vct, earth);
            updateSetTimes(vct, earth);

            List <GPLocationChange> chr = earth.getChangesForJulianDay(arunodaya.getJulianGreenwichNoon());

            processTravellingChanges(chr);

            // finally calculate length of the daylight
            DayLength = (set.getJulianGreenwichTime() - rise.getJulianGreenwichTime()) * 24.0;
        }
Пример #12
0
        private void calculateRiseSetMethodM(double D, GPLocationProvider ed)
        {
            GPLocation obs = ed.getLocation(D);
            double     a1, a2, a3;
            double     d1, d2, d3;
            double     siderealTime = GPAstroEngine.GetSiderealTime(D);
            double     h0           = -0.833333;

            calculateCoordinatesMethodM(D - 1);
            a1 = rightAscession;
            d1 = declination;
            calculateCoordinatesMethodM(D);
            a2 = rightAscession;
            d2 = declination;
            calculateCoordinatesMethodM(D + 1);
            a3 = rightAscession;
            d3 = declination;
            double longitude = -ed.GetLongitudeEastPositive();
            double latitude  = ed.GetLatitudeNorthPositive();
            double cosH0     = (GPMath.sinDeg(h0) - GPMath.sinDeg(latitude) * GPMath.sinDeg(d2))
                               / (GPMath.cosDeg(latitude) * GPMath.cosDeg(d2));
            double H0 = GPMath.arccosDeg(cosH0);

            H0 = GPMath.putIn180(H0);

            double m0     = (a2 + longitude - siderealTime) / 360;
            double m1     = m0 - H0 / 360;
            double m2     = m0 + H0 / 360;
            double deltaM = 0;

            deltaM = getCorrection(D, a1, a2, a3, d1, d2, d3, siderealTime, h0, longitude, latitude, m0, true);
            m0    += deltaM;
            deltaM = getCorrection(D, a1, a2, a3, d1, d2, d3, siderealTime, h0, longitude, latitude, m1, false);
            m1    += deltaM;
            deltaM = getCorrection(D, a1, a2, a3, d1, d2, d3, siderealTime, h0, longitude, latitude, m2, false);
            m2    += deltaM;

            julianDayRise = julianDay + m1;
            julianDayNoon = julianDay + m0;
            julianDaySet  = julianDay + m2;

            sunrise_deg = GPMath.putIn360(m1 * 360);
            noon_deg    = GPMath.putIn360(m0 * 360);
            sunset_deg  = GPMath.putIn360(m2 * 360);
        }
Пример #13
0
        public static void TestMoonEvents()
        {
            TRiseSet     kind;
            GPJulianTime dp = new GPJulianTime();

            dp.setLocalJulianDay(defJulian);
            GPLocation obs = new GPLocation();

            obs.setLatitudeNorthPositive(defLatitude).setLongitudeEastPositive(defLongitude).SetAltitude(0.2);
            GPLocationProvider prov = new GPLocationProvider(obs);

            for (int k = 0; k < 26; k++)
            {
                dp = GPAstroEngine.GetNextMoonEvent(dp, prov, out kind);
                Log("next event = {0}, {1}\n", dp, kind);
                dp.AddHours(1);
            }
        }
Пример #14
0
        public static void TestConjunctions()
        {
            Log("== start test conjunctions ==");

            double date = 2451919.500000;

            for (int i = 0; i < 30; i++)
            {
                date = GPAstroEngine.FindNextConjunction(date);
                Log("Conjunction at: {0}", date);
                if (date < 0)
                {
                    break;
                }
                date += 20;
            }
            Log("== end test conjunctions ==");
        }
Пример #15
0
        public static void TestSunEclipse()
        {
            Log("=== start sun eclipse ====");
            GPObserver obs = new GPObserver();
            double     srt;

            obs.setLongitudeEastPositive(-25.858).setLatitudeNorthPositive(-23.983);
            srt = 2452081.000000;
            GPAstroEngine.FindNextEclipse(ref srt, true);
            Log("Next eclipse = {0}", srt);
            double[] times = null;
            GPAstroEngine.CalculateTimesSunEclipse(srt, obs, out times);
            for (int i = 0; i < times.Length; i++)
            {
                Log("times[{0}] = {1}", times[i]);
            }
            Log("=== end sun eclipse ====");
        }
Пример #16
0
        public static void TestMoonEclipse()
        {
            Log("=== start moon eclipse ====");
            GPObserver obs = new GPObserver();
            double     srt;

            obs.setLongitudeEastPositive(-25.858).setLatitudeNorthPositive(-23.983);
            srt = 2451919.500000;
            //GPMeeusEngine.NextEclipse(ref srt, false);
            Log("Next eclipse = {0}", srt);
            double[] times = null;
            GPAstroEngine.CalculateTimesMoonEclipse(srt, obs, out times);

            for (int i = 0; i < times.Length; i++)
            {
                Log("times[{0}] = {1}", i, times[i]);
            }
            Log("=== end moon eclipse ====");
        }
Пример #17
0
        public void updateSunriseTimes(GPGregorianTime vct, GPLocationProvider earth)
        {
            arunodaya_deg      = sunrise_deg - 24.0;
            longitude_arun_deg = eclipticalLongitude - 24.0 / 365.25;
            arunodaya          = new GPGregorianTime(vct);
            rise = new GPGregorianTime(vct);

            if (sunPosMethod == SUNPOSMETHOD_CALCULATOR)
            {
                // arunodaya is 96 min before sunrise
                //  sunrise_deg is from range 0-360 so 96min=24deg
                arunodaya.setDayHours(SetDegTime(arunodaya_deg + earth.getTimeZoneOffsetHours() * 15.0));
                rise.setDayHours(SetDegTime(sunrise_deg + earth.getTimeZoneOffsetHours() * 15.0));
            }
            else
            {
                arunodaya.setJulianGreenwichTime(GPAstroEngine.ConvertDynamicToUniversal(julianDayRise - 96 / 1440.0));
                rise.setJulianGreenwichTime(GPAstroEngine.ConvertDynamicToUniversal(julianDayRise));
            }
        }
Пример #18
0
        private static double getCorrection(double D, double a1, double a2, double a3, double d1, double d2, double d3, double siderealTime, double h0, double longitude, double latitude, double m0, bool transit)
        {
            double deltaM = 0;
            double PHI    = siderealTime + 360.985647 * m0;
            double n      = m0 + GPDynamicTime.GetDeltaT(D) / 86400;

            double alpha = GPAstroEngine.interpolation(a1, a2, a3, n);
            double delta = GPAstroEngine.interpolation(d1, d2, d3, n);

            double H = GPMath.putIn180(PHI - longitude - alpha);
            double h = 0;

            if (transit)
            {
                deltaM = -H / 360;
            }
            else
            {
                double sinH = GPMath.sinDeg(latitude) * GPMath.sinDeg(delta) + GPMath.cosDeg(latitude) * GPMath.cosDeg(delta) * GPMath.cosDeg(H);
                h      = GPMath.arcsinDeg(sinH);
                deltaM = (h - h0) / (360 * GPMath.cosDeg(delta) * GPMath.cosDeg(latitude) * GPMath.sinDeg(H));
            }
            return(deltaM);
        }
Пример #19
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="arg">Julian Ephemeris (Dynamical) Time</param>
        /// <returns></returns>
        public override double getDoubleValue(double arg)
        {
            coordMoon = GPAstroEngine.moon_coordinate(arg);
            coordSun  = GPAstroEngine.sun_coordinate(arg);

            switch (valueType)
            {
            case ValueType.Longitude:
                return(GPMath.putIn180(coordMoon.eclipticalLongitude - coordSun.eclipticalLongitude));

            case ValueType.Latitude:
                return(GPMath.putIn180(coordMoon.eclipticalLatitude - coordSun.eclipticalLatitude));

            case ValueType.Azimuth:
                if (obs != null)
                {
                    coordMoon.makeTopocentric(obs);
                    GPAstroEngine.calcHorizontal(coordMoon, obs);

                    GPAstroEngine.calcHorizontal(coordSun, obs);
                    return(GPMath.putIn180(coordMoon.azimuth - coordSun.azimuth));
                }
                break;

            case ValueType.Elevation:
                if (obs != null)
                {
                    coordMoon.makeTopocentric(obs);
                    GPAstroEngine.calcHorizontal(coordMoon, obs);
                    GPAstroEngine.calcHorizontal(coordSun, obs);
                    return(GPMath.putIn180(coordMoon.elevation - coordSun.elevation));
                }
                break;

            case ValueType.DeclinationTopo:
                if (obs != null)
                {
                    coordMoon.makeTopocentric(obs);
                    return(GPMath.putIn180(coordMoon.declination - coordSun.declination));
                }
                break;

            case ValueType.RightAscessionTopo:
                if (obs != null)
                {
                    coordMoon.makeTopocentric(obs);
                    return(GPMath.putIn180(coordMoon.right_ascession - coordSun.right_ascession));
                }
                break;

            case ValueType.Declination:
                return(GPMath.putIn180(coordMoon.declination - coordSun.declination));

            case ValueType.TithiDistance:
            {
                double tithi = getTithiDouble();
                tithi = 0.51 - Math.Abs(tithi - Math.Floor(tithi) - 0.5);
                return(tithi);
            }

            case ValueType.YogaDistance:
            {
                double yoga = getYogaDouble(arg);
                yoga = 0.51 - Math.Abs(yoga - Math.Floor(yoga) - 0.5);
                return(yoga);
            }

            case ValueType.RightAscession:
                return(GPMath.putIn180(coordMoon.right_ascession - coordSun.right_ascession));

            case ValueType.RightAscessionAbs:
                return(Math.Abs(GPMath.putIn180(coordMoon.right_ascession - coordSun.right_ascession)));

            case ValueType.ApparentSiderealTime:
                return(coordMoon.apparent_sidereal_time);

            case ValueType.MeanSiderealTime:
                return(coordMoon.mean_sidereal_time);

            case ValueType.DynamicTime:
                return(coordMoon.getDynamicTime());

            case ValueType.Nutation:
                return(coordMoon.getNutation());

            case ValueType.Obliquity:
                return(coordMoon.getObliquity());

            case ValueType.AzimuthElevationDistance:
                if (obs != null)
                {
                    coordMoon.makeTopocentric(obs);
                    GPAstroEngine.calcHorizontal(coordMoon, obs);
                    GPAstroEngine.calcHorizontal(coordSun, obs);
                    return(GPMath.arcDistanceDeg(coordMoon.azimuth, coordMoon.elevation, coordSun.azimuth, coordSun.elevation));
                }
                break;

            case ValueType.RigthAscessionDeclinationDistance:
                return(GPMath.arcDistanceDeg(coordMoon.right_ascession, coordMoon.declination, coordSun.right_ascession, coordSun.declination));

            case ValueType.RigthAscessionDeclinationOpositeDistance:
                return(GPMath.arcDistanceDeg(180 + coordMoon.right_ascession, -coordMoon.declination, coordSun.right_ascession, coordSun.declination));

            case ValueType.Tithi:
                return(getTithiDouble());

            case ValueType.Yoga:
                return(getYogaDouble(arg));

            default:
                break;
            }

            return(0);
        }
Пример #20
0
        public override double getDoubleValue(double arg)
        {
            coord = GPAstroEngine.sun_coordinate(arg);

            switch (valueType)
            {
            case ValueType.Longitude:
                return(coord.eclipticalLongitude);

            case ValueType.Latitude:
                return(coord.eclipticalLatitude);

            case ValueType.Azimuth:
                if (obs != null)
                {
                    GPAstroEngine.calcHorizontal(coord, obs);
                    return(coord.azimuth);
                }
                break;

            case ValueType.Elevation:
                if (obs != null)
                {
                    GPAstroEngine.calcHorizontal(coord, obs);
                    return(coord.elevation);
                }
                break;

            case ValueType.DeclinationTopo:
                return(coord.declination);

            case ValueType.RightAscessionTopo:
                return(coord.right_ascession);

            case ValueType.Declination:
                return(coord.declination);

            case ValueType.RightAscession:
                return(coord.right_ascession);

            case ValueType.Distance:
                return(coord.distanceFromEarth);

            case ValueType.ApparentSiderealTime:
                return(coord.apparent_sidereal_time);

            case ValueType.MeanSiderealTime:
                return(coord.mean_sidereal_time);

            case ValueType.DynamicTime:
                return(coord.getDynamicTime());

            case ValueType.Nutation:
                return(coord.getNutation());

            case ValueType.Obliquity:
                return(coord.getObliquity());

            case ValueType.Sankranti:
                return(getSankrantiDouble(arg));

            case ValueType.SankrantiDistance:
            {
                double sankranti = getSankrantiDouble(arg);
                sankranti = 0.51 - Math.Abs(sankranti - Math.Floor(sankranti) - 0.5);
                return(sankranti);
            }

            default:
                break;
            }

            return(0);
        }
Пример #21
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="jdate">Julian day (Universal Time)</param>
        /// <returns>Returns value of ecliptic longitude</returns>
        public static double GetSunLongitude(double jdate)
        {
            GPCelestialBodyCoordinates coord = GPAstroEngine.sun_coordinate(jdate);

            return(coord.eclipticalLongitude);
        }
Пример #22
0
        public void CalculateEvents(GPLocationProvider loc, GPGregorianTime vcStart, GPGregorianTime vcEnd)
        {
            GPCoreEventResults inEvents = this;
            GPLocationProvider earth    = loc;
            GPGregorianTime    vc       = new GPGregorianTime(loc);
            GPSun sun = new GPSun();
            //int ndst = 0;
            int nData;

            inEvents.clear();
            inEvents.m_location = loc;
            inEvents.m_vcStart  = vcStart;
            inEvents.m_vcEnd    = vcEnd;

            GPGregorianTime vcAdd  = new GPGregorianTime(loc);
            GPGregorianTime vcTemp = null;
            GPGregorianTime vcNext = new GPGregorianTime(loc);

            vc.Copy(vcStart);

            if (GPDisplays.CoreEvents.Sunrise())
            {
                vcAdd.Copy(vc);
                while (vcAdd.IsBeforeThis(vcEnd))
                {
                    sun.SunCalc(vcAdd, earth);

                    vcTemp = new GPGregorianTime(sun.arunodaya);
                    inEvents.AddEvent(vcTemp, GPConstants.CCTYPE_S_ARUN, 0);

                    //GPJulianTime tr, tt, ts;
                    //GPAstroEngine.CalculateTimeSun(vcTemp, vcTemp.getLocation(), out tr, out tt, out ts);
                    vcTemp = new GPGregorianTime(sun.rise);
                    //vcTemp = new GPGregorianTime(vcTemp.getLocation(), tr);
                    inEvents.AddEvent(vcTemp, GPConstants.CCTYPE_S_RISE, 0);

                    vcTemp = new GPGregorianTime(sun.noon);
                    //vcTemp = new GPGregorianTime(vcTemp.getLocation(), tt);
                    inEvents.AddEvent(vcTemp, GPConstants.CCTYPE_S_NOON, 0);

                    vcTemp = new GPGregorianTime(sun.set);
                    //vcTemp = new GPGregorianTime(vcTemp.getLocation(), ts);
                    inEvents.AddEvent(vcTemp, GPConstants.CCTYPE_S_SET, 0);

                    vcAdd.NextDay();
                }
            }

            if (GPDisplays.CoreEvents.Tithi())
            {
                GPTithi te = new GPTithi();
                te.setStartDate(vc);
                vcAdd = te.getNext();
                while (vcAdd.IsBeforeThis(vcEnd))
                {
                    nData = te.getCurrentPosition();
                    //ndst = loc.getTimeZone().GetDaylightChangeType(vcNext);
                    inEvents.AddEvent(vcAdd, GPConstants.CCTYPE_TITHI, nData);
                    vcAdd = te.getNext();
                }
            }

            if (GPDisplays.CoreEvents.Naksatra())
            {
                GPNaksatra te = new GPNaksatra();
                te.setStartDate(vc);
                vcAdd = te.getNext();
                while (vcAdd.IsBeforeThis(vcEnd))
                {
                    nData = te.getCurrentNaksatra();
                    //ndst = loc.getTimeZone().GetDaylightChangeType(vcNext);
                    inEvents.AddEvent(vcAdd, GPConstants.CCTYPE_NAKS, nData);
                    vcAdd = te.getNext();
                }
            }

            if (GPDisplays.CoreEvents.Sankranti())
            {
                GPSankranti te = new GPSankranti();
                te.setStartDate(vc);
                vcAdd = te.getNext();
                while (vcAdd.IsBeforeThis(vcEnd))
                {
                    nData = te.getCurrentPosition();
                    //ndst = loc.getTimeZone().GetDaylightChangeType(vcNext);
                    inEvents.AddEvent(vcAdd, GPConstants.CCTYPE_SANK, nData);
                    vcAdd = te.getNext();
                }
            }

            if (GPDisplays.CoreEvents.Conjunction())
            {
                double[]      times = null;
                GPConjunction te    = new GPConjunction();
                te.setStartDate(vc);
                vcAdd = te.getNext();
                while (vcAdd.IsBeforeThis(vcEnd))
                {
                    nData = te.getCurrentPosition();
                    //ndst = loc.getTimeZone().GetDaylightChangeType(vcNext);
                    inEvents.AddEvent(vcAdd, GPConstants.CCTYPE_CONJ, nData);

                    if (GPDisplays.CoreEvents.SunEclipse())
                    {
                        GPAstroEngine.CalculateTimesSunEclipse(vcAdd.getJulianGreenwichTime(), vcAdd.getLocation(), out times);
                        if (times != null && times[2] > 0)
                        {
                            for (int i = 0; i < 5; i++)
                            {
                                if (times[i] > 0)
                                {
                                    GPGregorianTime gt = new GPGregorianTime(vcAdd.getLocation());
                                    gt.setJulianGreenwichTime(new GPJulianTime(times[i], 0.0));
                                    inEvents.AddEvent(gt, GPConstants.SUNECLIPSE_CONSTS[i], 0);
                                }
                            }
                        }
                    }

                    vcAdd = te.getNext();
                }
            }


            // moon eclipses
            if (GPDisplays.CoreEvents.MoonEclipse())
            {
                double[]      times = null;
                GPConjunction te    = new GPConjunction();
                te.setOpositeConjunction(true);
                te.setStartDate(vc);
                vcAdd = te.getNext();
                while (vcAdd.IsBeforeThis(vcEnd))
                {
                    GPAstroEngine.CalculateTimesMoonEclipse(vcAdd.getJulianGreenwichTime(), vcAdd.getLocation(), out times);
                    if (times != null && times[4] > 0)
                    {
                        for (int i = 0; i < 9; i++)
                        {
                            if (times[i] > 0 && GPConstants.MOONECLIPSE_CONSTS[i] > 0)
                            {
                                GPGregorianTime gt = new GPGregorianTime(vcAdd.getLocation());
                                gt.setJulianGreenwichTime(new GPJulianTime(times[i], 0.0));
                                inEvents.AddEvent(gt, GPConstants.MOONECLIPSE_CONSTS[i], 0);
                            }
                        }
                    }

                    vcAdd = te.getNext();
                }
            }

            // rise and set of the moon
            if (GPDisplays.CoreEvents.Moonrise())
            {
                GPJulianTime julian    = vc.getJulian();
                GPJulianTime julianEnd = vcEnd.getJulian();
                GPJulianTime nextJulian;
                TRiseSet     kind;

                while (julian.getGreenwichJulianDay() < julianEnd.getGreenwichJulianDay())
                {
                    nextJulian = GPAstroEngine.GetNextMoonEvent(julian, vc.getLocationProvider(), out kind);
                    if (kind == TRiseSet.RISE)
                    {
                        inEvents.AddEvent(new GPGregorianTime(loc, nextJulian), GPConstants.CoreEventMoonRise, 0);
                    }
                    else if (kind == TRiseSet.SET)
                    {
                        inEvents.AddEvent(new GPGregorianTime(loc, nextJulian), GPConstants.CoreEventMoonSet, 0);
                    }
                    julian.setGreenwichJulianDay(nextJulian.getGreenwichJulianDay() + 10.0 / 1440.0);
                }
            }

            // travellings
            {
                GPJulianTime julian = vc.getJulian();
                GPJulianTime julianEnd = vcEnd.getJulian();
                double       start, end;

                start = julian.getGreenwichJulianDay();
                end   = julianEnd.getGreenwichJulianDay();

                for (int i = 0; i < loc.getChangeCount(); i++)
                {
                    GPLocationChange chn = loc.getChangeAtIndex(i);
                    if ((chn.julianStart >= start && chn.julianStart <= end) ||
                        (chn.julianStart >= start && chn.julianEnd <= end))
                    {
                        GPGregorianTime startTime = new GPGregorianTime(chn.LocationA);
                        startTime.setJulianGreenwichTime(new GPJulianTime(chn.julianStart, 0));
                        GPGregorianTime endTime = new GPGregorianTime(chn.LocationB);
                        endTime.setJulianGreenwichTime(new GPJulianTime(chn.julianEnd, 0));
                        inEvents.AddEvent(startTime, GPConstants.CCTYPE_TRAVELLING_START, 0);
                        inEvents.AddEvent(endTime, GPConstants.CCTYPE_TRAVELLING_END, 0);
                    }
                }
            }

            // eventual sorting
            inEvents.Sort(GPDisplays.CoreEvents.Sort());
        }
Пример #23
0
        private void button1_Click(object sender, EventArgs e)
        {
            GPLocation loc;

            content.findLocations("Bratislava");
            loc = content.getLocation(0);
            GPLocationProvider provider = new GPLocationProvider(loc);
            int nCount = 365;

            GPGregorianTime   startDateA = new GPGregorianTime(loc);
            GPCalendarResults calA       = new GPCalendarResults();
            GPCalendarResults calB       = new GPCalendarResults();

            calA.progressReport = this;
            calB.progressReport = this;

            if (startDateA != null)
            {
                GPSun.sunPosMethod = GPSun.SUNPOSMETHOD_CALCULATOR;
                calA.CalculateCalendar(startDateA, nCount);
                GPSun.sunPosMethod = GPSun.SUNPOSMETHOD_CALCULATOREX;
                calB.CalculateCalendar(startDateA, nCount);
            }
            GPSun.sunPosMethod = GPSun.SUNPOSMETHOD_CALCULATOR;

            StringBuilder sb = new StringBuilder();

            GPCalendarTwoLocResults cals = new GPCalendarTwoLocResults();

            cals.CalendarA = calA;
            cals.CalendarB = calB;

            FormaterHtml.WriteCompareCalendarHTML(cals, sb);

            string HtmlText = sb.ToString();

            webBrowser1.DocumentText = HtmlText;

            GPObserver obs = new GPObserver();

            obs = loc;

            GPStrings.pushRich(false);

            StringBuilder sba = new StringBuilder();
            GPJulianTime  sunRise, sunNoon, sunSet;

            for (int i = 0; i < calA.getCount(); i++)
            {
                GPCalendarDay cd  = calA.get(i);
                GPCalendarDay cd2 = calB.get(i);
                GPAstroEngine.CalculateTimeSun(cd.date, loc, out sunRise, out sunNoon, out sunSet);
                GPGregorianTime gt = new GPGregorianTime(loc);

                GPCelestialBodyCoordinates pos = GPAstroEngine.sun_coordinate(GPDynamicTime.getUniversalTimeFromDynamicTime(2457012.82313));
                GPAstroEngine.calcHorizontal(pos, loc);

                sunRise.setLocalTimezoneOffset(loc.getTimeZoneOffsetHours());
                sba.AppendFormat("{0}     {1}    {2}  \n", cd.date.ToString(),
                                 cd.getSunriseTime().getLongTimeString(),
                                 cd2.getSunriseTime().getLongTimeString());
                gt.setDate(1992, 10, 13);
                //cd.astrodata.sun.calculateCoordinatesMethodM(gt, 360/24.0);
            }

            GPStrings.popRich();

            richTextBox1.Text = sba.ToString();


            GPGregorianTime t1 = new GPGregorianTime(loc);

            t1.setDate(2015, 4, 4);

            double jd = t1.getJulianLocalNoon();

            sba.Clear();
            for (double d = 0.3; d < 1.0; d += 0.01)
            {
                double ml  = GPAstroEngine.moon_coordinate(jd + d).eclipticalLongitude;
                double sl1 = GPAstroEngine.sun_coordinate(jd + d).eclipticalLongitude;
                double sl2 = GPAstroEngine.sunLongitudeMethodM(jd + d);
                sba.AppendFormat("{0} : {1} {2} {3}\n", jd + d, ml, sl1, sl2);
            }
            richTextBox2.Text = sba.ToString();
        }
Пример #24
0
 public static void calc_epsilon_phi(double date, out double delta_phi, out double epsilon)
 {
     GPAstroEngine.calc_epsilon_phi(date, out delta_phi, out epsilon);
 }
Пример #25
0
 public static double star_time(double date)
 {
     return(GPAstroEngine.GetSiderealTime(date));
 }
Пример #26
0
 public void setStartDate(GPGregorianTime st)
 {
     pStartDate  = new GPGregorianTime(st);
     pJulianDate = pStartDate.getJulianGreenwichTime();
     pJulianDate = GPAstroEngine.ConvertUniversalToDynamic(pJulianDate);
 }
Пример #27
0
        public override double getDoubleValue(double arg)
        {
            coord = GPAstroEngine.moon_coordinate(arg);

            switch (valueType)
            {
            case ValueType.Longitude:
                return(coord.eclipticalLongitude);

            case ValueType.Latitude:
                return(coord.eclipticalLatitude);

            case ValueType.Azimuth:
                if (obs != null)
                {
                    coord.makeTopocentric(obs);
                    GPAstroEngine.calcHorizontal(coord, obs);
                    return(coord.azimuth);
                }
                break;

            case ValueType.Elevation:
                if (obs != null)
                {
                    coord.makeTopocentric(obs);
                    GPAstroEngine.calcHorizontal(coord, obs);
                    return(coord.elevation);
                }
                break;

            case ValueType.DeclinationTopo:
                if (obs != null)
                {
                    coord.makeTopocentric(obs);
                    return(coord.declination);
                }
                break;

            case ValueType.RightAscessionTopo:
                if (obs != null)
                {
                    coord.makeTopocentric(obs);
                    return(coord.right_ascession);
                }
                break;

            case ValueType.Declination:
                return(coord.declination);

            case ValueType.RightAscession:
                return(coord.right_ascession);

            case ValueType.Distance:
                return(coord.distanceFromEarth);

            case ValueType.ApparentSiderealTime:
                return(coord.apparent_sidereal_time);

            case ValueType.MeanSiderealTime:
                return(coord.mean_sidereal_time);

            case ValueType.DynamicTime:
                return(coord.getDynamicTime());

            case ValueType.Nutation:
                return(coord.getNutation());

            case ValueType.Obliquity:
                return(coord.getObliquity());

            case ValueType.NaksatraDistance:
            {
                double naksatraReal = getNaksatraDouble(arg);
                naksatraReal = 0.51 - Math.Abs(naksatraReal - Math.Floor(naksatraReal) - 0.5);
                return(naksatraReal);
            }

            case ValueType.Naksatra:
                return(getNaksatraDouble(arg));

            default:
                break;
            }

            return(0);
        }