コード例 #1
0
ファイル: frmSetReferenceMag.cs プロジェクト: hpavlov/tangra3
        internal void SetCurrentMeasurements(LCMeasurement[] measurements, LightCurveContext context, int occultedStarIndex)
        {
            m_Context = context;
            m_OccultedStarIndex = occultedStarIndex;

            m_AllTargetColors = new Color[]
            {
                TangraConfig.Settings.Color.Target1,
                TangraConfig.Settings.Color.Target2,
                TangraConfig.Settings.Color.Target3,
                TangraConfig.Settings.Color.Target4
            };

            pb1.BackColor = m_AllTargetColors[0];
            pb2.BackColor = m_AllTargetColors[1];
            pb3.BackColor = m_AllTargetColors[2];
            pb4.BackColor = m_AllTargetColors[3];

            pnl1.Visible = false;
            pnl2.Visible = false;
            pnl3.Visible = false;
            pnl4.Visible = false;

            if (measurements == null || measurements.Length == 0)
            {
                int numFramesMedian = Math.Min(context.AllReadings[1].Count, TangraConfig.Settings.Photometry.SNFrameWindow);

                // If there is current selection then use the first reading from the LC file
                m_Intensities = new int[context.ObjectCount];
                m_Intensities[0] = context.AllReadings[0].Take(numFramesMedian).Select(x => x.AdjustedReading).ToList().Median();
                if (context.ObjectCount > 1) m_Intensities[1] = context.AllReadings[1].Take(numFramesMedian).Select(x => x.AdjustedReading).ToList().Median();
                if (context.ObjectCount > 2) m_Intensities[2] = context.AllReadings[2].Take(numFramesMedian).Select(x => x.AdjustedReading).ToList().Median();
                if (context.ObjectCount > 3) m_Intensities[3] = context.AllReadings[3].Take(numFramesMedian).Select(x => x.AdjustedReading).ToList().Median();
            }
        }
コード例 #2
0
        internal void SetLcFile(LCFile lcFile)
        {
            m_lcFile  = lcFile;
            m_Context = new LightCurveContext(lcFile);

            m_LightCurveForm.SetNewLcFile(lcFile);

            m_LightCurveForm.SetGeoLocation(m_VideoController.GeoLocation);
        }
コード例 #3
0
ファイル: frmPSFFits.cs プロジェクト: hpavlov/tangra3
        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};
        }
コード例 #4
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 };
        }
コード例 #5
0
        internal frmConfigureReprocessing(
            LCMeasurementHeader header,
			LCMeasurementFooter footer, 
            LightCurveContext context,
            Color[] allColors,
            Brush[] allBrushes,
            Pen[] allPens)
        {
            InitializeComponent();

            m_Context = context;
            m_Header = header;
            m_Footer = footer;
            m_AllColors = allColors;
            m_AllBrushes = allBrushes;
            m_AllPens = allPens;

            SetComboboxIndexFromBackgroundMethod(m_Context.BackgroundMethod);
            SetComboboxIndexFromPhotometryReductionMethod(m_Context.SignalMethod);
            SetComboboxIndexFromPsfQuadratureMethod(m_Context.PsfQuadratureMethod);
            cbxDigitalFilter.SelectedIndex = (int)m_Context.Filter;
            nudGamma.Value = (decimal)m_Context.EncodingGamma;
            cbxKnownResponse.SetCBXIndex((int)m_Context.ReverseCameraResponse);

            int maxApertureSize = m_Footer.ReductionContext.GetMaxApertureSize();

            nudAperture1.Maximum = maxApertureSize;
            nudAperture2.Maximum = maxApertureSize;
            nudAperture3.Maximum = maxApertureSize;
            nudAperture4.Maximum = maxApertureSize;

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

            if (TangraContext.Current.CanProcessLightCurvePixels)
                SetupControls();
        }
コード例 #6
0
        internal void SetLcFile(LCFile lcFile)
        {
            m_lcFile = lcFile;
            m_Context = new LightCurveContext(lcFile);

            m_LightCurveForm.SetNewLcFile(lcFile);

            m_LightCurveForm.SetGeoLocation(m_VideoController.GeoLocation);
        }
コード例 #7
0
 internal void ClearContext()
 {
     m_Context = null;
 }
コード例 #8
0
        public void OpenLcFile(string fileName)
        {
            var fi = new FileInfo(fileName);
            double expectedMemoryMbNeeded = 500 /* For Tangra to operate*/ + 20*fi.Length/(1024*1024) /* For the .lc file to be unpacked and loaded in memory */;

            double availableMemoryMb = CrossPlaform.GetAvailableMemoryInMegabytes();

            if (expectedMemoryMbNeeded > availableMemoryMb)
            {
                if (MessageBox.Show(
                    m_MainFormView,
                    string.Format("It appears that you may be running in a low memory conditions and opening this file will require at least {0}Gb of free memory. Do you wish to continue?", (Math.Ceiling(expectedMemoryMbNeeded/512.0)/2).ToString("0.0")),
                    "Warning",
                    MessageBoxButtons.YesNo,
                    MessageBoxIcon.Warning) == DialogResult.No)
                {
                    return;
                }
            }

            m_MainFormView.Cursor = Cursors.WaitCursor;
            LCFile lcFile = null;
            try
            {
                m_MainFormView.Update();

                lcFile = LCFile.Load(fileName, m_VideoController);
                if (lcFile != null)
                {
                    ReduceLightCurveOperation operation = (ReduceLightCurveOperation)m_VideoController.SetOperation<ReduceLightCurveOperation>(this, false);
                    operation.SetLCFile(lcFile);

                    string videoFile = GetVideoFileMatchingLcFile(lcFile, fileName);
                    if (!string.IsNullOrEmpty(videoFile) &&
                        File.Exists(videoFile))
                    {
                        if (m_VideoController.OpenVideoFile(videoFile, new TangraOpenFileArgs { FrameRate = lcFile.Header.FramesPerSecond, BitPix = lcFile.Footer.DataBitPix, SerTiming = lcFile.Header.SerTimingType }))
                        {
                            TangraContext.Current.CanPlayVideo = false;
                            m_VideoController.UpdateViews();
                        }
                    }
                    else
                    {
                        // NOTE: No video file found, just show the saved averaged frame
                        bool oldCanProcessLightCurvePixels = TangraContext.Current.CanProcessLightCurvePixels;
                        TangraContext.Current.Reset();
                        TangraContext.Current.CanProcessLightCurvePixels = oldCanProcessLightCurvePixels;

                        if (lcFile.Footer.AveragedFrameBytes != null)
                        {
                            if (m_VideoController.SingleBitmapFile(lcFile))
                            {
                                TangraContext.Current.CanPlayVideo = false;
                                m_VideoController.UpdateViews();

                                PSFFit.SetDataRange(lcFile.Footer.DataBitPix, lcFile.Footer.DataAav16NormVal);
                            }
                        }

                        TangraContext.Current.CanPlayVideo = false;
                        TangraContext.Current.CanScrollFrames = false;
                        m_VideoController.UpdateViews();
                    }

                    m_Context = new LightCurveContext(lcFile);
                    m_LightCurveForm = new frmLightCurve(this, m_AddinsController, lcFile, fileName);
                    m_LightCurveForm.SetGeoLocation(m_VideoController.GeoLocation);
                    m_LightCurveForm.Show(m_MainFormView);
                    m_LightCurveForm.Update();

                    // TODO: Review the VideoController-LightCurveController-ReduceLightCurveOperation relation and how they are initialized
                    // TODO: Provide a clean way of initializing the controller/operation state when opening an .lc file!
                    operation.EnterViewLightCurveMode(lcFile, m_VideoController, m_VideoController.ControlerPanel);

                    RegisterRecentFile(RecentFileType.LightCurve, fileName);

                    if (!string.IsNullOrEmpty(m_VideoController.CurrentVideoFileType))
                    {
                        // Move to the first frame in the light curve
                        m_VideoController.MoveToFrame((int) lcFile.Header.MinFrame);
                    }

                    TangraContext.Current.FileName = Path.GetFileName(fileName);
                    TangraContext.Current.FileFormat = m_lcFile.Header.SourceInfo;
                    m_VideoController.UpdateViews();
                }
            }
            catch (IOException ioex)
            {
                MessageBox.Show(ioex.Message, "Tangra", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                m_MainFormView.Cursor = Cursors.Default;
            }
        }
コード例 #9
0
 internal void ClearContext()
 {
     m_Context = null;
 }
コード例 #10
0
        public void OpenLcFile(string fileName)
        {
            var    fi = new FileInfo(fileName);
            double expectedMemoryMbNeeded = 500 /* For Tangra to operate*/ + 20 * fi.Length / (1024 * 1024) /* For the .lc file to be unpacked and loaded in memory */;

            double availableMemoryMb = CrossPlaform.GetAvailableMemoryInMegabytes();

            if (expectedMemoryMbNeeded > availableMemoryMb)
            {
                if (MessageBox.Show(
                        m_MainFormView,
                        string.Format("It appears that you may be running in a low memory conditions and opening this file will require at least {0}Gb of free memory. Do you wish to continue?", (Math.Ceiling(expectedMemoryMbNeeded / 512.0) / 2).ToString("0.0")),
                        "Warning",
                        MessageBoxButtons.YesNo,
                        MessageBoxIcon.Warning) == DialogResult.No)
                {
                    return;
                }
            }

            m_MainFormView.Cursor = Cursors.WaitCursor;
            LCFile lcFile = null;

            try
            {
                m_MainFormView.Update();

                lcFile = LCFile.Load(fileName, m_VideoController);
                if (lcFile != null)
                {
                    ReduceLightCurveOperation operation = (ReduceLightCurveOperation)m_VideoController.SetOperation <ReduceLightCurveOperation>(this, false);
                    operation.SetLCFile(lcFile);

                    bool flipVertically;
                    bool flipHorizontally;
                    FramePlayer.TranslateFlipRotate(lcFile.Footer.RotateFlipType, out flipVertically, out flipHorizontally);

                    object videoFile = GetVideoFileMatchingLcFile(lcFile, fileName);
                    if (videoFile is string &&
                        !string.IsNullOrEmpty((string)videoFile) &&
                        File.Exists((string)videoFile))
                    {
                        if (m_VideoController.OpenVideoFile((string)videoFile, new TangraOpenFileArgs {
                            FrameRate = lcFile.Header.FramesPerSecond, BitPix = lcFile.Footer.DataBitPix, SerTiming = lcFile.Header.SerTimingType
                        }))
                        {
                            TangraContext.Current.CanPlayVideo = false;
                            m_VideoController.UpdateViews();
                        }
                    }
                    else if (videoFile is string[] &&
                             ((string[])videoFile).Length > 0)
                    {
                        var fitsFiles = (string[])videoFile;
                        if (m_VideoController.OpenFitsFileSequence(Path.GetDirectoryName(fitsFiles[0]), fitsFiles, new LCFITSTimeStampReader(lcFile), null, 0, flipVertically, flipHorizontally, (int)lcFile.Data[0][0].CurrFrameNo))
                        {
                            TangraContext.Current.CanPlayVideo = false;
                            if (lcFile.Footer.FitsDynamicFromValue != -1 && lcFile.Footer.FitsDynamicToValue != -1)
                            {
                                m_VideoController.SetDisplayIntensifyMode(DisplayIntensifyMode.Dynamic, lcFile.Footer.FitsDynamicFromValue, lcFile.Footer.FitsDynamicToValue);
                            }

                            m_VideoController.UpdateViews();
                        }
                    }
                    else
                    {
                        // NOTE: No video file found, just show the saved averaged frame
                        bool oldCanProcessLightCurvePixels = TangraContext.Current.CanProcessLightCurvePixels;
                        TangraContext.Current.Reset();
                        TangraContext.Current.CanProcessLightCurvePixels = oldCanProcessLightCurvePixels;

                        if (lcFile.Footer.AveragedFrameBytes != null)
                        {
                            if (m_VideoController.SingleBitmapFile(lcFile))
                            {
                                TangraContext.Current.CanPlayVideo = false;
                                m_VideoController.UpdateViews();

                                PSFFit.SetDataRange(lcFile.Footer.DataBitPix, lcFile.Footer.DataAav16NormVal);
                            }
                        }

                        TangraContext.Current.CanPlayVideo    = false;
                        TangraContext.Current.CanScrollFrames = false;
                        m_VideoController.UpdateViews();
                    }

                    m_Context        = new LightCurveContext(lcFile);
                    m_LightCurveForm = new frmLightCurve(this, m_AddinsController, lcFile, fileName);
                    m_LightCurveForm.SetGeoLocation(m_VideoController.GeoLocation);
                    m_LightCurveForm.Show(m_MainFormView);
                    m_LightCurveForm.Update();

                    // TODO: Review the VideoController-LightCurveController-ReduceLightCurveOperation relation and how they are initialized
                    // TODO: Provide a clean way of initializing the controller/operation state when opening an .lc file!
                    operation.EnterViewLightCurveMode(lcFile, m_VideoController, m_VideoController.ControlerPanel);

                    RegisterRecentFile(RecentFileType.LightCurve, fileName);

                    if (!string.IsNullOrEmpty(m_VideoController.CurrentVideoFileType))
                    {
                        // Move to the first frame in the light curve
                        m_VideoController.MoveToFrame((int)lcFile.Header.MinFrame);
                    }

                    TangraContext.Current.FileName   = Path.GetFileName(fileName);
                    TangraContext.Current.FileFormat = m_lcFile.Header.SourceInfo;
                    m_VideoController.UpdateViews();
                }
            }
            catch (IOException ioex)
            {
                MessageBox.Show(ioex.Message, "Tangra", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                m_MainFormView.Cursor = Cursors.Default;
            }
        }
コード例 #11
0
ファイル: frmZoomedPixels.cs プロジェクト: hpavlov/tangra3
        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;
                }
            }
        }