Beispiel #1
0
        private void SingleButton_Click(object sender, EventArgs e)
        {
            //DialogResult odr = OrphanFileDialog.ShowDialog();

            //close the current tsx image if one is open
            if (TSX_Image != null)
            {
                VariScanFileManager.CloseImageFile(TSX_Image);
            }

            TargetList.TargetXDescriptor tgtDef = new TargetList.TargetXDescriptor("Orphan", 0, 0, 0);

            FitsIsOpen           = VariScanFileManager.DialogOrphanImageFile(TSX_Image, tgtDef.Name);
            OpenFileNameBox.Text = TSX_Image.Path;
            if (FitsIsOpen)
            {
                Fits fits = new Fits(TSX_Image);
                tgtDef.Name            = fits.FitsTarget;
                tgtDef.RA              = (double)(fits.FitsRA ?? 0);
                tgtDef.Dec             = (double)(fits.FitsDec ?? 0);
                tgtDef.Filter          = 3;
                tgtDef.LastImagingDate = fits.FitsUTCDateTime;

                TargetedNameBox.Text   = tgtDef.Name;
                TargetedRABox.Text     = Utility.SexidecimalRADec(tgtDef.RA, true);
                TargetedDecBox.Text    = Utility.SexidecimalRADec(tgtDef.Dec, false);
                TargetedFilterBox.Text = fits.Filter;
                TargetData tstar = Analyze(tgtDef.Name, tgtDef.RA, tgtDef.Dec);
                if (tstar.IsImageLinked)
                {
                    ManageTSXProcess.MinimizeTSX();
                    SourceRATextBox.Text  = Utility.SexidecimalRADec(tstar.SourceRA, true);
                    SourceDecTextBox.Text = Utility.SexidecimalRADec(tstar.SourceDec, false);
                    tstar = GraphMagnitudes(tstar);
                    tstar = GraphSource(tstar);
                    FillPhotometrySummary(tstar);
                    PlotPhotometryHistory(tgtDef.Name);
                    ManageTSXProcess.NormalizeTSX();
                }
            }
            Show();
            System.Windows.Forms.Application.DoEvents();
            return;
        }
Beispiel #2
0
        private void ScanImagesButton_Click(object sender, EventArgs e)
        {
            //Redden the command button
            Utility.ButtonRed(ScanImagesButton);
            Show();
            System.Windows.Forms.Application.DoEvents();

            //Get list of targets
            TargetList vList = new TargetList();
            List <TargetList.TargetXDescriptor> targetList = vList.GetTargetList();

            for (int iTgt = 0; iTgt < targetList.Count; iTgt++)
            {
                string targetDirectoryName = targetList[iTgt].Name;
                FitsNameBox.Text = targetDirectoryName;
                Show();
                System.Windows.Forms.Application.DoEvents();

                IEnumerable <string> targetImages = VariScanFileManager.TargetImageList(targetDirectoryName);
                if (targetImages != null)
                {
                    foreach (string iFile in targetImages)
                    {
                        //Use a direct fits reader to determine if the image has already been analyized, i.e. in Starchive (TSX is too slow)
                        Starchive recs  = new Starchive();
                        FitsFile  fitMe = new FitsFile(iFile);
                        FitsNameBox.Text   = targetDirectoryName;
                        FitsDateBox.Text   = fitMe.FitsUTCDateTime.ToShortDateString();
                        FitsTimeBox.Text   = fitMe.FitsUTCDateTime.ToShortTimeString();
                        FitsFilterBox.Text = fitMe.Filter.ToString();
                        Show();
                        System.Windows.Forms.Application.DoEvents();

                        if (!recs.HasMatchingPhotometryRecord(targetDirectoryName, fitMe.Filter, fitMe.FitsUTCDateTime))
                        {
                            if (TSX_Image != null)
                            {
                                VariScanFileManager.CloseImageFile(TSX_Image);
                            }
                            FitsIsOpen = VariScanFileManager.DirectOpenFitsFile(TSX_Image, iFile);
                            if (FitsIsOpen)
                            {
                                OpenFileNameBox.Text = iFile;
                                FITImage             = new Fits(TSX_Image);
                                //if (!recs.HasMatchingPhotometryRecord(targetDirectoryName, FITImage.Filter, FITImage.FitsUTCDateTime))
                                //{
                                ManageTSXProcess.MinimizeTSX();
                                TargetedNameBox.Text   = targetList[iTgt].Name;
                                TargetedRABox.Text     = Utility.SexidecimalRADec(targetList[iTgt].RA, true);
                                TargetedDecBox.Text    = Utility.SexidecimalRADec(targetList[iTgt].Dec, false);
                                TargetedFilterBox.Text = targetList[iTgt].Filter.ToString();
                                TargetData tstar = Analyze(targetList[iTgt].Name, targetList[iTgt].RA, targetList[iTgt].Dec);
                                if (tstar.IsImageLinked)
                                {
                                    SourceRATextBox.Text  = Utility.SexidecimalRADec(tstar.SourceRA, true);
                                    SourceDecTextBox.Text = Utility.SexidecimalRADec(tstar.SourceDec, false);
                                    tstar = GraphMagnitudes(tstar);
                                    tstar = GraphSource(tstar);
                                    FillPhotometrySummary(tstar);
                                    ArchiveStar(tstar);
                                    PlotPhotometryHistory(targetList[iTgt].Name);
                                    Show();
                                    System.Windows.Forms.Application.DoEvents();
                                }
                                else
                                {
                                    //Star did not image link -- archive it as is
                                    ArchiveStar(tstar);
                                }
                                ManageTSXProcess.NormalizeTSX();
                                //}
                                Show();
                                System.Windows.Forms.Application.DoEvents();
                            }
                        }
                    }
                }
            }
            breakLoop = false;
            Utility.ButtonGreen(BreakButton);
            //Green the command button
            Utility.ButtonGreen(ScanImagesButton);
            return;
        }
Beispiel #3
0
        private TargetData Analyze(string targetName, double targetRA, double targetDec)
        {
            //This is the primary routine.  The current image in TSX is activated and FITS information acquired.
            //  The image is { sent through image link to compute WCS information for each star.
            //  The results are sorted by magnitude, averaged, seeing estimated and results displayed.
            //
            Configuration cfg = new Configuration();

            TargetData targetData = new TargetData()
            {
                TargetName = targetName,
                TargetRA   = targetRA,
                TargetDec  = targetDec
            };

            //tsximg = new ccdsoftImage();
            TSXimglnk = new ImageLink();
            //Using FITS file information...
            FITImage = new Fits(TSX_Image);

            //Compute pixel scale = 206.256 * pixel size (in microns) / focal length
            //Set initial values in case the FITS words aren't there
            FITImage.PixSize = FITImage.PixSize ?? 9;
            //if (FITImage.FocalLength == null)
            //    MessageBox.Show("Focal Length was not set for this FITS image: defaulting to 2000 mm");
            FITImage.FocalLength = FITImage.FocalLength ?? 2563; //mm
            //if (FITImage.Aperture == null)
            //    MessageBox.Show("Aperture was not set for this FITS image: defaulting to 254 mm");
            FITImage.Aperture      = FITImage.Aperture ?? 356.0; //mm
            FocalRatio             = (double)FITImage.FocalLength / (double)FITImage.Aperture;
            targetData.ImageFilter = FITImage.Filter;
            targetData.ImageDate   = FITImage.FitsUTCDateTime;
            targetData.AirMass     = (double)(FITImage.FitsAirMass ?? 0);

            FITImage.Exposure = FITImage.Exposure ?? 0;
            //  focal length must be set to correct value in FITS header -- comes from camera set up in TSX
            PixelScale_arcsec = ConvertToArcSec((double)FITImage.PixSize, (double)FITImage.FocalLength);

            //Set the pixel scale for an InsertWCS image linking
            TSX_Image.ScaleInArcsecondsPerPixel = PixelScale_arcsec;

            //set saturation threshold
            SaturationADU = Math.Pow(2, (double)FITImage.PixBits) * 0.95;
            //set nonlinear threshold
            NonLinearADU = Convert.ToDouble(cfg.ADUMax);

            //ImageLink for light sources (Insert WCS)
            try { int ferr = TSX_Image.InsertWCS(true); }
            catch
            {
                targetData.IsImageLinked = false;
                return(targetData);
            }
            targetData.IsImageLinked = true;
            //Collect astrometric light source data from the image linking into single index arrays:
            //  magnitude, fmhm, ellipsicity, x and y position
            try { MagArr = (TSX_Image.InventoryArray((int)TSXEnums.ccdsoftInventoryIndex.cdInventoryMagnitude)); }
            catch
            {
                targetData.IsImageLinked = false;
                return(targetData);
            }

            FWHMArr        = TSX_Image.InventoryArray((int)TSXEnums.ccdsoftInventoryIndex.cdInventoryFWHM);        //FMHW, we think
            EllipticityArr = TSX_Image.InventoryArray((int)TSXEnums.ccdsoftInventoryIndex.cdInventoryEllipticity); //Ellipsity, we think
            XPosArr        = TSX_Image.InventoryArray((int)TSXEnums.ccdsoftInventoryIndex.cdInventoryX);           //X position, we think
            YPosArr        = TSX_Image.InventoryArray((int)TSXEnums.ccdsoftInventoryIndex.cdInventoryY);           //Y position, we think

            //Collect light sources used for image linking
            try { WCSActiveArr = TSX_Image.WCSArray((int)TSXEnums.ccdsoftWCSIndex.cdActive); }
            catch { return(targetData); }
            WCSRAArr            = TSX_Image.WCSArray((int)TSXEnums.ccdsoftWCSIndex.cdWCSRA);
            WCSDecArr           = TSX_Image.WCSArray((int)TSXEnums.ccdsoftWCSIndex.cdWCSDec);
            WCSXPosArr          = TSX_Image.WCSArray((int)TSXEnums.ccdsoftWCSIndex.cdWCSX);
            WCSYPosArr          = TSX_Image.WCSArray((int)TSXEnums.ccdsoftWCSIndex.cdWCSY);
            WCSResidualArr      = TSX_Image.WCSArray((int)TSXEnums.ccdsoftWCSIndex.cdWCSResidual);
            WCSCatalogIDArr     = TSX_Image.WCSArray((int)TSXEnums.ccdsoftWCSIndex.cdWCSCatalogID);
            WCSPositionErrorArr = TSX_Image.WCSArray((int)TSXEnums.ccdsoftWCSIndex.cdWCSPositionError);

            //Fill in Seeing Analysis information in the windows form:
            //Instrument info
            FocalLengthBox.Text         = ((double)FITImage.FocalLength).ToString("0");
            ApertureBox.Text            = ((double)FITImage.Aperture).ToString("0");
            FocalRatioBox.Text          = FocalRatio.ToString("0.0");
            PixSizeMicronBox.Text       = ((double)FITImage.PixSize).ToString("0.0");
            PixSizeArcSecBox.Text       = (ConvertToArcSec((double)FITImage.PixSize, (double)FITImage.FocalLength)).ToString("0.00");
            MaxResolutionArcSecBox.Text = ((ConvertToArcSec((double)FITImage.PixSize, (double)FITImage.FocalLength)) * 3.3).ToString("0.00");

            AirMassBox.Text = ((double)(FITImage.FitsAirMass ?? 0)).ToString("0.000");

            double FWHMAvg_pixels = MathNet.Numerics.Statistics.ArrayStatistics.Mean(Array.ConvertAll <object, double>(FWHMArr, x => (double)x));

            EllipticityAvg = MathNet.Numerics.Statistics.ArrayStatistics.Mean(Array.ConvertAll <object, double>(EllipticityArr, x => (double)x));
            //Star Size = (Seeing * Focal Length)/206.3 => Seeing = Star Size *206.3/focal length or Seeing = FWHM * focal length/ 206.3* microns;
            double FWHMAvg_arcsec = FWHMAvg_pixels * TSX_Image.ScaleInArcsecondsPerPixel;
            double FWHMAvg_micron = FWHMAvg_pixels * (double)FITImage.PixSize;

            SeeingMeanFWHMBox.Text = FWHMAvg_arcsec.ToString("0.00");
            FWHMSeeing_arcsec      = FWHMAvg_micron * 206.3 / ((double)FITImage.FocalLength);

            SeeingClassBox.Text       = GetSeeingClass(FWHMAvg_arcsec, (double)FITImage.Aperture);
            targetData.ComputedSeeing = GetSeeingClass(FWHMAvg_arcsec, (double)FITImage.Aperture);

            SeeingMeanEllipticityBox.Text = EllipticityAvg.ToString("0.00");
            //Create sorted index of stars, based on magnitude, high to low
            //Generate initial ordered array
            //Set the global sort array index to the first (greatest magnitude) entry {.
            //Create new target data for this variable target
            targetData = SearchForLightSourceInventory(TSX_Image, targetData);
            targetData = NearestCatalogedStar.AcquireNearestQualifiedStar(targetData);

            if (FitsIsOpen)
            {
                //Done
                //Display target, date and time for fits file
                FitsNameBox.Text = FITImage.FitsTarget;
                FitsDateBox.Text = FITImage.FitsUTCDate;
                FitsTimeBox.Text = FITImage.FitsUTCTime;
                //MeanLumBox.Text =  MeanAduToMag(24000).ToString("0.0");
                double backgroundADU = TSX_Image.Background;
                SourceBackgroundADUBox.Text = backgroundADU.ToString("0");
                FitsExposureBox.Text        = ((double)FITImage.Exposure).ToString("0.0");
                FitsFilterBox.Text          = FITImage.Filter;
                //Set the global value for the maximum pixel (used for determine staturation) at 95% of maximum ADU
            }
            return(targetData);
        }