Exemplo n.º 1
0
        private void SaveDarkFrame(ModelConfig modelConfig, float[,] averagedFrame)
        {
            string fileName = null;

            if (m_VideoController.ShowSaveFileDialog(
                    "Save Simulated Dark fame",
                    "FITS Image (*.fit)|*.fit",
                    ref fileName, this) == DialogResult.OK)
            {
                MakeDarkFlatOperation.SaveDarkOrFlatFrame(fileName, modelConfig.FrameWidth, modelConfig.FrameHeight, string.Format("Simulated dark frame from Mean {0} +/- 1", modelConfig.DarkFrameMean), averagedFrame, 0, modelConfig.TotalFrames);
            }
        }
Exemplo n.º 2
0
        public void NextFrame(int frameNo, MovementType movementType, bool isLastFrame, AstroImage astroImage, int firstFrameInIntegrationPeriod, string frameFileName)
        {
            m_CurrentAstroImage = astroImage;
            m_FrameNumber       = frameNo;
            TangraContext.Current.CrashReportInfo.FrameNumber = frameNo;

            if (m_Running)
            {
                if (m_FramesDone < m_NumFrames)
                {
                    Pixelmap currPixelmap = astroImage.Pixelmap;
                    if (m_FramesDone == 0)
                    {
                        m_AveragedData = new float[currPixelmap.Width, currPixelmap.Height];
                    }

                    for (int x = 0; x < currPixelmap.Width; x++)
                    {
                        for (int y = 0; y < currPixelmap.Height; y++)
                        {
                            m_AveragedData[x, y] += currPixelmap[x, y];
                        }
                    }

                    m_FramesDone++;
                    m_ControlPanel.SetProgress(m_FramesDone);

                    if (m_FramesDone == m_NumFrames)
                    {
                        // Averaging
                        for (int x = 0; x < currPixelmap.Width; x++)
                        {
                            for (int y = 0; y < currPixelmap.Height; y++)
                            {
                                m_AveragedData[x, y] = (m_AveragedData[x, y] / (ulong)m_FramesDone);
                            }
                        }

                        m_ControlPanel.SetStopped();

                        string fileName = string.Format("{0}_{1}.fit", Path.GetFileNameWithoutExtension(m_VideoController.CurrentVideoFileName), m_FrameType.ToString());

                        if (m_VideoController.ShowSaveFileDialog(
                                "Save " + m_FrameType.ToString() + " fame",
                                "FITS Image (*.fit)|*.fit",
                                ref fileName) == DialogResult.OK)
                        {
                            string notes = string.Format("{0} generated from {1}", m_FrameType.ToString(), Path.GetFileNameWithoutExtension(m_VideoController.CurrentVideoFileName));

                            SaveDarkOrFlatFrame(fileName, currPixelmap.Width, currPixelmap.Height, notes, m_AveragedData, m_ExposureSeconds, m_NumFrames);
                        }

                        m_Running = false;
                        m_VideoController.StopVideo();

                        if (m_FrameType == FrameType.Dark)
                        {
                            UsageStats.Instance.DarkFramesProduced++;
                        }
                        if (m_FrameType == FrameType.MasterFlat)
                        {
                            UsageStats.Instance.FlatFramesProduced++;
                        }

                        UsageStats.Instance.Save();
                    }
                }
            }
        }