Example #1
0
        /// <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);
        }
Example #2
0
        public static AltAzm RaDec2AltAzm2(Coordinates coord, LatLon location, DateTime UTCtime, double elevation)
        {
            var utils = new ASCOM.Astrometry.NOVAS.NOVAS31();

            var ra       = coord.Ra * 15;
            var dec      = coord.Dec;
            var time     = UTCtime.TimeOfDay.TotalHours;
            var lat      = location.Lat;
            var lon      = location.Lon;
            var j200Time = utils.JulianDate((short)UTCtime.Year, (short)UTCtime.Month, (short)UTCtime.Day, time);

            j200Time -= 2451545.0;
            var LST = 100.46 + 0.985647 * j200Time + lon + 15 * time;

            LST = LST.ToRange(0, 360);

            var HA = (LST - ra).ToRange(0, 360);

            var sinALT = Math.Sin(dec.ToRad()) * Math.Sin(lat.ToRad()) + Math.Cos(dec.ToRad()) * Math.Cos(lat.ToRad()) * Math.Cos(HA.ToRad());
            var ALT    = Math.Asin(sinALT);
            var alt    = ALT.ToDeg();

            var cosA = (Math.Sin(dec.ToRad()) - Math.Sin(ALT) * Math.Sin(lat.ToRad())) / (Math.Cos(ALT) * Math.Cos(lat.ToRad()));
            var A    = Math.Acos(cosA).ToDeg();

            var Azm = Math.Sin(HA.ToRad()) < 0 ? A : 360 - A;

            return(new AltAzm(alt, Azm));
        }
Example #3
0
        static public double NowLST(LatLon location)
        {
            var    nov    = new ASCOM.Astrometry.NOVAS.NOVAS31();
            var    ast    = new ASCOM.Astrometry.AstroUtils.AstroUtils();
            var    currJD = ast.JulianDateUT1(0);
            double lstNow = 0;
            var    res    = nov.SiderealTime(
                currJD, 0d, 0, GstType.GreenwichApparentSiderealTime, Method.EquinoxBased, Accuracy.Full, ref lstNow);

            if (res != 0)
            {
                throw new Exception("Error getting Local Apparent Sidereal time");
            }
            return(lstNow);
        }
Example #4
0
        public void init()
        {
            if (_initialized)
            {
                return;
            }

            debugger     = Debugger.Instance;
            novas31      = new Astrometry.NOVAS.NOVAS31();
            astroutils   = new AstroUtils();
            _arrivedAtAz = new AutoResetEvent(false);
            wisedome.SetArrivedAtAzEvent(_arrivedAtAz);
            _minimalMovement = new Angle(WiseTele._minimalDomeTrackingMovement, Angle.Type.Az);

            _initialized = true;
            #region debug
            debugger.WriteLine(Debugger.DebugLevel.DebugAxes, "DomeSlaveDriver: init() done.");
            #endregion
        }
Example #5
0
        private double CalculateSiderealTime()
        {
            double siderealTime = double.NaN;

            // Now using NOVAS 3.1
            using (var novas = new ASCOM.Astrometry.NOVAS.NOVAS31())
            {
                var jd = utilities.DateUTCToJulian(DateTime.UtcNow);
                novas.SiderealTime(jd, 0, novas.DeltaT(jd),
                                   ASCOM.Astrometry.GstType.GreenwichApparentSiderealTime,
                                   ASCOM.Astrometry.Method.EquinoxBased,
                                   ASCOM.Astrometry.Accuracy.Reduced, ref siderealTime);
            }
            // Allow for the longitude
            siderealTime += SiteLongitude / 360.0 * 24.0;

            // Reduce to the range 0 to 24 hours
            siderealTime = astroUtilities.ConditionRA(siderealTime);
            return(siderealTime);
        }
Example #6
0
        /// <summary>
        /// Calculates Greenwich Mean Sidereal time
        /// </summary>
        /// <returns>HourDouble format</returns>
        static public double NowLMST()
        {
            var nov = new ASCOM.Astrometry.NOVAS.NOVAS31();
            var ast = new ASCOM.Astrometry.AstroUtils.AstroUtils();

            var currJD = ast.JulianDateUT1(0);

            double gstNow = 0;
            var    res    = nov.SiderealTime(
                currJD, 0d, 0, GstType.GreenwichMeanSiderealTime, Method.EquinoxBased, Accuracy.Full, ref gstNow);

            if (res != 0)
            {
                throw new InvalidValueException("Error getting Greenwich Mean Sidereal time");
            }

            double lstNow = gstNow + Longitude / 15;

            lstNow = lstNow - (lstNow >= 24 ? 24 : 0);

            return(lstNow);
        }
Example #7
0
        /// <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);
        }
Example #8
0
        public static AltAzm RaDec2AltAzm2(Coordinates coord, LatLon location, DateTime UTCtime, double elevation)
        {
            var utils = new ASCOM.Astrometry.NOVAS.NOVAS31();

            var ra = coord.Ra * 15;
            var dec = coord.Dec;
            var time = UTCtime.TimeOfDay.TotalHours;
            var lat = location.Lat;
            var lon = location.Lon;
            var j200Time = utils.JulianDate((short)UTCtime.Year, (short)UTCtime.Month, (short)UTCtime.Day, time);
            j200Time -= 2451545.0;
            var LST =  100.46 + 0.985647 * j200Time + lon + 15 * time;
            LST = LST.ToRange(0, 360);

            var HA = (LST - ra).ToRange(0, 360);

            var sinALT = Math.Sin(dec.ToRad()) * Math.Sin(lat.ToRad()) + Math.Cos(dec.ToRad()) * Math.Cos(lat.ToRad()) * Math.Cos(HA.ToRad());
            var ALT = Math.Asin(sinALT);
            var alt = ALT.ToDeg();

            var cosA = (Math.Sin(dec.ToRad()) - Math.Sin(ALT) * Math.Sin(lat.ToRad())) / (Math.Cos(ALT) * Math.Cos(lat.ToRad()));
            var A = Math.Acos(cosA).ToDeg();

            var Azm = Math.Sin(HA.ToRad()) < 0 ? A : 360 - A;

            return new AltAzm(alt, Azm);
        }
Example #9
0
 public static double NowLST(LatLon location)
 {
     var nov = new ASCOM.Astrometry.NOVAS.NOVAS31();
     var ast = new ASCOM.Astrometry.AstroUtils.AstroUtils();
     var currJD = ast.JulianDateUT1(0);
     double lstNow = 0;
     var res = nov.SiderealTime(
         currJD, 0d, 0, GstType.GreenwichApparentSiderealTime, Method.EquinoxBased, Accuracy.Full, ref lstNow);
     if (res != 0) throw new Exception("Error getting Local Apparent Sidereal time");
     return lstNow;
 }
Example #10
0
        public void MoonDistanceAndData_SelectDay(short Year, short Month, short Day, double Hour, double objRA, double objDEC, ref double distance, ref double bright, ref double moonRA, ref double moonDEC)
        {
            /*
             * El objRA y objDEC deben estar en las unidades comunes para este tipo de coordenadas
             * es decir RA en horas y DEC en grados, sin minutos y segundos ambos, deben ser por ejemplo
             * objRA = 18.25 (horas) y objDEC = 76.758 (grados)
             *
             * Devuelve la distancia a la luna y la luminosidad calculada en la fecha pasada por el parametro de entrada
             * dt.
             */

            //Inicialización de variables necesarias para calcular la posición de la luna

            ASCOM.Astrometry.Object3  moonObj3 = new ASCOM.Astrometry.Object3();
            ASCOM.Astrometry.Accuracy Accu;

            double JD        = 0;
            double rc        = 0;
            double moonDisUA = 0;


            //Creamos los objetos ASCOM que contienen los metodos necesarios para el calculo de la
            //posicion de la luna, de la luminosidad, del Julian Date y conversiones de datos.

            ASCOM.Astrometry.NOVAS.NOVAS31         ApASCOM2 = new ASCOM.Astrometry.NOVAS.NOVAS31();
            ASCOM.Astrometry.AstroUtils.AstroUtils ApASCOM1 = new ASCOM.Astrometry.AstroUtils.AstroUtils();

            //Creamos el objeto ASCOM de la luna

            moonObj3.Name   = "Moon";
            moonObj3.Type   = ASCOM.Astrometry.ObjectType.MajorPlanetSunOrMoon;
            moonObj3.Number = ASCOM.Astrometry.Body.Moon;

            //Definimos la precision del calculo

            Accu = ASCOM.Astrometry.Accuracy.Full;

            //Calculamos el Julian Date para el dia pasado por entrada

            JD = ApASCOM2.JulianDate(Year, Month, Day, Hour);


            //Calculamos las coordenadas de la luna en RA (Horas) y DEC (grados)
            //rc es un parámetro de control que dice si la función se ha ejecutado correctamente

            rc = ApASCOM2.AppPlanet(JD, moonObj3, Accu, ref moonRA, ref moonDEC, ref moonDisUA);

            //Calculamos el brillo de la luna en tanto por 1

            bright = ApASCOM1.MoonIllumination(JD);

            /* Pasamos al calculo de la distancia con el objeto que deseamos observar con el telescopio.
             * Para ello tendremos que cambiar los datos de coordenadas de ambos objetos ya que RA esta
             * en GRADOS y DEC en GRADOS SEXAGESIMALES. Con lo cual se haran las conversiones pertinentes para obtener radianes
             * tras los cálculos en radianes se devolverá el resultado en GRADOS.
             ****************************************************************************
             */
            moonRA  = moonRA * 15 * Math.PI / 180;    //Conversión a  radianes (pi/180) y a grados (15)
            moonDEC = moonDEC * Math.PI / 180;
            double objRA1  = objRA * Math.PI / 180;   //Conversión a radianes (pi/180)
            double objDEC1 = objDEC * Math.PI / 180;  //Solo necesitamos conversión a radianes.

            //La formula para calcular la distancia ha sido obtenida de la página web http://aa.quae.nl/en/reken/afstanden.html (equation 11 from polar coordinates)
            //Devuelve el resultado de distance en Grados Sexagesimales

            //q es una variable auxiliar para poder hacer los calculos de manera mas ordenada.
            //q is a auxiliar variable just to calculate the distance in a clearer way.


            double q  = Math.Pow(Math.Sin((0.5 * (objDEC1 - moonDEC))), (double)2) + Math.Cos(moonDEC) * Math.Cos(objDEC1) * Math.Pow(Math.Sin(0.5 * (objRA1 - moonRA)), (double)2);
            double q2 = Math.Pow(Math.Sin((0.5 * (objDEC1 + moonDEC))), (double)2) + Math.Cos(moonDEC) * Math.Cos(objDEC1) * Math.Pow(Math.Cos(0.5 * (objRA1 - moonRA)), (double)2);

            distance = Math.Abs(2 * Math.Atan(Math.Sqrt(q / q2)) * 180 / Math.PI);    //el resultado de ATAN es radianes de ahí que se multiplique por la conversión para pasar a grados.

            //Devolvemos a grados el moonRA y moonDEC

            moonRA  = Math.Round(moonRA * 180 / Math.PI, 12);    //Conversión a  grados (180/pi)
            moonDEC = Math.Round(moonDEC * 180 / Math.PI, 12);
        }