/// <summary> /// /// </summary> /// <param name="ra"></param> /// <param name="dec"></param> /// <param name="lat"></param> /// <param name="lon"></param> /// <param name="jd"></param> /// <returns></returns> public static structAltAz GetAltAz(double ra, double dec, double lat, double lon, double jd) { ASCOM.Astrometry.OnSurface OS = new ASCOM.Astrometry.OnSurface(); OS.Latitude = lat; OS.Longitude = lon; OS.Height = Properties.Settings.Default.site_altitude; OS.Temperature = Properties.Settings.Default.site_temperature; OS.Temperature = Properties.Settings.Default.site_pressure; ASCOM.Utilities.Util UT = new ASCOM.Utilities.Util(); double JDate = UT.DateLocalToJulian(DateTime.Now); double Zd = 0.0; double Az = 0.0; double RaR = 0.0; double DecR = 0.0; ASCOM.Astrometry.NOVAS.NOVAS31 N = new ASCOM.Astrometry.NOVAS.NOVAS31(); N.Equ2Hor(JDate, 0, ASCOM.Astrometry.Accuracy.Reduced, 0, 0, OS, ra, dec, ASCOM.Astrometry.RefractionOption.LocationRefraction, ref Zd, ref Az, ref RaR, ref DecR); //N.Equ2Hor(jd, 0, ASCOM.Astrometry.Accuracy.Reduced, 0, 0, OS, ra, dec, ASCOM.Astrometry.RefractionOption.LocationRefraction, ref Zd, ref Az, ref RaR, ref DecR); structAltAz ret_value = default(structAltAz); ret_value.Alt = 90.0 - Zd; ret_value.Az = Az; return(ret_value); }
/// <summary> /// </summary> /// <param name="RA">The right ascension in decimal value</param> /// <param name="Dec">The declination in decimal value</param> /// <param name="Lat">The latitude in decimal value</param> /// <param name="Long">The longitude in decimal value</param> /// <param name="Date">The date(time) in UTC</param> /// <returns>The altitude and azimuth in decimal value</returns> public static structAltAz Calculate(double RA, double Dec, double Lat, double Long, DateTime Date) { structAltAz ret_value = default(structAltAz); // Day offset and Local Siderial Time double dayOffset = (Date - new DateTime(2000, 1, 1, 12, 0, 0, DateTimeKind.Utc)).TotalDays; double LST = (100.46 + 0.985647 * dayOffset + Long + 15 * (Date.Hour + Date.Minute / 60d) + 360) % 360; // Hour Angle double HA = (LST - RA + 360) % 360; // HA, DEC, Lat to Alt, AZ double x = Math.Cos(HA * (Math.PI / 180)) * Math.Cos(Dec * (Math.PI / 180)); double y = Math.Sin(HA * (Math.PI / 180)) * Math.Cos(Dec * (Math.PI / 180)); double z = Math.Sin(Dec * (Math.PI / 180)); double xhor = x * Math.Cos((90 - Lat) * (Math.PI / 180)) - z * Math.Sin((90 - Lat) * (Math.PI / 180)); double yhor = y; double zhor = x * Math.Sin((90 - Lat) * (Math.PI / 180)) + z * Math.Cos((90 - Lat) * (Math.PI / 180)); double az = Math.Atan2(yhor, xhor) * (180 / Math.PI) + 180; double alt = Math.Asin(zhor) * (180 / Math.PI); ret_value.Alt = alt; ret_value.Az = az; return(ret_value); }
/// <summary> /// Returns a struct with alt & az coordinates of an object given it's Ra & Dec from a specific lat & lon on a specific date (jd) /// </summary> /// <param name="Lat"></param> /// <param name="Lon"></param> /// <param name="Ra"></param> /// <param name="Dec"></param> /// <param name="Prof"></param> /// <param name="jd"></param> /// <returns></returns> public static structAltAz GetAltAz(double Lat, double Lon, double Ra, double Dec, clsSharedData Prof, double jd) { //Lat = Current Observing Latitude //Lon = Current Observing Longitude //Ra = Right Ascention of Object //Dec = Declination of object //jd = Julian Date //GSTime = GMT Sidereal Time structAltAz ret_value = default(structAltAz); double ASCOMAlt = 0; double ASCOMAz = 0; ASCOM.Astrometry.NOVASCOM.Site Site = default(ASCOM.Astrometry.NOVASCOM.Site); ASCOM.Utilities.Util utl = default(ASCOM.Utilities.Util); ASCOM.Astrometry.NOVASCOM.Star Obj = default(ASCOM.Astrometry.NOVASCOM.Star); ASCOM.Astrometry.NOVASCOM.PositionVector PosVector = default(ASCOM.Astrometry.NOVASCOM.PositionVector); //ASCOM.Astrometry.SiteInfo Site = default(ASCOM.Astrometry.SiteInfo); //ASCOM.Astrometry.PosVector PVector = default(ASCOM.Astrometry.PosVector); ASCOM.Astrometry.NOVAS.NOVAS31 N = new ASCOM.Astrometry.NOVAS.NOVAS31(); ASCOM.Astrometry.SOFA.SOFA S = new ASCOM.Astrometry.SOFA.SOFA(); ASCOM.Astrometry.OnSurface onSurface = default(ASCOM.Astrometry.OnSurface); onSurface = new ASCOM.Astrometry.OnSurface(); onSurface.Latitude = Lat; onSurface.Longitude = Lon; onSurface.Height = Properties.Settings.Default.site_altitude; onSurface.Pressure = Properties.Settings.Default.site_pressure; onSurface.Pressure = Properties.Settings.Default.site_temperature; Site = new ASCOM.Astrometry.NOVASCOM.Site(); utl = new ASCOM.Utilities.Util(); Obj = new ASCOM.Astrometry.NOVASCOM.Star(); PosVector = new ASCOM.Astrometry.NOVASCOM.PositionVector(); //Site = new ASCOM.Astrometry.SiteInfo(); //PVector = new ASCOM.Astrometry.PosVector(); //double jd = JDNow(); double GSTime = GMSTime(); Site.Latitude = Lat; Site.Longitude = Lon; Site.Height = Properties.Settings.Default.site_altitude; Site.Pressure = Properties.Settings.Default.site_pressure; Site.Temperature = Properties.Settings.Default.site_temperature; PosVector.SetFromSite(Site, GSTime); Obj.Set(Ra, Dec, 0.0, 0.0, 0.0, 0.0); PosVector = Obj.GetTopocentricPosition(jd, Site, false); ASCOMAlt = PosVector.Elevation; ASCOMAz = PosVector.Azimuth; ret_value.Alt = ASCOMAlt; ret_value.Az = ASCOMAz; return(ret_value); }