示例#1
0
        public PlateSolve(string psfilepath)
        //Creates a new instance of a plateImage and sets the filepath for storing it
        {
            plateImageName = psfilepath;
            ImageLink tsx_il = new ImageLink();

            tsx_il.pathToFITS = psfilepath;
            try
            {
                tsx_il.execute();
            }
            catch (Exception ex)
            {
                string evx = ex.Message;
                plateImageResult = ex.HResult;
                return;
            }
            ImageLinkResults tsx_ilr = new ImageLinkResults();

            plateImageRA    = tsx_ilr.imageCenterRAJ2000;
            plateImageDec   = tsx_ilr.imageCenterDecJ2000;
            plateImagePA    = tsx_ilr.imagePositionAngle;
            plateImageScale = tsx_ilr.imageScale;
            tsx_il          = null;
            tsx_ilr         = null;
            GC.Collect();
            return;
        }
示例#2
0
            public static PlateSolution PlateSolve(string path)
            {
                ImageLink tsxl = new ImageLink
                {
                    pathToFITS = path
                };

                try
                { tsxl.execute(); }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    return(null);
                }
                ImageLinkResults tsxr = new ImageLinkResults();
                ccdsoftCamera    tcam = new ccdsoftCamera();
                PlateSolution    ipa  = new PlateSolution
                {
                    ImageRA         = tsxr.imageCenterRAJ2000,
                    ImageDec        = tsxr.imageCenterDecJ2000,
                    ImagePA         = tsxr.imagePositionAngle,
                    ImageIsMirrored = Convert.ToBoolean(tsxr.imageIsMirrored)
                };

                return(ipa);
            }
示例#3
0
    const int ifilter      = 3;   ///4nd filter slot, probably clear/lumenscent

    public void ImageLinkerSample()
    {
        ///Create camera object and connect

        ImageLink        tsx_il  = new ImageLink();
        ImageLinkResults tsx_ilr = new ImageLinkResults();

        ///Set path to file
        tsx_il.pathToFITS = PathName;

        ///Run ImageLink
        tsx_il.execute();

        ///Check on result
        if (tsx_ilr.succeeded == 0)
        {
            MessageBox.Show("Error: " + tsx_ilr.errorCode.ToString() + "  " + tsx_ilr.errorText);
            return;
        }

        ///Print the image center location

        MessageBox.Show("RA: " + tsx_ilr.imageCenterRAJ2000.ToString() + "  Dec: " + tsx_ilr.imageCenterDecJ2000.ToString());
        return;
    }
示例#4
0
        /// <summary>
        /// Asks TSX for the star count in an image
        /// </summary>
        /// <param name="fPath"></param>
        /// <returns></returns>
        private static int CountStars(string fPath)
        {
            //Have TSX open the fits file fPath
            ImageLink tsxil = new ImageLink();

            tsxil.pathToFITS = fPath;
            //Image Link the image, return 0 if it fails
            try { tsxil.execute(); }
            catch (Exception ex) { return(0); }
            //return the count of stars
            ImageLinkResults tsxilr = new ImageLinkResults();

            return(tsxilr.imageStarCount);
        }
示例#5
0
        private double PlateSolve()
        {
            //runs an image link on the current location to get PA data
            //assume camera, mount etc are connected and properly configured.
            ccdsoftCamera tsxcc = new ccdsoftCamera
            {
                Autoguider   = 0,
                Frame        = ccdsoftImageFrame.cdLight,
                ExposureTime = 10,
                Delay        = 0,
                Asynchronous = 0,
                AutoSaveOn   = 1,
                Subframe     = 0
            };

            try { tsxcc.TakeImage(); }
            catch (Exception ex)
            {
                WriteLog(ex.Message);
                return(0);
            }

            ccdsoftImage tsxi  = new ccdsoftImage();
            ImageLink    tsxil = new ImageLink
            {
                pathToFITS = tsxcc.LastImageFileName,
                scale      = 1.70
            };

            try { tsxil.execute(); }
            catch (Exception ex)
            {
                return(0);
            }
            ImageLinkResults tsxir = new ImageLinkResults();
            double           iPA   = tsxir.imagePositionAngle;

            //Check for image link success, return 0 if not.
            if (tsxir.succeeded == 1)
            {
                return(iPA);
            }
            else
            {
                return(0);
            }
        }
示例#6
0
        static double PlateSolve()
        {
            //runs an image link on the current location to get PA data
            //assume camera, mount etc are connected and properly configured.
            ccdsoftCamera tsxcc = new ccdsoftCamera
            {
                Autoguider   = 0,
                Frame        = ccdsoftImageFrame.cdLight,
                ExposureTime = 10,
                Delay        = 0,
                Asynchronous = 0,
                AutoSaveOn   = 1
            };

            tsxcc.TakeImage();

            ccdsoftImage tsxi  = new ccdsoftImage();
            ImageLink    tsxil = new ImageLink
            {
                scale      = TSXLink.FOVI.GetFOVScale(), //set Scale
                pathToFITS = tsxcc.LastImageFileName
            };

            tsxil.execute();
            ImageLinkResults tsxir = new ImageLinkResults();
            double           iPA   = tsxir.imagePositionAngle;

            //Check for image link success, return 0 if not.
            if (tsxir.succeeded == 1)
            {
                return(iPA);
            }
            else
            {
                return(0);
            }
        }
示例#7
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());
        }