Exemplo n.º 1
0
 public Transform()
 {
     this.disposedValue = false;
     this.TL            = new TraceLogger("", "Transform");
     this.TL.Enabled    = RegistryCommonCode.GetBool("Trace Transform", false);
     this.TL.LogMessage("New", "Trace logger created OK");
     this.Utl                 = new Util();
     this.Sw                  = new Stopwatch();
     this.SwRecalculate       = new Stopwatch();
     this.AstroUtl            = new ASCOM.Astrometry.AstroUtils.AstroUtils();
     this.SOFA                = new ASCOM.Astrometry.SOFA.SOFA();
     this.RAJ2000Value        = double.NaN;
     this.DECJ2000Value       = double.NaN;
     this.RATopoValue         = double.NaN;
     this.DECTopoValue        = double.NaN;
     this.SiteElevValue       = double.NaN;
     this.SiteLatValue        = double.NaN;
     this.SiteLongValue       = double.NaN;
     this.RefracValue         = false;
     this.LastSetBy           = ASCOM.Astrometry.Transform.Transform.SetBy.Never;
     this.RequiresRecalculate = true;
     this.JulianDateTTValue   = 0.0;
     this.CheckGAC();
     this.TL.LogMessage("New", "NOVAS initialised OK");
 }
Exemplo n.º 2
0
 protected virtual void Dispose(bool disposing)
 {
     if (!this.disposedValue)
     {
         if (this.Utl != null)
         {
             this.Utl.Dispose();
             this.Utl = (Util)null;
         }
         if (this.AstroUtl != null)
         {
             this.AstroUtl.Dispose();
             this.AstroUtl = (ASCOM.Astrometry.AstroUtils.AstroUtils)null;
         }
         if (this.Sw != null)
         {
             this.Sw.Stop();
             this.Sw = (Stopwatch)null;
         }
         if (this.SwRecalculate != null)
         {
             this.SwRecalculate.Stop();
             this.SwRecalculate = (Stopwatch)null;
         }
     }
     this.disposedValue = true;
 }
Exemplo n.º 3
0
        static public double JDtime(DateTime time)
        {
            var utils   = new ASCOM.Astrometry.AstroUtils.AstroUtils();
            var MJDdate = utils.CalendarToMJD(time.Day, time.Month, time.Year);

            MJDdate += time.TimeOfDay.TotalDays + 2400000.5;
            return(MJDdate);
        }
Exemplo n.º 4
0
        // private readonly Timer TelescopeUpdateTimer = new Timer { AutoReset = true };
        // public TimeSpan TelescopeUpdateTickInterval { get; set; } = TimeSpan.FromMilliseconds(1000);

        public TelescopeController(ITransactionProcessorFactory factory)
        {
            this.factory   = factory;
            utilities      = new ASCOM.Utilities.Util();                   //Initialise util object
            astroUtilities = new ASCOM.Astrometry.AstroUtils.AstroUtils(); // Initialise astro-utilities object
            // TelescopeUpdateTimer.Interval = TelescopeUpdateTickInterval.TotalMilliseconds;
            // TelescopeUpdateTimer.Elapsed += TelescopeUpdateTimerElapsed;
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
0
        static public RaDec AltAz2RaDec(AltAz altAzm, LatLon location, DateTime time, double elevation)
        {
            var utils   = new ASCOM.Astrometry.AstroUtils.AstroUtils();
            var MJDdate = utils.CalendarToMJD(time.Day, time.Month, time.Year);

            MJDdate += time.TimeOfDay.TotalDays;

            var tfm = new ASCOM.Astrometry.Transform.Transform();

            tfm.JulianDateTT    = MJDdate;
            tfm.SiteElevation   = elevation * 1000;
            tfm.SiteLatitude    = location.Lat;
            tfm.SiteLongitude   = location.Lon;
            tfm.SiteTemperature = 0;
            tfm.SetAzimuthElevation(altAzm.Az, altAzm.Alt);
            tfm.Refresh();
            var res = new RaDec(tfm.RAJ2000, tfm.DecJ2000);

            return(res);
        }
Exemplo n.º 7
0
        static public AltAz RaDec2AltAz(RaDec coord, LatLon location, DateTime time, double elevation)
        {
            var utils   = new ASCOM.Astrometry.AstroUtils.AstroUtils();
            var MJDdate = utils.CalendarToMJD(time.Day, time.Month, time.Year);

            MJDdate += time.TimeOfDay.TotalDays;

            var tfm = new ASCOM.Astrometry.Transform.Transform();

            tfm.JulianDateTT    = MJDdate;
            tfm.SiteElevation   = elevation * 1000;
            tfm.SiteLatitude    = location.Lat;
            tfm.SiteLongitude   = location.Lon;
            tfm.SiteTemperature = 0;
            tfm.SetJ2000(coord.Ra, coord.Dec);
            tfm.Refresh();

            var res = new AltAz(tfm.ElevationTopocentric, tfm.AzimuthTopocentric);

            return(res);
        }
        public static AltAzm RaDec2AltAzm(Coordinates coord, LatLon location, DateTime time, double elevation)
        {
            var utils = new ASCOM.Astrometry.AstroUtils.AstroUtils();
            var MJDdate = utils.CalendarToMJD(time.Day, time.Month, time.Year);
            MJDdate += time.TimeOfDay.TotalDays;

            var tfm = new ASCOM.Astrometry.Transform.Transform();
            tfm.JulianDateTT = MJDdate;
            tfm.SiteElevation = elevation * 1000;
            tfm.SiteLatitude = location.Lat;
            tfm.SiteLongitude = location.Lon;
            tfm.SiteTemperature = 0;
            tfm.SetJ2000(coord.Ra, coord.Dec);
            tfm.Refresh();

            var res = new AltAzm(tfm.ElevationTopocentric, tfm.AzimuthTopocentric);
            return res;
        }
        public static Coordinates AltAzm2RaDec(AltAzm altAzm, LatLon location, DateTime time, double elevation)
        {
            var utils = new ASCOM.Astrometry.AstroUtils.AstroUtils();
            var MJDdate = utils.CalendarToMJD(time.Day, time.Month, time.Year);
            MJDdate += time.TimeOfDay.TotalDays;

            var tfm = new ASCOM.Astrometry.Transform.Transform();
            tfm.JulianDateTT = MJDdate;
            tfm.SiteElevation = elevation * 1000;
            tfm.SiteLatitude = location.Lat;
            tfm.SiteLongitude = location.Lon;
            tfm.SiteTemperature = 0;
            tfm.SetAzimuthElevation(altAzm.Azm, altAzm.Alt);
            tfm.Refresh();
            var res = new Coordinates(tfm.RAJ2000, tfm.DecJ2000);
            return res;
        }
Exemplo n.º 10
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;
 }
Exemplo n.º 11
0
 public static double JDtime(DateTime time)
 {
     var utils = new ASCOM.Astrometry.AstroUtils.AstroUtils();
     var MJDdate = utils.CalendarToMJD(time.Day, time.Month, time.Year);
     MJDdate += time.TimeOfDay.TotalDays + 2400000.5;
     return MJDdate;
 }
Exemplo n.º 12
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);
        }
Exemplo n.º 13
0
        public void UpdateEnvironmentals()
        {
            //StartMJD =
            var      utils     = new ASCOM.Astrometry.AstroUtils.AstroUtils();
            DateTime startdate = SequenceStartDateTimePicker.SelectedDate.Value.Date;

            if (SequenceStartHour.SelectedIndex > -1)
            {
                startdate = startdate.AddHours(((double)SequenceStartHour.SelectedIndex));
            }
            if (SequenceStartMinute.SelectedIndex > -1)
            {
                startdate = startdate.AddMinutes((double)SequenceStartMinute.SelectedIndex);
            }

//            Console.WriteLine("Local: {0}", startdate);

            string MoonInfo  = "";
            string SunInfo   = "";
            string AstroInfo = "";


            //StartMJD = utils.CalendarToMJD(startdate.Day, startdate.Month, startdate.Year);
            //julian  utility.DateLocalToJulian(startdate);
            StartJulian = utility.DateLocalToJulian(startdate);

            //if (SequenceStartHour.SelectedIndex > -1) { StartMJD = StartMJD + ((double) SequenceStartHour.SelectedIndex / 24); }
            //if (SequenceStartMinute.SelectedIndex > -1) { StartMJD = StartMJD + ((double)SequenceStartMinute.SelectedIndex / 1440); }

            //Console.WriteLine("{0}", StartMJD);
            Console.WriteLine(" Illumination: {0}", utils.MoonIllumination(StartJulian));
            MoonInfo = utils.MoonIllumination(StartJulian).ToString("p") + " Illumination      \n";

            //ASCOM.Astrometry.AstroUtils.AstroUtils apUtil = new ASCOM.Astrometry.AstroUtils.AstroUtils();
            System.Collections.ArrayList astroNight  = new System.Collections.ArrayList();
            System.Collections.ArrayList civilNight  = new System.Collections.ArrayList();
            System.Collections.ArrayList sunRiseSet  = new System.Collections.ArrayList();
            System.Collections.ArrayList MoonRiseSet = new System.Collections.ArrayList();
            //DateTime lastUpdate = TimeZoneInfo.ConvertTimeToUtc(startdate, SequenceTimeZone);
            DateTime lastUpdate = startdate;

            double lat = SiteLat;
            double lon = SiteLong;

            civilNight  = apUtil.EventTimes(ASCOM.Astrometry.EventType.CivilTwilight, lastUpdate.Day, lastUpdate.Month, lastUpdate.Year, lat, lon, SequenceTimeZoneOffset.TotalHours);
            astroNight  = apUtil.EventTimes(ASCOM.Astrometry.EventType.AstronomicalTwilight, lastUpdate.Day, lastUpdate.Month, lastUpdate.Year, lat, lon, SequenceTimeZoneOffset.TotalHours);
            sunRiseSet  = apUtil.EventTimes(ASCOM.Astrometry.EventType.SunRiseSunset, lastUpdate.Day, lastUpdate.Month, lastUpdate.Year, lat, lon, SequenceTimeZoneOffset.TotalHours);
            MoonRiseSet = apUtil.EventTimes(ASCOM.Astrometry.EventType.MoonRiseMoonSet, lastUpdate.Day, lastUpdate.Month, lastUpdate.Year, lat, lon, SequenceTimeZoneOffset.TotalHours);


//            Console.WriteLine("SunSet: " + TimeSpan.FromHours((double)(sunRiseSet[4])).ToString("h\\:mm"));

            if (sunRiseSet.Count > 0)
            {
                int NumberOfRises = ((int)sunRiseSet[1]); //' Retrieve the number of sunsets
                int NumberOfSets  = ((int)sunRiseSet[2]); //' Retrieve the number of sunsets

                for (int sets = 0; sets < NumberOfRises; sets++)
                {
                    if ((double)(sunRiseSet[sets + 3]) > (double)(sunRiseSet[sets + 4]))
                    {
                        SunInfo += " Sunset: " + TimeSpan.FromHours((double)(sunRiseSet[sets + 4])).ToString("h\\:mm");
                        SunInfo += " Sunrise: " + TimeSpan.FromHours((double)(sunRiseSet[sets + 3])).ToString("h\\:mm");
                    }
                    else
                    {
                        SunInfo += " Sunrise: " + TimeSpan.FromHours((double)(sunRiseSet[sets + 3])).ToString("h\\:mm");
                        SunInfo += " Sunset: " + TimeSpan.FromHours((double)(sunRiseSet[sets + 4])).ToString("h\\:mm");
                    }
                }
            }
            Console.WriteLine("Suninfo : " + SunInfo);

            if (MoonRiseSet.Count > 0)
            {
                int NumberOfRises = ((int)MoonRiseSet[1]); //' Retrieve the number of sunsets
                int NumberOfSets  = ((int)MoonRiseSet[2]); //' Retrieve the number of sunsets
                for (int sets = 0; sets < NumberOfRises; sets++)
                {
                    if ((double)(MoonRiseSet[sets + 3]) > (double)(MoonRiseSet[sets + 4]))
                    {
                        MoonInfo += " Moonset: " + TimeSpan.FromHours((double)(MoonRiseSet[sets + 4])).ToString("h\\:mm");
                        MoonInfo += " Moonrise: " + TimeSpan.FromHours((double)(MoonRiseSet[sets + 3])).ToString("h\\:mm");
                    }
                    else
                    {
                        MoonInfo += " Moonrise: " + TimeSpan.FromHours((double)(MoonRiseSet[sets + 3])).ToString("h\\:mm");
                        MoonInfo += " Moonset: " + TimeSpan.FromHours((double)(MoonRiseSet[sets + 4])).ToString("h\\:mm");
                    }
                }
                //MoonInfo += TimeSpan.FromHours((double)(MoonRiseSet[NumberOfSets + 3])).ToString("h\\:mm");
            }
            Console.WriteLine("Mooninfo: " + MoonInfo);

            if (astroNight.Count > 0)
            {
                int NumberOfRises = ((int)astroNight[1]); //' Retrieve the number of sunsets
                int NumberOfSets  = ((int)astroNight[2]); //' Retrieve the number of sunsets
                for (int sets = 0; sets < NumberOfRises; sets++)
                {
                    if ((double)(astroNight[sets + 3]) > (double)(astroNight[sets + 4]))
                    {
                        AstroInfo += " AstroStart: " + TimeSpan.FromHours((double)(astroNight[sets + 4])).ToString("h\\:mm");
                        AstroInfo += " AstroEnd: " + TimeSpan.FromHours((double)(astroNight[sets + 3])).ToString("h\\:mm");
                    }
                    else
                    {
                        AstroInfo += " AstroEnd: " + TimeSpan.FromHours((double)(astroNight[sets + 3])).ToString("h\\:mm");
                        AstroInfo += " AstroStart: " + TimeSpan.FromHours((double)(astroNight[sets + 4])).ToString("h\\:mm");
                    }
                }
                //MoonInfo += TimeSpan.FromHours((double)(MoonRiseSet[NumberOfSets + 3])).ToString("h\\:mm");
            }
            Console.WriteLine("AstroInfo: " + AstroInfo);

            //Console.WriteLine("Event Times 1: " + EventTimes1);
            //Console.WriteLine("Event Times 2: " + EventTimes2);

            EnvironmentalTextBlock.Text = SunInfo + "\n" + AstroInfo;
            MoonInfoTextBlock.Text      = MoonInfo;

            /*
             * Console.WriteLine("Latitude: " + lat.ToString());
             * Console.WriteLine("Longitude:" + lon.ToString());
             * Console.WriteLine("Time" + lastUpdate.ToString());
             *
             *
             * Console.WriteLine("sunRiseSet cont :" + sunRiseSet.Count.ToString());
             * foreach (var e in sunRiseSet) Console.WriteLine("Array sunRiseSet:" + e.ToString());
             * Console.WriteLine("civilNignht cont :" + civilNight.Count.ToString());
             * foreach (var e in astroNight) Console.WriteLine("Array astro:" + e.ToString());
             *
             * Console.WriteLine("astroNight cont :" + astroNight.Count.ToString());
             *
             * DateTime objDateWoHour = lastUpdate.Date;*/
        }