public static AAS2DCoordinate SunPosition(DateTime dateTime)
        {
            var bHighPrecision = false;

            dateTime = dateTime.ToUniversalTime(); // NOTE: time must be converted to Universal Time

            //Calculate the topocentric horizontal position of the Sun
            AASDate         dateSunCalc           = new AASDate(dateTime.Year, dateTime.Month, dateTime.Day, dateTime.Hour, dateTime.Minute, dateTime.Second, true);
            double          JDSun                 = dateSunCalc.Julian + AASDynamicalTime.DeltaT(dateSunCalc.Julian) / 86400.0;
            double          SunLong               = AASSun.ApparentEclipticLongitude(JDSun, bHighPrecision);
            double          SunLat                = AASSun.ApparentEclipticLatitude(JDSun, bHighPrecision);
            AAS2DCoordinate Equatorial            = AASCoordinateTransformation.Ecliptic2Equatorial(SunLong, SunLat, AASNutation.TrueObliquityOfEcliptic(JDSun));
            double          SunRad                = AASEarth.RadiusVector(JDSun, bHighPrecision);
            AAS2DCoordinate SunTopo               = AASParallax.Equatorial2Topocentric(Equatorial.X, Equatorial.Y, SunRad, RT_LONG, RT_LAT, RT_HEIGHT, JDSun);
            double          AST                   = AASSidereal.ApparentGreenwichSiderealTime(dateSunCalc.Julian);
            double          LongtitudeAsHourAngle = AASCoordinateTransformation.DegreesToHours(RT_LONG);
            double          LocalHourAngle        = AST - LongtitudeAsHourAngle - SunTopo.X;
            AAS2DCoordinate SunHorizontal         = AASCoordinateTransformation.Equatorial2Horizontal(LocalHourAngle, SunTopo.Y, RT_LAT);

            SunHorizontal.Y += AASRefraction.RefractionFromTrue(SunHorizontal.Y, 1013, 10);

            //The result above should be that we have a setting Sun at Y degrees above the horizon at azimuth X degrees south of the westerly horizon
            //NOTE: for azimuth west is considered positive, to get east as positive subtract the result from 360
            return(SunHorizontal);
        }
        public void EclipticRectangularCoordinatesJ2000Test(double JD, bool bHighPrecision, double expectedX, double expectedY, double expectedZ)
        {
            AAS3DCoordinate sunCoord = AASSun.EclipticRectangularCoordinatesJ2000(JD, bHighPrecision);

            Assert.Equal(expectedX, sunCoord.X);
            Assert.Equal(expectedY, sunCoord.Y);
            Assert.Equal(expectedZ, sunCoord.Z);
        }
        public void EquatorialRectangularCoordinatesMeanEquinoxTest(double JD, bool bHighPrecision, double expectedX, double expectedY, double expectedZ)
        {
            AAS3DCoordinate sunCoord = AASSun.EquatorialRectangularCoordinatesMeanEquinox(JD, bHighPrecision);

            Assert.Equal(expectedX, sunCoord.X);
            Assert.Equal(expectedY, sunCoord.Y);
            Assert.Equal(expectedZ, sunCoord.Z);
        }
        public Coordinate GetSunCoordinate(DateTime datetime)
        {
            AASDate date    = new AASDate(datetime.Year, datetime.Month, datetime.Day, datetime.Hour, datetime.Minute, datetime.Second, true);
            double  JD      = date.Julian + AASDynamicalTime.DeltaT(date.Julian) / 86400.0;
            double  SunLong = AASSun.ApparentEclipticLongitude(JD, false);
            double  SunLat  = AASSun.ApparentEclipticLatitude(JD, false);

            AAS2DCoordinate equatorial = AASCoordinateTransformation.Ecliptic2Equatorial(SunLong, SunLat, AASNutation.TrueObliquityOfEcliptic(JD));
            double          SunRad     = AASEarth.RadiusVector(JD, false);

            // This line gives us RA & Declination.
            AAS2DCoordinate SunTopo = AASParallax.Equatorial2Topocentric(equatorial.X, equatorial.Y, SunRad, Location.Longitude, Location.Latitude, Location.Altitude, JD);

            return(new Coordinate(SunTopo.X, SunTopo.Y));
        }
Exemple #5
0
    protected void CorrectForAberration()
    {
        double e  = GetEarthEccentricity(jd);
        double pi = GetEarthPerihelionLongitude(jd);

        double theta = AASSun.GeometricEclipticLongitude(jdeCorrected);

        double appGeoLon = GetGeocentricLongitude(vectorToEarthCorrected.x, vectorToEarthCorrected.y);
        double appGeoLat = GetGeocentricLatitude(vectorToEarthCorrected.x, vectorToEarthCorrected.y, vectorToEarthCorrected.z);


        double deltaLambda = GetAberrationDeltaLongitude(theta, appGeoLon, appGeoLat, e, pi);
        double deltaBeta   = GetAberrationDeltaLatitude(theta, appGeoLon, appGeoLat, e, pi);


        lambdaAberration = appGeoLon + deltaLambda;
        betaAberration   = appGeoLat + deltaBeta;
    }
        public void GeometricEclipticLongitudeTest(double JD, bool bHighPrecision, double expectedLongitude)
        {
            double longitude = AASSun.GeometricEclipticLongitude(JD, bHighPrecision);

            Assert.Equal(expectedLongitude, longitude);
        }
        public void ApparentEclipticLatitudeTest(double JD, bool bHighPrecision, double expectedLatitude)
        {
            double latitude = AASSun.ApparentEclipticLatitude(JD, bHighPrecision);

            Assert.Equal(expectedLatitude, latitude);
        }