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

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

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

        return(sunRAHour, sunRAMin, sunRASec, sunDecDeg, sunDecMin, sunDecSec);
    }
    /// <summary>
    /// Calculate 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);
    }
Пример #7
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);
    }
Пример #8
0
    /// <summary>
    /// Calculate approximate position of a planet.
    /// </summary>
    public (double planetRAHour, double planetRAMin, double planetRASec, double planetDecDeg, double planetDecMin, double planetDecSec) ApproximatePositionOfPlanet(double lctHour, double lctMin, double lctSec, bool isDaylightSaving, int zoneCorrectionHours, double localDateDay, int localDateMonth, int localDateYear, string planetName)
    {
        var daylightSaving = (isDaylightSaving) ? 1 : 0;

        var planetInfo = PlanetInfo.GetPlanetInfo(planetName);

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

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

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

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

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

        return(planetRAHour, planetRAMin, planetRASec, planetDecDeg, planetDecMin, planetDecSec);
    }
Пример #9
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);
    }
Пример #11
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);
    }
Пример #12
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);
    }
Пример #14
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);
    }
Пример #15
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);
    }
Пример #16
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);
    }
    /// <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);
    }
Пример #19
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);
    }
Пример #20
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);
    }
Пример #21
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);
    }
Пример #23
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
            );
    }