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); }
public void GetHourAngleTest(double siderealTime, double rightAscension, double expectedHourAngle) { var hourAngle = Astrometry.GetHourAngle(siderealTime, rightAscension); Assert.AreEqual(expectedHourAngle, hourAngle, ANGLE_TOLERANCE); }
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); }