Example #1
0
    /// Windows C# Sample Console Application: Solar
    ///
    /// ------------------------------------------------------------------------
    ///               Vaguely adapted from Solar.vbs
    ///               Copyright Software Bisque
    ///
    ///               Converted by:  R.McAlister 2017
    ///
    /// ------------------------------------------------------------------------
    ///
    ///Very simple demonstration application that targets the telescope on the Sun -- careful now.
    ///
    ///  Note:  this is basically simplification of "ListSearch.vb" where the only target is the Sun.
    ///
    ///


    public void SolarSample()
    {
        ///Target Sun
        string target = "Sun";

        ///Create Objects
        sky6StarChart         tsx_sc = new sky6StarChart();
        sky6RASCOMTele        tsx_ts = new sky6RASCOMTele();
        sky6ObjectInformation tsx_oi = new sky6ObjectInformation();

        ///Connect telescope
        tsx_ts.Connect();

        tsx_sc.Find(target);
        tsx_oi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_ALT);
        double dAlt = tsx_oi.ObjInfoPropOut;

        tsx_oi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_AZM);
        double dAz = tsx_oi.ObjInfoPropOut;

        try {
            tsx_ts.SlewToAzAlt(dAz, dAlt, target);
        }
        catch {
            MessageBox.Show("An error has occurred running slew");
            return;
        };
        MessageBox.Show("The Sun's location is at: Altitude: " + dAlt.ToString() + "  Azimuth: " + dAz.ToString());

        ///Disconnect telesope
        tsx_ts.Disconnect();
        return;
    }
Example #2
0
        public static sky6ObjectInformation GetStars()
        {
            //Runs the database query and checks results. objecty information false
            //   else returns null
            sky6DataWizard        tsx_dw = new sky6DataWizard();
            sky6ObjectInformation tsx_oi = new sky6ObjectInformation();

            ///Set query path
            tsx_dw.Path = StarSearchDBQPath;
            tsx_dw.Open();
            string tst = tsx_dw.Path;

            try { tsx_oi = tsx_dw.RunQuery; }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return(null);
            }
            if (tsx_oi.Count == 0)
            {
                return(null);
            }
            else
            {
                return(tsx_oi);
            }
        }
Example #3
0
    /// Windows C# Sample Console Application: DataWizard
    ///
    /// ------------------------------------------------------------------------
    ///
    ///               Authored:  R.McAlister 2017
    ///
    ///
    /// ------------------------------------------------------------------------
    ///
    ///This C# console application demonstrates the usage of the Data Wizard and Object Information classes.
    ///
    ///The application opens and runs a built-in Observing List search then accesses a few of the return properties,
    ///    for no particularly good reason.
    ///
    ///The application uses the standard query "Bright objects visible now.dbq"
    ///
    public void DataWizardSample()
    {
        string sname = "";
        string sRA;
        string sDec;

        ///Create object information and datawizard objects
        sky6DataWizard        tsx_dw = new sky6DataWizard();
        sky6ObjectInformation tsx_oi = new sky6ObjectInformation();

        ///Set query path to a user-defined test query database for this example.  If you don///t have it, make it.  Best if the Messier catalog is selected.
        tsx_dw.Path = "C:\\Users\\Rick\\Documents\\Software Bisque\\TheSkyX Professional Edition\\Database Queries\\Bright objects visible now.dbq";
        tsx_dw.Open();
        tsx_oi = tsx_dw.RunQuery;
        ///
        ///tsx_oi is an array (tsx_oi.Count) of object information indexed by the tsx_oi.Index property
        ///
        ///For each object information in the list, get the name, perform a "Find" and look for the catalog ID.  If there is one, print it.
        for (int i = 0; i <= (tsx_oi.Count - 1); i++)
        {
            tsx_oi.Index = i;
            tsx_oi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_NAME1);
            sname = tsx_oi.ObjInfoPropOut;
            tsx_oi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_RA_2000);
            sRA = tsx_oi.ObjInfoPropOut.ToString();
            tsx_oi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_DEC_2000);
            sDec = tsx_oi.ObjInfoPropOut.ToString();
            MessageBox.Show("Name: " + sname + "   RA: " + sRA + "  Dec:  " + sDec);
        }
        return;
    }
Example #4
0
        public string GetTargetName()
        {
            sky6ObjectInformation tsxoi = new sky6ObjectInformation();

            tsxoi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_NAME1);
            string tgtName = tsxoi.ObjInfoPropOut;

            return(tgtName);
        }
Example #5
0
        public FormTargetTrack(DailyPosition dp, DailyPosition mp, string targetNameS)
        {
            InitializeComponent();
            targetName = targetNameS;

            tgtDateUTC   = dp.UTCdate;
            moonDateUTC  = mp.iRise;
            tgtUpH       = dp.Rising.ToLocalTime().Hour + (dp.Rising.ToLocalTime().Minute / 60.0);
            tgtDownH     = dp.Setting.ToLocalTime().Hour + (dp.Setting.ToLocalTime().Minute / 60.0);
            tgtDecD      = 90.0 - Transform.RadiansToDegrees(dp.Position.Dec);
            tgtPosition  = dp.Position;
            MoonPosition = mp.Position;
            obsLocation  = dp.Location;
            //Set lat
            obsLatD = Transform.RadiansToDegrees(dp.Location.Lat);

            //Moon look up stuff
            Celestial.RADec moonRADec = DailyPosition.MoonRaDec(Celestial.DateToJ2kC(dp.UTCdate));
            moonDecD = 90 - Transform.RadiansToDegrees(mp.Position.Dec);
            //Get the rise/set times from TSX
            sky6StarChart         tsxs = new sky6StarChart();
            sky6ObjectInformation tsxo = new sky6ObjectInformation();

            //Set the date/time to the local date for the target
            tsxs.SetDocumentProperty(Sk6DocumentProperty.sk6DocProp_JulianDateNow, Celestial.DateToJulian(tgtDateUTC));

            //Get some target stuff that's hard to calculate
            tsxs.Find(targetName);
            //wait a second
            System.Threading.Thread.Sleep(500);
            tsxo.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_TRANSIT_TIME);
            tgtTransitH = tsxo.ObjInfoPropOut;

            //Test stuff
            //double testmoontransitH = MoonPosition.TransitTime(tgtDateUTC, obsLocation);

            //Get some moon stuff now
            tsxs.SetDocumentProperty(Sk6DocumentProperty.sk6DocProp_JulianDateNow, Celestial.DateToJulian(moonDateUTC));
            tsxs.Find("Moon");
            //wait a second
            System.Threading.Thread.Sleep(500);
            tsxo.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_RISE_TIME);
            moonRiseH = tsxo.ObjInfoPropOut;
            tsxo.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_SET_TIME);
            moonSetH = tsxo.ObjInfoPropOut;
            //put the target back in
            tsxs.Find(targetName);

            tsxs = null;
            tsxo = null;
            return;
        }
Example #6
0
        public ObjectList()
        {
            //Create the object list
            //Need to make this a bunch more robust later, including installing search database file, if not already installed
            //
            //Determine if search database file exists, if not, create it
            if (!DBQFileManagement.DBQInstalled())
            {
                DBQFileManagement.InstallDBQ();
            }
            sky6DataWizard tsxdw = new sky6DataWizard();

            tsxdw.Path = DBQFileManagement.QuickPickDestinationPath;
            System.Threading.Thread.Sleep(1000);
            string testw1 = tsxdw.Path;

            System.Threading.Thread.Sleep(100);
            string testw2 = tsxdw.Path;

            tsxdw.Open();
            //sky6ObjectInformation tsxoi = new sky6ObjectInformation();
            sky6ObjectInformation tsxoi = tsxdw.RunQuery;

            //Fill in data arrays (for speed purposes)
            for (int i = 0; i < tsxoi.Count; i++)
            {
                tsxoi.Index = i;
                tsxoi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_NAME1);
                oname = (tsxoi.ObjInfoPropOut);
                tsxoi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_OBJECTTYPE);
                otype = (tsxoi.ObjInfoPropOut);
                tsxoi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_MAJ_AXIS_MINS);
                osize = (tsxoi.ObjInfoPropOut);
                tsxoi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_RISE_TIME);
                orise = (DateTime.Now - DateTime.Now.TimeOfDay).AddHours(tsxoi.ObjInfoPropOut);
                tsxoi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_SET_TIME);
                oset = (DateTime.Now - DateTime.Now.TimeOfDay).AddHours(tsxoi.ObjInfoPropOut);
                tsxoi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_ALT);
                oaltitude = (tsxoi.ObjInfoPropOut);
                tsxoi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_AZM);
                oazimuth = (tsxoi.ObjInfoPropOut);
                tsxoi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_DEC_2000);
                oDec = (tsxoi.ObjInfoPropOut);
                tsxoi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_RA_2000);
                oRA = (tsxoi.ObjInfoPropOut);
                dbqList.Add(new DBQObject(oname, otype, osize, oset, orise, oaltitude, oazimuth, oDec, oRA));
            }
            return;
        }
Example #7
0
        public StarProspects(double searchAreaDeg)
        {
            //Creates a list of star prospects from the associated observing list

            //Set StarChart FOV to something reasonable for this search
            sky6StarChart tsxsc = new sky6StarChart
            {
                FieldOfView = searchAreaDeg
            };

            //Determine if search database file exists, if not, create it
            //if (!IsDBQInstalled())
            //{ InstallDBQ(); }

            //Load the path, open and run the selected search database query
            sky6DataWizard tsxdw = new sky6DataWizard();

            tsxdw.Path = GetDBQPath();
            tsxdw.Open();
            sky6ObjectInformation tsxoi = tsxdw.RunQuery;

            //Create a star list array for population of data

            //Fill in data arrays (for speed purposes)
            for (int i = 0; i < tsxoi.Count; i++)
            {
                tsxoi.Index = i;

                tsxoi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_NAME1);
                string starName = (tsxoi.ObjInfoPropOut);
                tsxoi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_RA_2000);
                double starRA = (tsxoi.ObjInfoPropOut);
                tsxoi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_DEC_2000);
                double starDec = (tsxoi.ObjInfoPropOut);
                tsxoi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_MAG);
                double  starMag = (tsxoi.ObjInfoPropOut);
                DBQStar newStar = new DBQStar
                {
                    StarName = starName,
                    StarRA   = starRA,
                    StarDec  = starDec,
                    StarMag  = starMag
                };
                starProspectList.Add(newStar);
            }
            return;
        }
Example #8
0
        public void UpdateSequence()
        {
            //Update Sequence will load the target name (or adjusted location) into the Find
            //  function and update all the location information, then run a new calculation on times, etc
            SessionControl        openSession = new SessionControl();
            TargetPlan            tPlan       = new TargetPlan(openSession.CurrentTargetName);
            sky6ObjectInformation tsxo        = new sky6ObjectInformation();
            string targetName = tPlan.TargetName;

            //if the targetName is null, then pull the targetName from TSX, load into the textbox and store in configuration file
            if (targetName == "")
            {
                tsxo.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_NAME1);
                string tName = tsxo.ObjInfoPropOut;
                tPlan.TargetName = tName;
                TargetBox.Text   = tName;
                return;
            }
            //if the adjust target is checked, then run FInd on the target coordinates
            //otherwise, run a find on the target name
            string targetTitle;

            if (tPlan.TargetAdjustEnabled)
            {
                targetTitle = tPlan.TargetRA.ToString() + "," + tPlan.TargetDec.ToString();
            }
            else
            {
                targetTitle = targetName;
            }
            TSXLink.Target tgto = TSXLink.StarChart.FindTarget(targetTitle);

            //Update the target Name in box
            TargetBox.Text     = targetName;
            TargetRABox.Value  = (decimal)tgto.RA;
            TargetDecBox.Value = (decimal)tgto.Dec;

            //Update the start time in the target plan
            tPlan.SequenceStartTime = StartTimeBox.Value;
            tPlan.SequenceDawnTime  = DawnTimeBox.Value;

            //Save the new configuration information
            UpdateFormFromPlan();
            RegenerateSequence();
        }
        private static InfoObj[] GetNearbyStars(sky6StarChart tsxsc, int xC, int yC)
        {
            sky6ObjectInformation tsxod = new sky6ObjectInformation();

            tsxsc.ClickFind(xC, yC);
            int objcnt = tsxod.Count;

            InfoObj[] infoObj = new InfoObj[objcnt];
            for (int i = 0; i < objcnt; i++)
            {
                tsxod.Index = i;
                tsxod.Property(TheSky64Lib.Sk6ObjectInformationProperty.sk6ObjInfoProp_NAME1);
                infoObj[i].CatalogedName = tsxod.ObjInfoPropOut;
                tsxod.Property(TheSky64Lib.Sk6ObjectInformationProperty.sk6ObjInfoProp_MAG);
                infoObj[i].CatalogMag = tsxod.ObjInfoPropOut;
                tsxod.Property(TheSky64Lib.Sk6ObjectInformationProperty.sk6ObjInfoProp_RA_2000);
                infoObj[i].CatalogRA = tsxod.ObjInfoPropOut;
                tsxod.Property(TheSky64Lib.Sk6ObjectInformationProperty.sk6ObjInfoProp_DEC_2000);
                infoObj[i].CatalogDec = tsxod.ObjInfoPropOut;
                if (infoObj[i].CatalogedName.Contains("Gaia"))
                {
                    tsxod.Property(TheSky64Lib.Sk6ObjectInformationProperty.sk6ObjInfoProp_DB_FIELD_1); //FIlter G
                    infoObj[i].CatalogMagG = Convert.ToDouble(tsxod.ObjInfoPropOut);
                    tsxod.Property(TheSky64Lib.Sk6ObjectInformationProperty.sk6ObjInfoProp_DB_FIELD_2); //Filter PB
                    infoObj[i].CatalogMagB = Convert.ToDouble(tsxod.ObjInfoPropOut);
                    tsxod.Property(TheSky64Lib.Sk6ObjectInformationProperty.sk6ObjInfoProp_DB_FIELD_3); //Filter PR
                    infoObj[i].CatalogMagR = Convert.ToDouble(tsxod.ObjInfoPropOut);
                }
                else if (infoObj[i].CatalogedName.Contains("APASS"))
                {
                    tsxod.Property(TheSky64Lib.Sk6ObjectInformationProperty.sk6ObjInfoProp_STAR_MAGB);
                    infoObj[i].CatalogMagB = tsxod.ObjInfoPropOut;
                    tsxod.Property(TheSky64Lib.Sk6ObjectInformationProperty.sk6ObjInfoProp_STAR_MAGV);
                    infoObj[i].CatalogMagV = tsxod.ObjInfoPropOut;
                    tsxod.Property(TheSky64Lib.Sk6ObjectInformationProperty.sk6ObjInfoProp_STAR_MAGR);
                    infoObj[i].CatalogMagR = tsxod.ObjInfoPropOut;
                    tsxod.Property(TheSky64Lib.Sk6ObjectInformationProperty.sk6ObjInfoProp_DB_FIELD_4);
                    char[] s = new char[] { ' ' };
                    infoObj[i].CatalogMagG = Convert.ToDouble(tsxod.ObjInfoPropOut.Split(s, StringSplitOptions.RemoveEmptyEntries)[0]);
                }
            }
            return(infoObj);
        }
Example #10
0
        //Find the coordinates of the object galaxyName and perform a slew, then CLS to it.
        private bool SeekGalaxy()
        {
            sky6StarChart         tsx_sc  = new sky6StarChart();
            ClosedLoopSlew        tsx_cl  = new ClosedLoopSlew();
            sky6RASCOMTele        tsx_mt  = new sky6RASCOMTele();
            sky6Raven             tsx_rv  = new sky6Raven();
            sky6ObjectInformation tsx_obj = new sky6ObjectInformation();

            //Clear any camera set up stuff that might be hanging around
            //  and there has been some on occasion
            //Removed subframe on request for cameras with long download times
            ccdsoftCamera tsx_cc = new ccdsoftCamera()
            {
                //Subframe = 0,
                Delay = 0
            };

            LogEntry("Finding coordinates for " + freshImageName);
            tsx_sc.Find(freshImageName);

            // Perform slew to new location before starting CLS -- TSX does not wait for dome rotation.
            tsx_obj.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_RA_2000);
            double tRA = tsx_obj.ObjInfoPropOut;

            tsx_obj.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_DEC_2000);
            double tDec = tsx_obj.ObjInfoPropOut;;

            //Make sure that the mount commands are synchronous
            tsx_mt.Asynchronous = 0;
            //LogEntry("Initial slew to target");
            ////Slew the mount and dome should follow before completion...
            // try { tsx_mt.SlewToRaDec(tRA, tDec, freshImageName); }
            //catch (Exception ex) { LogEntry("Slew error: " + ex.Message); }

            //Test to see if a dome tracking operation is underway.
            // If so, doing a IsGotoComplete will throw an Error 212.
            //  Ignore it a wait a few seconds for stuff to clear

            //If using dome, toggle dome coupling:  this appears to clear most Error 123 problems
            Configuration ss_cfg  = new Configuration();
            bool          hasDome = Convert.ToBoolean(ss_cfg.UsesDome);

            if (hasDome)
            {
                sky6Dome tsx_dm = new sky6Dome();
                tsx_dm.IsCoupled = 0;
                System.Threading.Thread.Sleep(1000);
                tsx_dm.IsCoupled = 1;
            }

            //Wait for any Error 123//s to clear

            LogEntry("Precision slew (CLS) to target");
            //Now try the CLS, but if an Error 123 is thrown, keep trying
            //  every five seconds until the dome slew catches up.
            //int clsStatus = 123;
            //while (clsStatus == 123)
            //{
            //    try { clsStatus = tsx_cl.exec(); }
            //    catch (Exception ex)
            //    {
            //        clsStatus = ex.HResult - 1000;
            //        LogEntry("CLS Error: " + ex.Message);
            //    };
            //}
            DeviceControl dctl      = new DeviceControl();
            int           clsStatus = dctl.ReliableClosedLoopSlew(tRA, tDec, freshImageName, hasDome);

            LogEntry("Precision Slew Complete:  ");
            if (clsStatus == 0)
            {
                LogEntry("    CLS successful");
                return(true);
            }
            else
            {
                LogEntry("    CLS unsucessful: Error: " + clsStatus.ToString());
                return(false);
            }
        }
    /// Windows C# Sample Console Application: ListSearch
    ///
    /// ------------------------------------------------------------------------
    ///               Vaguely adapted from ErrorHandling.vbs  (Visual Basic Script)
    ///               Copyright (C) Software Bisque (2013)
    ///
    ///				Converted 2015, R.McAlister
    ///
    /// ------------------------------------------------------------------------
    ///
    /// This C# console application demonstrates how to run the telescope through a list of targets as defined
    ///   by a list of names.
    ///
    ///  Note:  The gist of the orginal VBS script was entitled "ErrorHandling.vbs".  However, that
    ///  script, however labeled, performed the functions as adapted to VB herein.
    ///


    public void ListSearchSample()
    {
        ///Set the exposure time for the image
        double dExposure = 1.0;

        ///Target List
        string[] targetlist = new string[] {
            "NGC1348",
            "NGC1491",
            "NGC1708",
            "NGC179",
            "NGC1798",
            "NGC2165",
            "NGC2334",
            "NGC2436",
            "NGC2519",
            "NGC2605",
            "NGC2689",
            "NGC2666",
            "NGC4381",
            "NGC5785",
            "NGC5804",
            "NGC6895",
            "NGC6991",
            "NGC7011",
            "NGC7058",
            "M39",
            "NGC7071",
            "NGC7150",
            "NGC7295",
            "NGC7394",
            "NGC7686",
            "NGC7801"
        };

        ///Create objects

        sky6StarChart         objChrt = new sky6StarChart();
        sky6RASCOMTele        objTele = new sky6RASCOMTele();
        ccdsoftCamera         objCam  = new ccdsoftCamera();
        sky6Utils             objUtil = new sky6Utils();
        sky6ObjectInformation objInfo = new sky6ObjectInformation();

        ///Connect Objects
        objTele.Connect();
        objCam.Connect();

        ///Run loop over array of target names
        double dAlt;
        double dAz;
        bool   iError;

        foreach (string target in targetlist)
        {
            objChrt.Find(target);
            objInfo.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_ALT);
            dAlt = objInfo.ObjInfoPropOut;
            objInfo.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_AZM);
            dAz = objInfo.ObjInfoPropOut;

            try
            {
                objTele.SlewToAzAlt(dAz, dAlt, target);
            }
            catch
            {
                MessageBox.Show("An error has occurred running slew");
                return;
            };

            ///Set exposure time and try for image, exit if error
            objCam.ExposureTime = dExposure;
            try
            {
                objCam.TakeImage();
            }
            catch
            {
                MessageBox.Show("An error has occurred running image");
            };
        }

        ///Disconnect telescope and camera
        objTele.Disconnect();
        objCam.Disconnect();
        return;
    }
Example #12
0
        public string Display(string galaxyName, double suspectRAhrs, double suspectDecdeg)
        {
            const int sampleSize = 20;

            //Test code for PlateSolve2 Wrapper
            //CancellationToken cToken;
            TargetName   = galaxyName;
            TargetRAhrs  = suspectRAhrs;
            TargetDecdeg = suspectDecdeg;
            string followUpfileName = FollowUpPath + "\\" + TargetName + ".fit";

            TargetImageDir = ImageBankPath + "\\" + TargetName;
            //Show suspect in astroimage form, if PlateSolve2 is installed
            // if not, then an exception will be thrown

            //
            //test code
            //fileName = "C:\\Users\\Rick McAlister\\Documents\\SuperScan\\Image Bank\\NGC 1023\\NGC 1023_2019-10-31-2138.fit";
            //fileName = "C:\\Users\\Rick McAlister\\Documents\\SuperScan\\Image Bank\\NGC 1023\\CurrentImage.fit";
            //

            TargetFits = new FitsFile(followUpfileName, true);
            double pixSize = 1;

            if (TargetFits.FocalLength != 0)
            {
                pixSize = (206.265 / TargetFits.FocalLength) * TargetFits.XpixSz;
            }
            //
            ccdsoftImage tsxim = new ccdsoftImage();

            tsxim.Path = FollowUpPath + "\\" + galaxyName + ".fit";
            tsxim.Open();
            //Try to image link.  If not successful, probably too few stars
            //  if so, just return out of this;
            ImageLink tsxil = new ImageLink();

            tsxil.pathToFITS = tsxim.Path;
            try { tsxil.execute(); }
            catch (Exception ex)
            {
                return("Image Link Error: " + ex.Message);
            }
            //Show pic on scrren
            tsxim.Visible = 0;

            ImageLinkResults tsxilr = new ImageLinkResults();
            int    rlt     = tsxilr.succeeded;
            string rltText = tsxilr.errorText;

            try
            {
                //tsxim.InsertWCS(true);
                tsxim.ShowInventory();
            }
            catch (Exception ex)
            {
                string evx = ex.Message;
                return(evx);
            }

            //Look for a light source within 10 pixels of the target RA/Dec
            //The developer is picking an arbitrary 10 pixel square box as "near"
            int iLS = FindClosestLightSource(tsxim, TargetRAhrs, TargetDecdeg, 10);

            if (iLS == -1)
            {
                return("No light source found at suspect location\r\n  **Aborting check**");
            }

            //Success -- light source at target location.  Get magnitude and X,Y coordinates for all light sources
            var rMagArr = tsxim.InventoryArray((int)ccdsoftInventoryIndex.cdInventoryMagnitude);
            var rXArr   = tsxim.InventoryArray((int)ccdsoftInventoryIndex.cdInventoryX);
            var rYArr   = tsxim.InventoryArray((int)ccdsoftInventoryIndex.cdInventoryY);

            double rMag;
            string cName;
            int    starIndex    = 0;
            int    starCount    = 0;
            int    minStarCount = sampleSize;
            double tMag         = rMagArr[iLS];

            //Collect a set of catalog stars that have positions that match up
            //  with reference light sources of similar intensity to the target
            //  light source.
            //
            //  first, create data arrays for reference magnitudes and catalog magnitudes
            double[] refMag = new double[sampleSize];
            double[] catMag = new double[sampleSize];
            double[] difMag = new double[sampleSize];
            //double[] meanDev = new double[sampleSize];
            //  second, create TSX objects for the star chart and object information
            sky6StarChart         tsxsc = new sky6StarChart();
            sky6ObjectInformation tsxoi = new sky6ObjectInformation();

            //loop over all the stars in the light source magnitude array,
            // or until a sufficient number of stars are found that match  up
            do
            {
                //Compare the reference light source magnitude to the target light source magnitude
                //  if within 1 magnitude of each other then look up the associated star, if any
                rMag = (double)rMagArr[starIndex];
                if (Math.Abs(tMag - rMag) <= 1.0)
                {
                    //Get the RA/Dec location of the reference light source
                    tsxim.XYToRADec(rXArr[starIndex], rYArr[starIndex]);
                    double rRA  = tsxim.XYToRADecResultRA();
                    double rDec = tsxim.XYToRADecResultDec();
                    //Center the star chart on the RA/Dec coordinates
                    tsxsc.RightAscension = rRA;
                    tsxsc.Declination    = rDec;
                    int Xcen = tsxsc.WidthInPixels / 2;
                    int Ycen = tsxsc.HeightInPixels / 2;
                    //find the star at the center of the chart
                    tsxsc.ClickFind(Xcen, Ycen);
                    //get the name of the star, if any
                    tsxoi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_SOURCE_CATALOG);
                    string cSrc = tsxoi.ObjInfoPropOut;
                    //if there is a name, then get its properties
                    if (cSrc != "")
                    {
                        //Get the name of the star
                        tsxoi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_NAME1);
                        cName = tsxoi.ObjInfoPropOut;
                        //Get the catalog magnitude of the star
                        tsxoi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_MAG);
                        catMag[starCount] = tsxoi.ObjInfoPropOut;
                        refMag[starCount] = rMag;
                        starCount++;
                    }
                }
                starIndex++;
            } while ((starCount < minStarCount) && (starIndex < rMagArr.Length));

            //Compute the difference bewtween reference magnitude and catalog magnitude
            for (int i = 0; i < starCount; i++)
            {
                difMag[i] = refMag[i] - catMag[i];
            }
            //Compute the average difference
            double avgMagDif = 0;

            for (int i = 0; i < starCount; i++)
            {
                avgMagDif += difMag[i];
            }
            avgMagDif = avgMagDif / starCount;
            //Compute the mean square of the deviation
            double avgMagDev = 0;

            for (int i = 0; i < starCount; i++)
            {
                avgMagDev += Math.Pow((difMag[i] - avgMagDif), 2);
            }
            avgMagDev = Math.Sqrt(avgMagDev / starCount);

            //Compute the adjusted magnitude for target
            double avgTgtAdjMag = tMag - avgMagDif;
            //Compute the adjusted magnitude error
            double meanDevTgtAdjMag = avgMagDev;

            //Return center of starchart to target location
            //Set the center of view to the suspect//s RA/Dec and light up the target icon
            //
            //Recenter the star chart on the RA/Dec coordinates
            tsxsc.RightAscension = TargetRAhrs;
            tsxsc.Declination    = TargetDecdeg;
            int Xtcen = tsxsc.WidthInPixels / 2;
            int Ytcen = tsxsc.HeightInPixels / 2;

            //find the star at the center of the chart
            tsxsc.ClickFind(Xtcen, Ytcen);
            tsxoi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_NAME1);
            string starName = tsxoi.ObjInfoPropOut;

            //Open astrodisplay form of follow up image

            tsxim = null;
            tsxoi = null;
            tsxsc = null;
            //Report on computed apparant magnitude
            return("Nearest star: " + starName + "\r\n" +
                   "Adjusted apparent magnitude = " +
                   avgTgtAdjMag.ToString() + "  +/- " +
                   meanDevTgtAdjMag.ToString());
        }
Example #13
0
        public static string TargetStarSearch()
        {
            //Upon instantiation...
            //Open empty working XML file for Star list
            //Create connection to TSX DataWizard
            //Get the path to the query files, then set the path to SuperScanQuery.sdb
            //Run the DataWizard
            //Create an XML datastructure for the Observing List and load it with Observing LIst entries
            //Replace the current working Star List file with the new XML data list
            //Close the file
            string gName;
            double gRA;
            double gDec;

            //Locate current position on star chart and set FOV to 3 degrees
            sky6StarChart tsxsc     = new sky6StarChart();
            double        centerRA  = tsxsc.RightAscension;
            double        centerDec = tsxsc.Declination;

            tsxsc.FieldOfView = 3.0;


            //Look for closest member of list
            //Note the Hour Angle should always be greater than zero
            // and the search area witin 3 degrees of the center of the chart
            // Also only uses HIP stars because "Find" doesn't work on all names, like Tycho

            double bestSeparation = 100.0;
            double tSeparation;

            TargetRA  = centerRA;
            TargetDec = centerDec;
            sky6ObjectInformation tsx_oi = new sky6ObjectInformation();

            do
            {
                //tsx_oi = GetStars(); // will return null if null tsx_oi (including exception thrown) or count = 0;
                //Runs the database query and checks results. objecty information false
                //   else returns null
                sky6DataWizard tsx_dw = new sky6DataWizard();
                ///Set query path
                tsx_dw.Path = StarSearchDBQPath;
                tsx_dw.Open();
                string tst = tsx_dw.Path;
                try { tsx_oi = tsx_dw.RunQuery; }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    return(null);
                }
                if (tsx_oi.Count == 0)
                {
                    return(null);
                }
                //
                //
                if (tsx_oi == null)
                {
                    MessageBox.Show("Waiting half a minute for a better target star");
                    System.Threading.Thread.Sleep(30000); //sleep for thirty seconds then try again
                }
            } while (tsx_oi == null);
            int oiCount = tsx_oi.Count;

            for (int i = 0; i < oiCount; i++)
            {
                tsx_oi.Index = i;
                tsx_oi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_NAME1);
                gName = (string)tsx_oi.ObjInfoPropOut;
                tsx_oi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_RA_2000);
                gRA = (double)tsx_oi.ObjInfoPropOut;
                tsx_oi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_DEC_2000);
                gDec = (double)tsx_oi.ObjInfoPropOut;
                if (gName.Contains("HIP"))
                {
                    tSeparation = ComputeDistance(centerRA, centerDec, gRA, gDec);
                    if (tSeparation < bestSeparation)
                    {
                        bestSeparation = tSeparation;
                        TargetName     = gName;
                        TargetRA       = gRA;
                        TargetDec      = gDec;
                    }
                }
            }
            tsxsc.Find(TargetName);
            return(TargetName);
        }
Example #14
0
        double MinGalAlt = 30;  //Minimum altitude will default to 30 degrees if not set

        public GalaxyList()

        //Upon instantiation...
        //Open empty working XML file for galaxy list
        //Create connection to TSX DataWizard
        //Get the path to the query files, then set the path to SuperScanQuery.sdb
        //Run the DataWizard
        //Create an XML datastructure for the Observing List and load it with Observing LIst entries
        //Replace the current working Galaxy List file with the new XML data list
        //Close the file
        {
            string gname = "";
            string gRA;
            string gDec;
            string gMag;
            string gMajorAxis;
            string gMinorAxis;
            string gAltitude;
            string gHA;
            string gSide;

            XElement gXgalaxies = new XElement("TargetGalaxies");
            XElement gXrec;

            Configuration ss_cfg = new Configuration();

            //if targets are to be refreshed, then run a new observing list query and save the results in the gXgalaxies XML list
            if (Convert.ToBoolean(ss_cfg.RefreshTargets))
            {
                ///Create object information and datawizard objects
                sky6DataWizard tsx_dw = new sky6DataWizard();
                ///Set query path
                tsx_dw.Path = ss_cfg.QueryPath;
                tsx_dw.Open();
                string tst = tsx_dw.Path;

                sky6ObjectInformation tsx_oi = new sky6ObjectInformation();
                tsx_oi = tsx_dw.RunQuery;
                ///
                ///tsx_oi is an array (tsx_oi.Count) of object information indexed by the tsx_oi.Index property
                ///
                ///For each object information in the list, get the name, perform a "Find" and look for the catalog ID.  If there is one, print it.

                for (int i = 0; i <= (tsx_oi.Count - 1); i++)
                {
                    tsx_oi.Index = i;
                    tsx_oi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_NAME1);
                    gname = tsx_oi.ObjInfoPropOut.ToString();
                    tsx_oi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_RA_2000);
                    gRA = tsx_oi.ObjInfoPropOut.ToString();
                    tsx_oi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_DEC_2000);
                    gDec = tsx_oi.ObjInfoPropOut.ToString();
                    tsx_oi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_MAG);
                    gMag = tsx_oi.ObjInfoPropOut.ToString();
                    tsx_oi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_MAJ_AXIS_MINS);
                    gMajorAxis = tsx_oi.ObjInfoPropOut.ToString();
                    tsx_oi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_MIN_AXIS_MINS);
                    gMinorAxis = tsx_oi.ObjInfoPropOut.ToString();
                    tsx_oi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_ALT);
                    gAltitude = tsx_oi.ObjInfoPropOut.ToString();
                    tsx_oi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_HA_HOURS);
                    gHA = tsx_oi.ObjInfoPropOut.ToString();

                    if (System.Convert.ToDouble(gHA) < 0)
                    {
                        gSide = "East";
                    }
                    else
                    {
                        gSide = "West";
                    };

                    gXrec = new XElement("Galaxy",
                                         new XElement("Name", gname),
                                         new XElement("RA", gRA),
                                         new XElement("Dec", gDec),
                                         new XElement("Magnitude", gMag),
                                         new XElement("MajorAxis", gMajorAxis),
                                         new XElement("MinorAxis", gMinorAxis),
                                         new XElement("Altitude", gAltitude),
                                         new XElement("HA", gHA),
                                         new XElement("Side", gSide));
                    //check for galaxy size, if less than the configured minimum, then discard
                    if (Convert.ToDouble(gMajorAxis) >= Convert.ToDouble(ss_cfg.MinGalaxySize))
                    {
                        gXgalaxies.Add(gXrec);
                    }
                }

                gXgalaxies.Save(ss_cfg.GalaxyListPath);
                return;
            }
            else
            {
                //List is not to be refreshed.  Look for the "SuperScanObservingList" in the SuperScan directory.
                //   if one, then parse it into an XML tree
                if (File.Exists(ss_cfg.ObservingListPath))
                {
                    ObservingListLoader oLoad  = new ObservingListLoader(ss_cfg.ObservingListPath);
                    XElement            oListX = oLoad.TSXtoXML();
                    //The XML doc may or may not have all the galaxy information that we need, so use the Find function to go through the
                    //targets and capture all the information
                    TheSky64Lib.sky6StarChart tsxsc  = new sky6StarChart();
                    sky6ObjectInformation     tsx_oi = new sky6ObjectInformation();

                    foreach (XElement galaxyXList in oListX.Elements("target"))
                    {
                        string gName = galaxyXList.Element("name").Value;
                        tsxsc.Find(gName);
                        tsx_oi.Index = 0;
                        tsx_oi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_NAME1);
                        gname = tsx_oi.ObjInfoPropOut.ToString();
                        tsx_oi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_RA_2000);
                        gRA = tsx_oi.ObjInfoPropOut.ToString();
                        tsx_oi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_DEC_2000);
                        gDec = tsx_oi.ObjInfoPropOut.ToString();
                        tsx_oi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_MAG);
                        gMag = tsx_oi.ObjInfoPropOut.ToString();
                        tsx_oi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_MAJ_AXIS_MINS);
                        gMajorAxis = tsx_oi.ObjInfoPropOut.ToString();
                        tsx_oi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_MIN_AXIS_MINS);
                        gMinorAxis = tsx_oi.ObjInfoPropOut.ToString();
                        tsx_oi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_ALT);
                        gAltitude = tsx_oi.ObjInfoPropOut.ToString();
                        tsx_oi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_HA_HOURS);
                        gHA = tsx_oi.ObjInfoPropOut.ToString();

                        if (System.Convert.ToDouble(gHA) < 0)
                        {
                            gSide = "East";
                        }
                        else
                        {
                            gSide = "West";
                        };

                        gXrec = new XElement("Galaxy",
                                             new XElement("Name", gname),
                                             new XElement("RA", gRA),
                                             new XElement("Dec", gDec),
                                             new XElement("Magnitude", gMag),
                                             new XElement("MajorAxis", gMajorAxis),
                                             new XElement("MinorAxis", gMinorAxis),
                                             new XElement("Altitude", gAltitude),
                                             new XElement("HA", gHA),
                                             new XElement("Side", gSide));
                        //check for galaxy size, if less than the configured minimum, then discard
                        if (Convert.ToDouble(gMajorAxis) >= Convert.ToDouble(ss_cfg.MinGalaxySize))
                        {
                            gXgalaxies.Add(gXrec);
                        }
                    }
                    gXgalaxies.Save(ss_cfg.GalaxyListPath);
                }
            }
        }
Example #15
0
        public ObjectList(DBQFileManagement.SearchType searchDB, DateTime duskDateLocal, DateTime dawnDateLocal)
        {
            //Determine if search database file exists, if not, create it
            if (!DBQFileManagement.DBQsInstalled())
            {
                DBQFileManagement.InstallDBQs();
            }

            //Load the path to the selected search database query
            sky6DataWizard tsxdw = new sky6DataWizard();

            tsxdw.Path = DBQFileManagement.GetDBQPath(searchDB);
            //Set the search date for the dusk query
            sky6StarChart tsxs = new sky6StarChart();

            tsxs.DocumentProperty(Sk6DocumentProperty.sk6DocProp_Latitude);
            oLat = tsxs.DocPropOut;
            tsxs.DocumentProperty(Sk6DocumentProperty.sk6DocProp_Longitude);
            oLong = tsxs.DocPropOut;
            double jdate = Celestial.DateToJulian(duskDateLocal.ToUniversalTime());

            tsxs.SetDocumentProperty(Sk6DocumentProperty.sk6DocProp_JulianDateNow, jdate);
            tsxdw.Open();
            //sky6ObjectInformation tsxoi = new sky6ObjectInformation();
            sky6ObjectInformation tsxoi = tsxdw.RunQuery;

            //Fill in data arrays (for speed purposes)
            int tgtcount = tsxoi.Count;

            for (int i = 0; i < tgtcount; i++)
            {
                tsxoi.Index = i;
                //tsxoi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_ALL_INFO);
                //var AllInfo = tsxoi.ObjInfoPropOut;

                tsxoi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_NAME1);
                oname = (tsxoi.ObjInfoPropOut);
                tsxoi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_OBJECTTYPE);
                otype = (tsxoi.ObjInfoPropOut);
                tsxoi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_MAJ_AXIS_MINS);
                osize = (tsxoi.ObjInfoPropOut);
                tsxoi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_RISE_TIME);
                orise = (duskDateLocal - duskDateLocal.TimeOfDay).AddHours(tsxoi.ObjInfoPropOut);
                tsxoi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_SET_TIME);
                oset = (duskDateLocal - duskDateLocal.TimeOfDay).AddHours(tsxoi.ObjInfoPropOut);
                tsxoi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_DEC_2000);
                oDec = (tsxoi.ObjInfoPropOut);
                tsxoi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_RA_2000);
                oRA = (tsxoi.ObjInfoPropOut);
                //compute the duration
                oduration = Celestial.IntervalOverlap(duskDateLocal, dawnDateLocal, orise, oset);
                //compute the maximum altitude
                omaxaltitude = ComputeMaxAltitude(duskDateLocal, dawnDateLocal, oRA, oDec, oLat, oLong);
                // if the duration is greater than zero, then add it
                if (oduration > 0)
                {
                    dbqList.Add(new DBQObject(oname, otype, osize, oset, orise, oDec, oRA, oLat, oLong, oduration, omaxaltitude));
                }
            }
            //Note that all these entries should have at least some duration
            //Set the search date for the dawn query
            jdate = Celestial.DateToJulian(dawnDateLocal.ToUniversalTime());
            tsxs.SetDocumentProperty(Sk6DocumentProperty.sk6DocProp_JulianDateNow, jdate);
            tsxdw.Open();
            tsxoi = tsxdw.RunQuery;

            //check each entry to see if it is already in the dusk list
            //  if so, just ignor, if not get the resf of the info and add it
            for (int i = 0; i < tsxoi.Count; i++)
            {
                tsxoi.Index = i;
                tsxoi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_NAME1);
                oname = (tsxoi.ObjInfoPropOut);
                bool newEntry = true;
                foreach (DBQObject tgt in dbqList)
                {
                    if (tgt.Name == oname)
                    {
                        newEntry = false;
                        break;
                    }
                }
                if (newEntry)
                {
                    tsxoi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_OBJECTTYPE);
                    otype = (tsxoi.ObjInfoPropOut);
                    tsxoi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_MAJ_AXIS_MINS);
                    osize = (tsxoi.ObjInfoPropOut);
                    tsxoi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_RISE_TIME);
                    orise = (duskDateLocal - duskDateLocal.TimeOfDay).AddHours(tsxoi.ObjInfoPropOut);
                    tsxoi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_SET_TIME);
                    oset = (duskDateLocal - duskDateLocal.TimeOfDay).AddHours(tsxoi.ObjInfoPropOut);
                    tsxoi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_DEC_2000);
                    oDec = (tsxoi.ObjInfoPropOut);
                    tsxoi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_RA_2000);
                    oRA = (tsxoi.ObjInfoPropOut);
                    //compute the duration
                    oduration = Celestial.IntervalOverlap(duskDateLocal, dawnDateLocal, orise, oset);
                    //compute the maximum altitude
                    omaxaltitude = ComputeMaxAltitude(duskDateLocal, dawnDateLocal, oRA, oDec, oLat, oLong);
                    // if the duration is greater than zero, then add it
                    if (oduration > 0)
                    {
                        dbqList.Add(new DBQObject(oname, otype, osize, oset, orise, oDec, oRA, oLat, oLong, oduration, omaxaltitude));
                    }
                }
            }

            //Now clear out all the entries that have no duration between
            //Reset tsx to computer clock
            tsxs.SetDocumentProperty(Sk6DocumentProperty.sk6DocProp_UseComputerClock, 1);
            tsxs  = null;
            tsxoi = null;
            return;
        }
Example #16
0
        //When a suspect is chosen from the textbox list, parse the line for galaxy name and date
        //  then have TSX open the difference image, the reference image and the current image
        //  then have TSX set the FOV to the size of the galaxy, set the center of the chart to the
        //  coordinates of the suspect and place the target circle over the coordinates.
        //
        //Then...
        //
        private void SuspectListbox_SelectedIndexChanged(object sender, EventArgs e)
        {
            ///If nothing selected then exit
            ///
            ///Parse the selected line for the galaxy name and image time.
            ///Load up the suspect data
            ///Lay in the clearer follow up image and prep to blink the two latest images
            ///

            //Set the cursor to wait
            UseWaitCursor = true;
            Show();
            FormCrunchingNotice cForm = new FormCrunchingNotice();

            cForm.Show();
            BlinkButton.BackColor = Color.LightSalmon;
            //pull the selected suspect entry from the suspect list box
            string susitem;

            try { susitem = SuspectListbox.Items[SuspectListbox.SelectedIndex].ToString(); }
            catch (Exception ex) { return; }
            //Clear the blink list
            BlinkList = null;
            //Parse the selected entry for relavent info and create a suspect object to work with
            int    galLen  = susitem.IndexOf("\t");
            string galname = susitem.Substring(0, galLen - 1);

            galname = galname.TrimEnd();
            int      dateLen  = susitem.IndexOf(":") - galLen + 2;
            string   galevent = susitem.Substring(galLen + 1, dateLen);
            DateTime galdate  = Convert.ToDateTime(galevent);

            CurrentSuspect = new Suspect();
            //Check to see if the stored suspect info loads ok, if so then
            //  have TSX upload the image files and target the RA/Dec
            bool susLoad = CurrentSuspect.Load(galname, galdate);

            if (susLoad)
            {
                CurrentDrillDown = new DrillDown(CurrentSuspect.Event);

                CurrentDrillDown.Display(galname, CurrentSuspect.SuspectRA, CurrentSuspect.SuspectDec);

                sky6StarChart         tsx_sc = new sky6StarChart();
                sky6ObjectInformation tsx_oi = new sky6ObjectInformation();
                //Get the galaxy major axis
                tsx_sc.Find(galname);
                tsx_oi.Index = 0;
                tsx_oi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_MAJ_AXIS_MINS);
                double galaxis = tsx_oi.ObjInfoPropOut;
                //Set the FOV size to  the galaxy size
                tsx_sc.FieldOfView = galaxis / 60;
                //Set the center of view to the suspect//s RA/Dec and light up the target icon
                //tsx_sc.Find(suspect.SuspectRA.ToString() + ", " + suspect.SuspectDec.ToString());
                tsx_sc.RightAscension = CurrentSuspect.SuspectRA;
                tsx_sc.Declination    = CurrentSuspect.SuspectDec;
                //Check TNS for supernova reports for 60 arc seconds around this location for the last 10 days
                TNSReader     tnsReport = new TNSReader();
                List <string> snList    = tnsReport.RunLocaleQuery(CurrentSuspect.SuspectRA, CurrentSuspect.SuspectDec, 60, 10);
                if (snList != null)
                {
                    NotesTextBox.AppendText("Supernova reported for " + snList[0] + " at this location\r\n");
                }
                else
                {
                    NotesTextBox.AppendText("No supernova report for this location\r\n");
                }
                //Give the user an opportunity to clear the suspect by updating its status to cleared -- or not.
                Clipboard.Clear();
                try { Clipboard.SetText(CurrentSuspect.SuspectRA.ToString() + ", " + CurrentSuspect.SuspectDec.ToString()); }
                catch (Exception ex)
                {
                    NotesTextBox.AppendText(ex.Message);
                    return;
                }
                //Display the suspect position information
                NotesTextBox.AppendText("Suspect RA and Dec written to clipboard\r\n");
                LocationTextBox.Text = CurrentSuspect.SuspectRA.ToString() + ", " + CurrentSuspect.SuspectDec.ToString();
                Show();
                System.Windows.Forms.Application.DoEvents();
                //Show followup Image in picture box
                CurrentFollowUpImage     = CurrentDrillDown.GetFollowUpImage(ImageZoom);
                ImagePictureBox.SizeMode = PictureBoxSizeMode.CenterImage;
                ImagePictureBox.Image    = CurrentFollowUpImage;
                BlinkButton.BackColor    = Color.LightGreen;
                ClearButton.BackColor    = Color.LightGreen;
                UseWaitCursor            = false;
            }
            cForm.Close();
            Show();
            return;
        }
Example #17
0
        private void ReScan()
        {
            string curFilePath      = "";
            string refFilePath      = "";
            string singleTargetName = "";
            bool   scanAll          = true;

            //Open up the configuration parameteters, update with current form inputs
            Configuration ss_cfg = new Configuration();

            LogEventHandler("Starting ReScan");

            string ibdir = ss_cfg.ImageBankFolder;

            string[] imageBankDirs = System.IO.Directory.GetDirectories(ibdir);
            GalaxyCount.Text = imageBankDirs.Length.ToString();

            if (imageBankDirs.Length == 0)
            {
                LogEventHandler("Empty Image Bank");
                return;
            }
            //Determine if all or just one target is to be tested
            DialogResult testDR = MessageBox.Show("Test All?", "Detection Scope", MessageBoxButtons.YesNo);

            if (testDR == DialogResult.No)
            {
                scanAll = false;
                FormEnterGalaxyNumber ngd = new FormEnterGalaxyNumber();
                ngd.ShowDialog(this);
                singleTargetName = "NGC " + ngd.NGCnumberTextBox.Text;
                ngd.Dispose();
                if (singleTargetName == "NGC")
                {
                    return;
                }
            }
            foreach (string galdir in imageBankDirs)
            {
                System.IO.DirectoryInfo sys_imd = new System.IO.DirectoryInfo(galdir);
                if (!scanAll && sys_imd.Name == singleTargetName)
                {
                    string targetName = sys_imd.Name;
                    LogEventHandler("Running " + targetName);
                    System.IO.DirectoryInfo sys_gal = new System.IO.DirectoryInfo(galdir);
                    if (sys_gal.GetFiles("NGC*.fit").Length >= 2)
                    {
                        curFilePath = FindCurrentFile(galdir);
                        refFilePath = FindReferenceFile(galdir);

                        CurrentGalaxyName.Text = targetName;
                        sky6StarChart         tsx_sc = new sky6StarChart();
                        sky6ObjectInformation tsx_oi = new sky6ObjectInformation();
                        tsx_sc.Find(targetName);
                        tsx_oi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_RA_2000);
                        double gRA = Convert.ToDouble(tsx_oi.ObjInfoPropOut);
                        tsx_oi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_DEC_2000);
                        double gDec = Convert.ToDouble(tsx_oi.ObjInfoPropOut);
                        tsx_oi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_MAJ_AXIS_MINS);
                        double gMaxArcMin = Convert.ToDouble(tsx_oi.ObjInfoPropOut);
                        CurrentGalaxySizeArcmin.Text = gMaxArcMin.ToString();
                        int subFrameSize = Convert.ToInt32(60 * gMaxArcMin);

                        NovaDetection ss_ndo = new NovaDetection();
                        ss_ndo.LogUpdate += LogEventHandler;
                        ss_ndo.Detect(targetName, subFrameSize, gRA, gDec, curFilePath, refFilePath, galdir);
                    }
                    else
                    {
                        LogEventHandler("Insufficient Images");
                    }
                }
                GalaxyCount.Text = (Convert.ToInt16(GalaxyCount.Text) - 1).ToString();
            }
            LogEventHandler("ReScan Done");
            return;
        }
Example #18
0
        private void PickButton_Click(object sender, EventArgs e)
        {
            PickButton.BackColor  = Color.LightSalmon;
            StartButton.BackColor = Color.LightSalmon;
            //Pick up the target star location as selected in TSX Star Chart
            MessageBox.Show("Select target star");
            WriteLog("Picking up coordinates of selected target star");
            sky6ObjectInformation tsxoi     = new sky6ObjectInformation();
            StarProspect          foundStar = new StarProspect();

            tsxoi.Index = 0;
            tsxoi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_NAME1);
            foundStar.StarName = (tsxoi.ObjInfoPropOut);
            tsxoi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_RA_2000);
            foundStar.StarRA = (tsxoi.ObjInfoPropOut);
            tsxoi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_DEC_2000);
            foundStar.StarDec = (tsxoi.ObjInfoPropOut);
            tsxoi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_MAG);
            foundStar.StarMag = (tsxoi.ObjInfoPropOut);

            WriteLog("Target star found: " + foundStar.StarName);
            //Closed Loop Slew (following standard slew -- see notes) to the target guide star
            WriteLog("Centering imaging camera on target star");
            bool slewDone1 = SlewToStar(foundStar.StarName, foundStar.StarRA, foundStar.StarDec);

            if (slewDone1)
            {
                WriteLog("Target star centered");
            }
            else
            {
                WriteLog("There was a problem centering the target star");
            }
            //Calculate a pointing position that would put the target star in the guider FOV
            WriteLog("Calculating offset for centering star in guider FOV");
            StarProspect tgtPosition = guiderFOV.OffsetCenter(foundStar, imagePA);

            WriteLog("Offset calculated for pointing at " + tgtPosition.StarRA.ToString("0.000") + " , " + tgtPosition.StarDec.ToString("0.000"));

            //Closed Loop Slew (following standard slew -- see notes) to that offset position
            WriteLog("Centering target star in guider FOV");
            bool slewDone = SlewToPosition(tgtPosition.StarRA, tgtPosition.StarDec);

            if (slewDone1)
            {
                WriteLog("Target star centered in guider FOV");
            }
            else
            {
                WriteLog("Could not recenter the target star");
            }
            //plate solve current location -- not necessary but it sets up the star chart nicely for viewing
            //  note that we are not in such a hurry that we can't mess around a bit
            WriteLog("Checking offset position with a plate solve");
            imagePA = PlateSolve();
            //Reset the chart size for something pleasant around the FOVI's
            guiderFOV.SetStarChartSize();
            //center the star chart on the pointing location ==  once again, for esthetic purposes
            WriteLog("Recentering chart");
            sky6StarChart tsxsc = new sky6StarChart
            {
                RightAscension = tgtPosition.StarRA,
                Declination    = tgtPosition.StarDec
            };

            WriteLog("Target star centered in Guider FOV");
            PickButton.BackColor      = Color.LightGreen;
            StartButton.BackColor     = Color.LightGreen;
            OptimizeButton.Enabled    = true;
            CalibrateButton.Enabled   = true;
            OptimizeButton.BackColor  = Color.LightGreen;
            CalibrateButton.BackColor = Color.LightGreen;

            //all done
            return;
        }
Example #19
0
        public TargetSpecs(string targetName)
        {
            //Use TSX find to load information about the given target
            //Open TSX starchart object
            TargetName = targetName;
            sky6StarChart tsxsc = new sky6StarChart();

            try { tsxsc.Find(targetName); }
            catch (Exception ex) { return; }
            sky6ObjectInformation tsxoi = new sky6ObjectInformation();
            int objIndex = 0;
            //
            int oCount = tsxoi.Count;

            tsxoi.Index = objIndex;
            int pExists;

            tsxoi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_RISE_TIME);
            RiseTime = TimeSpan.FromHours(tsxoi.ObjInfoPropOut);

            tsxoi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_SET_TIME);
            SetTime = TimeSpan.FromHours(tsxoi.ObjInfoPropOut);

            tsxoi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_TRANSIT_TIME);
            TransitTime = TimeSpan.FromHours(tsxoi.ObjInfoPropOut);

            tsxoi.PropertyApplies(Sk6ObjectInformationProperty.sk6ObjInfoProp_PHASE_PERC);
            pExists = tsxoi.ObjInfoPropOut;
            if (pExists != 0)
            {
                tsxoi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_PHASE_PERC);
                PhasePercent = tsxoi.ObjInfoPropOut;
            }

            tsxoi.PropertyApplies(Sk6ObjectInformationProperty.sk6ObjInfoProp_TWIL_ASTRON_START);
            pExists = tsxoi.ObjInfoPropOut;
            if (pExists != 0)
            {
                tsxoi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_TWIL_ASTRON_START);
                TwilightSODTime = TimeSpan.FromHours(tsxoi.ObjInfoPropOut);
            }

            tsxoi.PropertyApplies(Sk6ObjectInformationProperty.sk6ObjInfoProp_TWIL_ASTRON_END);
            pExists = tsxoi.ObjInfoPropOut;
            if (pExists != 0)
            {
                tsxoi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_TWIL_ASTRON_END);
                TwilightEODTime = TimeSpan.FromHours(tsxoi.ObjInfoPropOut);
            }

            //TSX always returns 0 (false) on PropertyApplies for ALL_INFO, so ignor it
            tsxoi.Property(TheSky64Lib.Sk6ObjectInformationProperty.sk6ObjInfoProp_ALL_INFO);
            string sAllInfo = tsxoi.ObjInfoPropOut;

            sAllInfo = sAllInfo.Replace("/", "-");
            string[] sInfoDB = sAllInfo.Split('\n');
            foreach (string s in sInfoDB)
            {
                if (s.Contains("Constellation:") && (s.Count() > 18))
                {
                    Constellation = s.Remove(0, 15);
                    break;
                }
            }
            foreach (string s in sInfoDB)
            {
                if (s.Contains("Object Type:"))
                {
                    TargetType = s.Remove(0, 13);
                    break;
                }
            }
            return;
        }
Example #20
0
        private void AddTargetPlanButton_Click(Object sender, EventArgs e)  // Handles AddTargetPlanButton.Click
        {
            ButtonRed(AddTargetPlanButton);
            //Save a new Humason configuration file with this target name, RA and Dec and about nothing else

            string tgtName = TargetNameBox.Text;

            sky6StarChart         tsxs = new sky6StarChart();
            sky6ObjectInformation tsxo = new sky6ObjectInformation();

            //if (the object is not found, just return
            try
            {
                tsxs.Find(tgtName);
            }
            catch
            {
                ButtonGreen(AddTargetPlanButton);
                return;
            }
            int cnt = tsxo.Count;

            tsxo.Index = 0;
            tsxo.Property(TheSky64Lib.Sk6ObjectInformationProperty.sk6ObjInfoProp_RA_2000);
            double dRA = tsxo.ObjInfoPropOut;

            tsxo.Property(TheSky64Lib.Sk6ObjectInformationProperty.sk6ObjInfoProp_DEC_2000);
            double dDec = tsxo.ObjInfoPropOut;

            XFiles xfn = new XFiles(tgtName);

            if (xfn != null)
            {
                xfn.ReplaceItem(XFiles.sbTargetNameName, tgtName);
                xfn.ReplaceItem(XFiles.sbTargetAdjustCheckedName, false);
                xfn.ReplaceItem(XFiles.sbTargetRAName, dRA);
                xfn.ReplaceItem(XFiles.sbTargetDecName, dDec);
                xfn.SavePlan(tgtName);
            }
            //clear current target list box and reload
            ImagePlannerTargetList.Items.Clear();
            //Fill in Humason target plans
            XFiles        xf      = new XFiles();
            List <string> tgtList = xf.GetTargetFiles();

            foreach (string tgt in tgtList)
            {
                if (!(tgt.Contains("Default")))
                {
                    ImagePlannerTargetList.Items.Add(tgt);
                }
            }
            foreach (string tgt in ImagePlannerTargetList.Items)
            {
                if (tgt == tgtName)
                {
                    ImagePlannerTargetList.SelectedItem = tgt;
                }
            }
            ButtonGreen(AddTargetPlanButton);
            return;
        }
Example #21
0
        private void FillInTargetDetails(string tName)
        {
            //Retrieves details from TSX about the target object
            sky6StarChart         tsxs = new sky6StarChart();
            sky6ObjectInformation tsxo = new sky6ObjectInformation();

            try
            {
                tsxs.Find(tName);
            }
            catch
            {
                return;
            }
            tsxo.Index = 0;
            tsxo.Property(TheSky64Lib.Sk6ObjectInformationProperty.sk6ObjInfoProp_ALL_INFO);
            string sAllInfo = tsxo.ObjInfoPropOut;

            sAllInfo = sAllInfo.Replace("/", "-");

            string[] sInfoDB = sAllInfo.Split('\n');
            XElement infoX   = new XElement("All_Properties");

            foreach (string ipair in sInfoDB)
            {
                string[] infoPair = ipair.Split(':');
                infoPair[0] = infoPair[0].Replace(" ", "_");
                string[] firstSpace = infoPair[0].Split('(');
                if (firstSpace[0] != "")
                {
                    firstSpace[0] = firstSpace[0].Trim('_');
                    firstSpace[0] = System.Text.RegularExpressions.Regex.Replace(firstSpace[0], "//", "");
                    infoPair[1]   = infoPair[1].Trim(' ');
                    infoX.Add(new XElement(firstSpace[0], infoPair[1]));
                }
            }
            //Get rid of multiple constellations.  Got to do it twice for (some reason
            foreach (XElement xmv in infoX.Elements("Constellation"))
            {
                if (xmv.Value.Length < 4)
                {
                    xmv.Remove();
                }
            }
            foreach (XElement xmv in infoX.Elements("Constellation"))
            {
                if (xmv.Value.Length < 4)
                {
                    xmv.Remove();
                }
            }
            //Get rid of the first RA (that//s the current, not J2000)
            XElement xra = infoX.Element("RA");

            xra.Remove();
            XElement xdec = infoX.Element("Dec");

            xdec.Remove();
            //read out interesting data
            string details = "";

            details += "Object:        " + EntryCheck(infoX, "Object_Name");
            details += "Catalog Id:    " + EntryCheck(infoX, "Catalog_Identifier");
            details += "Object Type:   " + EntryCheck(infoX, "Object_Type");
            details += "Constellation: " + EntryCheck(infoX, "Constellation");
            details += "Magnitude:     " + EntryCheck(infoX, "Magnitude");
            details += "Major Axis:    " + EntryCheck(infoX, "Major_Axis");
            details += "Minor Axis:    " + EntryCheck(infoX, "Minor_Axis");
            details += "Axis PA:       " + EntryCheck(infoX, "Axis_Position_Angle");
            details += "RA (J2000):    " + EntryCheck(infoX, "RA");
            details += "Dec (J2000):   " + EntryCheck(infoX, "Dec");

            TargetDetailsTip.SetToolTip(TargetNameBox, details);
            return;
        }
Example #22
0
/// Windows C# Sample Console Application: AutoFocus
///
/// ------------------------------------------------------------------------
///
///               Author: R.McAlister (2017)
///
/// ------------------------------------------------------------------------
///
/// This application performs the following steps:
///   Saves the current target and imaging parameters
///   Turns off Autoguiding (if on)
///   Turns on AutoFocus
///   Returns to the current target

/// Note that "Automatically slew telescope to nearest appropriate focus star" must be checked in the @Focus2 start-up window.
///

    public void AutoFocusSample()
    {
        int iFilter = 3; ///Luminescent, I hope

        ///Connect the telescope for some slewing
        sky6RASCOMTele tsx_tt = new sky6RASCOMTele();

        tsx_tt.Connect();

        ///Work around and Run @Focus2
        ///   Save current target name so it can be found again
        ///   Run @Focus2 (which preempts the observating list and object)
        ///   Restore current target, using Name with Find method
        ///   ClosedLoopSlew back to target

        ccdsoftCamera tsx_cc = new ccdsoftCamera();

        tsx_cc.Connect();
        tsx_cc.focConnect();

        ///Get current target name so we can return after running @focus2
        sky6ObjectInformation tsx_oi = new sky6ObjectInformation();

        tsx_oi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_NAME1);
        string sTargetName = tsx_oi.ObjInfoPropOut;

        ///TBD: Set up parameters for @Focus2, if necessary
        ///
        ///Run Autofocus
        ///   Create a camera object
        ///   Launch the autofocus watching out for an exception -- which will be posted in TSX

        ///Save current camera delay, exposure and filter
        /// then set the camera delay = 0
        /// set the delay back when done with focusing

        tsx_cc.AutoSaveFocusImages = 0;
        var dCamDelay     = tsx_cc.Delay;
        var iCamReduction = tsx_cc.ImageReduction;
        var iCamFilter    = tsx_cc.FilterIndexZeroBased;
        var dCamExp       = tsx_cc.ExposureTime;
        var iFocStatus    = 0;

        tsx_cc.ImageReduction       = ccdsoftImageReduction.cdAutoDark;
        tsx_cc.FilterIndexZeroBased = 3; ///Luminance
        tsx_cc.ExposureTime         = 10;
        tsx_cc.Delay = 0;
        tsx_cc.FilterIndexZeroBased = iFilter;

        iFocStatus = tsx_cc.AtFocus2();

        ///Restore the current target and slew back to it
        ///   Run a Find on the target -- which makes it the "observation"
        ///   Perform Closed Loop Slew to the target

        sky6StarChart tsx_sc = new sky6StarChart();

        tsx_sc.Find(sTargetName);
        ///Run a Closed Loop Slew to return
        ClosedLoopSlew tsx_cls = new ClosedLoopSlew();

        ///Set the exposure, filter to luminance and reduction, set the camera delay to 0 -- any backlash
        /// should be picked up in the mount driver
        tsx_cc.ImageReduction       = ccdsoftImageReduction.cdAutoDark;
        tsx_cc.FilterIndexZeroBased = iFilter; ///Luminance, probably
        tsx_cc.ExposureTime         = 10;
        tsx_cc.Delay = 0;
        try
        {
            var clsstat = tsx_cls.exec();
        }
        catch
        {
            ///Just close up: TSX will spawn error window
            ///System.Windows.Forms.Show("AutoFocus return failure")
        };
        ///Put back the orginal settings

        tsx_cc.ImageReduction       = iCamReduction;
        tsx_cc.FilterIndexZeroBased = iCamFilter;
        tsx_cc.ExposureTime         = dCamExp;
        tsx_cc.Delay = dCamDelay;

        return;
    }
Example #23
0
        //Find the coordinates of the object targetName and perform a slew, then CLS to it.
        private bool SeekTarget()
        {
            sky6StarChart         tsx_sc  = new sky6StarChart();
            ClosedLoopSlew        tsx_cl  = new ClosedLoopSlew();
            sky6RASCOMTele        tsx_mt  = new sky6RASCOMTele();
            sky6Raven             tsx_rv  = new sky6Raven();
            sky6ObjectInformation tsx_obj = new sky6ObjectInformation();

            //Clear any camera set up stuff that might be hanging around
            //  and there has been some on occasion
            //Removed subframe on request for cameras with long download times
            ccdsoftCamera tsx_cc = new ccdsoftCamera()
            {
                Subframe = 0,
                Delay    = 0
            };

            LogEntry("Finding coordinates for " + freshImageName);
            tsx_sc.Find(this.freshImageRA.ToString() + "," + this.freshImageDec.ToString());

            //Make sure that the mount commands are synchronous
            tsx_mt.Asynchronous = 0;
            //LogEntry("Initial slew to target");
            ////Slew the mount and dome should follow before completion...
            // try { tsx_mt.SlewToRaDec(tRA, tDec, freshImageName); }
            //catch (Exception ex) { LogEntry("Slew error: " + ex.Message); }

            //Test to see if a dome tracking operation is underway.
            // If so, doing a IsGotoComplete will throw an Error 212.
            //  Ignore it a wait a few seconds for stuff to clear

            //If using dome, toggle dome coupling:  this appears to clear most Error 123 problems
            Configuration cfg     = new Configuration();
            bool          hasDome = Convert.ToBoolean(cfg.UsesDome);

            if (hasDome)
            {
                sky6Dome tsx_dm = new sky6Dome();
                tsx_dm.IsCoupled = 0;
                System.Threading.Thread.Sleep(1000);
                tsx_dm.IsCoupled = 1;
            }

            //Wait for any Error 123//s to clear

            LogEntry("Precision slew (CLS) to target");
            DeviceControl dctl      = new DeviceControl();
            int           clsStatus = dctl.ReliableClosedLoopSlew(freshImageRA, freshImageDec, freshImageName, hasDome);

            LogEntry("Precision Slew Complete:  ");
            if (clsStatus == 0)
            {
                LogEntry("    CLS successful");
                return(true);
            }
            else
            {
                LogEntry("    CLS unsucessful: Error: " + clsStatus.ToString());
                return(false);
            }
        }
Example #24
0
        //Calendar generation methods

        private void GenerateCalendar()
        {
            sky6StarChart         tdoc = new sky6StarChart();
            sky6Utils             tute = new sky6Utils();
            sky6ObjectInformation tobj = new sky6ObjectInformation();

            double traH;      //target RA in hours
            double tdecD;     //target Dec in degrees
            double tlatD;     //Observer Latitude in degrees
            double tlongD;    //Observer Longitude in degrees

            try
            {
                tdoc.Find(TargetNameBox.Text);
            }
            catch (Exception ex)
            {
                //! found
                System.Windows.Forms.MessageBox.Show("Target not Found: " + TargetNameBox.Text + " " + ex.Message);
                TargetNameBox.Text = "";
                return;
            }
            //Reset the target name to whatever TSX found
            tobj.Index = 0;
            //tobj.Property(TheSky64Lib.Sk6ObjectInformationProperty.sk6ObjInfoProp_NAME1);
            //TargetNameBox.Text = tobj.ObjInfoPropOut;
            enteringTargetState = false;
            //TargetNameBox.Text = TargetNameBox.Text.Replace(" ", "");

            int vj = tobj.Count;

            tobj.Property(TheSky64Lib.Sk6ObjectInformationProperty.sk6ObjInfoProp_RA_2000);
            traH = tobj.ObjInfoPropOut;
            tobj.Property(TheSky64Lib.Sk6ObjectInformationProperty.sk6ObjInfoProp_DEC_2000);
            tdecD = tobj.ObjInfoPropOut;
            tdoc.DocumentProperty(TheSky64Lib.Sk6DocumentProperty.sk6DocProp_Latitude);
            tlatD = tdoc.DocPropOut;
            tdoc.DocumentProperty(TheSky64Lib.Sk6DocumentProperty.sk6DocProp_Longitude);
            tlongD = tdoc.DocPropOut;
            tdoc.DocumentProperty(TheSky64Lib.Sk6DocumentProperty.sk6DocProp_Time_Zone);

            Celestial.RADec  tgtRADec    = new Celestial.RADec(Transform.HoursToRadians(traH), Transform.DegreesToRadians(tdecD));
            Celestial.LatLon obsLocation = new Celestial.LatLon(Transform.DegreesToRadians(tlatD), Transform.DegreesToRadians(-tlongD));

            sundata = TargetControl.SunCycle((int)CurrentYearPick.Value, obsLocation);
            tgtdata = TargetControl.TargetCycle(tgtRADec, sundata, obsLocation, (double)MinAltitudeBox.Value);
            tgtdata = TargetControl.MoonPhase(tgtdata);

            moondata = TargetControl.MoonCycle(tgtdata, obsLocation);
            //Update the target positions with the moonfree properties
            tgtdata = TargetControl.MoonClear(tgtdata, moondata);

            WriteTitle(TargetNameBox.Text, CurrentYearPick.Value.ToString());
            SpawnCalendar(tgtdata);
            if ((CurrentYearPick.Value % 4) != 0)
            {
                ClearLeapDay();
            }
            WriteMoonTip(moondata);
            Show();
            System.Windows.Forms.Application.DoEvents();
            return;
        }
Example #25
0
        public FormPreview(string targetName)
        {
            InitializeComponent();
            //
            //private string isource1 = "http://server1.sky-map.org/skywindow?img_source=DSS2&object=ic2177&zoom=8";
            string isource1                     = "http://server1.sky-map.org/skywindow?img_source=DSS2";
            string izoom                        = "zoom=";
            string ira                          = "ra=";
            string idec                         = "de=";
            string ishowbox                     = "show_box=1";
            string ishowboxwidth                = "box_width=";
            string ishowboxheight               = "box_height=";
            string ishowgrids                   = "show_grid=0";
            string ishowconstellationlines      = "show_constellation_lines=0";
            string ishowconstellationboundaries = "show_constellation_boundaries=0";
            int    angularFrameWidth            = 0;
            double iWidthD                      = 60; //default width of 1 degree
            double iHeightD                     = 45; //default height of 2/3 degree

            FOVX fovXML = new FOVX();
            //Check for valid content in converted My Equipment List XML file
            string FOVName = fovXML.GetActiveFOVHead(fovXML.Description1FieldXName);

            if (FOVName != null)
            {
                //get image fov center, convert to degreess (sky6MyFOV returns arc minutes)
                iWidthD  = Convert.ToDouble(fovXML.GetActiveFOVElementEntry(0, fovXML.SizeXFieldXName)); //arc min
                iHeightD = Convert.ToDouble(fovXML.GetActiveFOVElementEntry(0, fovXML.SizeYFieldXName)); //arc min
                //get overall image width at 4 times FOV, convert to degrees
                angularFrameWidth = (int)(4 * iWidthD / 60);
                //Get RA/Dec coordinates for target in box
                //string targetName = parentForm.TargetNameBox.Text;
                this.Text = targetName + ": " + FOVName;
            }
            else
            {
                this.Text = targetName + ": Default FOV";
            }

            if (iWidthD == 0)
            {
                MessageBox.Show("Zero width FOV is active", "Preview Error", MessageBoxButtons.OK);
                iWidthD = 60;
            }

            angularFrameWidth = (int)(4 * iWidthD / 60);

            sky6StarChart         tsxs = new sky6StarChart();
            sky6ObjectInformation tsxo = new sky6ObjectInformation();

            //if the object is not found, just return
            try
            {
                tsxs.Find(targetName);
            }
            catch
            {
                fovXML = null;
                tsxs   = null;
                tsxo   = null;
                return;
            }

            int cnt = tsxo.Count;

            tsxo.Index = 0;
            tsxo.Property(TheSky64Lib.Sk6ObjectInformationProperty.sk6ObjInfoProp_RA_2000);
            double dRA = tsxo.ObjInfoPropOut;

            tsxo.Property(TheSky64Lib.Sk6ObjectInformationProperty.sk6ObjInfoProp_DEC_2000);
            double dDec = tsxo.ObjInfoPropOut;

            tsxs.RightAscension = dRA;
            tsxs.Declination    = dDec;
            tsxs.FieldOfView    = angularFrameWidth;

            double fullpixDeg0 = (2000.0 / 360.0);                         //pixels per degree at zoom = 0 (maximum pixel width = 2000, at frame width = 360 degrees)
            double fullpixDegN = (2000.0 / angularFrameWidth);             //pixels per degree where the frame width == maximum width in pixels, scaled
            double fullzoomX   = Math.Log((fullpixDegN / fullpixDeg0), 2); //zoom level N that produces a pixel per degree of pixDegN
            int    fullzoom    = Convert.ToInt32(fullzoomX) - 1;
            //convert zoom to integer
            int fullpixDegAtZoomN = (int)(Math.Pow(2, fullzoom) * fullpixDeg0);       //pixels per degree at integer zoom N (integerized)

            int showboxWidth  = Convert.ToInt32((iWidthD / 60) * fullpixDegAtZoomN);  //width of showbox in frame which is zoomed to N
            int showboxHeight = Convert.ToInt32((iHeightD / 60) * fullpixDegAtZoomN); //width of showbox in frame which is zoomed to N

            string iframer = "<IFRAME SRC=" +
                             isource1 + "&" +
                             izoom + fullzoom.ToString() + "&" +
                             ira + dRA.ToString("0.0000") + "&" +
                             idec + dDec.ToString("0.0000") + "&" +
                             ishowbox + "&" +
                             ishowboxwidth + showboxWidth.ToString("00") + "&" +
                             ishowboxheight + showboxHeight.ToString("00") + "&" +
                             ishowgrids + "&" +
                             ishowconstellationlines + "&" +
                             ishowconstellationboundaries + "&" +
                             " WIDTH=400 HEIGHT=400></IFRAME";

            //set the preview window so that it always shows in front of imageforecast window, if active
            //this.Owner = FormImagePlanner;
            //We had some fatal errors here with loading the iframe, i think, so try to catch and ignor
            try
            {
                WebBrowserFrame.DocumentText = iframer;
            }
            catch
            {
                // Do nothing
            }

            System.Threading.Thread.Sleep(1000);
            this.Show();
            fovXML = null;
            tsxo   = null;
            tsxs   = null;
            return;
        }