示例#1
0
        private void CompleteActivation()
        {
            m_VideoController.SetPictureBoxCursor(CustomCursors.PanCursor);

            m_FieldSolveContext = AstrometryContext.Current.FieldSolveContext;

            m_Image = m_AstrometryController.GetCurrentAstroPlate();
            m_Image.EffectiveFocalLength = m_FieldSolveContext.FocalLength;

            m_RADegCenter = m_FieldSolveContext.RADeg;
            m_DEDegCenter = m_FieldSolveContext.DEDeg;

            StarCatalogueFacade facade = new StarCatalogueFacade(TangraConfig.Settings.StarCatalogue);

            m_CatalogueStars = facade.GetStarsInRegion(
                m_FieldSolveContext.RADeg, m_FieldSolveContext.DEDeg,
                2.5 * m_Image.GetMaxFOVInArcSec() / 3600.0, m_FieldSolveContext.LimitMagn, (float)m_FieldSolveContext.Epoch);

            m_Eta            = GetUserCameraConfigParam("rotation", 0.0);
            m_FLength        = m_FieldSolveContext.FocalLength;
            m_Aspect         = GetUserCameraConfigParam("aspect", 1.0);
            m_LimitMag       = (int)Math.Round(m_FieldSolveContext.LimitMagn);
            m_ShowLabels     = GetUserCameraConfigParam("labels", 0) == 1;
            m_Grid           = GetUserCameraConfigParam("grid", 0) == 1;
            m_ShowMagnitudes = GetUserCameraConfigParam("magnitudes", 0) == 1;

            UpdateControls();

            InitStarMap();

            m_SolvedPlate = new DirectTransRotAstrometry(m_Image, m_FieldSolveContext.RADeg, m_FieldSolveContext.DEDeg, m_Eta, m_Aspect);

            m_CalibrationContext                   = new CalibrationContext();
            m_CalibrationContext.StarMap           = AstrometryContext.Current.StarMap;
            m_CalibrationContext.PreliminaryFit    = m_SolvedPlate;
            m_FieldSolveContext.CatalogueStars     = m_CatalogueStars;
            m_CalibrationContext.FieldSolveContext = m_FieldSolveContext;
            m_CalibrationContext.PlateConfig       = m_Image;

            TangraConfig.AstrometrySettings calibrationSettings = TangraConfig.Settings.Astrometry.Clone();
            calibrationSettings.MaxResidualInPixels = CorePyramidConfig.Default.CalibrationMaxResidualInPixels;
            calibrationSettings.PyramidDistanceToleranceInPixels = CorePyramidConfig.Default.CalibrationPyramidDistanceToleranceInPixels;
            calibrationSettings.MinimumNumberOfStars             = CorePyramidConfig.Default.CalibrationNumberOfStars;
            m_PlateCalibrator = new PlateCalibration(m_CalibrationContext, calibrationSettings, m_AstrometryController);

            UpdateToolControlDisplay();
            m_PlatesolveController.SetupControls();
            m_SolveState = -1;
            DrawCatalogStarsFit();

            m_State = FittingsState.Activated;
        }
示例#2
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            double raHours, deDeg, /*errDeg,*/ foclen, limmag;

            try
            {
                raHours = AstroConvert.ToRightAcsension(cbxRA.Text);
            }
            catch
            {
                MessageBox.Show(this, "Enter a valid RA value", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                cbxRA.Focus();
                cbxRA.Select();
                return;
            }

            try
            {
                deDeg = AstroConvert.ToDeclination(cbxDE.Text);
            }
            catch
            {
                MessageBox.Show(this, "Enter a valid DE value", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                cbxDE.Focus();
                cbxDE.Select();
                return;
            }

            try
            {
                foclen = double.Parse(tbxFocalLength.Text);
                if (foclen < 30)
                {
                    MessageBox.Show(this, "The current minimum supported focal length is 30mm", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    tbxFocalLength.Focus();
                    tbxFocalLength.Select();
                    return;
                }
                if (foclen > 100000)
                {
                    MessageBox.Show(this, "The current maximum supported focal length is 100m", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    tbxFocalLength.Focus();
                    tbxFocalLength.Select();
                    return;
                }
            }
            catch
            {
                MessageBox.Show(this, "Enter a valid positive floating point value", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                tbxFocalLength.Focus();
                tbxFocalLength.Select();
                return;
            }

            try
            {
                limmag = double.Parse(tbxLimitMag.Text);
                if (limmag < 5 || limmag > 20)
                {
                    throw new FormatException();
                }
            }
            catch
            {
                MessageBox.Show(this, "Enter a valid magnitude int the range ot 5 to 20", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                tbxLimitMag.Focus();
                tbxLimitMag.Select();
                return;
            }


            AstroPlate image = m_AstrometryController.GetCurrentAstroPlate();

            image.EffectiveFocalLength = foclen;

            Context = new FieldSolveContext();

            Context.RADeg          = raHours * 15;
            Context.DEDeg          = deDeg;
            Context.FocalLength    = foclen;
            Context.LimitMagn      = limmag;
            Context.Epoch          = dtpEpoch.Value.Year + (dtpEpoch.Value.Month / 12.0);
            Context.ErrFoVs        = 2.5;
            Context.DataBaseServer = null;
            Context.DataBaseName   = null;
            Context.Method         = RecognitionMethod.KnownCenter;

            cbxRA.Persist();
            cbxDE.Persist();

            TangraConfig.Settings.LastUsed.FocalLength      = foclen;
            TangraConfig.Settings.LastUsed.AstrRAHours      = cbxRA.Text;
            TangraConfig.Settings.LastUsed.AstrDEDeg        = cbxDE.Text;
            TangraConfig.Settings.LastUsed.ObservationEpoch = dtpEpoch.Value;
            TangraConfig.Settings.Save();

            DialogResult = DialogResult.OK;
            Close();
        }
示例#3
0
        public AstrometricSolutionImpl(LeastSquareFittedAstrometry astrometry, StarMagnitudeFit photometry, AstrometricState state, FieldSolveContext fieldSolveContext, MeasurementContext measurementContext)
        {
            StarCatalog        = fieldSolveContext.StarCatalogueFacade.CatalogNETCode;
            UtcTime            = fieldSolveContext.UtcTime;
            FrameNoOfUtcTime   = fieldSolveContext.FrameNoOfUtcTime;
            AutoLimitMagnitude = (float)fieldSolveContext.AutoLimitMagnitude;

            ResolvedFocalLength = (float)fieldSolveContext.FocalLength;

            if (astrometry != null)
            {
                ResolvedCenterRADeg = (float)astrometry.RA0Deg;
                ResolvedCenterDEDeg = (float)astrometry.DE0Deg;
                StdDevRAArcSec      = (float)astrometry.StdDevRAArcSec;
                StdDevDEArcSec      = (float)astrometry.StdDevDEArcSec;
                ArcSecsInPixel      = 1 / astrometry.GetDistanceInPixels(1);
            }
            else
            {
                ResolvedCenterRADeg = float.NaN;
                ResolvedCenterDEDeg = float.NaN;
                StdDevRAArcSec      = float.NaN;
                StdDevDEArcSec      = float.NaN;
                ArcSecsInPixel      = 0;
            }

            if (state.SelectedObject != null)
            {
                m_UserObject       = new TangraUserObjectImpl();
                m_UserObject.RADeg = (float)state.SelectedObject.RADeg;
                m_UserObject.DEDeg = (float)state.SelectedObject.DEDeg;
                m_UserObject.X     = (float)state.SelectedObject.X0;
                m_UserObject.Y     = (float)state.SelectedObject.Y0;

                if (state.IdentifiedObjects != null &&
                    state.IdentifiedObjects.Count == 1)
                {
                    foreach (IIdentifiedObject idObj in state.IdentifiedObjects)
                    {
                        if (AngleUtility.Elongation(idObj.RAHours * 15.0, idObj.DEDeg, state.SelectedObject.RADeg, state.SelectedObject.DEDeg) * 3600 < 120)
                        {
                            m_UserObject.ResolvedName = idObj.ObjectName;
                            break;
                        }
                    }
                }
            }

            InstrumentalDelay         = measurementContext.InstrumentalDelay;
            InstrumentalDelayUnits    = measurementContext.InstrumentalDelayUnits.ToString();
            FrameTimeType             = measurementContext.FrameTimeType.ToString();
            IntegratedFramesCount     = measurementContext.IntegratedFramesCount;
            IntegratedExposureSeconds = measurementContext.IntegratedExposureSeconds;
            AavIntegration            = measurementContext.AavIntegration;
            AavStackedMode            = measurementContext.AavStackedMode;
            VideoFileFormat           = measurementContext.VideoFileFormat.ToString();
            NativeVideoFormat         = measurementContext.NativeVideoFormat;
            if (!string.IsNullOrEmpty(state.IdentifiedObjectToMeasure))
            {
                ObjectDesignation = MPCObsLine.GetObjectCode(state.IdentifiedObjectToMeasure);
            }
            else if (state.IdentifiedObjects != null && state.IdentifiedObjects.Count == 1)
            {
                ObjectDesignation = MPCObsLine.GetObjectCode(state.IdentifiedObjects[0].ObjectName);
            }

            ObservatoryCode = fieldSolveContext.ObsCode;
            CatalogueCode   = measurementContext.StarCatalogueFacade.CatalogNETCode;

            m_MeasurementsImpl = new List <TangraAstrometricMeasurementImpl>();

            if (state.Measurements != null)
            {
                foreach (var mea in state.Measurements)
                {
                    m_MeasurementsImpl.Add(new TangraAstrometricMeasurementImpl()
                    {
                        DEDeg   = mea.DEDeg,
                        RADeg   = mea.RADeg,
                        FrameNo = mea.FrameNo,
                        SolutionUncertaintyRACosDEArcSec = mea.SolutionUncertaintyRACosDEArcSec,
                        SolutionUncertaintyDEArcSec      = mea.SolutionUncertaintyDEArcSec,
                        FWHMArcSec           = mea.FWHMArcSec,
                        Detection            = mea.Detection,
                        SNR                  = mea.SNR,
                        UncorrectedTimeStamp = mea.FrameTimeStamp,
                        Mag                  = mea.Mag
                    });
                }
            }

            m_MatchedStarImpl = new List <TangraMatchedStarImpl>();

            if (astrometry != null)
            {
                foreach (PlateConstStarPair pair in astrometry.FitInfo.AllStarPairs)
                {
                    if (pair.FitInfo.UsedInSolution)
                    {
                        var star = new TangraMatchedStarImpl()
                        {
                            X      = (float)pair.x,
                            Y      = (float)pair.y,
                            RADeg  = (float)pair.RADeg,
                            DEDeg  = (float)pair.DEDeg,
                            StarNo = pair.StarNo,
                            ExcludedForHighResidual = pair.FitInfo.ExcludedForHighResidual,
                            ResidualRAArcSec        = (float)pair.FitInfo.ResidualRAArcSec,
                            ResidualDEArcSec        = (float)pair.FitInfo.ResidualDEArcSec,
                            DetectionCertainty      = (float)pair.DetectionCertainty,
                            PSFAmplitude            = (int)pair.Intensity,
                            IsSaturated             = pair.IsSaturated,
                            Mag = (float)pair.Mag
                        };

                        TangraCatalogStarImpl catStar = null;

                        IStar catalogStar = fieldSolveContext.CatalogueStars.Find(s => s.StarNo == pair.StarNo);
                        if (catalogStar != null)
                        {
                            if (catalogStar is UCAC4Entry)
                            {
                                catStar = new TangraAPASSStar();
                            }
                            else
                            {
                                catStar = new TangraCatalogStarImpl();
                            }

                            catStar.StarNo = catalogStar.StarNo;
                            catStar.MagR   = (float)catalogStar.MagR;
                            catStar.MagV   = (float)catalogStar.MagV;
                            catStar.MagB   = (float)catalogStar.MagB;
                            catStar.Mag    = (float)catalogStar.Mag;

                            if (catalogStar is UCAC3Entry)
                            {
                                UCAC3Entry ucac3Star = (UCAC3Entry)catalogStar;
                                catStar.MagJ       = (float)(ucac3Star.jmag * 0.001);
                                catStar.MagK       = (float)(ucac3Star.kmag * 0.001);
                                catStar.RAJ2000Deg = (float)ucac3Star.RACat;
                                catStar.DEJ2000Deg = (float)ucac3Star.DECat;
                            }
                            else if (catalogStar is UCAC2Entry)
                            {
                                UCAC2Entry ucac2Star = (UCAC2Entry)catalogStar;
                                catStar.MagJ       = (float)(ucac2Star._2m_J * 0.001);
                                catStar.MagK       = (float)(ucac2Star._2m_Ks * 0.001);
                                catStar.RAJ2000Deg = (float)ucac2Star.RACat;
                                catStar.DEJ2000Deg = (float)ucac2Star.DECat;
                            }
                            else if (catalogStar is NOMADEntry)
                            {
                                NOMADEntry nomadStar = (NOMADEntry)catalogStar;
                                catStar.MagJ       = (float)(nomadStar.m_J * 0.001);
                                catStar.MagK       = (float)(nomadStar.m_K * 0.001);
                                catStar.RAJ2000Deg = (float)nomadStar.RACat;
                                catStar.DEJ2000Deg = (float)nomadStar.DECat;
                            }
                            else if (catalogStar is UCAC4Entry)
                            {
                                UCAC4Entry ucac4Star = (UCAC4Entry)catalogStar;
                                catStar.MagJ       = (float)(ucac4Star.MagJ);
                                catStar.MagK       = (float)(ucac4Star.MagK);
                                catStar.RAJ2000Deg = (float)ucac4Star.RACat;
                                catStar.DEJ2000Deg = (float)ucac4Star.DECat;

                                ((TangraAPASSStar)catStar).B   = (float)ucac4Star.MagB;
                                ((TangraAPASSStar)catStar).V   = (float)ucac4Star.MagV;
                                ((TangraAPASSStar)catStar).g   = (float)ucac4Star.Mag_g;
                                ((TangraAPASSStar)catStar).r   = (float)ucac4Star.Mag_r;
                                ((TangraAPASSStar)catStar).i   = (float)ucac4Star.Mag_i;
                                ((TangraAPASSStar)catStar).e_B = ucac4Star.apase_B * 0.001f;
                                ((TangraAPASSStar)catStar).e_V = ucac4Star.apase_V * 0.001f;
                                ((TangraAPASSStar)catStar).e_g = ucac4Star.apase_g * 0.001f;
                                ((TangraAPASSStar)catStar).e_r = ucac4Star.apase_r * 0.001f;
                                ((TangraAPASSStar)catStar).e_i = ucac4Star.apase_i * 0.001f;
                            }
                        }

                        star.CatalogStar = catStar;

                        if (photometry != null)
                        {
                            IStar photometryStar = photometry.StarNumbers.FirstOrDefault(s => s.StarNo == pair.StarNo);
                            if (photometryStar != null)
                            {
                                int idx = photometry.StarNumbers.IndexOf(photometryStar);
                                star.Intensity               = (float)photometry.Intencities[idx];
                                star.IsSaturated             = photometry.SaturatedFlags[idx];
                                star.MeaSignalMethod         = ConvertSignalMethod(photometry.MeaSignalMethod);
                                star.MeaBackgroundMethod     = ConvertBackgroundMethod(photometry.MeaBackgroundMethod);
                                star.MeaSingleApertureSize   = photometry.MeaSingleAperture;
                                star.MeaBackgroundPixelCount = photometry.MeaBackgroundPixelCount;
                                star.MeaSaturationLevel      = photometry.MeaSaturationLevel;
                            }
                        }

                        m_MatchedStarImpl.Add(star);
                    }
                }
            }
        }
示例#4
0
 protected override void ReinitializePlateConstants()
 {
     m_FieldSolveContext = AstrometryContext.Current.FieldSolveContext;
     base.ReinitializePlateConstants();
 }
示例#5
0
        internal frmRunMultiFrameMeasurements(
            VideoController videoController,
            AstrometryController astrometryController,
            AddinsController addinsController,
            VideoAstrometryOperation astrometry,
            MeasurementContext measurementContext,
            FieldSolveContext fieldSolveContext,
            out List <ITangraAddinAction> astrometryAddinActions,
            out List <ITangraAddin> astrometryAddins)
        {
            InitializeComponent();

            pboxAperturePreview.Image = new Bitmap(pboxAperturePreview.Width, pboxAperturePreview.Height, PixelFormat.Format24bppRgb);

            m_VideoController      = videoController;
            m_AddinsController     = addinsController;
            m_AstrometryController = astrometryController;

            m_VideoAstrometry    = astrometry;
            m_MeasurementContext = measurementContext;
            m_FieldSolveContext  = fieldSolveContext;

            SyncTimeStampControlWithExpectedFrameTime();
            nudMinStars.SetNUDValue(TangraConfig.Settings.Astrometry.MinimumNumberOfStars);

            m_MeasurementContext.MaxMeasurements = 200;

            #region Configure the Reduction Settings. The same must be done in the frmConfigureReprocessing and frmSelectReductionType
            // Removes the Background Gradient
            cbxBackgroundMethod.Items.RemoveAt(2);
            #endregion

            SetComboboxIndexFromPhotometryReductionMethod(TangraConfig.Settings.LastUsed.AstrometryPhotometryReductionMethod);
            SetComboboxIndexFromBackgroundMethod(TangraConfig.Settings.LastUsed.AstrometryPhotometryBackgroundMethod);
            cbxFitMagnitudes.Checked = TangraConfig.Settings.LastUsed.AstrometryFitMagnitudes;


            if (TangraConfig.Settings.LastUsed.AstrometryMagFitAperture.HasValue &&
                TangraConfig.Settings.LastUsed.AstrometryMagFitGap.HasValue &&
                TangraConfig.Settings.LastUsed.AstrometryMagFitAnnulus.HasValue)
            {
                nudAperture.ValueChanged -= nudAperture_ValueChanged;
                try
                {
                    nudAperture.SetNUDValue(TangraConfig.Settings.LastUsed.AstrometryMagFitAperture.Value);
                    nudGap.SetNUDValue(TangraConfig.Settings.LastUsed.AstrometryMagFitGap.Value);
                    nudAnnulus.SetNUDValue(TangraConfig.Settings.LastUsed.AstrometryMagFitAnnulus.Value);
                }
                finally
                {
                    nudAperture.ValueChanged += nudAperture_ValueChanged;
                }
            }
            else
            {
                ResetAperture();
            }

            cbxOutputMagBand.SelectedIndex = (int)TangraConfig.Settings.Astrometry.DefaultMagOutputBand;

            lblCatBand.Text = string.Format("Magnitude Band for Photometry (from {0})", m_FieldSolveContext.StarCatalogueFacade.CatalogNETCode);
            cbxCatalogPhotometryBand.Items.Clear();
            cbxCatalogPhotometryBand.Items.AddRange(m_FieldSolveContext.StarCatalogueFacade.CatalogMagnitudeBands);
            CatalogMagnitudeBand defaultBand = cbxCatalogPhotometryBand.Items.Cast <CatalogMagnitudeBand>().FirstOrDefault(e => e.Id == TangraConfig.Settings.StarCatalogue.CatalogMagnitudeBandId);
            if (defaultBand != null)
            {
                cbxCatalogPhotometryBand.SelectedItem = defaultBand;
            }
            else
            {
                cbxCatalogPhotometryBand.SelectedIndex = 0;
            }

            cbxExpectedMotion.SelectedIndex = 1;
            cbxSignalType.Visible           = false;
            cbxSignalType.SelectedIndex     = 0;
            cbxFrameTimeType.SelectedIndex  = 0;
            pnlIntegration.Visible          = false;
            cbxInstDelayUnit.SelectedIndex  = 0;

            m_AstrometryAddinActions = m_AddinsController.GetAstrometryActions(out m_AstrometryAddins);

            foreach (ITangraAddinAction action in m_AstrometryAddinActions)
            {
                clbAddinsToRun.Items.Add(new AddinActionEntry(action));
            }
            astrometryAddinActions = m_AstrometryAddinActions;
            astrometryAddins       = m_AstrometryAddins;

            cbxInstDelayCamera.Items.Clear();
            cbxInstDelayCamera.Items.Add(string.Empty);
            cbxInstDelayCamera.Items.AddRange(InstrumentalDelayConfigManager.GetAvailableCameras().ToArray());

            m_Initialised = true;
        }