コード例 #1
0
    /// <summary>
    /// Calculate date/time of local moonrise and moonset.
    /// </summary>
    /// <returns>
    /// <para>mrLTHour -- Moonrise, local time (hour part)</para>
    /// <para>mrLTMin -- Moonrise, local time (minutes part)</para>
    /// <para>mrLocalDateDay -- Moonrise, local date (day)</para>
    /// <para>mrLocalDateMonth -- Moonrise, local date (month)</para>
    /// <para>mrLocalDateYear -- Moonrise, local date (year)</para>
    /// <para>mrAzimuthDeg -- Moonrise, azimuth (degrees)</para>
    /// <para>msLTHour -- Moonset, local time (hour part)</para>
    /// <para>msLTMin -- Moonset, local time (minutes part)</para>
    /// <para>msLocalDateDay -- Moonset, local date (day)</para>
    /// <para>msLocalDateMonth -- Moonset, local date (month)</para>
    /// <para>msLocalDateYear -- Moonset, local date (year)</para>
    /// <para>msAzimuthDeg -- Moonset, azimuth (degrees)</para>
    /// </returns>
    public (double mrLTHour, double mrLTMin, double mrLocalDateDay, int mrLocalDateMonth, int mrLocalDateYear, double mrAzimuthDeg, double msLTHour, double msLTMin, double msLocalDateDay, int msLocalDateMonth, int msLocalDateYear, double msAzimuthDeg) MoonriseAndMoonset(double localDateDay, int localDateMonth, int localDateYear, bool isDaylightSaving, int zoneCorrectionHours, double geogLongDeg, double geogLatDeg)
    {
        var daylightSaving = (isDaylightSaving) ? 1 : 0;

        var localTimeOfMoonriseHours = PAMacros.MoonRiseLCT(localDateDay, localDateMonth, localDateYear, daylightSaving, zoneCorrectionHours, geogLongDeg, geogLatDeg);
        var moonRiseLCResult         = PAMacros.MoonRiseLcDMY(localDateDay, localDateMonth, localDateYear, daylightSaving, zoneCorrectionHours, geogLongDeg, geogLatDeg);
        var localAzimuthDeg1         = PAMacros.MoonRiseAz(localDateDay, localDateMonth, localDateYear, daylightSaving, zoneCorrectionHours, geogLongDeg, geogLatDeg);

        var localTimeOfMoonsetHours = PAMacros.MoonSetLCT(localDateDay, localDateMonth, localDateYear, daylightSaving, zoneCorrectionHours, geogLongDeg, geogLatDeg);
        var moonSetLCResult         = PAMacros.MoonSetLcDMY(localDateDay, localDateMonth, localDateYear, daylightSaving, zoneCorrectionHours, geogLongDeg, geogLatDeg);
        var localAzimuthDeg2        = PAMacros.MoonSetAz(localDateDay, localDateMonth, localDateYear, daylightSaving, zoneCorrectionHours, geogLongDeg, geogLatDeg);

        var mrLTHour         = PAMacros.DecimalHoursHour(localTimeOfMoonriseHours + 0.008333);
        var mrLTMin          = PAMacros.DecimalHoursMinute(localTimeOfMoonriseHours + 0.008333);
        var mrLocalDateDay   = moonRiseLCResult.dy1;
        var mrLocalDateMonth = moonRiseLCResult.mn1;
        var mrLocalDateYear  = moonRiseLCResult.yr1;
        var mrAzimuthDeg     = Math.Round(localAzimuthDeg1, 2);
        var msLTHour         = PAMacros.DecimalHoursHour(localTimeOfMoonsetHours + 0.008333);
        var msLTMin          = PAMacros.DecimalHoursMinute(localTimeOfMoonsetHours + 0.008333);
        var msLocalDateDay   = moonSetLCResult.dy1;
        var msLocalDateMonth = moonSetLCResult.mn1;
        var msLocalDateYear  = moonSetLCResult.yr1;
        var msAzimuthDeg     = Math.Round(localAzimuthDeg2, 2);

        return(mrLTHour, mrLTMin, mrLocalDateDay, mrLocalDateMonth, mrLocalDateYear, mrAzimuthDeg, msLTHour, msLTMin, msLocalDateDay, msLocalDateMonth, msLocalDateYear, msAzimuthDeg);
    }
    /// <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);
    }
コード例 #3
0
    /// <summary>
    /// Calculate precise position of the Moon.
    /// </summary>
    /// <returns>
    /// <para>moonRAHour -- Right ascension of Moon (hour part)</para>
    /// <para>moonRAMin -- Right ascension of Moon (minutes part)</para>
    /// <para>moonRASec -- Right ascension of Moon (seconds part)</para>
    /// <para>moonDecDeg -- Declination of Moon (degrees part)</para>
    /// <para>moonDecMin -- Declination of Moon (minutes part)</para>
    /// <para>moonDecSec -- Declination of Moon (seconds part)</para>
    /// <para>earthMoonDistKM -- Distance from Earth to Moon (km)</para>
    /// <para>moonHorParallaxDeg -- Horizontal parallax of Moon (degrees)</para>
    /// </returns>
    public (double moonRAHour, double moonRAMin, double moonRASec, double moonDecDeg, double moonDecMin, double moonDecSec, double earthMoonDistKM, double moonHorParallaxDeg) PrecisePositionOfMoon(double lctHour, double lctMin, double lctSec, bool isDaylightSaving, int zoneCorrectionHours, double localDateDay, int localDateMonth, int localDateYear)
    {
        var daylightSaving = (isDaylightSaving) ? 1 : 0;

        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 moonResult = PAMacros.MoonLongLatHP(lctHour, lctMin, lctSec, daylightSaving, zoneCorrectionHours, localDateDay, localDateMonth, localDateYear);

        var nutationInLongitudeDeg = PAMacros.NutatLong(gdateDay, gdateMonth, gdateYear);
        var correctedLongDeg       = moonResult.moonLongDeg + nutationInLongitudeDeg;
        var earthMoonDistanceKM    = 6378.14 / moonResult.moonHorPara.ToRadians().Sine();
        var moonRAHours1           = PAMacros.DecimalDegreesToDegreeHours(PAMacros.EcRA(correctedLongDeg, 0, 0, moonResult.moonLatDeg, 0, 0, gdateDay, gdateMonth, gdateYear));
        var moonDecDeg1            = PAMacros.EcDec(correctedLongDeg, 0, 0, moonResult.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);
        var earthMoonDistKM    = Math.Round(earthMoonDistanceKM, 0);
        var moonHorParallaxDeg = Math.Round(moonResult.moonHorPara, 6);

        return(moonRAHour, moonRAMin, moonRASec, moonDecDeg, moonDecMin, moonDecSec, earthMoonDistKM, moonHorParallaxDeg);
    }
コード例 #4
0
    /// <summary>
    /// Determine if a lunar eclipse is likely to occur.
    /// </summary>
    /// <returns>
    /// <para>status -- One of "Lunar eclipse certain", "Lunar eclipse possible", or "No lunar eclipse".</para>
    /// <para>eventDateDay -- Date of eclipse event (day).</para>
    /// <para>eventDateMonth -- Date of eclipse event (month).</para>
    /// <para>eventDateYear -- Date of eclipse event (year).</para>
    /// </returns>
    public (string status, double eventDateDay, int eventDateMonth, int eventDateYear) LunarEclipseOccurrence(double localDateDay, int localDateMonth, int localDateYear, bool isDaylightSaving, int zoneCorrectionHours)
    {
        var daylightSaving = (isDaylightSaving) ? 1 : 0;

        var julianDateOfFullMoon = PAMacros.FullMoon(daylightSaving, zoneCorrectionHours, localDateDay, localDateMonth, localDateYear);

        var gDateOfFullMoonDay   = PAMacros.JulianDateDay(julianDateOfFullMoon);
        var integerDay           = (gDateOfFullMoonDay).Floor();
        var gDateOfFullMoonMonth = PAMacros.JulianDateMonth(julianDateOfFullMoon);
        var gDateOfFullMoonYear  = PAMacros.JulianDateYear(julianDateOfFullMoon);
        var utOfFullMoonHours    = gDateOfFullMoonDay - integerDay;

        var localCivilDateDay   = PAMacros.UniversalTime_LocalCivilDay(utOfFullMoonHours, 0.0, 0.0, daylightSaving, zoneCorrectionHours, integerDay, gDateOfFullMoonMonth, gDateOfFullMoonYear);
        var localCivilDateMonth = PAMacros.UniversalTime_LocalCivilMonth(utOfFullMoonHours, 0.0, 0.0, daylightSaving, zoneCorrectionHours, integerDay, gDateOfFullMoonMonth, gDateOfFullMoonYear);
        var localCivilDateYear  = PAMacros.UniversalTime_LocalCivilYear(utOfFullMoonHours, 0.0, 0.0, daylightSaving, zoneCorrectionHours, integerDay, gDateOfFullMoonMonth, gDateOfFullMoonYear);

        var eclipseOccurrence = PAMacros.LunarEclipseOccurrence(daylightSaving, zoneCorrectionHours, localDateDay, localDateMonth, localDateYear);

        var status         = eclipseOccurrence;
        var eventDateDay   = localCivilDateDay;
        var eventDateMonth = localCivilDateMonth;
        var eventDateYear  = localCivilDateYear;

        return(status, eventDateDay, eventDateMonth, eventDateYear);
    }
コード例 #5
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-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);
    }
    /// <summary>
    /// Convert Equatorial Coordinates to Ecliptic Coordinates
    /// </summary>
    /// <returns>Tuple (outEclLongDeg, outEclLongMin, outEclLongSec, outEclLatDeg, outEclLatMin, outEclLatSec)</returns>
    public (double outEclLongDeg, double outEclLongMin, double outEclLongSec, double outEclLatDeg, double outEclLatMin, double outEclLatSec) EquatorialCoordinateToEclipticCoordinate(double raHours, double raMinutes, double raSeconds, double decDegrees, double decMinutes, double decSeconds, double gwDay, int gwMonth, int gwYear)
    {
        var raDeg       = PAMacros.DegreeHoursToDecimalDegrees(PAMacros.HMStoDH(raHours, raMinutes, raSeconds));
        var decDeg      = PAMacros.DegreesMinutesSecondsToDecimalDegrees(decDegrees, decMinutes, decSeconds);
        var raRad       = raDeg.ToRadians();
        var decRad      = decDeg.ToRadians();
        var obliqDeg    = PAMacros.Obliq(gwDay, gwMonth, gwYear);
        var obliqRad    = obliqDeg.ToRadians();
        var sinEclLat   = decRad.Sine() * obliqRad.Cosine() - decRad.Cosine() * obliqRad.Sine() * raRad.Sine();
        var eclLatRad   = sinEclLat.ASine();
        var eclLatDeg   = PAMacros.Degrees(eclLatRad);
        var y           = raRad.Sine() * obliqRad.Cosine() + decRad.Tangent() * obliqRad.Sine();
        var x           = raRad.Cosine();
        var eclLongRad  = y.AngleTangent2(x);
        var eclLongDeg1 = PAMacros.Degrees(eclLongRad);
        var eclLongDeg2 = eclLongDeg1 - 360 * (eclLongDeg1 / 360).Floor();

        var outEclLongDeg = PAMacros.DecimalDegreesDegrees(eclLongDeg2);
        var outEclLongMin = PAMacros.DecimalDegreesMinutes(eclLongDeg2);
        var outEclLongSec = PAMacros.DecimalDegreesSeconds(eclLongDeg2);
        var outEclLatDeg  = PAMacros.DecimalDegreesDegrees(eclLatDeg);
        var outEclLatMin  = PAMacros.DecimalDegreesMinutes(eclLatDeg);
        var outEclLatSec  = PAMacros.DecimalDegreesSeconds(eclLatDeg);

        return(outEclLongDeg, outEclLongMin, outEclLongSec, outEclLatDeg, outEclLatMin, outEclLatSec);
    }
コード例 #8
0
    /// <summary>
    /// Calculate new moon and full moon instances.
    /// </summary>
    /// <returns>
    /// <para>nmLocalTimeHour -- new Moon instant - local time (hour)</para>
    /// <para>nmLocalTimeMin -- new Moon instant - local time (minutes)</para>
    /// <para>nmLocalDateDay -- new Moon instance - local date (day)</para>
    /// <para>nmLocalDateMonth -- new Moon instance - local date (month)</para>
    /// <para>nmLocalDateYear -- new Moon instance - local date (year)</para>
    /// <para>fmLocalTimeHour -- full Moon instant - local time (hour)</para>
    /// <para>fmLocalTimeMin -- full Moon instant - local time (minutes)</para>
    /// <para>fmLocalDateDay -- full Moon instance - local date (day)</para>
    /// <para>fmLocalDateMonth -- full Moon instance - local date (month)</para>
    /// <para>fmLocalDateYear -- full Moon instance - local date (year)</para>
    /// </returns>
    public (double nmLocalTimeHour, double nmLocalTimeMin, double nmLocalDateDay, int nmLocalDateMonth, int nmLocalDateYear, double fmLocalTimeHour, double fmLocalTimeMin, double fmLocalDateDay, int fmLocalDateMonth, int fmLocalDateYear) TimesOfNewMoonAndFullMoon(bool isDaylightSaving, int zoneCorrectionHours, double localDateDay, int localDateMonth, int localDateYear)
    {
        var daylightSaving = (isDaylightSaving) ? 1 : 0;

        var jdOfNewMoonDays  = PAMacros.NewMoon(daylightSaving, zoneCorrectionHours, localDateDay, localDateMonth, localDateYear);
        var jdOfFullMoonDays = PAMacros.FullMoon(3, zoneCorrectionHours, localDateDay, localDateMonth, localDateYear);

        var gDateOfNewMoonDay   = PAMacros.JulianDateDay(jdOfNewMoonDays);
        var integerDay1         = gDateOfNewMoonDay.Floor();
        var gDateOfNewMoonMonth = PAMacros.JulianDateMonth(jdOfNewMoonDays);
        var gDateOfNewMoonYear  = PAMacros.JulianDateYear(jdOfNewMoonDays);

        var gDateOfFullMoonDay   = PAMacros.JulianDateDay(jdOfFullMoonDays);
        var integerDay2          = gDateOfFullMoonDay.Floor();
        var gDateOfFullMoonMonth = PAMacros.JulianDateMonth(jdOfFullMoonDays);
        var gDateOfFullMoonYear  = PAMacros.JulianDateYear(jdOfFullMoonDays);

        var utOfNewMoonHours   = 24.0 * (gDateOfNewMoonDay - integerDay1);
        var utOfFullMoonHours  = 24.0 * (gDateOfFullMoonDay - integerDay2);
        var lctOfNewMoonHours  = PAMacros.UniversalTimeToLocalCivilTime(utOfNewMoonHours + 0.008333, 0, 0, daylightSaving, zoneCorrectionHours, integerDay1, gDateOfNewMoonMonth, gDateOfNewMoonYear);
        var lctOfFullMoonHours = PAMacros.UniversalTimeToLocalCivilTime(utOfFullMoonHours + 0.008333, 0, 0, daylightSaving, zoneCorrectionHours, integerDay2, gDateOfFullMoonMonth, gDateOfFullMoonYear);

        var nmLocalTimeHour  = PAMacros.DecimalHoursHour(lctOfNewMoonHours);
        var nmLocalTimeMin   = PAMacros.DecimalHoursMinute(lctOfNewMoonHours);
        var nmLocalDateDay   = PAMacros.UniversalTime_LocalCivilDay(utOfNewMoonHours, 0, 0, daylightSaving, zoneCorrectionHours, integerDay1, gDateOfNewMoonMonth, gDateOfNewMoonYear);
        var nmLocalDateMonth = PAMacros.UniversalTime_LocalCivilMonth(utOfNewMoonHours, 0, 0, daylightSaving, zoneCorrectionHours, integerDay1, gDateOfNewMoonMonth, gDateOfNewMoonYear);
        var nmLocalDateYear  = PAMacros.UniversalTime_LocalCivilYear(utOfNewMoonHours, 0, 0, daylightSaving, zoneCorrectionHours, integerDay1, gDateOfNewMoonMonth, gDateOfNewMoonYear);
        var fmLocalTimeHour  = PAMacros.DecimalHoursHour(lctOfFullMoonHours);
        var fmLocalTimeMin   = PAMacros.DecimalHoursMinute(lctOfFullMoonHours);
        var fmLocalDateDay   = PAMacros.UniversalTime_LocalCivilDay(utOfFullMoonHours, 0, 0, daylightSaving, zoneCorrectionHours, integerDay2, gDateOfFullMoonMonth, gDateOfFullMoonYear);
        var fmLocalDateMonth = PAMacros.UniversalTime_LocalCivilMonth(utOfFullMoonHours, 0, 0, daylightSaving, zoneCorrectionHours, integerDay2, gDateOfFullMoonMonth, gDateOfFullMoonYear);
        var fmLocalDateYear  = PAMacros.UniversalTime_LocalCivilYear(utOfFullMoonHours, 0, 0, daylightSaving, zoneCorrectionHours, integerDay2, gDateOfFullMoonMonth, gDateOfFullMoonYear);

        return(nmLocalTimeHour, nmLocalTimeMin, nmLocalDateDay, nmLocalDateMonth, nmLocalDateYear, fmLocalTimeHour, fmLocalTimeMin, fmLocalDateDay, fmLocalDateMonth, fmLocalDateYear);
    }
    /// <summary>
    /// Convert Galactic Coordinates to Equatorial Coordinates
    /// </summary>
    /// <returns>Tuple (raHours, raMinutes, raSeconds, decDegrees, decMinutes, decSeconds)</returns>
    public (double raHours, double raMinutes, double raSeconds, double decDegrees, double decMinutes, double decSeconds) GalacticCoordinateToEquatorialCoordinate(double galLongDeg, double galLongMin, double galLongSec, double galLatDeg, double galLatMin, double galLatSec)
    {
        var glongDeg   = PAMacros.DegreesMinutesSecondsToDecimalDegrees(galLongDeg, galLongMin, galLongSec);
        var glatDeg    = PAMacros.DegreesMinutesSecondsToDecimalDegrees(galLatDeg, galLatMin, galLatSec);
        var glongRad   = glongDeg.ToRadians();
        var glatRad    = glatDeg.ToRadians();
        var sinDec     = glatRad.Cosine() * (27.4).ToRadians().Cosine() * (glongRad - (33.0).ToRadians()).Sine() + glatRad.Sine() * (27.4).ToRadians().Sine();
        var decRadians = sinDec.ASine();
        var decDeg     = PAMacros.Degrees(decRadians);
        var y          = glatRad.Cosine() * (glongRad - (33.0).ToRadians()).Cosine();
        var x          = glatRad.Sine() * ((27.4).ToRadians()).Cosine() - (glatRad).Cosine() * ((27.4).ToRadians()).Sine() * (glongRad - (33.0).ToRadians()).Sine();

        var raDeg1   = PAMacros.Degrees(y.AngleTangent2(x)) + 192.25;
        var raDeg2   = raDeg1 - 360 * (raDeg1 / 360).Floor();
        var raHours1 = PAMacros.DecimalDegreesToDegreeHours(raDeg2);

        var raHours    = PAMacros.DecimalHoursHour(raHours1);
        var raMinutes  = PAMacros.DecimalHoursMinute(raHours1);
        var raSeconds  = PAMacros.DecimalHoursSecond(raHours1);
        var decDegrees = PAMacros.DecimalDegreesDegrees(decDeg);
        var decMinutes = PAMacros.DecimalDegreesMinutes(decDeg);
        var decSeconds = PAMacros.DecimalDegreesSeconds(decDeg);

        return(raHours, raMinutes, raSeconds, decDegrees, decMinutes, decSeconds);
    }
コード例 #10
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);
    }
コード例 #11
0
    /// <summary>
    /// Calculate Moon phase and position angle of bright limb.
    /// </summary>
    /// <returns>
    /// <para>moonPhase -- Phase of Moon, between 0 and 1, where 0 is New and 1 is Full.</para>
    /// <para>paBrightLimbDeg -- Position angle of the bright limb (degrees)</para>
    /// </returns>
    public (double moonPhase, double paBrightLimbDeg) MoonPhase(double lctHour, double lctMin, double lctSec, bool isDaylightSaving, int zoneCorrectionHours, double localDateDay, int localDateMonth, int localDateYear, PAAccuracyLevel accuracyLevel)
    {
        var daylightSaving = (isDaylightSaving) ? 1 : 0;

        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 sunLongDeg = PAMacros.SunLong(lctHour, lctMin, lctSec, daylightSaving, zoneCorrectionHours, localDateDay, localDateMonth, localDateYear);
        var moonResult = PAMacros.MoonLongLatHP(lctHour, lctMin, lctSec, daylightSaving, zoneCorrectionHours, localDateDay, localDateMonth, localDateYear);
        var dRad       = (moonResult.moonLongDeg - sunLongDeg).ToRadians();

        var moonPhase1 = (accuracyLevel == PAAccuracyLevel.Precise) ? PAMacros.MoonPhase(lctHour, lctMin, lctSec, daylightSaving, zoneCorrectionHours, localDateDay, localDateMonth, localDateYear) : (1.0 - (dRad).Cosine()) / 2.0;

        var sunRARad   = (PAMacros.EcRA(sunLongDeg, 0, 0, 0, 0, 0, gdateDay, gdateMonth, gdateYear)).ToRadians();
        var moonRARad  = (PAMacros.EcRA(moonResult.moonLongDeg, 0, 0, moonResult.moonLatDeg, 0, 0, gdateDay, gdateMonth, gdateYear)).ToRadians();
        var sunDecRad  = (PAMacros.EcDec(sunLongDeg, 0, 0, 0, 0, 0, gdateDay, gdateMonth, gdateYear)).ToRadians();
        var moonDecRad = (PAMacros.EcDec(moonResult.moonLongDeg, 0, 0, moonResult.moonLatDeg, 0, 0, gdateDay, gdateMonth, gdateYear)).ToRadians();

        var y = (sunDecRad).Cosine() * (sunRARad - moonRARad).Sine();
        var x = (moonDecRad).Cosine() * (sunDecRad).Sine() - (moonDecRad).Sine() * (sunDecRad).Cosine() * (sunRARad - moonRARad).Cosine();

        var chiDeg = PAMacros.Degrees(y.AngleTangent2(x));

        var moonPhase       = Math.Round(moonPhase1, 2);
        var paBrightLimbDeg = Math.Round(chiDeg, 2);

        return(moonPhase, paBrightLimbDeg);
    }
    /// <summary>
    /// Calculate the angle between two celestial objects
    /// </summary>
    /// <returns>Tuple (angleDeg, angleMin, angleSec)</returns>
    public (double angleDeg, double angleMin, double angleSec) AngleBetweenTwoObjects(double raLong1HourDeg, double raLong1Min, double raLong1Sec, double decLat1Deg, double decLat1Min, double decLat1Sec, double raLong2HourDeg, double raLong2Min, double raLong2Sec, double decLat2Deg, double decLat2Min, double decLat2Sec, PAAngleMeasure hourOrDegree)
    {
        var raLong1Decimal = (hourOrDegree == PAAngleMeasure.Hours) ? PAMacros.HMStoDH(raLong1HourDeg, raLong1Min, raLong1Sec) : PAMacros.DegreesMinutesSecondsToDecimalDegrees(raLong1HourDeg, raLong1Min, raLong1Sec);
        var raLong1Deg     = (hourOrDegree == PAAngleMeasure.Hours) ? PAMacros.DegreeHoursToDecimalDegrees(raLong1Decimal) : raLong1Decimal;

        var raLong1Rad  = raLong1Deg.ToRadians();
        var decLat1Deg1 = PAMacros.DegreesMinutesSecondsToDecimalDegrees(decLat1Deg, decLat1Min, decLat1Sec);
        var decLat1Rad  = decLat1Deg1.ToRadians();

        var raLong2Decimal = (hourOrDegree == PAAngleMeasure.Hours) ? PAMacros.HMStoDH(raLong2HourDeg, raLong2Min, raLong2Sec) : PAMacros.DegreesMinutesSecondsToDecimalDegrees(raLong2HourDeg, raLong2Min, raLong2Sec);
        var raLong2Deg     = (hourOrDegree == PAAngleMeasure.Hours) ? PAMacros.DegreeHoursToDecimalDegrees(raLong2Decimal) : raLong2Decimal;
        var raLong2Rad     = raLong2Deg.ToRadians();
        var decLat2Deg1    = PAMacros.DegreesMinutesSecondsToDecimalDegrees(decLat2Deg, decLat2Min, decLat2Sec);
        var decLat2Rad     = decLat2Deg1.ToRadians();

        var cosD = decLat1Rad.Sine() * decLat2Rad.Sine() + decLat1Rad.Cosine() * decLat2Rad.Cosine() * (raLong1Rad - raLong2Rad).Cosine();
        var dRad = cosD.ACosine();
        var dDeg = PAMacros.Degrees(dRad);

        var angleDeg = PAMacros.DecimalDegreesDegrees(dDeg);
        var angleMin = PAMacros.DecimalDegreesMinutes(dDeg);
        var angleSec = PAMacros.DecimalDegreesSeconds(dDeg);

        return(angleDeg, angleMin, angleSec);
    }
    /// <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);
    }
コード例 #14
0
    /// <summary>
    /// Calculate local sunrise and sunset.
    /// </summary>
    /// <returns>
    /// <para>localSunriseHour -- Local sunrise, hour part</para>
    /// <para>localSunriseMinute -- Local sunrise, minutes part</para>
    /// <para>localSunsetHour -- Local sunset, hour part</para>
    /// <para>localSunsetMinute -- Local sunset, minutes part</para>
    /// <para>azimuthOfSunriseDeg -- Azimuth (horizon direction) of sunrise, in degrees</para>
    /// <para>azimuthOfSunsetDeg -- Azimuth (horizon direction) of sunset, in degrees</para>
    /// <para>status -- Calculation status</para>
    /// </returns>
    public (double localSunriseHour, double localSunriseMinute, double localSunsetHour, double localSunsetMinute, double azimuthOfSunriseDeg, double azimuthOfSunsetDeg, string status) SunriseAndSunset(double localDay, int localMonth, int localYear, bool isDaylightSaving, int zoneCorrection, double geographicalLongDeg, double geographicalLatDeg)
    {
        var daylightSaving = (isDaylightSaving) ? 1 : 0;

        var localSunriseHours = PAMacros.SunriseLCT(localDay, localMonth, localYear, daylightSaving, zoneCorrection, geographicalLongDeg, geographicalLatDeg);
        var localSunsetHours  = PAMacros.SunsetLCT(localDay, localMonth, localYear, daylightSaving, zoneCorrection, geographicalLongDeg, geographicalLatDeg);

        var sunRiseSetStatus = PAMacros.ESunRS(localDay, localMonth, localYear, daylightSaving, zoneCorrection, geographicalLongDeg, geographicalLatDeg);

        var adjustedSunriseHours = localSunriseHours + 0.008333;
        var adjustedSunsetHours  = localSunsetHours + 0.008333;

        var azimuthOfSunriseDeg1 = PAMacros.SunriseAZ(localDay, localMonth, localYear, daylightSaving, zoneCorrection, geographicalLongDeg, geographicalLatDeg);
        var azimuthOfSunsetDeg1  = PAMacros.SunsetAZ(localDay, localMonth, localYear, daylightSaving, zoneCorrection, geographicalLongDeg, geographicalLatDeg);

        var localSunriseHour   = (sunRiseSetStatus.Equals("OK")) ? PAMacros.DecimalHoursHour(adjustedSunriseHours) : 0;
        var localSunriseMinute = (sunRiseSetStatus.Equals("OK")) ? PAMacros.DecimalHoursMinute(adjustedSunriseHours) : 0;

        var localSunsetHour   = (sunRiseSetStatus.Equals("OK")) ? PAMacros.DecimalHoursHour(adjustedSunsetHours) : 0;
        var localSunsetMinute = (sunRiseSetStatus.Equals("OK")) ? PAMacros.DecimalHoursMinute(adjustedSunsetHours) : 0;

        var azimuthOfSunriseDeg = (sunRiseSetStatus.Equals("OK")) ? Math.Round(azimuthOfSunriseDeg1, 2) : 0;
        var azimuthOfSunsetDeg  = (sunRiseSetStatus.Equals("OK")) ? Math.Round(azimuthOfSunsetDeg1, 2) : 0;

        var status = sunRiseSetStatus;

        return(localSunriseHour, localSunriseMinute, localSunsetHour, localSunsetMinute, azimuthOfSunriseDeg, azimuthOfSunsetDeg, status);
    }
    /// <summary>
    /// Convert Ecliptic Coordinates to Equatorial Coordinates
    /// </summary>
    /// <returns>Tuple (outRAHours, outRAMinutes, outRASeconds, outDecDegrees, outDecMinutes, outDecSeconds)</returns>
    public (double outRAHours, double outRAMinutes, double outRASeconds, double outDecDegrees, double outDecMinutes, double outDecSeconds) EclipticCoordinateToEquatorialCoordinate(double eclipticLongitudeDegrees, double eclipticLongitudeMinutes, double eclipticLongitudeSeconds, double eclipticLatitudeDegrees, double eclipticLatitudeMinutes, double eclipticLatitudeSeconds, double greenwichDay, int greenwichMonth, int greenwichYear)
    {
        var eclonDeg = PAMacros.DegreesMinutesSecondsToDecimalDegrees(eclipticLongitudeDegrees, eclipticLongitudeMinutes, eclipticLongitudeSeconds);
        var eclatDeg = PAMacros.DegreesMinutesSecondsToDecimalDegrees(eclipticLatitudeDegrees, eclipticLatitudeMinutes, eclipticLatitudeSeconds);
        var eclonRad = eclonDeg.ToRadians();
        var eclatRad = eclatDeg.ToRadians();
        var obliqDeg = PAMacros.Obliq(greenwichDay, greenwichMonth, greenwichYear);
        var obliqRad = obliqDeg.ToRadians();
        var sinDec   = eclatRad.Sine() * obliqRad.Cosine() + eclatRad.Cosine() * obliqRad.Sine() * eclonRad.Sine();
        var decRad   = sinDec.ASine();
        var decDeg   = PAMacros.Degrees(decRad);
        var y        = eclonRad.Sine() * obliqRad.Cosine() - eclatRad.Tangent() * obliqRad.Sine();
        var x        = eclonRad.Cosine();
        var raRad    = y.AngleTangent2(x);
        var raDeg1   = PAMacros.Degrees(raRad);
        var raDeg2   = raDeg1 - 360 * (raDeg1 / 360).Floor();
        var raHours  = PAMacros.DecimalDegreesToDegreeHours(raDeg2);

        var outRAHours    = PAMacros.DecimalHoursHour(raHours);
        var outRAMinutes  = PAMacros.DecimalHoursMinute(raHours);
        var outRASeconds  = PAMacros.DecimalHoursSecond(raHours);
        var outDecDegrees = PAMacros.DecimalDegreesDegrees(decDeg);
        var outDecMinutes = PAMacros.DecimalDegreesMinutes(decDeg);
        var outDecSeconds = PAMacros.DecimalDegreesSeconds(decDeg);

        return(outRAHours, outRAMinutes, outRASeconds, outDecDegrees, outDecMinutes, outDecSeconds);
    }
コード例 #16
0
    /// <summary>
    /// Calculate position of a parabolic comet.
    /// </summary>
    /// <returns>
    /// cometRAHour -- Right ascension of comet (hour part)
    /// cometRAMin -- Right ascension of comet (minutes part)
    /// cometRASec -- Right ascension of comet (seconds part)
    /// cometDecDeg -- Declination of comet (degrees part)
    /// cometDecMin -- Declination of comet (minutes part)
    /// cometDecSec -- Declination of comet (seconds part)
    /// cometDistEarth -- Comet's distance from Earth (AU)
    /// </returns>
    /// <returns></returns>
    public (double cometRAHour, double cometRAMin, double cometRASec, double cometDecDeg, double cometDecMin, double cometDecSec, double cometDistEarth) PositionOfParabolicComet(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 = CometInfoParabolic.GetCometParabolicInfo(cometName);

        var perihelionEpochDay   = cometInfo.EpochPeriDay;
        var perihelionEpochMonth = cometInfo.EpochPeriMonth;
        var perihelionEpochYear  = cometInfo.EpochPeriYear;
        var qAU            = cometInfo.PeriDist;
        var inclinationDeg = cometInfo.Incl;
        var perihelionDeg  = cometInfo.ArgPeri;
        var nodeDeg        = cometInfo.Node;

        var cometLongLatDist = PAMacros.PCometLongLatDist(lctHour, lctMin, lctSec, daylightSaving, zoneCorrectionHours, localDateDay, localDateMonth, localDateYear, perihelionEpochDay, perihelionEpochMonth, perihelionEpochYear, qAU, inclinationDeg, perihelionDeg, nodeDeg);

        var cometRAHours = PAMacros.DecimalDegreesToDegreeHours(PAMacros.EcRA(cometLongLatDist.cometLongDeg, 0, 0, cometLongLatDist.cometLatDeg, 0, 0, greenwichDateDay, greenwichDateMonth, greenwichDateYear));
        var cometDecDeg1 = PAMacros.EcDec(cometLongLatDist.cometLongDeg, 0, 0, cometLongLatDist.cometLatDeg, 0, 0, greenwichDateDay, greenwichDateMonth, greenwichDateYear);

        var cometRAHour    = PAMacros.DecimalHoursHour(cometRAHours);
        var cometRAMin     = PAMacros.DecimalHoursMinute(cometRAHours);
        var cometRASec     = PAMacros.DecimalHoursSecond(cometRAHours);
        var cometDecDeg    = PAMacros.DecimalDegreesDegrees(cometDecDeg1);
        var cometDecMin    = PAMacros.DecimalDegreesMinutes(cometDecDeg1);
        var cometDecSec    = PAMacros.DecimalDegreesSeconds(cometDecDeg1);
        var cometDistEarth = Math.Round(cometLongLatDist.cometDistAU, 2);

        return(cometRAHour, cometRAMin, cometRASec, cometDecDeg, cometDecMin, cometDecSec, cometDistEarth);
    }
コード例 #17
0
    /// <summary>
    /// Convert Decimal Hours to Civil Time
    /// </summary>
    /// <returns>Tuple(hours (double), minutes (double), seconds (double))</returns>
    public (double hours, double minutes, double seconds) DecimalHoursToCivilTime(double decimalHours)
    {
        var hours   = PAMacros.DecimalHoursHour(decimalHours);
        var minutes = PAMacros.DecimalHoursMinute(decimalHours);
        var seconds = PAMacros.DecimalHoursSecond(decimalHours);

        return(hours, minutes, seconds);
    }
    /// <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);
    }
コード例 #19
0
    /// <summary>
    /// Calculate solar elongation for a celestial body.
    /// </summary>
    /// <remarks>
    /// Solar elongation is the angle between the lines of sight from the Earth to the Sun and from the Earth to the celestial body.
    /// </remarks>
    /// <returns>solarElongationDeg -- Solar elongation, in degrees</returns>
    public double SolarElongation(double raHour, double raMin, double raSec, double decDeg, double decMin, double decSec, double gwdateDay, int gwdateMonth, int gwdateYear)
    {
        var sunLongitudeDeg    = PAMacros.SunLong(0, 0, 0, 0, 0, gwdateDay, gwdateMonth, gwdateYear);
        var sunRAHours         = PAMacros.DecimalDegreesToDegreeHours(PAMacros.EcRA(sunLongitudeDeg, 0, 0, 0, 0, 0, gwdateDay, gwdateMonth, gwdateYear));
        var sunDecDeg          = PAMacros.EcDec(sunLongitudeDeg, 0, 0, 0, 0, 0, gwdateDay, gwdateMonth, gwdateYear);
        var solarElongationDeg = PAMacros.Angle(sunRAHours, 0, 0, sunDecDeg, 0, 0, raHour, raMin, raSec, decDeg, decMin, decSec, PAAngleMeasure.Hours);

        return(Math.Round(solarElongationDeg, 2));
    }
    /// <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);
    }
コード例 #21
0
    /// <summary>
    /// Calculate the circumstances of a lunar eclipse.
    /// </summary>
    /// <returns>
    /// <para>lunarEclipseCertainDateDay -- Lunar eclipse date (day)</para>
    /// <para>lunarEclipseCertainDateMonth -- Lunar eclipse date (month)</para>
    /// <para>lunarEclipseCertainDateYear -- Lunar eclipse date (year)</para>
    /// <para>utstartPenPhaseHour -- Start of penumbral phase (hour)</para>
    /// <para>utStartPenPhaseMinutes -- Start of penumbral phase (minutes)</para>
    /// <para>utStartUmbralPhaseHour -- Start of umbral phase (hour)</para>
    /// <para>utStartUmbralPhaseMinutes -- Start of umbral phase (minutes)</para>
    /// <para>utStartTotalPhaseHour -- Start of total phase (hour)</para>
    /// <para>utStartTotalPhaseMinutes -- Start of total phase (minutes)</para>
    /// <para>utMidEclipseHour -- Mid-eclipse (hour)</para>
    /// <para>utMidEclipseMinutes -- Mid-eclipse (minutes)</para>
    /// <para>utEndTotalPhaseHour -- End of total phase (hour)</para>
    /// <para>utEndTotalPhaseMinutes -- End of total phase (minutes)</para>
    /// <para>utEndUmbralPhaseHour -- End of umbral phase (hour)</para>
    /// <para>utEndUmbralPhaseMinutes -- End of umbral phase (minutes)</para>
    /// <para>utEndPenPhaseHour -- End of penumbral phase (hour)</para>
    /// <para>utEndPenPhaseMinutes -- End of penumbral phase (minutes)</para>
    /// <para>eclipseMagnitude -- Eclipse magnitude</para>
    /// </returns>
    public (double lunarEclipseCertainDateDay, double lunarEclipseCertainDateMonth, double lunarEclipseCertainDateYear, double utStartPenPhaseHour, double utStartPenPhaseMinutes, double utStartUmbralPhaseHour, double utStartUmbralPhaseMinutes, double utStartTotalPhaseHour, double utStartTotalPhaseMinutes, double utMidEclipseHour, double utMidEclipseMinutes, double utEndTotalPhaseHour, double utEndTotalPhaseMinutes, double utEndUmbralPhaseHour, double utEndUmbralPhaseMinutes, double utEndPenPhaseHour, double utEndPenPhaseMinutes, double eclipseMagnitude) LunarEclipseCircumstances(double localDateDay, int localDateMonth, int localDateYear, bool isDaylightSaving, int zoneCorrectionHours)
    {
        var daylightSaving = (isDaylightSaving) ? 1 : 0;

        var julianDateOfFullMoon = PAMacros.FullMoon(daylightSaving, zoneCorrectionHours, localDateDay, localDateMonth, localDateYear);
        var gDateOfFullMoonDay   = PAMacros.JulianDateDay(julianDateOfFullMoon);
        var integerDay           = gDateOfFullMoonDay.Floor();
        var gDateOfFullMoonMonth = PAMacros.JulianDateMonth(julianDateOfFullMoon);
        var gDateOfFullMoonYear  = PAMacros.JulianDateYear(julianDateOfFullMoon);
        var utOfFullMoonHours    = gDateOfFullMoonDay - integerDay;

        var localCivilDateDay   = PAMacros.UniversalTime_LocalCivilDay(utOfFullMoonHours, 0.0, 0.0, daylightSaving, zoneCorrectionHours, integerDay, gDateOfFullMoonMonth, gDateOfFullMoonYear);
        var localCivilDateMonth = PAMacros.UniversalTime_LocalCivilMonth(utOfFullMoonHours, 0.0, 0.0, daylightSaving, zoneCorrectionHours, integerDay, gDateOfFullMoonMonth, gDateOfFullMoonYear);
        var localCivilDateYear  = PAMacros.UniversalTime_LocalCivilYear(utOfFullMoonHours, 0.0, 0.0, daylightSaving, zoneCorrectionHours, integerDay, gDateOfFullMoonMonth, gDateOfFullMoonYear);

        var utMaxEclipse       = PAMacros.UTMaxLunarEclipse(localDateDay, localDateMonth, localDateYear, daylightSaving, zoneCorrectionHours);
        var utFirstContact     = PAMacros.UTFirstContactLunarEclipse(localDateDay, localDateMonth, localDateYear, daylightSaving, zoneCorrectionHours);
        var utLastContact      = PAMacros.UTLastContactLunarEclipse(localDateDay, localDateMonth, localDateYear, daylightSaving, zoneCorrectionHours);
        var utStartUmbralPhase = PAMacros.UTStartUmbraLunarEclipse(localDateDay, localDateMonth, localDateYear, daylightSaving, zoneCorrectionHours);
        var utEndUmbralPhase   = PAMacros.UTEndUmbraLunarEclipse(localDateDay, localDateMonth, localDateYear, daylightSaving, zoneCorrectionHours);
        var utStartTotalPhase  = PAMacros.UTStartTotalLunarEclipse(localDateDay, localDateMonth, localDateYear, daylightSaving, zoneCorrectionHours);
        var utEndTotalPhase    = PAMacros.UTEndTotalLunarEclipse(localDateDay, localDateMonth, localDateYear, daylightSaving, zoneCorrectionHours);

        var eclipseMagnitude1 = PAMacros.MagLunarEclipse(localDateDay, localDateMonth, localDateYear, daylightSaving, zoneCorrectionHours);

        var lunarEclipseCertainDateDay   = localCivilDateDay;
        var lunarEclipseCertainDateMonth = localCivilDateMonth;
        var lunarEclipseCertainDateYear  = localCivilDateYear;

        var utStartPenPhaseHour    = (utFirstContact == -99.0) ? -99.0 : PAMacros.DecimalHoursHour(utFirstContact + 0.008333);
        var utStartPenPhaseMinutes = (utFirstContact == -99.0) ? -99.0 : PAMacros.DecimalHoursMinute(utFirstContact + 0.008333);

        var utStartUmbralPhaseHour    = (utStartUmbralPhase == -99.0) ? -99.0 : PAMacros.DecimalHoursHour(utStartUmbralPhase + 0.008333);
        var utStartUmbralPhaseMinutes = (utStartUmbralPhase == -99.0) ? -99.0 : PAMacros.DecimalHoursMinute(utStartUmbralPhase + 0.008333);

        var utStartTotalPhaseHour    = (utStartTotalPhase == -99.0) ? -99.0 : PAMacros.DecimalHoursHour(utStartTotalPhase + 0.008333);
        var utStartTotalPhaseMinutes = (utStartTotalPhase == -99.0) ? -99.0 : PAMacros.DecimalHoursMinute(utStartTotalPhase + 0.008333);

        var utMidEclipseHour    = (utMaxEclipse == -99.0) ? -99.0 : PAMacros.DecimalHoursHour(utMaxEclipse + 0.008333);
        var utMidEclipseMinutes = (utMaxEclipse == -99.0) ? -99.0 : PAMacros.DecimalHoursMinute(utMaxEclipse + 0.008333);

        var utEndTotalPhaseHour    = (utEndTotalPhase == -99.0) ? -99.0 : PAMacros.DecimalHoursHour(utEndTotalPhase + 0.008333);
        var utEndTotalPhaseMinutes = (utEndTotalPhase == -99.0) ? -99.0 : PAMacros.DecimalHoursMinute(utEndTotalPhase + 0.008333);

        var utEndUmbralPhaseHour    = (utEndUmbralPhase == -99.0) ? -99.0 : PAMacros.DecimalHoursHour(utEndUmbralPhase + 0.008333);
        var utEndUmbralPhaseMinutes = (utEndUmbralPhase == -99.0) ? -99.0 : PAMacros.DecimalHoursMinute(utEndUmbralPhase + 0.008333);

        var utEndPenPhaseHour    = (utLastContact == -99.0) ? -99.0 : PAMacros.DecimalHoursHour(utLastContact + 0.008333);
        var utEndPenPhaseMinutes = (utLastContact == -99.0) ? -99.0 : PAMacros.DecimalHoursMinute(utLastContact + 0.008333);

        var eclipseMagnitude = (eclipseMagnitude1 == -99.0) ? -99.0 : Math.Round(eclipseMagnitude1, 2);

        return(lunarEclipseCertainDateDay, lunarEclipseCertainDateMonth, lunarEclipseCertainDateYear, utStartPenPhaseHour, utStartPenPhaseMinutes, utStartUmbralPhaseHour, utStartUmbralPhaseMinutes, utStartTotalPhaseHour, utStartTotalPhaseMinutes, utMidEclipseHour, utMidEclipseMinutes, utEndTotalPhaseHour, utEndTotalPhaseMinutes, utEndUmbralPhaseHour, utEndUmbralPhaseMinutes, utEndPenPhaseHour, utEndPenPhaseMinutes, eclipseMagnitude);
    }
コード例 #22
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);
    }
コード例 #23
0
    /// <summary>
    /// Calculate the equation of time. (The difference between the real Sun time and the mean Sun time.)
    /// </summary>
    /// <param name="gwdateDay">Greenwich date (day part)</param>
    /// <param name="gwdateMonth">Greenwich date (month part)</param>
    /// <param name="gwdateYear">Greenwich date (year part)</param>
    /// <returns>
    /// <para>equation_of_time_min -- equation of time (minute part)</para>
    /// <para>equation_of_time_sec -- equation of time (seconds part)</para>
    /// </returns>
    public (double equationOfTimeMin, double equationOfTimeSec) EquationOfTime(double gwdateDay, int gwdateMonth, int gwdateYear)
    {
        var sunLongitudeDeg     = PAMacros.SunLong(12, 0, 0, 0, 0, gwdateDay, gwdateMonth, gwdateYear);
        var sunRAHours          = PAMacros.DecimalDegreesToDegreeHours(PAMacros.EcRA(sunLongitudeDeg, 0, 0, 0, 0, 0, gwdateDay, gwdateMonth, gwdateYear));
        var equivalentUTHours   = PAMacros.GreenwichSiderealTimeToUniversalTime(sunRAHours, 0, 0, gwdateDay, gwdateMonth, gwdateYear);
        var equationOfTimeHours = equivalentUTHours - 12;

        var equationOfTimeMin = PAMacros.DecimalHoursMinute(equationOfTimeHours);
        var equationOfTimeSec = PAMacros.DecimalHoursSecond(equationOfTimeHours);

        return(equationOfTimeMin, equationOfTimeSec);
    }
    /// <summary>
    /// Convert Hour Angle to Right Ascension
    /// </summary>
    /// <returns>Tuple (rightAscensionHours, rightAscensionMinutes, rightAscensionSeconds)</returns>
    public (double raHours, double raMinutes, double raSeconds) HourAngleToRightAscension(double hourAngleHours, double hourAngleMinutes, double hourAngleSeconds, double lctHours, double lctMinutes, double lctSeconds, bool isDaylightSaving, int zoneCorrection, double localDay, int localMonth, int localYear, double geographicalLongitude)
    {
        var daylightSaving = (isDaylightSaving) ? 1 : 0;

        var rightAscension = PAMacros.HourAngleToRightAscension(hourAngleHours, hourAngleMinutes, hourAngleSeconds, lctHours, lctMinutes, lctSeconds, daylightSaving, zoneCorrection, localDay, localMonth, localYear, geographicalLongitude);

        var rightAscensionHours   = PAMacros.DecimalHoursHour(rightAscension);
        var rightAscensionMinutes = PAMacros.DecimalHoursMinute(rightAscension);
        var rightAscensionSeconds = PAMacros.DecimalHoursSecond(rightAscension);

        return(rightAscensionHours, rightAscensionMinutes, rightAscensionSeconds);
    }
コード例 #25
0
    /// <summary>
    /// Convert Greenwich Sidereal Time to Local Sidereal Time
    /// </summary>
    /// <returns>Tuple (int lstHours, int lstMinutes, double lstSeconds)</returns>
    public (int lstHours, int lstMinutes, double lstSeconds) GreenwichSiderealTimeToLocalSiderealTime(double gstHours, double gstMinutes, double gstSeconds, double geographicalLongitude)
    {
        var gst       = PAMacros.HMStoDH(gstHours, gstMinutes, gstSeconds);
        var offset    = geographicalLongitude / 15;
        var lstHours1 = gst + offset;
        var lstHours2 = lstHours1 - (24 * (lstHours1 / 24).Floor());

        var lstHours   = PAMacros.DecimalHoursHour(lstHours2);
        var lstMinutes = PAMacros.DecimalHoursMinute(lstHours2);
        var lstSeconds = PAMacros.DecimalHoursSecond(lstHours2);

        return(lstHours, lstMinutes, lstSeconds);
    }
コード例 #26
0
    /// <summary>
    /// Convert Local Sidereal Time to Greenwich Sidereal Time
    /// </summary>
    /// <returns>Tuple (int gstHours, int gstMinutes, double gstSeconds)</returns>
    public (int gstHours, int gstMinutes, double gstSeconds) LocalSiderealTimeToGreenwichSiderealTime(double lstHours, double lstMinutes, double lstSeconds, double geographicalLongitude)
    {
        var gst       = PAMacros.HMStoDH(lstHours, lstMinutes, lstSeconds);
        var longHours = geographicalLongitude / 15;
        var gst1      = gst - longHours;
        var gst2      = gst1 - (24 * (gst1 / 24).Floor());

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

        return(gstHours, gstMinutes, gstSeconds);
    }
    /// <summary>
    /// Convert Horizon Coordinates to Equatorial Coordinates
    /// </summary>
    /// <returns>Tuple (hourAngleHours, hourAngleMinutes, hourAngleSeconds, declinationDegrees, declinationMinutes, declinationSeconds)</returns>
    public (double hour_angle_hours, double hour_angle_minutes, double hour_angle_seconds, double declination_degrees, double declination_minutes, double declinationseconds) HorizonCoordinatesToEquatorialCoordinates(double azimuthDegrees, double azimuthMinutes, double azimuthSeconds, double altitudeDegrees, double altitudeMinutes, double altitudeSeconds, double geographicalLatitude)
    {
        var hourAngleInDecimalDegrees = PAMacros.HorizonCoordinatesToHourAngle(azimuthDegrees, azimuthMinutes, azimuthSeconds, altitudeDegrees, altitudeMinutes, altitudeSeconds, geographicalLatitude);

        var declinationInDecimalDegrees = PAMacros.HorizonCoordinatesToDeclination(azimuthDegrees, azimuthMinutes, azimuthSeconds, altitudeDegrees, altitudeMinutes, altitudeSeconds, geographicalLatitude);

        var hourAngleHours   = PAMacros.DecimalHoursHour(hourAngleInDecimalDegrees);
        var hourAngleMinutes = PAMacros.DecimalHoursMinute(hourAngleInDecimalDegrees);
        var hourAngleSeconds = PAMacros.DecimalHoursSecond(hourAngleInDecimalDegrees);

        var declinationDegrees = PAMacros.DecimalDegreesDegrees(declinationInDecimalDegrees);
        var declinationMinutes = PAMacros.DecimalDegreesMinutes(declinationInDecimalDegrees);
        var declinationSeconds = PAMacros.DecimalDegreesSeconds(declinationInDecimalDegrees);

        return(hourAngleHours, hourAngleMinutes, hourAngleSeconds, declinationDegrees, declinationMinutes, declinationSeconds);
    }
    /// <summary>
    /// Convert Equatorial Coordinates to Horizon Coordinates
    /// </summary>
    /// <returns>Tuple (azimuthDegrees, azimuthMinutes, azimuthSeconds, altitudeDegrees, altitudeMinutes, altitudeSeconds)</returns>
    public (double azimuthDegrees, double azimuthMinutes, double azimuthSeconds, double altitudeDegrees, double altitudeMinutes, double altitudeSeconds) EquatorialCoordinatesToHorizonCoordinates(double hourAngleHours, double hourAngleMinutes, double hourAngleSeconds, double declinationDegrees, double declinationMinutes, double declinationSeconds, double geographicalLatitude)
    {
        var azimuthInDecimalDegrees = PAMacros.EquatorialCoordinatesToAzimuth(hourAngleHours, hourAngleMinutes, hourAngleSeconds, declinationDegrees, declinationMinutes, declinationSeconds, geographicalLatitude);

        var altitudeInDecimalDegrees = PAMacros.EquatorialCoordinatesToAltitude(hourAngleHours, hourAngleMinutes, hourAngleSeconds, declinationDegrees, declinationMinutes, declinationSeconds, geographicalLatitude);

        var azimuthDegrees = PAMacros.DecimalDegreesDegrees(azimuthInDecimalDegrees);
        var azimuthMinutes = PAMacros.DecimalDegreesMinutes(azimuthInDecimalDegrees);
        var azimuthSeconds = PAMacros.DecimalDegreesSeconds(azimuthInDecimalDegrees);

        var altitudeDegrees = PAMacros.DecimalDegreesDegrees(altitudeInDecimalDegrees);
        var altitudeMinutes = PAMacros.DecimalDegreesMinutes(altitudeInDecimalDegrees);
        var altitudeSeconds = PAMacros.DecimalDegreesSeconds(altitudeInDecimalDegrees);

        return(azimuthDegrees, azimuthMinutes, azimuthSeconds, altitudeDegrees, altitudeMinutes, altitudeSeconds);
    }
コード例 #29
0
    /// <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);
    }
コード例 #30
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);
    }