コード例 #1
0
        public static FitsFile StraightStack(FitsFile[] fsSet, int count)
        {
            FitsFile iStack = new FitsFile(fsSet[0]);

            if (fsSet.Count() > 1)
            {
                for (int fs = 1; fs < count; fs++)
                {
                    for (int iy = 0; iy < fsSet[fs].Yaxis; iy++)
                    {
                        for (int ix = 0; ix < fsSet[fs].Xaxis; ix++)
                        {
                            iStack.FITSArray[ix, iy] += fsSet[fs].FITSArray[ix, iy];
                        }
                    }
                }
                for (int iy = 0; iy < iStack.Yaxis; iy++)
                {
                    for (int ix = 0; ix < iStack.Xaxis; ix++)
                    {
                        iStack.FITSArray[ix, iy] /= (ushort)fsSet.Count();
                    }
                }
            }
            return(iStack);
        }
コード例 #2
0
ファイル: AstroDisplay.cs プロジェクト: rrskybox/AstroImage
        public static Image[] FitsFilesToTargetImages(string[] fileList, double targetRAHrs, double targetDecDeg, int zoom)
        {
            int fileCount = fileList.Length;

            //Open a fitsfile object for each
            FitsFile[] fitsList  = new FitsFile[fileCount];
            AstroPic[] apList    = new AstroPic[fileCount];
            Image[]    blinkList = new Image[fileCount];

            for (int i = 0; i < fileCount; i++)
            {
                fitsList[i] = new FitsFile(fileList[i], true);
                if ((targetRAHrs == 0) && (targetDecDeg == 0))
                {
                    targetRAHrs  = fitsList[i].RA;
                    targetDecDeg = fitsList[i].Dec;
                }
                apList[i] = new AstroPic(fitsList[i]);
                Point center = fitsList[i].RADECtoImageXY(targetRAHrs, targetDecDeg);
                center.X += -40;
                center.Y += -2;
                apList[i].AddCrossHair(center, 80, 2);
                //Point center = fitsList[i].RADECtoImageXY(fitsList[i].RA, fitsList[i].Dec);
                Size   framesize = new Size(apList[i].PixImage.Width / zoom, apList[i].PixImage.Height / zoom);
                double rotation  = -fitsList[i].PA;
                blinkList[i] = apList[i].RotateTranslateCrop(center, rotation, framesize);
                Size sizeUp = new Size(blinkList[i].Size.Width * zoom, blinkList[i].Size.Height * zoom);
                blinkList[i] = AstroPic.Zoom(blinkList[i], sizeUp);
            }

            return(blinkList);
        }
コード例 #3
0
        public FormAstroDisplay(FitsFile af, double targetRA, double targetDec, int zoom, string targetName)
        {
            InitializeComponent();
            Image fit = AstroDisplay.FitsToTargetImage(af, targetRA, targetDec, zoom);

            fitsPictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
            this.Text            = targetName;
            fitsPictureBox.Image = fit;
            return;
        }
コード例 #4
0
        }                            //null instance

        public FitsFile(FitsFile fs) //make a copy
        {
            FITSArray   = fs.FITSArray;
            Xaxis       = fs.Xaxis;
            Yaxis       = fs.Yaxis;
            RA          = fs.RA;
            Dec         = fs.Dec;
            PA          = fs.PA;
            XpixSz      = fs.XpixSz;
            YpixSz      = fs.YpixSz;
            FocalLength = fs.FocalLength;
            PixelScale  = fs.PixelScale;
            MaxValue    = fs.MaxValue;
            AvgValue    = fs.AvgValue;
        }
コード例 #5
0
ファイル: AstroPic.cs プロジェクト: rrskybox/AstroImage
 public AstroPic(FitsFile af)
 {
     //Plate solve image and update centerRA, centerDec, centerPA
     fitsIn = af;
     if ((fitsIn.PixelScale == 0) && (fitsIn.FocalLength != 0))
     {
         fitsIn.PixelScale = (206.265 / fitsIn.FocalLength) * fitsIn.XpixSz;
     }
     if (af.PlateSolve())
     {
         PixImage = fitsIn.LinearStretch();
     }
     //else PixImage = null;
     else
     {
         PixImage = fitsIn.LinearStretch();
     }
     return;
 }
コード例 #6
0
ファイル: AstroDisplay.cs プロジェクト: rrskybox/AstroImage
        public static Image FitsToTargetImage(FitsFile af, double targetRA, double targetDec, int zoom)
        {
            AstroPic ap = new AstroPic(af);

            if (ap.PixImage == null)
            {
                return(null);
            }
            if ((targetRA == 0) && (targetDec == 0))
            {
                targetRA  = af.RA;
                targetDec = af.Dec;
            }
            Point target = af.RADECtoImageXY(targetRA, targetDec);

            target.X   -= 40;
            target.Y   -= 2;
            ap.PixImage = ap.AddCrossHair(target, 80, 2);
            Size sizeUp = new Size(ap.PixImage.Size.Width / zoom, ap.PixImage.Size.Height / zoom);

            return(AstroPic.Zoom(ap.PixImage, sizeUp));
        }
コード例 #7
0
ファイル: DrillDown.cs プロジェクト: rrskybox/SuperScan
        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());
        }
コード例 #8
0
        private void StackButton_Click(object sender, EventArgs e)
        {
            FitsPictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage;
            const double defaultRAHours    = 0;
            const double defaultDecDegrees = 0;

            StackButton.BackColor  = Color.Salmon;
            openFileDialog1.Filter = "FITS files (*.fit)|*.fit";
            openFileDialog1.ShowDialog();
            string[] fileNames = openFileDialog1.FileNames;
            if (fileNames.Length < 1)
            {
                return;
            }
            fitsFileTextBox.Text = fileNames[0];
            FitsFile[] fsSet = new FitsFile[fileNames.Length];
            for (int fs = 0; fs < fileNames.Length; fs++)
            {
                fsSet[fs] = new AstroImage.FitsFile(fileNames[fs], true);
            }
            //
            //Stack fsSet
            int pCount;

            if (SequentialBox.Checked)
            {
                pCount = 0;
            }
            else
            {
                pCount = fsSet.Length - 1;
            }

            for (int i = pCount; i < fsSet.Length; i++)
            {
                FitsFile af = Stack.StraightStack(fsSet, i);

                double pixSize = 1;
                if (af.FocalLength != 0)
                {
                    pixSize = (206.265 / af.FocalLength) * af.XpixSz;
                }
                if (af.RA == 0)
                {
                    af.RA = defaultRAHours;
                }
                if (af.Dec == 0)
                {
                    af.Dec = defaultDecDegrees;
                }


                ap = new AstroPic(af);

                //target cross hairs
                //Point target;
                //target = af.RADECtoImageXY(af.RA, af.Dec);
                //target.X -= 40;
                //target.Y += 2;

                //ap.AddCrossHair(target, 80, 2);

                //Size subSize = new Size(ap.PixImage.Width / 1, ap.PixImage.Height / 1);

                //Image subImage = af.FitsSubframe(ap.PixImage, target, subSize);
                //Size sizeUp = new Size(ap.PixImage.Size.Width / 2, ap.PixImage.Size.Height / 2);
                //Image baseImage = AstroPic.Zoom(ap.PixImage, sizeUp);
                Image baseImage = ap.ResizeImage(FitsPictureBox.Size, true);

                FitsPictureBox.Image = baseImage;
                //System.Threading.Thread.Sleep(1000);
                Show();
                Application.DoEvents();
            }
            StackButton.BackColor = Color.Green;

            return;
        }