/// <summary>
    /// Calculate selenographic (lunar) coordinates (sub-Solar)
    /// </summary>
    /// <returns>sub-solar longitude, sub-solar colongitude, and sub-solar latitude</returns>
    public (double subSolarLongitude, double subSolarColongitude, double subSolarLatitude) SelenographicCoordinates2(double gwdateDay, int gwdateMonth, int gwdateYear)
    {
        var julianDateDays           = PAMacros.CivilDateToJulianDate(gwdateDay, gwdateMonth, gwdateYear);
        var tCenturies               = (julianDateDays - 2451545) / 36525;
        var longAscNodeDeg           = 125.044522 - 1934.136261 * tCenturies;
        var f1                       = 93.27191 + 483202.0175 * tCenturies;
        var f2                       = f1 - 360 * (f1 / 360).Floor();
        var sunGeocentricLongDeg     = PAMacros.SunLong(0, 0, 0, 0, 0, gwdateDay, gwdateMonth, gwdateYear);
        var moonEquHorParallaxArcMin = PAMacros.MoonHP(0, 0, 0, 0, 0, gwdateDay, gwdateMonth, gwdateYear) * 60;
        var sunEarthDistAU           = PAMacros.SunDist(0, 0, 0, 0, 0, gwdateDay, gwdateMonth, gwdateYear);
        var geocentricMoonLatRad     = (PAMacros.MoonLat(0, 0, 0, 0, 0, gwdateDay, gwdateMonth, gwdateYear)).ToRadians();
        var geocentricMoonLongDeg    = PAMacros.MoonLong(0, 0, 0, 0, 0, gwdateDay, gwdateMonth, gwdateYear);
        var adjustedMoonLongDeg      = sunGeocentricLongDeg + 180 + (26.4 * (geocentricMoonLatRad).Cosine() * ((sunGeocentricLongDeg - geocentricMoonLongDeg).ToRadians()).Sine() / (moonEquHorParallaxArcMin * sunEarthDistAU));
        var adjustedMoonLatRad       = 0.14666 * geocentricMoonLatRad / (moonEquHorParallaxArcMin * sunEarthDistAU);
        var inclinationRad           = (PAMacros.DegreesMinutesSecondsToDecimalDegrees(1, 32, 32.7)).ToRadians();
        var nodeLongRad              = (longAscNodeDeg - adjustedMoonLongDeg).ToRadians();
        var sinBs                    = -(inclinationRad).Cosine() * (adjustedMoonLatRad).Sine() + (inclinationRad).Sine() * (adjustedMoonLatRad).Cosine() * (nodeLongRad).Sine();
        var subSolarLatDeg           = PAMacros.Degrees((sinBs).ASine());
        var aRad                     = (-(adjustedMoonLatRad).Sine() * (inclinationRad).Sine() - (adjustedMoonLatRad).Cosine() * (inclinationRad).Cosine() * (nodeLongRad).Sine()).AngleTangent2((adjustedMoonLatRad).Cosine() * (nodeLongRad).Cosine());
        var aDeg                     = PAMacros.Degrees(aRad);
        var subSolarLongDeg1         = aDeg - f2;
        var subSolarLongDeg2         = subSolarLongDeg1 - 360 * (subSolarLongDeg1 / 360).Floor();
        var subSolarLongDeg3         = (subSolarLongDeg2 > 180) ? subSolarLongDeg2 - 360 : subSolarLongDeg2;
        var subSolarColongDeg        = 90 - subSolarLongDeg3;

        var subSolarLongitude   = Math.Round(subSolarLongDeg3, 2);
        var subSolarColongitude = Math.Round(subSolarColongDeg, 2);
        var subSolarLatitude    = Math.Round(subSolarLatDeg, 2);

        return(subSolarLongitude, subSolarColongitude, subSolarLatitude);
    }
Exemple #2
0
    /// <summary>
    /// Convert local Civil Time to Universal Time
    /// </summary>
    /// <returns>Tuple (int utHours, int utMinutes, int utSeconds, int gwDay, int gwMonth, int gwYear)</returns>
    public (int utHours, int utMinutes, int utSeconds, int gwDay, int gwMonth, int gwYear) LocalCivilTimeToUniversalTime(double lctHours, double lctMinutes, double lctSeconds, bool isDaylightSavings, int zoneCorrection, double localDay, int localMonth, int localYear)
    {
        var lct = CivilTimeToDecimalHours(lctHours, lctMinutes, lctSeconds);

        var daylightSavingsOffset = (isDaylightSavings) ? 1 : 0;

        var utInterim   = lct - daylightSavingsOffset - zoneCorrection;
        var gdayInterim = localDay + (utInterim / 24);

        var jd = PAMacros.CivilDateToJulianDate(gdayInterim, localMonth, localYear);

        var gDay   = PAMacros.JulianDateDay(jd);
        var gMonth = PAMacros.JulianDateMonth(jd);
        var gYear  = PAMacros.JulianDateYear(jd);

        var ut = 24 * (gDay - gDay.Floor());

        return(
            PAMacros.DecimalHoursHour(ut),
            PAMacros.DecimalHoursMinute(ut),
            (int)PAMacros.DecimalHoursSecond(ut),
            (int)gDay.Floor(),
            gMonth,
            gYear
            );
    }
    /// <summary>
    /// Calculate selenographic (lunar) coordinates (sub-Earth)
    /// </summary>
    /// <returns>sub-earth longitude, sub-earth latitude, and position angle of pole</returns>
    public (double subEarthLongitude, double subEarthLatitude, double positionAngleOfPole) SelenographicCoordinates1(double gwdateDay, int gwdateMonth, int gwdateYear)
    {
        var julianDateDays        = PAMacros.CivilDateToJulianDate(gwdateDay, gwdateMonth, gwdateYear);
        var tCenturies            = (julianDateDays - 2451545) / 36525;
        var longAscNodeDeg        = 125.044522 - 1934.136261 * tCenturies;
        var f1                    = 93.27191 + 483202.0175 * tCenturies;
        var f2                    = f1 - 360 * (f1 / 360).Floor();
        var geocentricMoonLongDeg = PAMacros.MoonLong(0, 0, 0, 0, 0, gwdateDay, gwdateMonth, gwdateYear);
        var geocentricMoonLatRad  = (PAMacros.MoonLat(0, 0, 0, 0, 0, gwdateDay, gwdateMonth, gwdateYear)).ToRadians();
        var inclinationRad        = (PAMacros.DegreesMinutesSecondsToDecimalDegrees(1, 32, 32.7)).ToRadians();
        var nodeLongRad           = (longAscNodeDeg - geocentricMoonLongDeg).ToRadians();
        var sinBe                 = -(inclinationRad).Cosine() * (geocentricMoonLatRad).Sine() + (inclinationRad).Sine() * (geocentricMoonLatRad).Cosine() * (nodeLongRad).Sine();
        var subEarthLatDeg        = PAMacros.Degrees((sinBe).ASine());
        var aRad                  = (-(geocentricMoonLatRad).Sine() * (inclinationRad).Sine() - (geocentricMoonLatRad).Cosine() * (inclinationRad).Cosine() * (nodeLongRad).Sine()).AngleTangent2((geocentricMoonLatRad).Cosine() * (nodeLongRad).Cosine());
        var aDeg                  = PAMacros.Degrees(aRad);
        var subEarthLongDeg1      = aDeg - f2;
        var subEarthLongDeg2      = subEarthLongDeg1 - 360 * (subEarthLongDeg1 / 360).Floor();
        var subEarthLongDeg3      = (subEarthLongDeg2 > 180) ? subEarthLongDeg2 - 360 : subEarthLongDeg2;
        var c1Rad                 = ((nodeLongRad).Cosine() * (inclinationRad).Sine() / ((geocentricMoonLatRad).Cosine() * (inclinationRad).Cosine() + (geocentricMoonLatRad).Sine() * (inclinationRad).Sine() * (nodeLongRad).Sine())).AngleTangent();
        var obliquityRad          = (PAMacros.Obliq(gwdateDay, gwdateMonth, gwdateYear)).ToRadians();
        var c2Rad                 = ((obliquityRad).Sine() * ((geocentricMoonLongDeg).ToRadians()).Cosine() / ((obliquityRad).Sine() * (geocentricMoonLatRad).Sine() * ((geocentricMoonLongDeg).ToRadians()).Sine() - (obliquityRad).Cosine() * (geocentricMoonLatRad).Cosine())).AngleTangent();
        var cDeg                  = PAMacros.Degrees(c1Rad + c2Rad);

        var subEarthLongitude   = Math.Round(subEarthLongDeg3, 2);
        var subEarthLatitude    = Math.Round(subEarthLatDeg, 2);
        var positionAngleOfPole = Math.Round(cDeg, 2);

        return(subEarthLongitude, subEarthLatitude, positionAngleOfPole);
    }
    /// <summary>
    /// Calculate heliographic coordinates for a given Greenwich date, with a given heliographic position angle and heliographic displacement in arc minutes.
    /// </summary>
    /// <returns>heliographic longitude and heliographic latitude, in degrees</returns>
    public (double helioLongDeg, double helioLatDeg) HeliographicCoordinates(double helioPositionAngleDeg, double helioDisplacementArcmin, double gwdateDay, int gwdateMonth, int gwdateYear)
    {
        var julianDateDays = PAMacros.CivilDateToJulianDate(gwdateDay, gwdateMonth, gwdateYear);
        var tCenturies     = (julianDateDays - 2415020) / 36525;
        var longAscNodeDeg = PAMacros.DegreesMinutesSecondsToDecimalDegrees(74, 22, 0) + (84 * tCenturies / 60);
        var sunLongDeg     = PAMacros.SunLong(0, 0, 0, 0, 0, gwdateDay, gwdateMonth, gwdateYear);
        var y         = ((longAscNodeDeg - sunLongDeg).ToRadians()).Sine() * ((PAMacros.DegreesMinutesSecondsToDecimalDegrees(7, 15, 0)).ToRadians()).Cosine();
        var x         = -((longAscNodeDeg - sunLongDeg).ToRadians()).Cosine();
        var aDeg      = PAMacros.Degrees(y.AngleTangent2(x));
        var mDeg1     = 360 - (360 * (julianDateDays - 2398220) / 25.38);
        var mDeg2     = mDeg1 - 360 * (mDeg1 / 360).Floor();
        var l0Deg1    = mDeg2 + aDeg;
        var b0Rad     = (((sunLongDeg - longAscNodeDeg).ToRadians()).Sine() * ((PAMacros.DegreesMinutesSecondsToDecimalDegrees(7, 15, 0)).ToRadians()).Sine()).ASine();
        var theta1Rad = (-((sunLongDeg).ToRadians()).Cosine() * ((PAMacros.Obliq(gwdateDay, gwdateMonth, gwdateYear)).ToRadians()).Tangent()).AngleTangent();
        var theta2Rad = (-((longAscNodeDeg - sunLongDeg).ToRadians()).Cosine() * ((PAMacros.DegreesMinutesSecondsToDecimalDegrees(7, 15, 0)).ToRadians()).Tangent()).AngleTangent();
        var pDeg      = PAMacros.Degrees(theta1Rad + theta2Rad);
        var rho1Deg   = helioDisplacementArcmin / 60;
        var rhoRad    = (2 * rho1Deg / PAMacros.SunDia(0, 0, 0, 0, 0, gwdateDay, gwdateMonth, gwdateYear)).ASine() - (rho1Deg).ToRadians();
        var bRad      = ((b0Rad).Sine() * (rhoRad).Cosine() + (b0Rad).Cosine() * (rhoRad).Sine() * ((pDeg - helioPositionAngleDeg).ToRadians()).Cosine()).ASine();
        var bDeg      = PAMacros.Degrees(bRad);
        var lDeg1     = PAMacros.Degrees(((rhoRad).Sine() * ((pDeg - helioPositionAngleDeg).ToRadians()).Sine() / (bRad).Cosine()).ASine()) + l0Deg1;
        var lDeg2     = lDeg1 - 360 * (lDeg1 / 360).Floor();

        var helioLongDeg = Math.Round(lDeg2, 2);
        var helioLatDeg  = Math.Round(bDeg, 2);

        return(helioLongDeg, helioLatDeg);
    }
Exemple #5
0
    /// <summary>
    /// Calculate approximate position of the sun for a local date and time.
    /// </summary>
    /// <param name="lctHours">Local civil time, in hours.</param>
    /// <param name="lctMinutes">Local civil time, in minutes.</param>
    /// <param name="lctSeconds">Local civil time, in seconds.</param>
    /// <param name="localDay">Local day, day part.</param>
    /// <param name="localMonth">Local day, month part.</param>
    /// <param name="localYear">Local day, year part.</param>
    /// <param name="isDaylightSaving">Is daylight savings in effect?</param>
    /// <param name="zoneCorrection">Time zone correction, in hours.</param>
    /// <returns>
    /// <para>sunRAHour -- Right Ascension of Sun, hour part</para>
    /// <para>sunRAMin -- Right Ascension of Sun, minutes part</para>
    /// <para>sunRASec -- Right Ascension of Sun, seconds part</para>
    /// <para>sunDecDeg -- Declination of Sun, degrees part</para>
    /// <para>sunDecMin -- Declination of Sun, minutes part</para>
    /// <para>sunDecSec -- Declination of Sun, seconds part</para>
    /// </returns>
    public (double sunRAHour, double sunRAMin, double sunRASec, double sunDecDeg, double sunDecMin, double sunDecSec) ApproximatePositionOfSun(double lctHours, double lctMinutes, double lctSeconds, double localDay, int localMonth, int localYear, bool isDaylightSaving, int zoneCorrection)
    {
        var daylightSaving = (isDaylightSaving == true) ? 1 : 0;

        var greenwichDateDay   = PAMacros.LocalCivilTimeGreenwichDay(lctHours, lctMinutes, lctSeconds, daylightSaving, zoneCorrection, localDay, localMonth, localYear);
        var greenwichDateMonth = PAMacros.LocalCivilTimeGreenwichMonth(lctHours, lctMinutes, lctSeconds, daylightSaving, zoneCorrection, localDay, localMonth, localYear);
        var greenwichDateYear  = PAMacros.LocalCivilTimeGreenwichYear(lctHours, lctMinutes, lctSeconds, daylightSaving, zoneCorrection, localDay, localMonth, localYear);
        var utHours            = PAMacros.LocalCivilTimeToUniversalTime(lctHours, lctMinutes, lctSeconds, daylightSaving, zoneCorrection, localDay, localMonth, localYear);
        var utDays             = utHours / 24;
        var jdDays             = PAMacros.CivilDateToJulianDate(greenwichDateDay, greenwichDateMonth, greenwichDateYear) + utDays;
        var dDays   = jdDays - PAMacros.CivilDateToJulianDate(0, 1, 2010);
        var nDeg    = 360 * dDays / 365.242191;
        var mDeg1   = nDeg + PAMacros.SunELong(0, 1, 2010) - PAMacros.SunPeri(0, 1, 2010);
        var mDeg2   = mDeg1 - 360 * (mDeg1 / 360).Floor();
        var eCDeg   = 360 * PAMacros.SunEcc(0, 1, 2010) * mDeg2.ToRadians().Sine() / Math.PI;
        var lSDeg1  = nDeg + eCDeg + PAMacros.SunELong(0, 1, 2010);
        var lSDeg2  = lSDeg1 - 360 * (lSDeg1 / 360).Floor();
        var raDeg   = PAMacros.EcRA(lSDeg2, 0, 0, 0, 0, 0, greenwichDateDay, greenwichDateMonth, greenwichDateYear);
        var raHours = PAMacros.DecimalDegreesToDegreeHours(raDeg);
        var decDeg  = PAMacros.EcDec(lSDeg2, 0, 0, 0, 0, 0, greenwichDateDay, greenwichDateMonth, greenwichDateYear);

        var sunRAHour = PAMacros.DecimalHoursHour(raHours);
        var sunRAMin  = PAMacros.DecimalHoursMinute(raHours);
        var sunRASec  = PAMacros.DecimalHoursSecond(raHours);
        var sunDecDeg = PAMacros.DecimalDegreesDegrees(decDeg);
        var sunDecMin = PAMacros.DecimalDegreesMinutes(decDeg);
        var sunDecSec = PAMacros.DecimalDegreesSeconds(decDeg);

        return(sunRAHour, sunRAMin, sunRASec, sunDecDeg, sunDecMin, sunDecSec);
    }
    /// <summary>
    /// Calculate carrington rotation number for a Greenwich date
    /// </summary>
    /// <returns>carrington rotation number</returns>
    public int CarringtonRotationNumber(double gwdateDay, int gwdateMonth, int gwdateYear)
    {
        var julianDateDays = PAMacros.CivilDateToJulianDate(gwdateDay, gwdateMonth, gwdateYear);

        var crn = 1690 + (int)Math.Round((julianDateDays - 2444235.34) / 27.2753, 0);

        return(crn);
    }
    /// <summary>
    /// Calculate Mean Obliquity of the Ecliptic for a Greenwich Date
    /// </summary>
    public double MeanObliquityOfTheEcliptic(double greenwichDay, int greenwichMonth, int greenwichYear)
    {
        var jd  = PAMacros.CivilDateToJulianDate(greenwichDay, greenwichMonth, greenwichYear);
        var mjd = jd - 2451545;
        var t   = mjd / 36525;
        var de1 = t * (46.815 + t * (0.0006 - (t * 0.00181)));
        var de2 = de1 / 3600;

        return(23.439292 - de2);
    }
Exemple #8
0
    /// <summary>
    /// Calculate approximate position of a planet.
    /// </summary>
    public (double planetRAHour, double planetRAMin, double planetRASec, double planetDecDeg, double planetDecMin, double planetDecSec) ApproximatePositionOfPlanet(double lctHour, double lctMin, double lctSec, bool isDaylightSaving, int zoneCorrectionHours, double localDateDay, int localDateMonth, int localDateYear, string planetName)
    {
        var daylightSaving = (isDaylightSaving) ? 1 : 0;

        var planetInfo = PlanetInfo.GetPlanetInfo(planetName);

        var gdateDay   = PAMacros.LocalCivilTimeGreenwichDay(lctHour, lctMin, lctSec, daylightSaving, zoneCorrectionHours, localDateDay, localDateMonth, localDateYear);
        var gdateMonth = PAMacros.LocalCivilTimeGreenwichMonth(lctHour, lctMin, lctSec, daylightSaving, zoneCorrectionHours, localDateDay, localDateMonth, localDateYear);
        var gdateYear  = PAMacros.LocalCivilTimeGreenwichYear(lctHour, lctMin, lctSec, daylightSaving, zoneCorrectionHours, localDateDay, localDateMonth, localDateYear);

        var utHours = PAMacros.LocalCivilTimeToUniversalTime(lctHour, lctMin, lctSec, daylightSaving, zoneCorrectionHours, localDateDay, localDateMonth, localDateYear);
        var dDays   = PAMacros.CivilDateToJulianDate(gdateDay + (utHours / 24), gdateMonth, gdateYear) - PAMacros.CivilDateToJulianDate(0, 1, 2010);
        var npDeg1  = 360 * dDays / (365.242191 * planetInfo.tp_PeriodOrbit);
        var npDeg2  = npDeg1 - 360 * (npDeg1 / 360).Floor();
        var mpDeg   = npDeg2 + planetInfo.long_LongitudeEpoch - planetInfo.peri_LongitudePerihelion;
        var lpDeg1  = npDeg2 + (360 * planetInfo.ecc_EccentricityOrbit * mpDeg.ToRadians().Sine() / Math.PI) + planetInfo.long_LongitudeEpoch;
        var lpDeg2  = lpDeg1 - 360 * (lpDeg1 / 360).Floor();
        var planetTrueAnomalyDeg = lpDeg2 - planetInfo.peri_LongitudePerihelion;
        var rAU = planetInfo.axis_AxisOrbit * (1 - Math.Pow(planetInfo.ecc_EccentricityOrbit, 2)) / (1 + planetInfo.ecc_EccentricityOrbit * planetTrueAnomalyDeg.ToRadians().Cosine());

        var earthInfo = PlanetInfo.GetPlanetInfo("Earth");

        var neDeg1 = 360 * dDays / (365.242191 * earthInfo.tp_PeriodOrbit);
        var neDeg2 = neDeg1 - 360 * (neDeg1 / 360).Floor();
        var meDeg  = neDeg2 + earthInfo.long_LongitudeEpoch - earthInfo.peri_LongitudePerihelion;
        var leDeg1 = neDeg2 + earthInfo.long_LongitudeEpoch + 360 * earthInfo.ecc_EccentricityOrbit * meDeg.ToRadians().Sine() / Math.PI;
        var leDeg2 = leDeg1 - 360 * (leDeg1 / 360).Floor();
        var earthTrueAnomalyDeg = leDeg2 - earthInfo.peri_LongitudePerihelion;
        var rAU2       = earthInfo.axis_AxisOrbit * (1 - Math.Pow(earthInfo.ecc_EccentricityOrbit, 2)) / (1 + earthInfo.ecc_EccentricityOrbit * earthTrueAnomalyDeg.ToRadians().Cosine());
        var lpNodeRad  = (lpDeg2 - planetInfo.node_LongitudeAscendingNode).ToRadians();
        var psiRad     = ((lpNodeRad).Sine() * planetInfo.incl_OrbitalInclination.ToRadians().Sine()).ASine();
        var y          = lpNodeRad.Sine() * planetInfo.incl_OrbitalInclination.ToRadians().Cosine();
        var x          = lpNodeRad.Cosine();
        var ldDeg      = PAMacros.Degrees(y.AngleTangent2(x)) + planetInfo.node_LongitudeAscendingNode;
        var rdAU       = rAU * psiRad.Cosine();
        var leLdRad    = (leDeg2 - ldDeg).ToRadians();
        var atan2Type1 = (rdAU * leLdRad.Sine()).AngleTangent2(rAU2 - rdAU * leLdRad.Cosine());
        var atan2Type2 = (rAU2 * (-leLdRad).Sine()).AngleTangent2(rdAU - rAU2 * leLdRad.Cosine());
        var aRad       = (rdAU < 1) ? atan2Type1 : atan2Type2;
        var lamdaDeg1  = (rdAU < 1) ? 180 + leDeg2 + PAMacros.Degrees(aRad) : PAMacros.Degrees(aRad) + ldDeg;
        var lamdaDeg2  = lamdaDeg1 - 360 * (lamdaDeg1 / 360).Floor();
        var betaDeg    = PAMacros.Degrees((rdAU * psiRad.Tangent() * ((lamdaDeg2 - ldDeg).ToRadians()).Sine() / (rAU2 * (-leLdRad).Sine())).AngleTangent());
        var raHours    = PAMacros.DecimalDegreesToDegreeHours(PAMacros.EcRA(lamdaDeg2, 0, 0, betaDeg, 0, 0, gdateDay, gdateMonth, gdateYear));
        var decDeg     = PAMacros.EcDec(lamdaDeg2, 0, 0, betaDeg, 0, 0, gdateDay, gdateMonth, gdateYear);

        var planetRAHour = PAMacros.DecimalHoursHour(raHours);
        var planetRAMin  = PAMacros.DecimalHoursMinute(raHours);
        var planetRASec  = PAMacros.DecimalHoursSecond(raHours);
        var planetDecDeg = PAMacros.DecimalDegreesDegrees(decDeg);
        var planetDecMin = PAMacros.DecimalDegreesMinutes(decDeg);
        var planetDecSec = PAMacros.DecimalDegreesSeconds(decDeg);

        return(planetRAHour, planetRAMin, planetRASec, planetDecDeg, planetDecMin, planetDecSec);
    }
Exemple #9
0
    /// <summary>
    /// Calculate approximate position of the Moon.
    /// </summary>
    /// <returns>
    /// <para>moon_ra_hour -- Right ascension of Moon (hour part)</para>
    /// <para>moon_ra_min -- Right ascension of Moon (minutes part)</para>
    /// <para>moon_ra_sec -- Right ascension of Moon (seconds part)</para>
    /// <para>moon_dec_deg -- Declination of Moon (degrees part)</para>
    /// <para>moon_dec_min -- Declination of Moon (minutes part)</para>
    /// <para>moon_dec_sec -- Declination of Moon (seconds part)</para>
    /// </returns>
    public (double moonRAHour, double moonRAMin, double moonRASec, double moonDecDeg, double moonDecMin, double moonDecSec) ApproximatePositionOfMoon(double lctHour, double lctMin, double lctSec, bool isDaylightSaving, int zoneCorrectionHours, double localDateDay, int localDateMonth, int localDateYear)
    {
        var daylightSaving = (isDaylightSaving) ? 1 : 0;

        var l0 = 91.9293359879052;
        var p0 = 130.143076320618;
        var n0 = 291.682546643194;
        var i  = 5.145396;

        var gdateDay   = PAMacros.LocalCivilTimeGreenwichDay(lctHour, lctMin, lctSec, daylightSaving, zoneCorrectionHours, localDateDay, localDateMonth, localDateYear);
        var gdateMonth = PAMacros.LocalCivilTimeGreenwichMonth(lctHour, lctMin, lctSec, daylightSaving, zoneCorrectionHours, localDateDay, localDateMonth, localDateYear);
        var gdateYear  = PAMacros.LocalCivilTimeGreenwichYear(lctHour, lctMin, lctSec, daylightSaving, zoneCorrectionHours, localDateDay, localDateMonth, localDateYear);

        var utHours           = PAMacros.LocalCivilTimeToUniversalTime(lctHour, lctMin, lctSec, daylightSaving, zoneCorrectionHours, localDateDay, localDateMonth, localDateYear);
        var dDays             = PAMacros.CivilDateToJulianDate(gdateDay, gdateMonth, gdateYear) - PAMacros.CivilDateToJulianDate(0.0, 1, 2010) + utHours / 24;
        var sunLongDeg        = PAMacros.SunLong(lctHour, lctMin, lctSec, daylightSaving, zoneCorrectionHours, localDateDay, localDateMonth, localDateYear);
        var sunMeanAnomalyRad = PAMacros.SunMeanAnomaly(lctHour, lctMin, lctSec, daylightSaving, zoneCorrectionHours, localDateDay, localDateMonth, localDateYear);
        var lmDeg             = PAMacros.UnwindDeg(13.1763966 * dDays + l0);
        var mmDeg             = PAMacros.UnwindDeg(lmDeg - 0.1114041 * dDays - p0);
        var nDeg   = PAMacros.UnwindDeg(n0 - (0.0529539 * dDays));
        var evDeg  = 1.2739 * ((2.0 * (lmDeg - sunLongDeg) - mmDeg).ToRadians()).Sine();
        var aeDeg  = 0.1858 * (sunMeanAnomalyRad).Sine();
        var a3Deg  = 0.37 * (sunMeanAnomalyRad).Sine();
        var mmdDeg = mmDeg + evDeg - aeDeg - a3Deg;
        var ecDeg  = 6.2886 * mmdDeg.ToRadians().Sine();
        var a4Deg  = 0.214 * (2.0 * (mmdDeg).ToRadians()).Sine();
        var ldDeg  = lmDeg + evDeg + ecDeg - aeDeg + a4Deg;
        var vDeg   = 0.6583 * (2.0 * (ldDeg - sunLongDeg).ToRadians()).Sine();
        var lddDeg = ldDeg + vDeg;
        var ndDeg  = nDeg - 0.16 * (sunMeanAnomalyRad).Sine();
        var y      = ((lddDeg - ndDeg).ToRadians()).Sine() * i.ToRadians().Cosine();
        var x      = (lddDeg - ndDeg).ToRadians().Cosine();

        var moonLongDeg  = PAMacros.UnwindDeg(PAMacros.Degrees(y.AngleTangent2(x)) + ndDeg);
        var moonLatDeg   = PAMacros.Degrees(((lddDeg - ndDeg).ToRadians().Sine() * i.ToRadians().Sine()).ASine());
        var moonRAHours1 = PAMacros.DecimalDegreesToDegreeHours(PAMacros.EcRA(moonLongDeg, 0, 0, moonLatDeg, 0, 0, gdateDay, gdateMonth, gdateYear));
        var moonDecDeg1  = PAMacros.EcDec(moonLongDeg, 0, 0, moonLatDeg, 0, 0, gdateDay, gdateMonth, gdateYear);

        var moonRAHour = PAMacros.DecimalHoursHour(moonRAHours1);
        var moonRAMin  = PAMacros.DecimalHoursMinute(moonRAHours1);
        var moonRASec  = PAMacros.DecimalHoursSecond(moonRAHours1);
        var moonDecDeg = PAMacros.DecimalDegreesDegrees(moonDecDeg1);
        var moonDecMin = PAMacros.DecimalDegreesMinutes(moonDecDeg1);
        var moonDecSec = PAMacros.DecimalDegreesSeconds(moonDecDeg1);

        return(moonRAHour, moonRAMin, moonRASec, moonDecDeg, moonDecMin, moonDecSec);
    }
    /// <summary>
    /// Calculate position of an elliptical comet.
    /// </summary>
    /// <returns>
    /// cometRAHour -- Right ascension of comet (hour part)
    /// cometRAMin -- Right ascension of comet (minutes part)
    /// cometDecDeg -- Declination of comet (degrees part)
    /// cometDecMin -- Declination of comet (minutes part)
    /// cometDistEarth -- Comet's distance from Earth (AU)
    /// </returns>
    public (double cometRAHour, double cometRAMin, double cometDecDeg, double cometDecMin, double cometDistEarth) PositionOfEllipticalComet(double lctHour, double lctMin, double lctSec, bool isDaylightSaving, int zoneCorrectionHours, double localDateDay, int localDateMonth, int localDateYear, string cometName)
    {
        var daylightSaving = (isDaylightSaving) ? 1 : 0;

        var greenwichDateDay   = PAMacros.LocalCivilTimeGreenwichDay(lctHour, lctMin, lctSec, daylightSaving, zoneCorrectionHours, localDateDay, localDateMonth, localDateYear);
        var greenwichDateMonth = PAMacros.LocalCivilTimeGreenwichMonth(lctHour, lctMin, lctSec, daylightSaving, zoneCorrectionHours, localDateDay, localDateMonth, localDateYear);
        var greenwichDateYear  = PAMacros.LocalCivilTimeGreenwichYear(lctHour, lctMin, lctSec, daylightSaving, zoneCorrectionHours, localDateDay, localDateMonth, localDateYear);

        var cometInfo = CometInfoElliptical.GetCometEllipticalInfo(cometName);

        var timeSinceEpochYears = (PAMacros.CivilDateToJulianDate(greenwichDateDay, greenwichDateMonth, greenwichDateYear) - PAMacros.CivilDateToJulianDate(0.0, 1, greenwichDateYear)) / 365.242191 + greenwichDateYear - cometInfo.epoch_EpochOfPerihelion;
        var mcDeg          = 360 * timeSinceEpochYears / cometInfo.period_PeriodOfOrbit;
        var mcRad          = (mcDeg - 360 * (mcDeg / 360).Floor()).ToRadians();
        var eccentricity   = cometInfo.ecc_EccentricityOfOrbit;
        var trueAnomalyDeg = PAMacros.Degrees(PAMacros.TrueAnomaly(mcRad, eccentricity));
        var lcDeg          = trueAnomalyDeg + cometInfo.peri_LongitudeOfPerihelion;
        var rAU            = cometInfo.axis_SemiMajorAxisOfOrbit * (1 - eccentricity * eccentricity) / (1 + eccentricity * ((trueAnomalyDeg).ToRadians()).Cosine());
        var lcNodeRad      = (lcDeg - cometInfo.node_LongitudeOfAscendingNode).ToRadians();
        var psiRad         = ((lcNodeRad).Sine() * ((cometInfo.incl_InclinationOfOrbit).ToRadians()).Sine()).ASine();

        var y = (lcNodeRad).Sine() * ((cometInfo.incl_InclinationOfOrbit).ToRadians()).Cosine();
        var x = (lcNodeRad).Cosine();

        var ldDeg = PAMacros.Degrees(y.AngleTangent2(x)) + cometInfo.node_LongitudeOfAscendingNode;
        var rdAU  = rAU * (psiRad).Cosine();

        var earthLongitudeLeDeg = PAMacros.SunLong(lctHour, lctMin, lctSec, daylightSaving, zoneCorrectionHours, localDateDay, localDateMonth, localDateYear) + 180.0;
        var earthRadiusVectorAU = PAMacros.SunDist(lctHour, lctMin, lctSec, daylightSaving, zoneCorrectionHours, localDateDay, localDateMonth, localDateYear);

        var leLdRad = (earthLongitudeLeDeg - ldDeg).ToRadians();
        var aRad    = (rdAU < earthRadiusVectorAU) ? (rdAU * (leLdRad).Sine()).AngleTangent2(earthRadiusVectorAU - rdAU * (leLdRad).Cosine()) : (earthRadiusVectorAU * (-leLdRad).Sine()).AngleTangent2(rdAU - earthRadiusVectorAU * (leLdRad).Cosine());

        var cometLongDeg1   = (rdAU < earthRadiusVectorAU) ? 180.0 + earthLongitudeLeDeg + PAMacros.Degrees(aRad) : PAMacros.Degrees(aRad) + ldDeg;
        var cometLongDeg    = cometLongDeg1 - 360 * (cometLongDeg1 / 360).Floor();
        var cometLatDeg     = PAMacros.Degrees((rdAU * (psiRad).Tangent() * ((cometLongDeg1 - ldDeg).ToRadians()).Sine() / (earthRadiusVectorAU * (-leLdRad).Sine())).AngleTangent());
        var cometRAHours1   = PAMacros.DecimalDegreesToDegreeHours(PAMacros.EcRA(cometLongDeg, 0, 0, cometLatDeg, 0, 0, greenwichDateDay, greenwichDateMonth, greenwichDateYear));
        var cometDecDeg1    = PAMacros.EcDec(cometLongDeg, 0, 0, cometLatDeg, 0, 0, greenwichDateDay, greenwichDateMonth, greenwichDateYear);
        var cometDistanceAU = (Math.Pow(earthRadiusVectorAU, 2) + Math.Pow(rAU, 2) - 2.0 * earthRadiusVectorAU * rAU * ((lcDeg - earthLongitudeLeDeg).ToRadians()).Cosine() * (psiRad).Cosine()).SquareRoot();

        var cometRAHour    = PAMacros.DecimalHoursHour(cometRAHours1 + 0.008333);
        var cometRAMin     = PAMacros.DecimalHoursMinute(cometRAHours1 + 0.008333);
        var cometDecDeg    = PAMacros.DecimalDegreesDegrees(cometDecDeg1 + 0.008333);
        var cometDecMin    = PAMacros.DecimalDegreesMinutes(cometDecDeg1 + 0.008333);
        var cometDistEarth = Math.Round(cometDistanceAU, 2);

        return(cometRAHour, cometRAMin, cometDecDeg, cometDecMin, cometDistEarth);
    }
Exemple #11
0
    /// <summary>
    /// Convert Universal Time to Greenwich Sidereal Time
    /// </summary>
    /// <returns>Tuple (int gstHours, int gstMinutes, double gstSeconds)</returns>
    public (int gstHours, int gstMinutes, double gstSeconds) UniversalTimeToGreenwichSiderealTime(double utHours, double utMinutes, double utSeconds, double gwDay, int gwMonth, int gwYear)
    {
        var jd   = PAMacros.CivilDateToJulianDate(gwDay, gwMonth, gwYear);
        var s    = jd - 2451545;
        var t    = s / 36525;
        var t01  = 6.697374558 + (2400.051336 * t) + (0.000025862 * t * t);
        var t02  = t01 - (24.0 * (t01 / 24).Floor());
        var ut   = PAMacros.HMStoDH(utHours, utMinutes, utSeconds);
        var a    = ut * 1.002737909;
        var gst1 = t02 + a;
        var gst2 = gst1 - (24.0 * (gst1 / 24).Floor());

        var gstHours   = PAMacros.DecimalHoursHour(gst2);
        var gstMinutes = PAMacros.DecimalHoursMinute(gst2);
        var gstSeconds = PAMacros.DecimalHoursSecond(gst2);

        return(gstHours, gstMinutes, gstSeconds);
    }
Exemple #12
0
    /// <summary>
    /// Convert Greenwich Sidereal Time to Universal Time
    /// </summary>
    /// <returns>Tuple (int utHours, int utMinutes, double utSeconds, PAWarningFlag warningFlag)</returns>
    public (int utHours, int utMinutes, double utSeconds, PAWarningFlag warningFlag) GreenwichSiderealTimeToUniversalTime(double gstHours, double gstMinutes, double gstSeconds, double gwDay, int gwMonth, int gwYear)
    {
        var jd        = PAMacros.CivilDateToJulianDate(gwDay, gwMonth, gwYear);
        var s         = jd - 2451545;
        var t         = s / 36525;
        var t01       = 6.697374558 + (2400.051336 * t) + (0.000025862 * t * t);
        var t02       = t01 - (24 * (t01 / 24).Floor());
        var gstHours1 = PAMacros.HMStoDH(gstHours, gstMinutes, gstSeconds);

        var a         = gstHours1 - t02;
        var b         = a - (24 * (a / 24).Floor());
        var ut        = b * 0.9972695663;
        var utHours   = PAMacros.DecimalHoursHour(ut);
        var utMinutes = PAMacros.DecimalHoursMinute(ut);
        var utSeconds = PAMacros.DecimalHoursSecond(ut);

        var warningFlag = (ut < 0.065574) ? PAWarningFlag.Warning : PAWarningFlag.OK;

        return(utHours, utMinutes, utSeconds, warningFlag);
    }
    /// <summary>
    /// Calculate nutation for two values: ecliptic longitude and obliquity, for a Greenwich date.
    /// </summary>
    /// <returns>Tuple (nutation in ecliptic longitude (degrees), nutation in obliquity (degrees))</returns>
    public (double nutInLongDeg, double nutInOblDeg) NutationInEclipticLongitudeAndObliquity(double greenwichDay, int greenwichMonth, int greenwichYear)
    {
        var jdDays          = PAMacros.CivilDateToJulianDate(greenwichDay, greenwichMonth, greenwichYear);
        var tCenturies      = (jdDays - 2415020) / 36525;
        var aDeg            = 100.0021358 * tCenturies;
        var l1Deg           = 279.6967 + (0.000303 * tCenturies * tCenturies);
        var lDeg1           = l1Deg + 360 * (aDeg - aDeg.Floor());
        var lDeg2           = lDeg1 - 360 * (lDeg1 / 360).Floor();
        var lRad            = lDeg2.ToRadians();
        var bDeg            = 5.372617 * tCenturies;
        var nDeg1           = 259.1833 - 360 * (bDeg - bDeg.Floor());
        var nDeg2           = nDeg1 - 360 * ((nDeg1 / 360).Floor());
        var nRad            = nDeg2.ToRadians();
        var nutInLongArcsec = -17.2 * nRad.Sine() - 1.3 * (2 * lRad).Sine();
        var nutInOblArcsec  = 9.2 * nRad.Cosine() + 0.5 * (2 * lRad).Cosine();

        var nutInLongDeg = nutInLongArcsec / 3600;
        var nutInOblDeg  = nutInOblArcsec / 3600;

        return(nutInLongDeg, nutInOblDeg);
    }
    /// <summary>
    /// Calculate precession (corrected coordinates between two epochs)
    /// </summary>
    /// <returns>Tuple (correctedRAHour, correctedRAMinutes, correctedRASeconds, correctedDecDeg, correctedDecMinutes, correctedDecSeconds)</returns>
    public (double correctedRAHour, double correctedRAMinutes, double correctedRASeconds, double correctedDecDeg, double correctedDecMinutes, double correctedDecSeconds) CorrectForPrecession(double raHour, double raMinutes, double raSeconds, double decDeg, double decMinutes, double decSeconds, double epoch1Day, int epoch1Month, int epoch1Year, double epoch2Day, int epoch2Month, int epoch2Year)
    {
        var ra1Rad     = (PAMacros.DegreeHoursToDecimalDegrees(PAMacros.HMStoDH(raHour, raMinutes, raSeconds))).ToRadians();
        var dec1Rad    = (PAMacros.DegreesMinutesSecondsToDecimalDegrees(decDeg, decMinutes, decSeconds)).ToRadians();
        var tCenturies = (PAMacros.CivilDateToJulianDate(epoch1Day, epoch1Month, epoch1Year) - 2415020) / 36525;
        var mSec       = 3.07234 + (0.00186 * tCenturies);
        var nArcsec    = 20.0468 - (0.0085 * tCenturies);
        var nYears     = (PAMacros.CivilDateToJulianDate(epoch2Day, epoch2Month, epoch2Year) - PAMacros.CivilDateToJulianDate(epoch1Day, epoch1Month, epoch1Year)) / 365.25;
        var s1Hours    = ((mSec + (nArcsec * (ra1Rad).Sine() * (dec1Rad).Tangent() / 15)) * nYears) / 3600;
        var ra2Hours   = PAMacros.HMStoDH(raHour, raMinutes, raSeconds) + s1Hours;
        var s2Deg      = (nArcsec * (ra1Rad).Cosine() * nYears) / 3600;
        var dec2Deg    = PAMacros.DegreesMinutesSecondsToDecimalDegrees(decDeg, decMinutes, decSeconds) + s2Deg;

        var correctedRAHour     = PAMacros.DecimalHoursHour(ra2Hours);
        var correctedRAMinutes  = PAMacros.DecimalHoursMinute(ra2Hours);
        var correctedRASeconds  = PAMacros.DecimalHoursSecond(ra2Hours);
        var correctedDecDeg     = PAMacros.DecimalDegreesDegrees(dec2Deg);
        var correctedDecMinutes = PAMacros.DecimalDegreesMinutes(dec2Deg);
        var correctedDecSeconds = PAMacros.DecimalDegreesSeconds(dec2Deg);

        return(correctedRAHour, correctedRAMinutes, correctedRASeconds, correctedDecDeg, correctedDecMinutes, correctedDecSeconds);
    }
Exemple #15
0
    /// <summary>
    /// Convert Universal Time to local Civil Time
    /// </summary>
    /// <returns>Tuple (int lctHours, int lctMinutes, int lctSeconds, int localDay, int localMonth, int localYear)</returns>
    public (int lctHours, int lctMinutes, int lctSeconds, int localDay, int localMonth, int localYear) UniversalTimeToLocalCivilTime(double utHours, double utMinutes, double utSeconds, bool isDaylightSavings, int zoneCorrection, int gwDay, int gwMonth, int gwYear)
    {
        var dstValue             = (isDaylightSavings) ? 1 : 0;
        var ut                   = PAMacros.HMStoDH(utHours, utMinutes, utSeconds);
        var zoneTime             = ut + zoneCorrection;
        var localTime            = zoneTime + dstValue;
        var localJDPlusLocalTime = PAMacros.CivilDateToJulianDate(gwDay, gwMonth, gwYear) + (localTime / 24);
        var localDay             = PAMacros.JulianDateDay(localJDPlusLocalTime);
        var integerDay           = localDay.Floor();
        var localMonth           = PAMacros.JulianDateMonth(localJDPlusLocalTime);
        var localYear            = PAMacros.JulianDateYear(localJDPlusLocalTime);

        var lct = 24 * (localDay - integerDay);

        return(
            PAMacros.DecimalHoursHour(lct),
            PAMacros.DecimalHoursMinute(lct),
            (int)PAMacros.DecimalHoursSecond(lct),
            (int)integerDay,
            localMonth,
            localYear
            );
    }
Exemple #16
0
    /// <summary>
    /// Calculate orbital data for binary star.
    /// </summary>
    /// <returns>
    /// <para>positionAngleDeg -- Position angle (degrees)</para>
    /// <para>separationArcsec -- Separation of binary members (arcseconds)</para>
    /// </returns>
    public (double positionAngleDeg, double separationArcsec) BinaryStarOrbit(double greenwichDateDay, int greenwichDateMonth, int greenwichDateYear, string binaryName)
    {
        var binaryInfo = BinaryInfo.GetBinaryInfo(binaryName);

        var yYears         = (greenwichDateYear + (PAMacros.CivilDateToJulianDate(greenwichDateDay, greenwichDateMonth, greenwichDateYear) - PAMacros.CivilDateToJulianDate(0, 1, greenwichDateYear)) / 365.242191) - binaryInfo.EpochPeri;
        var mDeg           = 360 * yYears / binaryInfo.Period;
        var mRad           = (mDeg - 360 * (mDeg / 360).Floor()).ToRadians();
        var eccentricity   = binaryInfo.Ecc;
        var trueAnomalyRad = PAMacros.TrueAnomaly(mRad, eccentricity);
        var rArcsec        = (1 - eccentricity * (PAMacros.EccentricAnomaly(mRad, eccentricity)).Cosine()) * binaryInfo.Axis;
        var taPeriRad      = trueAnomalyRad + binaryInfo.LongPeri.ToRadians();

        var y         = (taPeriRad).Sine() * ((binaryInfo.Incl).ToRadians()).Cosine();
        var x         = (taPeriRad).Cosine();
        var aDeg      = PAMacros.Degrees(y.AngleTangent2(x));
        var thetaDeg1 = aDeg + binaryInfo.PANode;
        var thetaDeg2 = thetaDeg1 - 360 * (thetaDeg1 / 360).Floor();
        var rhoArcsec = rArcsec * (taPeriRad).Cosine() / ((thetaDeg2 - binaryInfo.PANode).ToRadians()).Cosine();

        var positionAngleDeg = Math.Round(thetaDeg2, 1);
        var separationArcsec = Math.Round(rhoArcsec, 2);

        return(positionAngleDeg, separationArcsec);
    }