Example #1
0
        internal void StartMeasurements()
        {
            MeasurementAreaWing   = m_SpectroscopyController.SpectraReductionContext.MeasurementAreaWing;
            BackgroundAreaWing    = m_SpectroscopyController.SpectraReductionContext.BackgroundAreaWing;
            BackgroundAreaGap     = m_SpectroscopyController.SpectraReductionContext.BackgroundAreaGap;
            PixelValueCoefficient = m_SpectroscopyController.SpectraReductionContext.PixelValueCoefficient;

            var starToTrack = new TrackedObjectConfig()
            {
                ApertureInPixels  = (float)(SelectedStarFWHM * 2),
                MeasureThisObject = false,
                ApertureDX        = 0,
                ApertureDY        = 0,

                Gaussian           = m_SelectedStarGaussian,
                ApertureStartingX  = (float)m_SelectedStarGaussian.XCenter,
                ApertureStartingY  = (float)m_SelectedStarGaussian.YCenter,
                TrackingType       = TrackingType.OccultedStar,
                IsWeakSignalObject = false
            };

            m_Tracker = new SpectroscopyStarTracker(starToTrack);

            m_OperationState = SpectroscopyState.RunningMeasurements;
            m_AllFramesSpectra.Clear();

            m_ControlPanel.MeasurementsStarted();

            m_FirstMeasuredFrame          = null;
            m_CancelMeasurementsRequested = false;
            m_FramePlayer.Start(FramePlaySpeed.Fastest, null, 1);
        }
Example #2
0
        private bool HasObjectsWithAutoAperutreCloserThan8PixelsApart()
        {
            for (int i = 0; i < m_StateMachine.MeasuringStars.Count; i++)
            {
                for (int j = i + 1; j < m_StateMachine.MeasuringStars.Count; j++)
                {
                    TrackedObjectConfig obj1 = m_StateMachine.MeasuringStars[i];
                    TrackedObjectConfig obj2 = m_StateMachine.MeasuringStars[j];

                    if (obj1.IsFixedAperture || obj2.IsFixedAperture)
                    {
                        continue;
                    }

                    double dist = ImagePixel.ComputeDistance(
                        obj1.ApertureStartingX, obj2.ApertureStartingX,
                        obj1.ApertureStartingY, obj2.ApertureStartingY);

                    double minDist = 8 + (obj1.ApertureInPixels + obj2.ApertureInPixels) / 2;

                    if (dist <= minDist && !obj1.ProcessInPsfGroup && !obj2.ProcessInPsfGroup)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Example #3
0
        private void ProcessSingleUnitSet(
            List <LCMeasurement> units,
            bool useLowPass,
            bool useLowPassDiff,
            MeasurementsHelper measurer)
        {
            for (int i = 0; i < units.Count; i++)
            {
                LCMeasurement reading          = units[i];
                IImagePixel[] groupCenters     = new IImagePixel[0];
                float[]       aperturesInGroup = new float[0];

                TrackedObjectConfig        objConfig     = Footer.TrackedObjects[reading.TargetNo];
                List <TrackedObjectConfig> gropedObjects = Footer.TrackedObjects.Where(x => objConfig.GroupId >= 0 && x.GroupId == objConfig.GroupId).ToList();
                if (gropedObjects.Count > 1)
                {
                    groupCenters     = new IImagePixel[gropedObjects.Count];
                    aperturesInGroup = new float[gropedObjects.Count];

                    for (int j = 0; j < gropedObjects.Count; j++)
                    {
                        LCMeasurement mea = units[Footer.TrackedObjects.IndexOf(gropedObjects[j])];
                        groupCenters[j]     = new ImagePixel(mea.X0, mea.Y0);
                        aperturesInGroup[j] = gropedObjects[j].ApertureInPixels;
                    }
                }

                units[i] = ProcessSingleUnit(
                    reading, useLowPass, useLowPassDiff,
                    Context.ReProcessFitAreas[i], Context.ReProcessApertures[i], Header.FixedApertureFlags[i],
                    measurer, groupCenters, aperturesInGroup);
            }
        }
Example #4
0
        private void GroupObjects()
        {
            List <int> objectsAlreadyInAGroup = new List <int>();

            for (int i = 0; i < m_TrackedObjects.Count; i++)
            {
                TrackedObjectConfig obj          = m_TrackedObjects[i];
                MeasurmentGroup     currentGroup = null;

                if (objectsAlreadyInAGroup.IndexOf(i) == -1)
                {
                    currentGroup = new MeasurmentGroup(m_FWHM, obj, i);
                    objectsAlreadyInAGroup.Add(i);
                    m_MeasurementGroups.Add(currentGroup);
                }
                else
                {
                    continue;
                }

                if (currentGroup != null)
                {
                    for (int j = i + 1; j < m_TrackedObjects.Count; j++)
                    {
                        if (currentGroup.IsCloseEnoughToBelongToTheGroup(m_TrackedObjects[j]))
                        {
                            currentGroup.AddObjectInGroup(m_TrackedObjects[j], j);
                            objectsAlreadyInAGroup.Add(j);
                        }
                    }
                }
            }
        }
Example #5
0
 public void AddObjectInGroup(TrackedObjectConfig objectToAdd, int targetNo)
 {
     if (m_ObjectIds.IndexOf(targetNo) == -1)
     {
         m_ObjectsInGroup.Add(objectToAdd);
         m_ObjectIds.Add(targetNo);
     }
 }
Example #6
0
 internal static void ConfigureTrackedObject(int objectId, TrackedObjectConfig obj)
 {
     TrackerConfigureObject(
         objectId,
         obj.IsFixedAperture,
         obj.TrackingType == TrackingType.OccultedStar,
         obj.ApertureStartingX,
         obj.ApertureStartingY,
         obj.ApertureInPixels);
 }
Example #7
0
        internal frmAddOrEditMutualEventsTarget(int objectId, TrackedObjectConfig selectedObject, LCStateMachine state, VideoController videoController)
        {
            InitializeComponent();

            m_VideoController = videoController;

            Text              = "Edit 'Mutual Event' Target";
            btnAdd.Text       = "Save";
            btnDontAdd.Text   = "Cancel";
            btnDelete.Visible = true;
            m_IsEdit          = true;

            m_ObjectId   = objectId;
            m_State      = state;
            m_AstroImage = m_VideoController.GetCurrentAstroImage(false);

            ObjectToAdd = selectedObject;

            float?commonAperture = m_State.MeasuringApertures.Count > 0
                                ? m_State.MeasuringApertures[0] :
                                   (float?)null;

            m_Aperture  = commonAperture;
            m_Aperture1 = commonAperture;
            m_Aperture2 = commonAperture;

            m_Center         = new ImagePixel(selectedObject.ApertureStartingX, selectedObject.ApertureStartingY);
            m_OriginalCenter = new ImagePixel(selectedObject.ApertureStartingX, selectedObject.ApertureStartingY);

            if (selectedObject.ProcessInPsfGroup)
            {
                m_GroupId = selectedObject.GroupId;

                List <TrackedObjectConfig> otherGroupedObjects = state.m_MeasuringStars.Where(x => m_GroupId >= 0 && x.GroupId == m_GroupId && x != selectedObject).ToList();
                if (otherGroupedObjects.Count == 1)
                {
                    ObjectToAdd2 = otherGroupedObjects[0];
                    m_ObjectId2  = state.m_MeasuringStars.IndexOf(ObjectToAdd2);
                }
            }
            else
            {
                ObjectToAdd2 = null;
                m_GroupId    = objectId;
                // If we are to use a second object, it should have the next available Id
                m_ObjectId2 = state.m_MeasuringStars.Count;
            }

            m_EditingOccultedStar = selectedObject.IsOcultedStar();

            Initialise();
        }
Example #8
0
        internal frmAddOrEditSingleTarget(int objectId, ImagePixel center, PSFFit gaussian, LCStateMachine state, VideoController videoController)
        {
            InitializeComponent();

            m_VideoController = videoController;

            m_AutocenteredApertureAvailable = true;

            Text              = "Add Object";
            btnAdd.Text       = "Add";
            btnDontAdd.Text   = "Don't Add";
            btnDelete.Visible = false;
            m_IsEdit          = false;

            nudFitMatrixSize.Value   = 11;
            nudFitMatrixSize.Maximum = 15;

            m_ObjectId   = objectId;
            m_State      = state;
            m_AstroImage = m_State.VideoOperation.m_StackedAstroImage;

            ObjectToAdd = new TrackedObjectConfig();

            m_Center = new ImagePixel(center);

            Initialize();

            if (rbOccultedStar.Enabled)
            {
                SelectedObjectType = TrackingType.OccultedStar;
            }
            else
            {
                SelectedObjectType = TrackingType.GuidingStar;
            }

            // Apply filtering to the processing pixels according to the configured default filter value
            int matirxSize = (int)nudFitMatrixSize.Value;

            GetFitInMatrix(gaussian, ref matirxSize);

            nudFitMatrixSize.Maximum = matirxSize;

            if (SelectedObjectType != TrackingType.OccultedStar)
            {
                SetHeightAndType();
            }
        }
Example #9
0
        public bool IsCloseEnoughToBelongToTheGroup(TrackedObjectConfig objectToCheck)
        {
            foreach (TrackedObjectConfig existingObject in m_ObjectsInGroup)
            {
                double distance =
                    ImagePixel.ComputeDistance(existingObject.ApertureStartingX, objectToCheck.ApertureStartingX,
                                               existingObject.ApertureStartingY, objectToCheck.ApertureStartingY);

                if (distance < m_FWHM * TangraConfig.Settings.Special.MinDistanceForPhotometricGroupingInFWHM)
                {
                    return(true);
                }
            }

            return(false);
        }
Example #10
0
        private void PlotPixels(PictureBox pic, int targetId)
        {
            TrackedObjectConfig target = Model.MeasuringStars[targetId];

            byte[,] pixels = Controller.GetDisplayBitmapPixels(target.OriginalFieldCenterX, target.OriginalFieldCenterY);

            using (Graphics g = Graphics.FromImage(pic.Image))
            {
                for (int x = 0; x < 35; x++)
                {
                    for (int y = 0; y < 35; y++)
                    {
                        byte pixel = pixels[x, y];
                        g.FillRectangle(m_GragBrushes[pixel], 2 * x, 2 * y, 2, 2);
                    }
                }

                float apertureInPixels = Model.Apertures[targetId];
                float apX          = 9 + target.ApertureMatrixX0;
                float apY          = 9 + target.ApertureMatrixY0;
                float apRectX      = 2 * (apX - apertureInPixels);
                float apRectY      = 2 * (apY - apertureInPixels);
                float apertureSize = 4 * apertureInPixels;
                g.DrawEllipse(Controller.DisplaySettings.TargetPens[targetId], apRectX, apRectY, apertureSize, apertureSize);

                float innerRadius = apertureInPixels * TangraConfig.Settings.Photometry.AnnulusInnerRadius;
                g.DrawEllipse(
                    Controller.DisplaySettings.TargetBackgroundPens[targetId],
                    2 * (apX - innerRadius),
                    2 * (apY - innerRadius),
                    4 * innerRadius, 4 * innerRadius);

                float outerRadius = (float)Math.Sqrt(TangraConfig.Settings.Photometry.AnnulusMinPixels / Math.PI + innerRadius * innerRadius);
                g.DrawEllipse(
                    Controller.DisplaySettings.TargetBackgroundPens[targetId],
                    2 * (apX - outerRadius),
                    2 * (apY - outerRadius),
                    4 * outerRadius, 4 * outerRadius);

                g.Save();
            }

            Controller.ApplyDisplayModeAdjustments((Bitmap)pic.Image);

            pic.Invalidate();
        }
Example #11
0
        private void CopyObjectToAdd()
        {
            ObjectToAdd = new TrackedObjectConfig();
            ObjectToAdd.ApertureInPixels  = (float)nudAperture1.Value;
            ObjectToAdd.MeasureThisObject = true;             /* We measure all objects (comparison or occulted), unless specified otherwise by the user */
            ObjectToAdd.ApertureMatrixX0  = m_X0;
            ObjectToAdd.ApertureMatrixY0  = m_Y0;
            ObjectToAdd.ApertureDX        = 0;
            ObjectToAdd.ApertureDY        = 0;

            ObjectToAdd.AutoStarsInArea.Clear();

            ObjectToAdd.OriginalFieldCenterX = m_Center.X;
            ObjectToAdd.OriginalFieldCenterY = m_Center.Y;

            ObjectToAdd.IsWeakSignalObject = false;

            ObjectToAdd.Gaussian          = m_Gaussian;
            ObjectToAdd.ApertureStartingX = m_X0Center;
            ObjectToAdd.ApertureStartingY = m_Y0Center;

            ObjectToAdd.GroupId = -1;

            if (rbOcculted.Checked)
            {
                ObjectToAdd.TrackingType      = TrackingType.OccultedStar;
                ObjectToAdd.PositionTolerance = 2;
                if (ObjectToAdd.Gaussian != null)
                {
                    // Correction for really large stars
                    ObjectToAdd.PositionTolerance += (float)(ObjectToAdd.Gaussian.FWHM / 2);
                }

                ObjectToAdd.PsfFitMatrixSize = TangraConfig.Settings.Special.DefaultOccultedStarPsfFitMatrixSize;
            }
            else
            {
                ObjectToAdd.TrackingType       = TrackingType.GuidingStar;
                ObjectToAdd.PsfFitMatrixSize   = (int)TangraConfig.Settings.Special.DefaultComparisonStarPsfFitMatrixSize;
                ObjectToAdd.IsWeakSignalObject = false;                 // Must have a fit for a guiding star
            }

            ObjectToAdd2 = null;
        }
Example #12
0
        internal frmAddOrEditMutualEventsTarget(int objectId, ImagePixel center, PSFFit gaussian, LCStateMachine state, VideoController videoController, bool tryAutoDoubleFind)
        {
            InitializeComponent();

            m_VideoController   = videoController;
            m_TryAutoDoubleFind = tryAutoDoubleFind;

            Text              = "Add 'Mutual Event' Target";
            btnAdd.Text       = "Add";
            btnDontAdd.Text   = "Don't Add";
            btnDelete.Visible = false;
            m_IsEdit          = false;

            m_ObjectId   = objectId;
            m_GroupId    = objectId;          // For Group Id we use the next object id
            m_State      = state;
            m_AstroImage = m_VideoController.GetCurrentAstroImage(false);

            ObjectToAdd  = null;
            ObjectToAdd2 = null;

            float?commonAperture = m_State.MeasuringApertures.Count > 0
                                ? m_State.MeasuringApertures[0] :
                                   (float?)null;

            m_Aperture  = commonAperture;
            m_Aperture1 = commonAperture;
            m_Aperture2 = commonAperture;

            m_Center         = new ImagePixel(center);
            m_OriginalCenter = new ImagePixel(center);

            m_EditingOccultedStar = false;

            Initialise();
        }
Example #13
0
 public virtual void ObjectSelected(TrackedObjectConfig selectedObject, bool shift, bool ctrl, int selectedStarId)
 {
 }
Example #14
0
 public void ObjectEdited(int selectedStarId, TrackedObjectConfig selectedObject)
 {
     m_CurrentStateObject.ObjectSelected(selectedObject, false, false, selectedStarId);
 }
Example #15
0
 public void ObjectSelected(TrackedObjectConfig selectedObject, bool shift, bool ctrl)
 {
     m_CurrentStateObject.ObjectSelected(selectedObject, shift, ctrl, -1);
 }
Example #16
0
        private LCMeasurement ProcessSingleUnit(
            LCMeasurement reading,
            bool useLowPass,
            bool useLowPassDiff,
            int newFitMatrixSize,
            float newSignalAperture,
            bool fixedAperture,
            MeasurementsHelper measurer,
            IImagePixel[] groupCenters,
            float[] aperturesInGroup)
        {
            reading.ReProcessingPsfFitMatrixSize = newFitMatrixSize;

            TrackedObjectConfig objConfig = Footer.TrackedObjects[reading.TargetNo];
            ImagePixel          center    = new ImagePixel(reading.X0, reading.Y0);

            int areaSize = groupCenters != null && groupCenters.Length > 1 ? 35 : 17;

            if (Context.Filter != LightCurveContext.FilterType.NoFilter)
            {
                areaSize += 2;
            }

            uint[,] data = BitmapFilter.CutArrayEdges(reading.PixelData, (35 - areaSize) / 2);

            var filter = TangraConfig.PreProcessingFilter.NoFilter;

            if (useLowPassDiff)
            {
                filter = TangraConfig.PreProcessingFilter.LowPassDifferenceFilter;
            }
            else if (useLowPass)
            {
                filter = TangraConfig.PreProcessingFilter.LowPassFilter;
            }

            NotMeasuredReasons rv = ReduceLightCurveOperation.MeasureObject(
                center,
                data,
                reading.PixelData,
                Context.BitPix,
                measurer,
                filter,
                Context.SignalMethod,
                Context.PsfQuadratureMethod,
                Context.PsfFittingMethod,
                newSignalAperture,
                objConfig.RefinedFWHM,
                Footer.RefinedAverageFWHM,
                reading,
                groupCenters,
                aperturesInGroup,
                Footer.ReductionContext.FullDisappearance);

            reading.SetIsMeasured(rv);
            reading.TotalReading    = (uint)measurer.TotalReading;
            reading.TotalBackground = (uint)measurer.TotalBackground;
            reading.ApertureX       = measurer.XCenter;
            reading.ApertureY       = measurer.YCenter;
            reading.ApertureSize    = measurer.Aperture;

            return(reading);
        }
Example #17
0
        internal frmZoomedPixels(LightCurveContext context, LCFile lcFile, TangraConfig.LightCurvesDisplaySettings displaySettings, LightCurveController lightcurveController)
        {
            InitializeComponent();

            m_Context              = context;
            m_LCFile               = lcFile;
            m_DisplaySettings      = displaySettings;
            m_LightcurveController = lightcurveController;

            m_Saturation = TangraConfig.Settings.Photometry.Saturation.GetSaturationForBpp(context.BitPix, context.MaxPixelValue);

            picTarget1Pixels.Image = new Bitmap(picTarget1Pixels.Width, picTarget1Pixels.Height);
            picTarget2Pixels.Image = new Bitmap(picTarget2Pixels.Width, picTarget2Pixels.Height);
            picTarget3Pixels.Image = new Bitmap(picTarget3Pixels.Width, picTarget3Pixels.Height);
            picTarget4Pixels.Image = new Bitmap(picTarget4Pixels.Width, picTarget4Pixels.Height);

            m_AllObjectsPeak = 0;

            if (lcFile.Footer.ReductionContext.BitPix <= 8)
            {
                lblDisplayBandTitle.Text = "Displayed Band:";
                lblDisplayedBand.Text    = lcFile.Footer.ReductionContext.ColourChannel.ToString();
            }
            else
            {
                lblDisplayBandTitle.Text = "Digital Video";
                lblDisplayedBand.Text    = "";
            }

            m_TargetBoxes = new PictureBox[] { picTarget1Pixels, picTarget2Pixels, picTarget3Pixels, picTarget4Pixels };

            for (int i = 0; i < m_TargetBoxes.Length; i++)
            {
                warningProvider.SetIconAlignment(m_TargetBoxes[i], ErrorIconAlignment.TopLeft);
                warningProvider.SetIconPadding(m_TargetBoxes[i], -17 - 16);

                infoProvider.SetIconAlignment(m_TargetBoxes[i], ErrorIconAlignment.TopLeft);
                infoProvider.SetIconPadding(m_TargetBoxes[i], -17);
            }

            for (int i = 0; i < m_LCFile.Footer.TrackedObjects.Count; i++)
            {
                TrackedObjectConfig cfg = m_LCFile.Footer.TrackedObjects[i];

                m_ObjectinGroup[i] = cfg.GroupId >= 0 && m_LCFile.Footer.TrackedObjects.Count(x => x.GroupId == cfg.GroupId) > 1;

                switch (cfg.TrackingType)
                {
                case TrackingType.OccultedStar:
                    m_ObjectTitles.Add(i, "Occulted");
                    break;

                case TrackingType.GuidingStar:
                    m_ObjectTitles.Add(i, "Guiding");
                    break;

                case TrackingType.ComparisonStar:
                    m_ObjectTitles.Add(i, "No Guiding");
                    break;
                }
            }
        }
Example #18
0
        internal frmAddOrEditSingleTarget(int objectId, TrackedObjectConfig selectedObject, LCStateMachine state, VideoController videoController)
        {
            InitializeComponent();

            m_VideoController = videoController;

            m_AutocenteredApertureAvailable = true;

            Text = "Edit Object";

            btnAdd.Text       = "Save";
            btnDontAdd.Text   = "Cancel";
            btnDelete.Visible = true;
            m_IsEdit          = true;

            m_ObjectId   = objectId;
            m_State      = state;
            m_AstroImage = m_State.VideoOperation.m_StackedAstroImage;

            ObjectToAdd = selectedObject;

            if (selectedObject.TrackingType != TrackingType.ComparisonStar)
            {
                nudFitMatrixSize.SetNUDValue(selectedObject.PsfFitMatrixSize);
            }

            m_Center = new ImagePixel(
                selectedObject.OriginalFieldCenterX,
                selectedObject.OriginalFieldCenterY);

            if (ObjectToAdd.PositionTolerance > 0)
            {
                nudPositionTolerance.SetNUDValue((decimal)ObjectToAdd.PositionTolerance);
            }

            Initialize();

            if (!selectedObject.IsWeakSignalObject && !selectedObject.IsFixedAperture)
            {
                int matrixSize = selectedObject.PsfFitMatrixSize;
                GetFitInMatrix(selectedObject.Gaussian, ref matrixSize, selectedObject.ApertureInPixels);
                selectedObject.PsfFitMatrixSize = matrixSize;
            }
            else
            {
                m_ProcessingPixels = m_AstroImage.GetMeasurableAreaPixels(m_Center);
                m_DisplayPixels    = m_AstroImage.GetMeasurableAreaDisplayBitmapPixels(m_Center);

                m_FWHM     = 6;
                m_Gaussian = null;
                m_X0       = selectedObject.ApertureMatrixX0;
                m_Y0       = selectedObject.ApertureMatrixY0;
                dx         = selectedObject.ApertureDX;
                dy         = selectedObject.ApertureDY;

                PlotSingleTargetPixels();

                nudAperture1.SetNUDValue((decimal)Math.Round(ObjectToAdd.ApertureInPixels, 2));
            }

            SetHeightAndType();

            if (selectedObject.TrackingType == TrackingType.GuidingStar)
            {
                SelectedObjectType = TrackingType.GuidingStar;
            }
            else if (selectedObject.TrackingType == TrackingType.OccultedStar)
            {
                SelectedObjectType = TrackingType.OccultedStar;
            }
        }
Example #19
0
        private void CopyDoubleObjectsToAdd()
        {
            // Add the first star (with bigger amplitude)
            ObjectToAdd = new TrackedObjectConfig();
            ObjectToAdd.ApertureInPixels  = (float)nudAperture1.Value;
            ObjectToAdd.MeasureThisObject = true;             /* We measure all objects (comparison or occulted), unless specified otherwise by the user */
            ObjectToAdd.ApertureMatrixX0  = m_X1;
            ObjectToAdd.ApertureMatrixY0  = m_Y1;
            ObjectToAdd.ApertureDX        = 0;
            ObjectToAdd.ApertureDY        = 0;

            ObjectToAdd.AutoStarsInArea.Clear();

            ObjectToAdd.OriginalFieldCenterX = m_Center.X;
            ObjectToAdd.OriginalFieldCenterY = m_Center.Y;

            ObjectToAdd.IsWeakSignalObject = false;

            ObjectToAdd.Gaussian          = m_DoubleGaussian.GetGaussian1();
            ObjectToAdd.ApertureStartingX = m_X1Center;
            ObjectToAdd.ApertureStartingY = m_Y1Center;

            ObjectToAdd.GroupId = m_GroupId;

            if (rbOcculted.Checked && rbOccElc1.Checked)
            {
                ObjectToAdd.TrackingType      = TrackingType.OccultedStar;
                ObjectToAdd.PositionTolerance = 2;
                if (ObjectToAdd.Gaussian != null)
                {
                    // Correction for really large stars
                    ObjectToAdd.PositionTolerance += (float)(ObjectToAdd.Gaussian.FWHM / 2);
                }

                ObjectToAdd.PsfFitMatrixSize = TangraConfig.Settings.Special.DefaultOccultedStarPsfFitMatrixSize;
            }
            else
            {
                ObjectToAdd.TrackingType       = TrackingType.GuidingStar;
                ObjectToAdd.PsfFitMatrixSize   = (int)TangraConfig.Settings.Special.DefaultComparisonStarPsfFitMatrixSize;
                ObjectToAdd.IsWeakSignalObject = false;                 // Must have a fit for a guiding star
            }

            // Add the second star (with bigger amplitude)
            ObjectToAdd2 = new TrackedObjectConfig();
            ObjectToAdd2.ApertureInPixels  = (float)nudAperture1.Value;
            ObjectToAdd2.MeasureThisObject = true;             /* We measure all objects (comparison or occulted), unless specified otherwise by the user */
            ObjectToAdd2.ApertureMatrixX0  = m_X2;
            ObjectToAdd2.ApertureMatrixY0  = m_Y2;
            ObjectToAdd2.ApertureDX        = 0;
            ObjectToAdd2.ApertureDY        = 0;

            ObjectToAdd2.AutoStarsInArea.Clear();

            ObjectToAdd2.OriginalFieldCenterX = m_Center.X;
            ObjectToAdd2.OriginalFieldCenterY = m_Center.Y;

            ObjectToAdd2.GroupId = m_GroupId;

            ObjectToAdd2.IsWeakSignalObject = false;

            ObjectToAdd2.Gaussian          = m_DoubleGaussian.GetGaussian2();
            ObjectToAdd2.ApertureStartingX = m_X2Center;
            ObjectToAdd2.ApertureStartingY = m_Y2Center;

            if (rbOcculted.Checked && rbOccElc2.Checked)
            {
                ObjectToAdd2.TrackingType      = TrackingType.OccultedStar;
                ObjectToAdd2.PositionTolerance = 2;
                if (ObjectToAdd.Gaussian != null)
                {
                    // Correction for really large stars
                    ObjectToAdd2.PositionTolerance += (float)(ObjectToAdd.Gaussian.FWHM / 2);
                }

                ObjectToAdd2.PsfFitMatrixSize = TangraConfig.Settings.Special.DefaultOccultedStarPsfFitMatrixSize;
            }
            else
            {
                ObjectToAdd2.TrackingType       = TrackingType.GuidingStar;
                ObjectToAdd2.PsfFitMatrixSize   = (int)TangraConfig.Settings.Special.DefaultComparisonStarPsfFitMatrixSize;
                ObjectToAdd2.IsWeakSignalObject = false;                 // Must have a fit for a guiding star
            }
        }
Example #20
0
 public MeasurmentGroup(float fwhm, TrackedObjectConfig firstObjectInGroup, int targetNo)
 {
     m_FWHM = fwhm;
     AddObjectInGroup(firstObjectInGroup, targetNo);
 }
Example #21
0
        public override bool IsNewObject(ImagePixel star, bool shift, bool ctrl, ref int newOrExistingObjectId)
        {
            if (ctrl)
            {
                // Delete last object
                int starIdx = -1;
                for (int i = 0; i < Context.MeasuringStars.Count; i++)
                {
                    TrackedObjectConfig obj = Context.MeasuringStars[i];

                    if (obj.AsImagePixel == star)
                    {
                        starIdx = i;
                        break;
                    }
                }

                newOrExistingObjectId = -1;

                if (starIdx > -1)
                {
                    Context.MeasuringStars.RemoveAt(starIdx);
                    Context.MeasuringApertures.RemoveAt(starIdx);
                    Context.PsfFitMatrixSizes.RemoveAt(starIdx);

                    if (Context.MeasuringStars.Count < 4)
                    {
                        Context.VideoOperation.MaxStarsReached(false);
                    }

                    return(false);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                // Add
                newOrExistingObjectId = -1;
                for (int i = 0; i < Context.MeasuringStars.Count; i++)
                {
                    TrackedObjectConfig obj = Context.MeasuringStars[i];

                    if (obj.AsImagePixel == star)
                    {
                        newOrExistingObjectId = i;
                        break;
                    }
                }

                if (newOrExistingObjectId == -1)
                {
                    newOrExistingObjectId = Context.MeasuringStars.Count;
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
Example #22
0
        private void btnStart_Click(object sender, EventArgs e)
        {
            bool ctrlHeld =
                Control.ModifierKeys == Keys.Control ||
                Control.ModifierKeys == Keys.ControlKey;

            LightCurveReductionContext.Instance.DebugTracking = ctrlHeld;

            TrackedObjectConfig occultedStar = m_StateMachine.MeasuringStars.Find(t => t.TrackingType == TrackingType.OccultedStar);

            if (occultedStar == null)
            {
                m_VideoController.ShowMessageBox(
                    "No 'Occulted Star' is selected", "Error",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
                return;
            }

            bool isLunarEvent = LightCurveReductionContext.Instance.LightCurveReductionType == LightCurveReductionType.LunarGrazingOccultation ||
                                LightCurveReductionContext.Instance.LightCurveReductionType == LightCurveReductionType.TotalLunarDisappearance ||
                                LightCurveReductionContext.Instance.LightCurveReductionType == LightCurveReductionType.TotalLunarReppearance;

            if (isLunarEvent && m_StateMachine.MeasuringStars.Count > 1)
            {
                m_VideoController.ShowMessageBox(
                    "Only an 'Occulted Star' must be selected for Lunar Events", "Error",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
                return;
            }

            if (LightCurveReductionContext.Instance.LightCurveReductionType == LightCurveReductionType.Asteroidal &&
                HasObjectsWithAutoAperutreCloserThan8PixelsApart())
            {
                // TODO: We should allow the measurement of close objects in Asteroidals too provided that PSF photometry is used and the objects are in a group

                m_VideoController.ShowMessageBox(
                    "Tangra cannot complete this measurement because two of the objects are too close.\r\n\r\n " +
                    "To continue you need to:\r\n\r\n1) Use Aperture Photometry \r\n2) Use 'Fixed - Manually Positioned' aperture for one of the two close objects",
                    "Error",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);

                return;
            }

            if (LightCurveReductionContext.Instance.ReductionMethod == TangraConfig.PhotometryReductionMethod.AperturePhotometry &&
                m_StateMachine.MeasuringStars.Any(x => x.GroupId >= 0))
            {
                if (m_VideoController.ShowMessageBox(
                        "You have selected two stars grouped in one measurement group but the current photometry method is set to 'Aperture Photometry'. This will lead to results that could be incorrect and/or unwanted. PSF Fitting Photometry should be used with grouped stars." +
                        "\r\n\r\nIf you want to change to using PSF Fitting Photometry and continue with the reduction then with press 'Yes'. Otherwise press 'No' to go back and reconfigure your objects.",
                        "Warning",
                        MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.No)
                {
                    return;
                }

                LightCurveReductionContext.Instance.ReductionMethod = TangraConfig.PhotometryReductionMethod.PsfPhotometry;
            }

            if (!isLunarEvent)
            {
                // Guiding stars checks are only applicable to non Lunar events

                int  numberGuidingStars      = m_StateMachine.MeasuringStars.Count(t => t.TrackingType == TrackingType.GuidingStar);
                int  numberComparisonStars   = m_StateMachine.MeasuringStars.Count(t => t.TrackingType == TrackingType.ComparisonStar);
                bool warnedAboutGuidingStars = false;

                if (occultedStar.AutoStarsInArea.Count != 1 ||
                    occultedStar.IsWeakSignalObject)
                {
                    // If this is a user defined position or not the only bright star in the region, we
                    // require at least one guiding star before we can start
                    if (numberGuidingStars == 0)
                    {
                        warnedAboutGuidingStars = true;
                        if (m_VideoController.ShowMessageBox(
                                "It seems that the occulted star is not very bright. For best tracking results it is recommended to select as many 'Guiding Stars' as possible.\r\n\r\nYou may also consider using software integration if there are no bright stars in the video." +
                                "\r\n\r\nWould you like to continue anyway without a 'Guiding Star'?",
                                "Warning",
                                MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.No)
                        {
                            return;
                        }
                    }
                }

                if (!warnedAboutGuidingStars &&
                    numberGuidingStars < numberComparisonStars)
                {
                    warnedAboutGuidingStars = true;
                    if (m_VideoController.ShowMessageBox(
                            "It seems that you may have too few 'Guiding Stars'. For best results it is recommended to use as many 'Guiding Stars' as possible.\r\n\r\nYou should also consider using software integration if there are no bright stars in the video." +
                            "\r\n\r\nWould you like to continue anyway?",
                            "Warning",
                            MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.No)
                    {
                        return;
                    }
                }
            }

            m_StoppedAtFrameNo = -1;
            m_StateMachine.VideoOperation.BeginMeasurements();
        }
Example #23
0
        public override void ObjectSelected(TrackedObjectConfig selectedObject, bool shift, bool ctrl, int selectedStarId)
        {
            if (ctrl)
            {
                // Delete
                int starIdx = -1;
                for (int i = 0; i < Context.MeasuringStars.Count; i++)
                {
                    TrackedObjectConfig obj = Context.MeasuringStars[i];

                    if (obj.AsImagePixel == selectedObject.AsImagePixel)
                    {
                        starIdx = i;
                        break;
                    }
                }

                if (starIdx > -1)
                {
                    Context.MeasuringStars.RemoveAt(starIdx);
                    Context.MeasuringApertures.RemoveAt(starIdx);
                    Context.PsfFitMatrixSizes.RemoveAt(starIdx);

                    if (Context.MeasuringStars.Count < 4)
                    {
                        Context.VideoOperation.MaxStarsReached(false);
                    }
                }
            }
            else if (shift)
            {
                Trace.Assert(false, "Overwriting is not implemented");
                //// Overwrite
                //if (MeasuringStars.Count > 0)
                //{
                //    MeasuringStars.RemoveAt(MeasuringStars.Count - 1);
                //    MeasuringApertures.RemoveAt(MeasuringStars.Count - 1);

                //    MeasuringStars.Add(star);
                //    MeasuringApertures.Add(ApertureSize(gaussian));
                //}
            }
            else
            {
                // Add/Update
                int idx = selectedStarId < 0 ? Context.MeasuringStars.IndexOf(selectedObject) : selectedStarId;
                if (idx > -1)
                {
                    if (idx >= 0 && idx < Context.MeasuringStars.Count)
                    {
                        Context.MeasuringStars[idx]     = selectedObject;
                        Context.MeasuringApertures[idx] = selectedObject.ApertureInPixels;
                        Context.PsfFitMatrixSizes[idx]  = selectedObject.PsfFitMatrixSize;

                        Context.VideoOperation.SelectedTargetChanged(idx);
                    }

                    return;
                }
                if (Context.MeasuringStars.FindAll(obj => obj.MeasureThisObject).Count >= 4)
                {
                    return;
                }

                Context.MeasuringStars.Add(selectedObject);
                Context.MeasuringApertures.Add(selectedObject.ApertureInPixels);
                Context.PsfFitMatrixSizes.Add(selectedObject.PsfFitMatrixSize);

                if (Context.MeasuringStars.Count >= 4)
                {
                    Context.VideoOperation.MaxStarsReached(true);
                }
            }

            Context.m_SelectedMeasuringStar = Context.MeasuringStars.Count - 1;
            Context.VideoOperation.SelectedTargetChanged(Context.m_SelectedMeasuringStar);

            // Make all the aperture the same size as the current one
            for (int i = 0; i < Context.MeasuringStars.Count; i++)
            {
                TrackedObjectConfig obj = Context.MeasuringStars[i];
                obj.ApertureInPixels            = selectedObject.ApertureInPixels;
                Context.m_MeasuringApertures[i] = selectedObject.ApertureInPixels;
            }
        }
Example #24
0
 public SpectroscopyStarTracker(TrackedObjectConfig starConfig)
 {
     TrackedStar = new TrackedObject(0, starConfig);
     TrackedStar.LastKnownGoodPosition = new ImagePixel(starConfig.ApertureStartingX, starConfig.ApertureStartingY);
 }