示例#1
0
 public TangraDrawingSettings(TangraConfig.LightCurvesDisplaySettings settings)
 {
     Target1Color = settings.Target1Color;
     Target2Color = settings.Target2Color;
     Target3Color = settings.Target3Color;
     Target4Color = settings.Target4Color;
 }
        internal bool AdjustApertures(Form parentForm, TangraConfig.LightCurvesDisplaySettings displaySettings, LCStateMachine stateMachine, VideoController videoController)
        {
            DisplaySettings = displaySettings;
            m_StateMachine = stateMachine;
            m_VideoController = videoController;

            var frm = new frmAdjustApertures(stateMachine);

            frm.Controller = this;
            frm.Model = new AdjustAperturesViewModel(m_StateMachine.MeasuringApertures, m_StateMachine.MeasuringStars);

            frm.StartPosition = FormStartPosition.CenterParent;
            if (frm.ShowDialog(parentForm) == DialogResult.OK)
            {
                for (int i = 0; i < m_StateMachine.MeasuringStars.Count; i++)
                {
                    m_StateMachine.MeasuringStars[i].ApertureInPixels = frm.Model.Apertures[i];
                    m_StateMachine.MeasuringApertures[i] = frm.Model.Apertures[i];
                }

                return true;
            }

            return false;
        }
示例#3
0
        private void btnResetDefaults_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show(
                    this,
                    "You are about to reset all Tangra settings to their default values. All customisations will be lost.\r\n\r\nDo you want to continue?",
                    "Tangra",
                    MessageBoxButtons.YesNo,
                    MessageBoxIcon.Warning,
                    MessageBoxDefaultButton.Button2) == DialogResult.Yes)
            {
                TangraConfig.Reset(ApplicationSettingsSerializer.Instance);

                foreach (SettingsPannel panel in m_PropertyPages.Values)
                {
                    panel.LoadSettings();
                    panel.Reset();
                }

                MessageBox.Show(
                    this,
                    "Tangra settings have been reset.",
                    "Tangra",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Information);
            }
        }
示例#4
0
        public frmLightCurveSettings(TangraConfig.LightCurvesDisplaySettings displaySettings, frmLightCurve frmLightCurve)
        {
            InitializeComponent();

            m_frmLightCurve = frmLightCurve;
            m_DisplaySettings = displaySettings;

            m_DontApplySettingsBack = true;
            try
            {
                cpBackground.SelectedColor = m_DisplaySettings.BackgroundColor;
                cpLabels.SelectedColor = m_DisplaySettings.LabelsColor;
                cpGrid.SelectedColor = m_DisplaySettings.GridLinesColor;

                cbxColorScheme.SelectedIndex = (int)m_DisplaySettings.ColorScheme;
                cbxTangraTargetColors.Checked = m_DisplaySettings.UseTangraTargetColors;
                nudPointSize.Value = (decimal)m_DisplaySettings.DatapointSize;
                cbxDrawGrid.Checked = m_DisplaySettings.DrawGrid;
                cbxDrawInvalidDatapoints.Checked = m_DisplaySettings.DrawInvalidDataPoints;

                cpFocusArea.SelectedColor = m_DisplaySettings.SmallGraphFocusBackgroundBrushColor;
                cpSelectionCursor.SelectedColor = m_DisplaySettings.SelectionCursorColor;

                SetColorScheme(m_DisplaySettings.ColorScheme);
            }
            finally
            {
                m_DontApplySettingsBack = false;
            }
        }
示例#5
0
 public StarCatalogueFacade(TangraConfig.CatalogSettings tangraSettings)
 {
     m_Settings = new TangraConfig.CatalogSettings()
                      {
                          Catalog = (TangraConfig.StarCatalog) tangraSettings.Catalog,
                          CatalogLocation = tangraSettings.CatalogLocation
                      };
 }
示例#6
0
        public static double ConvertMagnitude(double measuredMag, double vrColorIndex, Guid catalogMagBand, TangraConfig.MagOutputBand magOutputBand)
        {
            if (catalogMagBand == PPMXLEntry.BAND_ID_R && magOutputBand == TangraConfig.MagOutputBand.CousinsR) return measuredMag;
            if (catalogMagBand == PPMXLEntry.BAND_ID_R && magOutputBand == TangraConfig.MagOutputBand.JohnsonV) return ColourIndexTables.GetVFromRAndVR(measuredMag, vrColorIndex);

            if (catalogMagBand == PPMXLEntry.BAND_ID_B && magOutputBand == TangraConfig.MagOutputBand.CousinsR) return ColourIndexTables.GetRFromBAndVR(measuredMag, vrColorIndex);
            if (catalogMagBand == PPMXLEntry.BAND_ID_B && magOutputBand == TangraConfig.MagOutputBand.JohnsonV) return ColourIndexTables.GetVFromBAndVR(measuredMag, vrColorIndex);

            return double.NaN;
        }
示例#7
0
        public frmAbsFlux(TangraConfig.SpectraViewDisplaySettings displaySetting)
            : this()
        {
            m_DisplaySetting = displaySetting;

            m_NewlyOpened = true;
            m_AbsFluxCalibrator = new AbsFluxCalibrator();

            UpdateUIState();
        }
示例#8
0
        public frmTangraSettings(
            ILightCurveFormCustomizer lightCurveCustomizer,
            ISpectraViewFormCustomizer spectraViewCustomizer,
            IAdvStatusPopupFormCustomizer advPopupCustomizer,
            IAavStatusPopupFormCustomizer aavPopupCustomizer,
            AddinsController addinsController,
            IAddinContainer[] addinContainers,
            VideoController videoController)
        {
            InitializeComponent();

            m_AddinsController   = addinsController;
            m_AdvPopupCustomizer = advPopupCustomizer;
            m_AavPopupCustomizer = aavPopupCustomizer;
            m_AddinContainers    = addinContainers;
            m_VideoController    = videoController;

            InitAllPropertyPages();

            TangraConfig.Load(ApplicationSettingsSerializer.Instance);

            ucCustomizeLightCurveViewer lightCurvesColoursPanel = m_PropertyPages.Select(kvp => kvp.Value).FirstOrDefault(x => x is ucCustomizeLightCurveViewer) as ucCustomizeLightCurveViewer;

            if (lightCurvesColoursPanel != null)
            {
                lightCurvesColoursPanel.SetLightCurveFormCustomizer(lightCurveCustomizer);
            }

            ucCustomizeSpectroscopy spectroscopyColoursPanel = m_PropertyPages.Select(kvp => kvp.Value).FirstOrDefault(x => x is ucCustomizeSpectroscopy) as ucCustomizeSpectroscopy;

            if (spectroscopyColoursPanel != null)
            {
                spectroscopyColoursPanel.SetSpectraViewFormCustomizer(spectraViewCustomizer);
            }

            ucADVSVideo12bit AdvsVideo12bitPanel = m_PropertyPages.Select(kvp => kvp.Value).FirstOrDefault(x => x is ucADVSVideo12bit) as ucADVSVideo12bit;

            if (AdvsVideo12bitPanel != null)
            {
                AdvsVideo12bitPanel.SetAdvStatusPopupFormCustomizer(advPopupCustomizer);
            }

            ucAAV8bit Aav8bitPanel = m_PropertyPages.Select(kvp => kvp.Value).FirstOrDefault(x => x is ucAAV8bit) as ucAAV8bit;

            if (Aav8bitPanel != null)
            {
                Aav8bitPanel.SetAdvStatusPopupFormCustomizer(aavPopupCustomizer);
            }

            foreach (SettingsPannel panel in m_PropertyPages.Values)
            {
                panel.LoadSettings();
            }
        }
示例#9
0
        public frmViewSpectra(SpectroscopyController controller, VideoController videoController, TangraConfig.SpectraViewDisplaySettings displaySettings)
            : this()
        {
            m_SpectroscopyController = controller;
            m_DisplaySettings = displaySettings;

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

            m_StateManager = new SpectraViewerStateManager(m_SpectroscopyController, picSpectraGraph, this);
            m_VideoController = videoController;
        }
示例#10
0
 public MPCObsHeader(TangraConfig.MPCHeaderSettings basicSettings)
 {
     this.COD = basicSettings.COD;
     this.CON = basicSettings.CON;
     this.CON2 = basicSettings.CON2;
     this.OBS = basicSettings.OBS;
     this.MEA = basicSettings.MEA;
     this.TEL = basicSettings.TEL;
     this.ACK = basicSettings.ACK;
     this.AC2 = basicSettings.AC2;
     this.COM = basicSettings.COM;
 }
示例#11
0
        public MeasurementsHelper(
            int bitPix,
            TangraConfig.BackgroundMethod backgroundMethod,
            int subPixelSquare,
            uint saturationValue)
        {
            m_BitPix = bitPix;
            m_MaxPixelValue = Pixelmap.GetMaxValueForBitPix(m_BitPix);
            m_BackgroundMethod = backgroundMethod;
            m_SubPixelSquare = subPixelSquare;
            m_SaturationValue = saturationValue;

            m_TimesHigherPositionToleranceForFullyOccultedStars =
                TangraConfig.Settings.Special.TimesHigherPositionToleranceForFullyOccultedStars;
        }
示例#12
0
        internal frmPSFFits(LightCurveContext context, LCFile lcFile, TangraConfig.LightCurvesDisplaySettings displaySettings)
        {
            InitializeComponent();

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

            picTarget1PSF.Image = new Bitmap(picTarget1PSF.Width, picTarget1PSF.Height);
            picTarget2PSF.Image = new Bitmap(picTarget2PSF.Width, picTarget2PSF.Height);
            picTarget3PSF.Image = new Bitmap(picTarget3PSF.Width, picTarget3PSF.Height);
            picTarget4PSF.Image = new Bitmap(picTarget4PSF.Width, picTarget4PSF.Height);

            m_TargetBoxes = new PictureBox[] { picTarget1PSF, picTarget2PSF, picTarget3PSF, picTarget4PSF};
        }
示例#13
0
        internal frmBackgroundHistograms(LightCurveContext context, LCFile lcFile, TangraConfig.LightCurvesDisplaySettings displaySettings)
        {
            InitializeComponent();

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

            picTarget1Hist.Image = new Bitmap(picTarget1Hist.Width, picTarget1Hist.Height);
            picTarget2Hist.Image = new Bitmap(picTarget2Hist.Width, picTarget2Hist.Height);
            picTarget3Hist.Image = new Bitmap(picTarget3Hist.Width, picTarget3Hist.Height);
            picTarget4Hist.Image = new Bitmap(picTarget4Hist.Width, picTarget4Hist.Height);

            m_TargetBoxes = new PictureBox[] { picTarget1Hist, picTarget2Hist, picTarget3Hist, picTarget4Hist };
        }
示例#14
0
        public frmEditConfigName(
			TangraConfig.ScopeRecorderConfiguration config,
			VideoCamera camera,
			int frameWidth,
			int frameHeight,
			TangraConfig.PersistedPlateConstants pltConst)
        {
            InitializeComponent();

            m_FrameWidth = frameWidth;
            m_FrameHeight = frameHeight;

            if (config == null)
            {
                config = new TangraConfig.ScopeRecorderConfiguration(camera.Model, frameWidth, frameHeight);
                tbxConfigName.Enabled = true;
                m_New = true;
                Height = 260;
                pnlSolvedPlateConf.Visible = false;
                cbxEditConfig.Visible = false;
                pnlOSDAreaConf.Visible = false;
                cbxEditOSDArea.Visible = false;
            }
            else
            {
                tbxConfigName.Enabled = false;
                Height = 396;
                pnlSolvedPlateConf.Visible = true;
                cbxEditConfig.Visible = true;
                if (pltConst != null)
                {
                    tbxSolvedCellX.Text = pltConst.EffectivePixelWidth.ToString();
                    tbxSolvedCellY.Text = pltConst.EffectivePixelHeight.ToString();
                    tbxSolvedFocalLength.Text = pltConst.EffectiveFocalLength.ToString();
                }
            }

            cbxAreaType.SelectedIndex = config.IsInclusionArea ? 1 : 0;
            if (config.IsInclusionArea)
                SetOSDDimentions(config.InclusionArea);
            else
                SetOSDDimentions(config.OSDExclusionArea);

            m_Config = config;
            m_Camera = camera;
            tbxConfigName.Text = config.Title;
            m_PltConst = pltConst;
        }
示例#15
0
        public static double ConvertMagnitude(double measuredMag, double vrColorIndex, Guid catalogMagBand, TangraConfig.MagOutputBand magOutputBand)
        {
            if (catalogMagBand == UCAC3Entry.BAND_ID_R && magOutputBand == TangraConfig.MagOutputBand.CousinsR) return measuredMag;
            if (catalogMagBand == UCAC3Entry.BAND_ID_R && magOutputBand == TangraConfig.MagOutputBand.JohnsonV) return ColourIndexTables.GetVFromRAndVR(measuredMag, vrColorIndex);

            if (catalogMagBand == UCAC3Entry.BAND_ID_V && magOutputBand == TangraConfig.MagOutputBand.CousinsR) return ColourIndexTables.GetRFromVAndVR(measuredMag, vrColorIndex);
            if (catalogMagBand == UCAC3Entry.BAND_ID_V && magOutputBand == TangraConfig.MagOutputBand.JohnsonV) return measuredMag;

            if (catalogMagBand == UCAC3Entry.BAND_ID_UNFILTERED)
            {
                double jk = ColourIndexTables.GetJKFromVR(vrColorIndex);
                if (magOutputBand == TangraConfig.MagOutputBand.CousinsR) return -0.295 * jk + 1.323 * measuredMag - 0.0377 * measuredMag * measuredMag + 0.001142 * measuredMag * measuredMag * measuredMag - 0.68;
                if (magOutputBand == TangraConfig.MagOutputBand.JohnsonV) return 0.552 * jk + 1.578 * measuredMag - 0.0560 * measuredMag * measuredMag + 0.001562 * measuredMag * measuredMag * measuredMag - 1.76;
            }

            return double.NaN;
        }
示例#16
0
        public static int GetColourByteOffset32bbp(TangraConfig.ColourChannel channel)
        {
            if (channel == TangraConfig.ColourChannel.GrayScale)
                // Special meaning
                return -1;

            // BGRT
            switch (channel)
            {
                case TangraConfig.ColourChannel.Red:
                    return 2;
                case TangraConfig.ColourChannel.Green:
                    return 1;
                case TangraConfig.ColourChannel.Blue:
                    return 0;
            }

            return 1;
        }
        public frmEditWavelengthConfigName(
			TangraConfig.PersistedConfiguration config,
			int frameWidth,
			int frameHeight)
        {
            InitializeComponent();

            m_FrameWidth = frameWidth;
            m_FrameHeight = frameHeight;

            if (config == null)
            {
                config = new TangraConfig.PersistedConfiguration { Width = frameWidth, Height = frameHeight };
                tbxConfigName.Enabled = true;
                m_New = true;
                Height = 260;
                pnlSolvedWavelengthConf.Visible = false;
                cbxEditConfig.Visible = false;
            }
            else
            {
                tbxConfigName.Enabled = false;
                m_OriginalName = config.Name;
                Height = 324;
                pnlSolvedWavelengthConf.Visible = true;
                cbxEditConfig.Visible = true;

                tbxSolvedA.Text = config.A.ToString();
                tbxSolvedB.Text = config.B.ToString();
                if (config.Order > 1)
                {
                    tbxSolvedC.Text = config.C.ToString();
                    if (config.Order > 2)
                        tbxSolvedD.Text = config.D.ToString();
                }
                nudConfigOrder.SetNUDValue(config.Order);
            }

            m_Config = config;
            tbxConfigName.Text = config.Name;
        }
示例#18
0
        public frmSpectraViewSettings(TangraConfig.SpectraViewDisplaySettings displaySettings, frmViewSpectra frmSpectraView)
        {
            InitializeComponent();

            m_frmSpectraView = frmSpectraView;
            m_DisplaySettings = displaySettings;

            m_DontApplySettingsBack = true;
            try
            {
                ucColorPickerReferenceStar.SelectedColor = m_DisplaySettings.SpectraLineColor;
                ucColorPickerKnownLine.SelectedColor = m_DisplaySettings.KnownLineColor;
                ucColorPickerGridLines.SelectedColor = m_DisplaySettings.GridLinesColor;
                ucColorPickerGridLegend.SelectedColor = m_DisplaySettings.LegendColor;
                ucColorPickerAperture.SelectedColor = m_DisplaySettings.SpectraApertureColor;
                ucColorPickerBackground.SelectedColor = m_DisplaySettings.PlotBackgroundColor;
            }
            finally
            {
                m_DontApplySettingsBack = false;
            }
        }
示例#19
0
        public static double ConvertMagnitude(double measuredMag, double vrColorIndex, Guid catalogMagBand, TangraConfig.MagOutputBand magOutputBand)
        {
            if (catalogMagBand == UCAC4Entry.BAND_ID_R && magOutputBand == TangraConfig.MagOutputBand.CousinsR) return measuredMag;
            if (catalogMagBand == UCAC4Entry.BAND_ID_R && magOutputBand == TangraConfig.MagOutputBand.JohnsonV) return ColourIndexTables.GetVFromRAndVR(measuredMag, vrColorIndex);

            if (catalogMagBand == UCAC4Entry.BAND_ID_V && magOutputBand == TangraConfig.MagOutputBand.CousinsR) return ColourIndexTables.GetRFromVAndVR(measuredMag, vrColorIndex);
            if (catalogMagBand == UCAC4Entry.BAND_ID_V && magOutputBand == TangraConfig.MagOutputBand.JohnsonV) return measuredMag;

            // V = r + 0.44 * (g - r) - 0.02
            // B = V + 1.04 * (g - r) + 0.19
            // R = V - 0.508 * (B - V) - 0.040   (0.3 < B - V < 0.9)

            // V - R = 0.508 * (B - V) + 0.040
            // B = V + ((V - R) - 0.040) / 0.508 = V + 1.04 * (g - r) + 0.19 => 1.04 * (g - r) = ((V - R) - 0.040) / 0.508 - 0.19 => (g - r) = (((V - R) - 0.040) / 0.508 - 0.19) / 1.04
            double grColorIndex = (((vrColorIndex) - 0.040) / 0.508 - 0.19) / 1.04;

            // R = r + 0.44 * (g - r) - 0.02 - 0.508 * (1.04 * (g - r) + 0.19) - 0.040 = r + (0.44 - 0.508 * 1.04)*(g-r) + (-0.060 - 0.19 * 0.508)
            if (catalogMagBand == UCAC4Entry.BAND_ID_SLOAN_r && magOutputBand == TangraConfig.MagOutputBand.CousinsR) return measuredMag + (0.44 - 0.508 * 1.04) * grColorIndex + (-0.060 - 0.19 * 0.508);
            // V = r + 0.44 * (g - r) - 0.02
            if (catalogMagBand == UCAC4Entry.BAND_ID_SLOAN_r && magOutputBand == TangraConfig.MagOutputBand.JohnsonV) return measuredMag + 0.44 * grColorIndex - 0.02;

            if (catalogMagBand == UCAC4Entry.BAND_ID_SLOAN_g && magOutputBand == TangraConfig.MagOutputBand.CousinsR)
                throw new NotImplementedException();

            // V = r + 0.44 * (g - r) - 0.02 = 0.44 * g + 0.56 * r - 0.02
            // B = V + 1.04 * g - 1.04 * r + 0.19 | *0.56 / 1.04 => 0.56 * (B - V) / 1.04 = 0.56 * g - 0.56 * r + 0.56 * 0.19 / 1.04
            // (1.04 * V + 0.56 * B - 0.56 * V) / 1.04 = g + 0.56 * 0.16/1.04 - 0.02 => 0.48 * V + 0.56 * B = 1.04 * g + 0.0688 => V = 2.17 * g - 1.17 * B + 0.14
            if (catalogMagBand == UCAC4Entry.BAND_ID_SLOAN_g && magOutputBand == TangraConfig.MagOutputBand.JohnsonV)
                throw new NotImplementedException();

            if (catalogMagBand == UCAC4Entry.BAND_ID_UNFILTERED)
            {
                double jk = ColourIndexTables.GetJKFromVR(vrColorIndex);
                if (magOutputBand == TangraConfig.MagOutputBand.CousinsR) return -0.295 * jk + 1.323 * measuredMag - 0.0377 * measuredMag * measuredMag + 0.001142 * measuredMag * measuredMag * measuredMag - 0.68;
                if (magOutputBand == TangraConfig.MagOutputBand.JohnsonV) return 0.552 * jk + 1.578 * measuredMag - 0.0560 * measuredMag * measuredMag + 0.001562 * measuredMag * measuredMag * measuredMag - 1.76;
            }

            return double.NaN;
        }
示例#20
0
        private void btnImport_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog(this) == DialogResult.OK)
            {
                try
                {
                    string xmlString = File.ReadAllText(openFileDialog1.FileName);
                    var    ser       = new XmlSerializer(typeof(TangraConfig));
                    using (TextReader rdr = new StringReader(xmlString))
                    {
                        TangraConfig loadedSettings = (TangraConfig)ser.Deserialize(rdr);
                        if (loadedSettings != null)
                        {
                            if (MessageBox.Show(
                                    this,
                                    "This will overwrite your Tangra settings. This process cannot be undone. Do you want to continue?",
                                    "Tangra", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                            {
                                Properties.Settings.Default.TangraSettings = xmlString;
                                Properties.Settings.Default.Save();

                                TangraConfig.Load(ApplicationSettingsSerializer.Instance);

                                MessageBox.Show(this, "Settings imported successfuly.", "Tangra", MessageBoxButtons.OK, MessageBoxIcon.Information);

                                Close();
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(this, "Cannot import Tangra settings: " + ex.Message, "Tangra", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
示例#21
0
        public StarMagnitudeFit(
			AstroImage astroImage,
			int bitPix,
			List<double> intencities,
			List<double> magnitudes,
			List<double> colours,
			List<IStar> starNumbers,
			List<PSFFit> psfGaussians,
			List<double> profileFittedAmplitudes,
			List<bool> saturatedFlags,
			double a, double b, double c, float encodingGamma, TangraConfig.KnownCameraResponse reverseCameraResponse, int excludedStars,
			TangraConfig.PreProcessingFilter filter, double empericalFWHM, 
			TangraConfig.PhotometryReductionMethod photometryReductionMethod, 
			TangraConfig.BackgroundMethod photometryBackgroundMethod,
			TangraConfig.PsfQuadrature psfQuadrature,
			TangraConfig.PsfFittingMethod psfFittingMethod,
            MeasurementsHelper measurer,
            float? aperture)
        {
            m_CurrentAstroImage = astroImage;
            m_BitPix = bitPix;
            m_Intencities = intencities;
            m_Magnitudes = magnitudes;
            m_Colours = colours;
            m_Residuals = new List<double>();
            m_StarNumbers = starNumbers;
            m_PSFGaussians = psfGaussians;
            m_EncodingGamma = encodingGamma;
            m_ReverseCameraResponse = reverseCameraResponse;
            m_ExcludedStars = excludedStars;
            m_SaturatedFlags = saturatedFlags;
            m_ProfileFittedAmplitudes = profileFittedAmplitudes;

            m_Sigma = 0;
            for (int i = 0; i < intencities.Count; i++)
            {
                double computed = a * -2.5 * Math.Log10(intencities[i]) + b * colours[i] + c;
                double diff = Math.Abs(computed - magnitudes[i]);
                m_Residuals.Add(diff);

                m_Sigma += diff*diff;
            }
            m_Sigma = Math.Sqrt(m_Sigma / (m_Residuals.Count - 1));

            m_Filter = filter;
            m_EmpericalFWHM = empericalFWHM;
            m_PhotometryReductionMethod = photometryReductionMethod;
            m_PhotometryBackgroundMethod = photometryBackgroundMethod;
            m_PsfQuadrature = psfQuadrature;
            m_PsfFittingMethod = psfFittingMethod;

            m_A = a;
            m_B = b;
            m_C = c;

            m_Measurer = measurer.Clone();
            m_MeasurementAperture = aperture;

            m_Sigma = 0;
            m_MinRes = double.MaxValue;
            m_MaxRes = double.MinValue;
            m_MinMag = double.MaxValue;
            m_MaxMag = double.MinValue;
            for (int i = 0; i < m_Residuals.Count; i++)
            {
                double res = m_Residuals[i];

                m_Sigma += res * res;
                if (m_MinRes > res) m_MinRes = res;
                if (m_MaxRes < res) m_MaxRes = res;

                double mag = m_Magnitudes[i];
                if (m_MinMag > mag) m_MinMag = mag;
                if (m_MaxMag < mag) m_MaxMag = mag;
            }

            m_Sigma = Math.Sqrt(m_Sigma / m_Residuals.Count);
        }
示例#22
0
        public static bool IsValidCatalogLocation(TangraConfig.StarCatalog catalog, ref string folderPath)
        {
            if (catalog == TangraConfig.StarCatalog.UCAC2)
                return UCAC2Catalogue.IsValidCatalogLocation(ref folderPath);
            else if (catalog == TangraConfig.StarCatalog.NOMAD)
                return NOMADCatalogue.IsValidCatalogLocation(ref folderPath);
            else if (catalog == TangraConfig.StarCatalog.UCAC3)
                return UCAC3Catalogue.IsValidCatalogLocation(ref folderPath);
            else if (catalog == TangraConfig.StarCatalog.PPMXL)
                return PPMXLCatalogue.IsValidCatalogLocation(ref folderPath);
            else if (catalog == TangraConfig.StarCatalog.UCAC4)
                return UCAC4Catalogue.IsValidCatalogLocation(ref folderPath);

            return false;
        }
示例#23
0
 object[] ICatalogValidator.MagnitudeBandsForCatalog(TangraConfig.StarCatalog catalog)
 {
     return MagnitudeBandsForCatalog(catalog);
 }
示例#24
0
 bool ICatalogValidator.VerifyCurrentCatalogue(TangraConfig.StarCatalog catalog, ref string path)
 {
     return VerifyCurrentCatalogue(catalog, ref path);
 }
示例#25
0
        public double ConvertMagnitude(double measuredMag, double vrColorIndex, Guid catalogMagBand, TangraConfig.MagOutputBand magOutputBand)
        {
            if (m_Settings.Catalog == TangraConfig.StarCatalog.UCAC2)
            {
                return UCAC2Catalogue.ConvertMagnitude(measuredMag, vrColorIndex, catalogMagBand, magOutputBand);
            }
            else if (m_Settings.Catalog == TangraConfig.StarCatalog.UCAC3)
            {
                return UCAC3Catalogue.ConvertMagnitude(measuredMag, vrColorIndex, catalogMagBand, magOutputBand);
            }
            else if (m_Settings.Catalog == TangraConfig.StarCatalog.NOMAD)
            {
                return NOMADCatalogue.ConvertMagnitude(measuredMag, vrColorIndex, catalogMagBand, magOutputBand);
            }
            else if (m_Settings.Catalog == TangraConfig.StarCatalog.PPMXL)
            {
                return PPMXLCatalogue.ConvertMagnitude(measuredMag, vrColorIndex, catalogMagBand, magOutputBand);
            }
            else if (m_Settings.Catalog == TangraConfig.StarCatalog.UCAC4)
            {
                return UCAC4Catalogue.ConvertMagnitude(measuredMag, vrColorIndex, catalogMagBand, magOutputBand);
            }

            return double.NaN;
        }
示例#26
0
 bool ICatalogValidator.IsValidCatalogLocation(TangraConfig.StarCatalog catalog, ref string folderPath)
 {
     return IsValidCatalogLocation(catalog, ref folderPath);
 }
示例#27
0
        public static object[] MagnitudeBandsForCatalog(TangraConfig.StarCatalog catalog)
        {
            if (catalog == TangraConfig.StarCatalog.UCAC2)
                return UCAC2Catalogue.CatalogMagnitudeBands;
            else if (catalog == TangraConfig.StarCatalog.NOMAD)
                return NOMADCatalogue.CatalogMagnitudeBands;
            else if (catalog == TangraConfig.StarCatalog.UCAC3)
                return UCAC3Catalogue.CatalogMagnitudeBands;
            else if (catalog == TangraConfig.StarCatalog.PPMXL)
                return PPMXLCatalogue.CatalogMagnitudeBands;
            else if (catalog == TangraConfig.StarCatalog.UCAC4)
                return UCAC4Catalogue.CatalogMagnitudeBands;

            return new object[] { };
        }
示例#28
0
        public static bool VerifyCurrentCatalogue(TangraConfig.StarCatalog catalog, ref string path)
        {
            if (catalog == TangraConfig.StarCatalog.UCAC2)
            {
                if (!UCAC2Catalogue.IsValidCatalogLocation(ref path))
                    return false;

                if (!UCAC2Catalogue.CheckAndWarnIfNoBSS(path, null))
                    return false;
            }
            else if (catalog == TangraConfig.StarCatalog.NOMAD)
            {
                if (!NOMADCatalogue.IsValidCatalogLocation(ref path))
                    return false;

                // TODO: Check index files??
            }
            else if (catalog == TangraConfig.StarCatalog.UCAC3)
            {
                if (!UCAC3Catalogue.IsValidCatalogLocation(ref path))
                    return false;

            }
            else if (catalog == TangraConfig.StarCatalog.PPMXL)
            {
                if (!PPMXLCatalogue.IsValidCatalogLocation(ref path))
                    return false;

            }
            else if (catalog == TangraConfig.StarCatalog.UCAC4)
            {
                if (!UCAC4Catalogue.IsValidCatalogLocation(ref path))
                    return false;

            }

            return true;
        }
示例#29
0
        public static StarMagnitudeFit PerformFit(
			IAstrometryController astrometryController,
			IVideoController videoController,
			int bitPix,
            uint maxSignalValue,
			FitInfo astrometricFit,
			TangraConfig.PhotometryReductionMethod photometryReductionMethod,
			TangraConfig.PsfQuadrature psfQuadrature,
			TangraConfig.PsfFittingMethod psfFittingMethod,
			TangraConfig.BackgroundMethod photometryBackgroundMethod,
			TangraConfig.PreProcessingFilter filter,
			List<IStar> catalogueStars,
            Guid magnitudeBandId,
			float encodingGamma,
			TangraConfig.KnownCameraResponse reverseCameraResponse,
			float? aperture,
			float? annulusInnerRadius,
			int? annulusMinPixels,
			ref float empericalPSFR0)
        {
            uint saturatedValue = TangraConfig.Settings.Photometry.Saturation.GetSaturationForBpp(bitPix, maxSignalValue);

            MeasurementsHelper measurer = new MeasurementsHelper(
                bitPix,
                photometryBackgroundMethod,
                TangraConfig.Settings.Photometry.SubPixelSquareSize,
                saturatedValue);

            measurer.SetCoreProperties(
                annulusInnerRadius ?? TangraConfig.Settings.Photometry.AnnulusInnerRadius,
                annulusMinPixels ?? TangraConfig.Settings.Photometry.AnnulusMinPixels,
                CorePhotometrySettings.Default.RejectionBackgroundPixelsStdDev,
                2 /* TODO: This must be configurable */);

            var bgProvider = new BackgroundProvider(videoController);
            measurer.GetImagePixelsCallback += new MeasurementsHelper.GetImagePixelsDelegate(bgProvider.measurer_GetImagePixelsCallback);

            List<double> intencities = new List<double>();
            List<double> magnitudes = new List<double>();
            List<double> colours = new List<double>();
            List<double> residuals = new List<double>();
            List<bool> saturatedFlags = new List<bool>();
            List<IStar> stars = new List<IStar>();
            List<PSFFit> gaussians = new List<PSFFit>();

            List<MagFitRecord> fitRecords = new List<MagFitRecord>();

            AstroImage currentAstroImage = videoController.GetCurrentAstroImage(false);
            Rectangle osdRectToExclude = astrometryController.OSDRectToExclude;
            Rectangle rectToInclude = astrometryController.RectToInclude;
            bool limitByInclusion = astrometryController.LimitByInclusion;

            int matSize = CorePhotometrySettings.Default.MatrixSizeForCalibratedPhotometry;

            double a = double.NaN;
            double b = double.NaN;
            double c = double.NaN;
            int excludedStars = 0;
            double empericalFWHM = double.NaN;

            try
            {
                foreach (PlateConstStarPair pair in astrometricFit.AllStarPairs)
                {
                    if (limitByInclusion && !rectToInclude.Contains((int)pair.x, (int)pair.y)) continue;
                    if (!limitByInclusion && osdRectToExclude.Contains((int)pair.x, (int)pair.y)) continue;

                    IStar star = catalogueStars.Find(s => s.StarNo == pair.StarNo);
                    if (star == null || double.IsNaN(star.Mag) || star.Mag == 0) continue;

                    uint[,] data = currentAstroImage.GetMeasurableAreaPixels((int)pair.x, (int)pair.y, matSize);

                    PSFFit fit = new PSFFit((int)pair.x, (int)pair.y);
                    fit.Fit(data, PSF_FIT_AREA_SIZE);
                    if (!fit.IsSolved) continue;

                    MagFitRecord record = new MagFitRecord();
                    record.Star = star;
                    record.Pair = pair;
                    record.PsfFit = fit;
                    record.Saturation = IsSaturated(data, matSize, saturatedValue);

                    if (!EXCLUDE_SATURATED_STARS || !record.Saturation)
                        fitRecords.Add(record);
                }

                // We need the average R0 if it hasn't been determined yet
                if (float.IsNaN(empericalPSFR0))
                {
                    empericalPSFR0 = 0;
                    foreach (MagFitRecord rec in fitRecords)
                    {
                        empericalPSFR0 += (float)rec.PsfFit.R0;
                    }
                    empericalPSFR0 /= fitRecords.Count;
                }

                empericalFWHM = 2 * Math.Sqrt(Math.Log(2)) * empericalPSFR0;

                foreach (MagFitRecord record in fitRecords)
                {
                    ImagePixel center = new ImagePixel(255, record.Pair.x, record.Pair.y);
                    int areaSize = filter == TangraConfig.PreProcessingFilter.NoFilter ? 17 : 19;

                    int centerX = (int)Math.Round(center.XDouble);
                    int centerY = (int)Math.Round(center.YDouble);

                    uint[,] data = currentAstroImage.GetMeasurableAreaPixels(centerX, centerY, areaSize);
                    uint[,] backgroundPixels = currentAstroImage.GetMeasurableAreaPixels(centerX, centerY, 35);

                    measurer.MeasureObject(
                        center,
                        data,
                        backgroundPixels,
                        currentAstroImage.Pixelmap.BitPixCamera,
                        filter,
                        photometryReductionMethod,
                        psfQuadrature,
                        psfFittingMethod,
                        aperture != null ? aperture.Value : (float)Aperture(record.PsfFit.FWHM),
                        record.PsfFit.FWHM,
                        (float)empericalFWHM,
                        new FakeIMeasuredObject(record.PsfFit),
                        null,
                        null,
                        false);

                    double intensity = measurer.TotalReading - measurer.TotalBackground;
                    if (intensity > 0)
                    {
                        var mag = record.Star.GetMagnitudeForBand(magnitudeBandId);
                        var clr = record.Star.MagJ - record.Star.MagK;

                        if (!double.IsNaN(mag) && !double.IsNaN(clr) && !double.IsInfinity(mag) && !double.IsInfinity(clr))
                        {
                            intencities.Add(intensity);
                            magnitudes.Add(record.Star.GetMagnitudeForBand(magnitudeBandId));
                            colours.Add(record.Star.MagJ - record.Star.MagK);

                            gaussians.Add(record.PsfFit);
                            stars.Add(record.Star);
                            saturatedFlags.Add(measurer.HasSaturatedPixels || record.PsfFit.IMax >= measurer.SaturationValue);
                        }
                    }
                }

                // Remove stars with unusual PSF fit radii (once only)
                double sum = 0;
                for (int i = 0; i < gaussians.Count; i++)
                {
                    sum += gaussians[i].R0;
                }
                double averageR = sum / gaussians.Count;

                residuals.Clear();
                sum = 0;
                for (int i = 0; i < gaussians.Count; i++)
                {
                    residuals.Add(averageR - gaussians[i].R0);
                    sum += (averageR - gaussians[i].R0) * (averageR - gaussians[i].R0);
                }
                double stdDev = Math.Sqrt(sum) / gaussians.Count;

                if (EXCLUDE_BAD_RESIDUALS)
                {
                    for (int i = residuals.Count - 1; i >= 0; i--)
                    {
                        if (Math.Abs(residuals[i]) > 6 * stdDev)
                        {
                            intencities.RemoveAt(i);
                            magnitudes.RemoveAt(i);
                            colours.RemoveAt(i);
                            stars.RemoveAt(i);
                            gaussians.RemoveAt(i);
                            saturatedFlags.RemoveAt(i);
                        }
                    }
                }

                double maxResidual = Math.Max(0.1, TangraConfig.Settings.Photometry.MaxResidualStellarMags);

                for (int itter = 1; itter <= MAX_ITERR; itter++)
                {
                    residuals.Clear();

                    SafeMatrix A = new SafeMatrix(intencities.Count, 3);
                    SafeMatrix X = new SafeMatrix(intencities.Count, 1);

                    int idx = 0;
                    for (int i = 0; i < intencities.Count; i++)
                    {
                        A[idx, 0] = magnitudes[i];
                        A[idx, 1] = colours[i];
                        A[idx, 2] = 1;

                        X[idx, 0] = -2.5 * Math.Log10(intencities[i]);

                        idx++;
                    }

                    SafeMatrix a_T = A.Transpose();
                    SafeMatrix aa = a_T * A;
                    SafeMatrix aa_inv = aa.Inverse();
                    SafeMatrix bx = (aa_inv * a_T) * X;

                    double Ka = bx[0, 0];
                    double Kb = bx[1, 0];
                    double Kc = bx[2, 0];

                    // -2.5 * a * Log(Median-Intensity) = A * Mv + B * Mjk + C - b
                    // -2.5 * Log(Median-Intensity) = Ka * Mv + Kb * Mjk + Kc
                    // Mv = -2.5 * a * Log(Median-Intensity) - b * Mjk - c
                    a = 1 / Ka;
                    b = -Kb / Ka;
                    c = -Kc / Ka;

                    int starsExcludedThisTime = 0;

                    if (EXCLUDE_BAD_RESIDUALS)
                    {
                        List<int> indexesToRemove = new List<int>();
                        for (int i = 0; i < intencities.Count; i++)
                        {
                            double computed = a * -2.5 * Math.Log10(intencities[i]) + b * colours[i] + c;

                            double diff = Math.Abs(computed - magnitudes[i]);
                            if (itter < MAX_ITERR)
                            {
                                if (Math.Abs(diff) > maxResidual)
                                {
                                    indexesToRemove.Add(i);
                                }
                            }
                            else
                                residuals.Add(diff);
                        }

                        for (int i = indexesToRemove.Count - 1; i >= 0; i--)
                        {
                            int idxToRemove = indexesToRemove[i];
                            intencities.RemoveAt(idxToRemove);
                            magnitudes.RemoveAt(idxToRemove);
                            colours.RemoveAt(idxToRemove);
                            stars.RemoveAt(idxToRemove);
                            gaussians.RemoveAt(idxToRemove);
                            saturatedFlags.RemoveAt(idxToRemove);

                            excludedStars++;
                            starsExcludedThisTime++;
                        }
                    }

                    if (starsExcludedThisTime == 0)
                        break;
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.ToString());
            }

            return new StarMagnitudeFit(
                currentAstroImage,
                bitPix,
                intencities, magnitudes, colours, stars, gaussians, new List<double>(),
                saturatedFlags, a, b, c, encodingGamma, reverseCameraResponse, excludedStars, filter, empericalFWHM,
                photometryReductionMethod, photometryBackgroundMethod, psfQuadrature, psfFittingMethod, measurer, aperture);
        }
示例#30
0
 public static void AddDigitalFilter(TangraConfig.PreProcessingFilter filter)
 {
     PreProcessingAddDigitalFilter((int)filter);
 }
示例#31
0
 public static void AddCameraResponseCorrection(TangraConfig.KnownCameraResponse cameraResponse, int[] responseParams)
 {
     PreProcessingAddCameraResponseCorrection((int)cameraResponse, responseParams);
 }
        public void SetComboboxIndexFromPhotometryReductionMethod(TangraConfig.PhotometryReductionMethod method)
        {
            switch (method)
            {
                case TangraConfig.PhotometryReductionMethod.AperturePhotometry:
                    cbxReductionType.SelectedIndex = 0;
                    break;

                case TangraConfig.PhotometryReductionMethod.PsfPhotometry:
                    cbxReductionType.SelectedIndex = 1;
                    break;

                case TangraConfig.PhotometryReductionMethod.OptimalExtraction:
                    cbxReductionType.SelectedIndex = 2;
                    break;
            }
        }
        public void SetComboboxIndexFromBackgroundMethod(TangraConfig.BackgroundMethod method)
        {
            switch (method)
            {
                case TangraConfig.BackgroundMethod.AverageBackground:
                    cbxBackgroundMethod.SelectedIndex = 0;
                    break;

                case TangraConfig.BackgroundMethod.BackgroundMode:
                    cbxBackgroundMethod.SelectedIndex = 1;
                    break;

                case TangraConfig.BackgroundMethod.PSFBackground:
                    cbxBackgroundMethod.SelectedIndex = 2;
                    break;

                case TangraConfig.BackgroundMethod.BackgroundMedian:
                    cbxBackgroundMethod.SelectedIndex = 3;
                    break;
            }
        }