示例#1
0
        private void CalculateTransit(double latitude)
        {
            var    alt0   = Astrometry.GetAltitude(0, latitude, this.Coordinates.Dec);
            var    alt180 = Astrometry.GetAltitude(180, latitude, this.Coordinates.Dec);
            double transit;

            if (alt0 > alt180)
            {
                transit = Astrometry.GetAzimuth(0, alt0, latitude, this.Coordinates.Dec);
            }
            else
            {
                transit = Astrometry.GetAzimuth(180, alt180, latitude, this.Coordinates.Dec);
            }
            DoesTransitSouth = Convert.ToInt32(transit) == 180;
        }
示例#2
0
        private void CalculateAltitude()
        {
            var start = this._referenceDate;

            Altitudes.Clear();
            var siderealTime = Astrometry.GetLocalSiderealTime(start, _longitude);
            var hourAngle    = Astrometry.GetHourAngle(siderealTime, this.Coordinates.RA);

            for (double angle = hourAngle; angle < hourAngle + 24; angle += 0.1)
            {
                var degAngle = Astrometry.HoursToDegrees(angle);
                var altitude = Astrometry.GetAltitude(degAngle, _latitude, this.Coordinates.Dec);
                Altitudes.Add(new DataPoint(DateTimeAxis.ToDouble(start), altitude));
                start = start.AddHours(0.1);
            }

            MaxAltitude = Altitudes.OrderByDescending((x) => x.Y).FirstOrDefault();

            CalculateTransit(_latitude);
        }
示例#3
0
        public void GetAltitudeTest(double angle, double latitude, double longitude, double expectedAltitude)
        {
            var alt = Astrometry.GetAltitude(angle, latitude, longitude);

            Assert.AreEqual(expectedAltitude, alt, ANGLE_TOLERANCE);
        }
示例#4
0
        private async Task <bool> MeasurePolarError(IProgress <ApplicationStatus> progress, Direction direction)
        {
            if (CameraInfo?.Connected == true)
            {
                cancelMeasureErrorToken?.Dispose();
                cancelMeasureErrorToken = new CancellationTokenSource();
                Task moveBackTask = Task.CompletedTask;
                try {
                    var siderealTime = Astrometry.GetLocalSiderealTimeNow(profileService.ActiveProfile.AstrometrySettings.Longitude);
                    var latitude     = Angle.ByDegree(profileService.ActiveProfile.AstrometrySettings.Latitude);
                    var dec          = Angle.ByDegree(TelescopeInfo.Declination);
                    var hourAngle    = Astrometry.GetHourAngle(Angle.ByHours(siderealTime), Angle.ByHours(TelescopeInfo.Coordinates.RA));
                    var altitude     = Astrometry.GetAltitude(hourAngle, latitude, dec);
                    var azimuth      = Astrometry.GetAzimuth(hourAngle, altitude, latitude, dec);
                    var altitudeSide = azimuth.Degree < 180 ? AltitudeSite.EAST : AltitudeSite.WEST;

                    Coordinates startPosition = telescopeMediator.GetCurrentPosition();
                    double      poleErr       = await CalculatePoleError(startPosition, progress, cancelMeasureErrorToken.Token);

                    moveBackTask = telescopeMediator.SlewToCoordinatesAsync(startPosition);

                    string poleErrString = Deg2str(Math.Abs(poleErr), 4);
                    cancelMeasureErrorToken.Token.ThrowIfCancellationRequested();
                    if (double.IsNaN(poleErr))
                    {
                        /* something went wrong */
                        progress.Report(new ApplicationStatus()
                        {
                            Status = string.Empty
                        });
                        return(false);
                    }

                    string msg = "";

                    if (direction == Direction.ALTITUDE)
                    {
                        if (profileService.ActiveProfile.AstrometrySettings.HemisphereType == Hemisphere.NORTHERN)
                        {
                            if (altitudeSide == AltitudeSite.EAST)
                            {
                                if (poleErr < 0)
                                {
                                    msg = poleErrString + " too low";
                                }
                                else
                                {
                                    msg = poleErrString + " too high";
                                }
                            }
                            else
                            {
                                if (poleErr < 0)
                                {
                                    msg = poleErrString + " too high";
                                }
                                else
                                {
                                    msg = poleErrString + " too low";
                                }
                            }
                        }
                        else
                        {
                            if (altitudeSide == AltitudeSite.EAST)
                            {
                                if (poleErr < 0)
                                {
                                    msg = poleErrString + " too high";
                                }
                                else
                                {
                                    msg = poleErrString + " too low";
                                }
                            }
                            else
                            {
                                if (poleErr < 0)
                                {
                                    msg = poleErrString + " too low";
                                }
                                else
                                {
                                    msg = poleErrString + " too high";
                                }
                            }
                        }
                    }
                    else if (direction == Direction.AZIMUTH)
                    {
                        //if northern
                        if (profileService.ActiveProfile.AstrometrySettings.HemisphereType == Hemisphere.NORTHERN)
                        {
                            if (poleErr < 0)
                            {
                                msg = poleErrString + " too east";
                            }
                            else
                            {
                                msg = poleErrString + " too west";
                            }
                        }
                        else
                        {
                            if (poleErr < 0)
                            {
                                msg = poleErrString + " too west";
                            }
                            else
                            {
                                msg = poleErrString + " too east";
                            }
                        }
                    }

                    progress.Report(new ApplicationStatus()
                    {
                        Status = msg
                    });
                } catch (OperationCanceledException) {
                } finally {
                    await moveBackTask;
                }

                /*  Altitude
                 *      Northern
                 *          East side
                 *              poleError < 0 -> too low
                 *              poleError > 0 -> too high
                 *  Azimuth
                 *      Northern
                 *          South side
                 *              poleError < 0 -> too east
                 *              poleError > 0 -> too west
                 */
            }
            else
            {
                Notification.ShowWarning(Locale.Loc.Instance["LblNoCameraConnected"]);
            }

            return(true);
        }