Example #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;
        }
Example #2
0
        public void GetAzimuthTest(double angle, double altitude, double latitude, double declination, double expectedAzimuth)
        {
            var az = Astrometry.GetAzimuth(angle, altitude, latitude, declination);

            Assert.AreEqual(expectedAzimuth, az, ANGLE_TOLERANCE);
        }
Example #3
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);
        }