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
        /// <summary>
        /// Calculates the dome azimuth for a given telescope position.
        /// NOTE: Code adapted from Time_Coord.pas in the RemoteCommander Delphi project
        /// </summary>
        /// <param name="ra">Angle, target RA</param>
        /// <param name="dec">Angle, target DEC</param>
        /// <returns>Angle, dome azimuth</returns>
        public Angle CalculateDomeAzimuth(Angle ra, Angle dec)
        {
            const double X0           = 0.0;               // meters
            const double Y0           = 0.0;               // meters
            const double Z0           = 0.0;               // meters
            const double R            = 5.0;               // meters - dome radius
            const double L            = 1.2;               // meters - optical axis offset from ra axis
            const double SiteNorthLat = 0.534024354440983; //+30:35:50.43;

            double Lx, Ly, Lz, Px, Py, Pz, PL, QA, QB, QC, A1, Rx1, Ry1, DomeAz;
            double rar = 0, decr = 0, targetHA, targetAlt, targetAz = 0, zd = 0;

            wisesite.prepareRefractionData(true);
            novas31.Equ2Hor(astroutils.JulianDateUT1(0), 0,
                            WiseSite.astrometricAccuracy,
                            0, 0,
                            wisesite.onSurface,
                            ra.Hours, dec.Degrees,
                            WiseSite.refractionOption,
                            ref zd, ref targetAz, ref rar, ref decr);

            targetHA  = (wisesite.LocalSiderealTime - ra).Radians;
            targetAz  = Angle.FromDegrees(targetAz).Radians;
            targetAlt = Angle.FromDegrees(90.0 - zd).Radians;

            Lx = X0 - Math.Sin(SiteNorthLat) * Math.Sin(-targetHA) * L;
            Ly = Y0 + Math.Cos(-targetHA) * L;
            Lz = Z0 + Math.Cos(SiteNorthLat) * Math.Sin(-targetHA) * L;

            Px = Math.Cos(-targetAz) * Math.Cos(targetAlt);
            Py = Math.Sin(-targetAz) * Math.Cos(targetAlt);
            Pz = Math.Sin(targetAlt);

            PL = Px * Lx + Py * Ly + Pz * Lz;

            QA = 1;
            QB = 2 * PL;
            QC = L * L - R * R;
            A1 = (-QB + Math.Sqrt(QB * QB - 4 * QA * QC)) / (2 * QA);

            Rx1 = A1 * Px - Lx;
            Ry1 = A1 * Py - Ly;

            DomeAz = -Math.Atan2(Ry1, Rx1);

            if (DomeAz < 0)
            {
                DomeAz += 2 * Math.PI;
            }

            return(Angle.FromRadians(DomeAz));
        }