コード例 #1
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);
    }
コード例 #2
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);
    }
コード例 #3
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);
    }
    /// <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);
    }
コード例 #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
            );
    }
コード例 #6
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);
    }
    /// <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);
    }
コード例 #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);
    }
コード例 #9
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);
    }
コード例 #10
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);
    }
コード例 #11
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);
    }
コード例 #12
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);
    }
    /// <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);
    }
コード例 #14
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);
    }
コード例 #15
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);
    }
    /// <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);
    }
コード例 #17
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);
    }
コード例 #18
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);
    }
コード例 #19
0
    /// <summary>
    /// Calculate precise position of a planet.
    /// </summary>
    public (double planetRAHour, double planetRAMin, double planetRASec, double planetDecDeg, double planetDecMin, double planetDecSec) PrecisePositionOfPlanet(double lctHour, double lctMin, double lctSec, bool isDaylightSaving, int zoneCorrectionHours, double localDateDay, int localDateMonth, int localDateYear, string planetName)
    {
        var daylightSaving = (isDaylightSaving) ? 1 : 0;

        var coordinateResults = PAMacros.PlanetCoordinates(lctHour, lctMin, lctSec, daylightSaving, zoneCorrectionHours, localDateDay, localDateMonth, localDateYear, planetName);

        var planetRAHours = PAMacros.DecimalDegreesToDegreeHours(PAMacros.EcRA(coordinateResults.planetLongitude, 0, 0, coordinateResults.planetLatitude, 0, 0, localDateDay, localDateMonth, localDateYear));
        var planetDecDeg1 = PAMacros.EcDec(coordinateResults.planetLongitude, 0, 0, coordinateResults.planetLatitude, 0, 0, localDateDay, localDateMonth, localDateYear);

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

        return(planetRAHour, planetRAMin, planetRASec, planetDecDeg, planetDecMin, planetDecSec);
    }
コード例 #20
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);
    }
    /// <summary>
    /// Calculate corrected RA/Dec, accounting for geocentric parallax.
    /// </summary>
    /// <returns>corrected RA hours,minutes,seconds and corrected Declination degrees,minutes,seconds</returns>
    public (double correctedRAHour, double correctedRAMin, double correctedRASec, double correctedDecDeg, double correctedDecMin, double correctedDecSec) CorrectionsForGeocentricParallax(double raHour, double raMin, double raSec, double decDeg, double decMin, double decSec, PACoordinateType coordinateType, double equatorialHorParallaxDeg, double geogLongDeg, double geogLatDeg, double heightM, int daylightSaving, int timezoneHours, double lcdDay, int lcdMonth, int lcdYear, double lctHour, double lctMin, double lctSec)
    {
        var haHours = PAMacros.RightAscensionToHourAngle(raHour, raMin, raSec, lctHour, lctMin, lctSec, daylightSaving, timezoneHours, lcdDay, lcdMonth, lcdYear, geogLongDeg);

        var correctedHAHours = PAMacros.ParallaxHA(haHours, 0, 0, decDeg, decMin, decSec, coordinateType, geogLatDeg, heightM, equatorialHorParallaxDeg);

        var correctedRAHours = PAMacros.HourAngleToRightAscension(correctedHAHours, 0, 0, lctHour, lctMin, lctSec, daylightSaving, timezoneHours, lcdDay, lcdMonth, lcdYear, geogLongDeg);

        var correctedDecDeg1 = PAMacros.ParallaxDec(haHours, 0, 0, decDeg, decMin, decSec, coordinateType, geogLatDeg, heightM, equatorialHorParallaxDeg);

        var correctedRAHour = PAMacros.DecimalHoursHour(correctedRAHours);
        var correctedRAMin  = PAMacros.DecimalHoursMinute(correctedRAHours);
        var correctedRASec  = PAMacros.DecimalHoursSecond(correctedRAHours);
        var correctedDecDeg = PAMacros.DecimalDegreesDegrees(correctedDecDeg1);
        var correctedDecMin = PAMacros.DecimalDegreesMinutes(correctedDecDeg1);
        var correctedDecSec = PAMacros.DecimalDegreesSeconds(correctedDecDeg1);

        return(correctedRAHour, correctedRAMin, correctedRASec, correctedDecDeg, correctedDecMin, correctedDecSec);
    }
    /// <summary>
    /// Calculate corrected RA/Dec, accounting for atmospheric refraction.
    /// </summary>
    /// <remarks>
    /// NOTE: Valid values for coordinate_type are "TRUE" and "APPARENT".
    /// </remarks>
    /// <returns>
    /// <para>corrected RA hours,minutes,seconds</para>
    /// <para>corrected Declination degrees,minutes,seconds</para>
    /// </returns>
    public (double correctedRAHour, double correctedRAMin, double correctedRASec, double correctedDecDeg, double correctedDecMin, double correctedDecSec) AtmosphericRefraction(double trueRAHour, double trueRAMin, double trueRASec, double trueDecDeg, double trueDecMin, double trueDecSec, PACoordinateType coordinateType, double geogLongDeg, double geogLatDeg, int daylightSavingHours, int timezoneHours, double lcdDay, int lcdMonth, int lcdYear, double lctHour, double lctMin, double lctSec, double atmosphericPressureMbar, double atmosphericTemperatureCelsius)
    {
        var haHour               = PAMacros.RightAscensionToHourAngle(trueRAHour, trueRAMin, trueRASec, lctHour, lctMin, lctSec, daylightSavingHours, timezoneHours, lcdDay, lcdMonth, lcdYear, geogLongDeg);
        var azimuthDeg           = PAMacros.EquatorialCoordinatesToAzimuth(haHour, 0, 0, trueDecDeg, trueDecMin, trueDecSec, geogLatDeg);
        var altitudeDeg          = PAMacros.EquatorialCoordinatesToAltitude(haHour, 0, 0, trueDecDeg, trueDecMin, trueDecSec, geogLatDeg);
        var correctedAltitudeDeg = PAMacros.Refract(altitudeDeg, coordinateType, atmosphericPressureMbar, atmosphericTemperatureCelsius);

        var correctedHAHour  = PAMacros.HorizonCoordinatesToHourAngle(azimuthDeg, 0, 0, correctedAltitudeDeg, 0, 0, geogLatDeg);
        var correctedRAHour1 = PAMacros.HourAngleToRightAscension(correctedHAHour, 0, 0, lctHour, lctMin, lctSec, daylightSavingHours, timezoneHours, lcdDay, lcdMonth, lcdYear, geogLongDeg);
        var correctedDecDeg1 = PAMacros.HorizonCoordinatesToDeclination(azimuthDeg, 0, 0, correctedAltitudeDeg, 0, 0, geogLatDeg);

        var correctedRAHour = PAMacros.DecimalHoursHour(correctedRAHour1);
        var correctedRAMin  = PAMacros.DecimalHoursMinute(correctedRAHour1);
        var correctedRASec  = PAMacros.DecimalHoursSecond(correctedRAHour1);
        var correctedDecDeg = PAMacros.DecimalDegreesDegrees(correctedDecDeg1);
        var correctedDecMin = PAMacros.DecimalDegreesMinutes(correctedDecDeg1);
        var correctedDecSec = PAMacros.DecimalDegreesSeconds(correctedDecDeg1);

        return(correctedRAHour, correctedRAMin, correctedRASec, correctedDecDeg, correctedDecMin, correctedDecSec);
    }
コード例 #23
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);
    }
コード例 #24
0
    /// <summary>
    /// Calculate precise position of the sun for a local date and time.
    /// </summary>
    public (double sunRAHour, double sunRAMin, double sunRASec, double sunDecDeg, double sunDecMin, double sunDecSec) PrecisePositionOfSun(double lctHours, double lctMinutes, double lctSeconds, double localDay, int localMonth, int localYear, bool isDaylightSaving, int zoneCorrection)
    {
        var daylightSaving = (isDaylightSaving == true) ? 1 : 0;

        var gDay   = PAMacros.LocalCivilTimeGreenwichDay(lctHours, lctMinutes, lctSeconds, daylightSaving, zoneCorrection, localDay, localMonth, localYear);
        var gMonth = PAMacros.LocalCivilTimeGreenwichMonth(lctHours, lctMinutes, lctSeconds, daylightSaving, zoneCorrection, localDay, localMonth, localYear);
        var gYear  = PAMacros.LocalCivilTimeGreenwichYear(lctHours, lctMinutes, lctSeconds, daylightSaving, zoneCorrection, localDay, localMonth, localYear);
        var sunEclipticLongitudeDeg = PAMacros.SunLong(lctHours, lctMinutes, lctSeconds, daylightSaving, zoneCorrection, localDay, localMonth, localYear);
        var raDeg   = PAMacros.EcRA(sunEclipticLongitudeDeg, 0, 0, 0, 0, 0, gDay, gMonth, gYear);
        var raHours = PAMacros.DecimalDegreesToDegreeHours(raDeg);
        var decDeg  = PAMacros.EcDec(sunEclipticLongitudeDeg, 0, 0, 0, 0, 0, gDay, gMonth, gYear);

        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);
    }
コード例 #25
0
    /// <summary>
    /// Calculate several visual aspects of a planet.
    /// </summary>
    /// <returns>
    /// <para>distance_au -- Planet's distance from Earth, in AU.</para>
    /// <para>ang_dia_arcsec -- Angular diameter of the planet.</para>
    /// <para>phase -- Illuminated fraction of the planet.</para>
    /// <para>light_time_hour -- Light travel time from planet to Earth, hour part.</para>
    /// <para>light_time_minutes -- Light travel time from planet to Earth, minutes part.</para>
    /// <para>light_time_seconds -- Light travel time from planet to Earth, seconds part.</para>
    /// <para>pos_angle_bright_limb_deg -- Position-angle of the bright limb.</para>
    /// <para>approximate_magnitude -- Apparent brightness of the planet.</para>
    /// </returns>
    public (double distanceAU, double angDiaArcsec, double phase, double lightTimeHour, double lightTimeMinutes, double lightTimeSeconds, double posAngleBrightLimbDeg, double approximateMagnitude) VisualAspectsOfAPlanet(double lctHour, double lctMin, double lctSec, bool isDaylightSaving, int zoneCorrectionHours, double localDateDay, int localDateMonth, int localDateYear, string planetName)
    {
        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 planetCoordInfo = PAMacros.PlanetCoordinates(lctHour, lctMin, lctSec, daylightSaving, zoneCorrectionHours, localDateDay, localDateMonth, localDateYear, planetName);

        var planetRARad  = (PAMacros.EcRA(planetCoordInfo.planetLongitude, 0, 0, planetCoordInfo.planetLatitude, 0, 0, localDateDay, localDateMonth, localDateYear)).ToRadians();
        var planetDecRad = (PAMacros.EcDec(planetCoordInfo.planetLongitude, 0, 0, planetCoordInfo.planetLatitude, 0, 0, localDateDay, localDateMonth, localDateYear)).ToRadians();

        var lightTravelTimeHours  = planetCoordInfo.planetDistanceAU * 0.1386;
        var planetInfo            = PlanetInfo.GetPlanetInfo(planetName);
        var angularDiameterArcsec = planetInfo.theta0_AngularDiameter / planetCoordInfo.planetDistanceAU;
        var phase1 = 0.5 * (1.0 + ((planetCoordInfo.planetLongitude - planetCoordInfo.planetHLong1).ToRadians()).Cosine());

        var sunEclLongDeg = PAMacros.SunLong(lctHour, lctMin, lctSec, daylightSaving, zoneCorrectionHours, localDateDay, localDateMonth, localDateYear);
        var sunRARad      = (PAMacros.EcRA(sunEclLongDeg, 0, 0, 0, 0, 0, greenwichDateDay, greenwichDateMonth, greenwichDateYear)).ToRadians();
        var sunDecRad     = (PAMacros.EcDec(sunEclLongDeg, 0, 0, 0, 0, 0, greenwichDateDay, greenwichDateMonth, greenwichDateYear)).ToRadians();

        var y = (sunDecRad).Cosine() * (sunRARad - planetRARad).Sine();
        var x = (planetDecRad).Cosine() * (sunDecRad).Sine() - (planetDecRad).Sine() * (sunDecRad).Cosine() * (sunRARad - planetRARad).Cosine();

        var chiDeg                = PAMacros.Degrees(y.AngleTangent2(x));
        var radiusVectorAU        = planetCoordInfo.planetRVect;
        var approximateMagnitude1 = 5.0 * (radiusVectorAU * planetCoordInfo.planetDistanceAU / (phase1).SquareRoot()).Log10() + planetInfo.v0_VisualMagnitude;

        var distanceAU            = Math.Round(planetCoordInfo.planetDistanceAU, 5);
        var angDiaArcsec          = Math.Round(angularDiameterArcsec, 1);
        var phase                 = Math.Round(phase1, 2);
        var lightTimeHour         = PAMacros.DecimalHoursHour(lightTravelTimeHours);
        var lightTimeMinutes      = PAMacros.DecimalHoursMinute(lightTravelTimeHours);
        var lightTimeSeconds      = PAMacros.DecimalHoursSecond(lightTravelTimeHours);
        var posAngleBrightLimbDeg = Math.Round(chiDeg, 1);
        var approximateMagnitude  = Math.Round(approximateMagnitude1, 1);

        return(distanceAU, angDiaArcsec, phase, lightTimeHour, lightTimeMinutes, lightTimeSeconds, posAngleBrightLimbDeg, approximateMagnitude);
    }
    /// <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);
    }
    /// <summary>
    /// Calculate rising and setting times for an object.
    /// </summary>
    /// <returns>Tuple (riseSetStatus, utRiseHour, utRiseMin, utSetHour, utSetMin, azRise, azSet)</returns>
    public (string riseSetStatus, double utRiseHour, double utRiseMin, double utSetHour, double utSetMin, double azRise, double azSet) RisingAndSetting(double raHours, double raMinutes, double raSeconds, double decDeg, double decMin, double decSec, double gwDateDay, int gwDateMonth, int gwDateYear, double geogLongDeg, double geogLatDeg, double vertShiftDeg)
    {
        var raHours1             = PAMacros.HMStoDH(raHours, raMinutes, raSeconds);
        var decRad               = PAMacros.DegreesMinutesSecondsToDecimalDegrees(decDeg, decMin, decSec).ToRadians();
        var verticalDisplRadians = vertShiftDeg.ToRadians();
        var geoLatRadians        = geogLatDeg.ToRadians();
        var cosH                = -(verticalDisplRadians.Sine() + geoLatRadians.Sine() * decRad.Sine()) / (geoLatRadians.Cosine() * decRad.Cosine());
        var hHours              = PAMacros.DecimalDegreesToDegreeHours(PAMacros.Degrees(cosH.ACosine()));
        var lstRiseHours        = (raHours1 - hHours) - 24 * ((raHours1 - hHours) / 24).Floor();
        var lstSetHours         = (raHours1 + hHours) - 24 * ((raHours1 + hHours) / 24).Floor();
        var aDeg                = PAMacros.Degrees((((decRad).Sine() + (verticalDisplRadians).Sine() * (geoLatRadians).Sine()) / ((verticalDisplRadians).Cosine() * (geoLatRadians).Cosine())).ACosine());
        var azRiseDeg           = aDeg - 360 * (aDeg / 360).Floor();
        var azSetDeg            = (360 - aDeg) - 360 * ((360 - aDeg) / 360).Floor();
        var utRiseHours1        = PAMacros.GreenwichSiderealTimeToUniversalTime(PAMacros.LocalSiderealTimeToGreenwichSiderealTime(lstRiseHours, 0, 0, geogLongDeg), 0, 0, gwDateDay, gwDateMonth, gwDateYear);
        var utSetHours1         = PAMacros.GreenwichSiderealTimeToUniversalTime(PAMacros.LocalSiderealTimeToGreenwichSiderealTime(lstSetHours, 0, 0, geogLongDeg), 0, 0, gwDateDay, gwDateMonth, gwDateYear);
        var utRiseAdjustedHours = utRiseHours1 + 0.008333;
        var utSetAdjustedHours  = utSetHours1 + 0.008333;

        var riseSetStatus = "OK";

        if (cosH > 1)
        {
            riseSetStatus = "never rises";
        }
        if (cosH < -1)
        {
            riseSetStatus = "circumpolar";
        }

        var utRiseHour = (riseSetStatus == "OK") ? PAMacros.DecimalHoursHour(utRiseAdjustedHours) : 0;
        var utRiseMin  = (riseSetStatus == "OK") ? PAMacros.DecimalHoursMinute(utRiseAdjustedHours) : 0;
        var utSetHour  = (riseSetStatus == "OK") ? PAMacros.DecimalHoursHour(utSetAdjustedHours) : 0;
        var utSetMin   = (riseSetStatus == "OK") ? PAMacros.DecimalHoursMinute(utSetAdjustedHours) : 0;
        var azRise     = (riseSetStatus == "OK") ? Math.Round(azRiseDeg, 2) : 0;
        var azSet      = (riseSetStatus == "OK") ? Math.Round(azSetDeg, 2) : 0;

        return(riseSetStatus, utRiseHour, utRiseMin, utSetHour, utSetMin, azRise, azSet);
    }
コード例 #28
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
            );
    }
コード例 #29
0
    /// <summary>
    /// Calculate times of morning and evening twilight.
    /// </summary>
    /// <param name="localDay">Local date, day part.</param>
    /// <param name="localMonth">Local date, month part.</param>
    /// <param name="localYear">Local date, year part.</param>
    /// <param name="isDaylightSaving">Is daylight savings in effect?</param>
    /// <param name="zoneCorrection">Time zone correction, in hours.</param>
    /// <param name="geographicalLongDeg">Geographical longitude, in degrees.</param>
    /// <param name="geographicalLatDeg">Geographical latitude, in degrees.</param>
    /// <param name="twilightType">"C" (civil), "N" (nautical), or "A" (astronomical)</param>
    /// <returns>
    /// <para>amTwilightBeginsHour -- Beginning of AM twilight (hour part)</para>
    /// <para>amTwilightBeginsMin -- Beginning of AM twilight (minutes part)</para>
    /// <para>pmTwilightEndsHour -- Ending of PM twilight (hour part)</para>
    /// <para>pmTwilightEndsMin -- Ending of PM twilight (minutes part)</para>
    /// <para>status -- Calculation status</para>
    /// </returns>
    public (double amTwilightBeginsHour, double amTwilightBeginsMin, double pmTwilightEndsHour, double pmTwilightEndsMin, string status) MorningAndEveningTwilight(double localDay, int localMonth, int localYear, bool isDaylightSaving, int zoneCorrection, double geographicalLongDeg, double geographicalLatDeg, PATwilightType twilightType)
    {
        var daylightSaving = (isDaylightSaving) ? 1 : 0;

        var startOfAMTwilightHours = PAMacros.TwilightAMLCT(localDay, localMonth, localYear, daylightSaving, zoneCorrection, geographicalLongDeg, geographicalLatDeg, twilightType);

        var endOfPMTwilightHours = PAMacros.TwilightPMLCT(localDay, localMonth, localYear, daylightSaving, zoneCorrection, geographicalLongDeg, geographicalLatDeg, twilightType);

        var twilightStatus = PAMacros.ETwilight(localDay, localMonth, localYear, daylightSaving, zoneCorrection, geographicalLongDeg, geographicalLatDeg, twilightType);

        var adjustedAMStartTime = startOfAMTwilightHours + 0.008333;
        var adjustedPMStartTime = endOfPMTwilightHours + 0.008333;

        double amTwilightBeginsHour = (twilightStatus.Equals("OK")) ? PAMacros.DecimalHoursHour(adjustedAMStartTime) : -99;
        double amTwilightBeginsMin  = (twilightStatus.Equals("OK")) ? PAMacros.DecimalHoursMinute(adjustedAMStartTime) : -99;

        double pmTwilightEndsHour = (twilightStatus.Equals("OK")) ? PAMacros.DecimalHoursHour(adjustedPMStartTime) : -99;
        double pmTwilightEndsMin  = (twilightStatus.Equals("OK")) ? PAMacros.DecimalHoursMinute(adjustedPMStartTime) : -99;

        var status = twilightStatus;

        return(amTwilightBeginsHour, amTwilightBeginsMin, pmTwilightEndsHour, pmTwilightEndsMin, status);
    }
コード例 #30
0
    /// <summary>
    /// Calculate the circumstances of a solar eclipse.
    /// </summary>
    /// <returns>
    /// <para>solarEclipseCertainDateDay -- Solar eclipse date (day)</para>
    /// <para>solarEclipseCertainDateMonth -- Solar eclipse date (month)</para>
    /// <para>solarEclipseCertainDateYear -- Solar eclipse date (year)</para>
    /// <para>utFirstContactHour -- First contact of shadow (hour)</para>
    /// <para>utFirstContactMinutes -- First contact of shadow (minutes)</para>
    /// <para>utMidEclipseHour -- Mid-eclipse (hour)</para>
    /// <para>utMidEclipseMinutes -- Mid-eclipse (minutes)</para>
    /// <para>utLastContactHour -- Last contact of shadow (hour)</para>
    /// <para>utLastContactMinutes -- Last contact of shadow (minutes)</para>
    /// <para>eclipseMagnitude -- Eclipse magnitude</para>
    /// </returns>
    public (double solarEclipseCertainDateDay, int solarEclipseCertainDateMonth, int solarEclipseCertainDateYear, double utFirstContactHour, double utFirstContactMinutes, double utMidEclipseHour, double utMidEclipseMinutes, double utLastContactHour, double utLastContactMinutes, double eclipseMagnitude) SolarEclipseCircumstances(double localDateDay, int localDateMonth, int localDateYear, bool isDaylightSaving, int zoneCorrectionHours, double geogLongitudeDeg, double geogLatitudeDeg)
    {
        var daylightSaving = (isDaylightSaving) ? 1 : 0;

        var julianDateOfNewMoon = PAMacros.NewMoon(daylightSaving, zoneCorrectionHours, localDateDay, localDateMonth, localDateYear);
        var gDateOfNewMoonDay   = PAMacros.JulianDateDay(julianDateOfNewMoon);
        var integerDay          = (gDateOfNewMoonDay).Floor();
        var gDateOfNewMoonMonth = PAMacros.JulianDateMonth(julianDateOfNewMoon);
        var gDateOfNewMoonYear  = PAMacros.JulianDateYear(julianDateOfNewMoon);
        var utOfNewMoonHours    = gDateOfNewMoonDay - integerDay;
        var localCivilDateDay   = PAMacros.UniversalTime_LocalCivilDay(utOfNewMoonHours, 0.0, 0.0, daylightSaving, zoneCorrectionHours, integerDay, gDateOfNewMoonMonth, gDateOfNewMoonYear);
        var localCivilDateMonth = PAMacros.UniversalTime_LocalCivilMonth(utOfNewMoonHours, 0.0, 0.0, daylightSaving, zoneCorrectionHours, integerDay, gDateOfNewMoonMonth, gDateOfNewMoonYear);
        var localCivilDateYear  = PAMacros.UniversalTime_LocalCivilYear(utOfNewMoonHours, 0.0, 0.0, daylightSaving, zoneCorrectionHours, integerDay, gDateOfNewMoonMonth, gDateOfNewMoonYear);

        var utMaxEclipse   = PAMacros.UTMaxSolarEclipse(localDateDay, localDateMonth, localDateYear, daylightSaving, zoneCorrectionHours, geogLongitudeDeg, geogLatitudeDeg);
        var utFirstContact = PAMacros.UTFirstContactSolarEclipse(localDateDay, localDateMonth, localDateYear, daylightSaving, zoneCorrectionHours, geogLongitudeDeg, geogLatitudeDeg);
        var utLastContact  = PAMacros.UTLastContactSolarEclipse(localDateDay, localDateMonth, localDateYear, daylightSaving, zoneCorrectionHours, geogLongitudeDeg, geogLatitudeDeg);
        var magnitude      = PAMacros.MagSolarEclipse(localDateDay, localDateMonth, localDateYear, daylightSaving, zoneCorrectionHours, geogLongitudeDeg, geogLatitudeDeg);

        var solarEclipseCertainDateDay   = localCivilDateDay;
        var solarEclipseCertainDateMonth = localCivilDateMonth;
        var solarEclipseCertainDateYear  = localCivilDateYear;

        var utFirstContactHour    = (utFirstContact == -99.0) ? -99.0 : PAMacros.DecimalHoursHour(utFirstContact + 0.008333);
        var utFirstContactMinutes = (utFirstContact == -99.0) ? -99.0 : PAMacros.DecimalHoursMinute(utFirstContact + 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 utLastContactHour    = (utLastContact == -99.0) ? -99.0 : PAMacros.DecimalHoursHour(utLastContact + 0.008333);
        var utLastContactMinutes = (utLastContact == -99.0) ? -99.0 : PAMacros.DecimalHoursMinute(utLastContact + 0.008333);

        var eclipseMagnitude = (magnitude == -99.0) ? -99.0 : Math.Round(magnitude, 3);

        return(solarEclipseCertainDateDay, solarEclipseCertainDateMonth, solarEclipseCertainDateYear, utFirstContactHour, utFirstContactMinutes, utMidEclipseHour, utMidEclipseMinutes, utLastContactHour, utLastContactMinutes, eclipseMagnitude);
    }