private void IncludeInputFile(AbsFluxInputFile inputFile) { var spectra = new AbsFluxSpectra(inputFile); if (!spectra.IsComplete) { var frm = new frmCompleteSpectra(spectra); if (frm.ShowDialog(this) == DialogResult.Cancel) { return; } } if (spectra.IsComplete) { m_AbsFluxCalibrator.AddSpectra(spectra); lbIncludedSpecta.Items.Add(spectra); lbAvailableFiles.Items.Remove(inputFile); lbIncludedSpecta.ItemCheck -= lbIncludedSpecta_ItemCheck; try { lbIncludedSpecta.SetItemChecked(lbIncludedSpecta.Items.IndexOf(spectra), true); } finally { lbIncludedSpecta.ItemCheck += lbIncludedSpecta_ItemCheck; } PlotCalibration(); } }
internal AbsFluxSpectra(AbsFluxInputFile inputFile) { InputFile = inputFile; IsComplete = false; if (!string.IsNullOrEmpty(inputFile.Target)) { // First try to read the target from the export m_DisplayName = inputFile.Target; m_ExtractedStarName = null; } else { // Then try to parse the star from the file Match match = STAR_DESIGNATION_REGEX.Match(inputFile.FileName); if (match.Success && !string.IsNullOrEmpty(match.Value)) { m_ExtractedStarName = match.Value.Replace('_', ' ').Replace(" ", " ").Trim(); m_DisplayName = m_ExtractedStarName; } } HasObjectCoordinates = !float.IsNaN(inputFile.Latitude) && !float.IsNaN(inputFile.Longitude) && !float.IsNaN(inputFile.RAHours) && !float.IsNaN(inputFile.DEDeg); HasObservationTime = inputFile.Epoch != DateTime.MinValue; if (HasObservationTime && HasObjectCoordinates) { // If we have the center of the field saved in the export then identify the standard star by the position List <CalSpecStar> standardsInOneDegreeRadius = CalSpecDatabase.Instance.Stars.Where(x => AngleUtility.Elongation(x.RA_J2000_Hours * 15, x.DE_J2000_Deg, InputFile.RAHours * 15, InputFile.DEDeg) < 1).ToList(); if (standardsInOneDegreeRadius.Count == 1) { m_CalSpecStar = standardsInOneDegreeRadius[0]; m_DisplayName = m_CalSpecStar.AbsFluxStarId; IsComplete = true; PlotSpectra = true; } } if (inputFile.Epoch > DateTime.MinValue) { m_DisplayName += string.Format(" ({0} UT)", inputFile.Epoch.ToString("HH:mm")); } if (string.IsNullOrEmpty(m_DisplayName)) { m_DisplayName = Path.GetFileNameWithoutExtension(inputFile.FileName); } DataFromWavelength = (int)Math.Ceiling(inputFile.Wavelengths[0]); DataFromWavelength = (int)Math.Floor(inputFile.Wavelengths[inputFile.Wavelengths.Count - 1]); }
internal AbsFluxSpectra(AbsFluxInputFile inputFile) { InputFile = inputFile; IsComplete = false; if (!string.IsNullOrEmpty(inputFile.Target)) { // First try to read the target from the export m_DisplayName = inputFile.Target; m_ExtractedStarName = null; } else { // Then try to parse the star from the file Match match = STAR_DESIGNATION_REGEX.Match(inputFile.FileName); if (match.Success && !string.IsNullOrEmpty(match.Value)) { m_ExtractedStarName = match.Value.Replace('_', ' ').Replace(" ", " ").Trim(); m_DisplayName = m_ExtractedStarName; } } HasObjectCoordinates = !float.IsNaN(inputFile.Latitude) && !float.IsNaN(inputFile.Longitude) && !float.IsNaN(inputFile.RAHours) && !float.IsNaN(inputFile.DEDeg); HasObservationTime = inputFile.Epoch != DateTime.MinValue; if (HasObservationTime && HasObjectCoordinates) { // If we have the center of the field saved in the export then identify the standard star by the position List<CalSpecStar> standardsInOneDegreeRadius = CalSpecDatabase.Instance.Stars.Where(x => AngleUtility.Elongation(x.RA_J2000_Hours * 15, x.DE_J2000_Deg, InputFile.RAHours * 15, InputFile.DEDeg) < 1).ToList(); if (standardsInOneDegreeRadius.Count == 1) { m_CalSpecStar = standardsInOneDegreeRadius[0]; m_DisplayName = m_CalSpecStar.AbsFluxStarId; IsComplete = true; PlotSpectra = true; } } if (inputFile.Epoch > DateTime.MinValue) m_DisplayName += string.Format(" ({0} UT)", inputFile.Epoch.ToString("HH:mm")); if (string.IsNullOrEmpty(m_DisplayName)) m_DisplayName = Path.GetFileNameWithoutExtension(inputFile.FileName); DataFromWavelength = (int)Math.Ceiling(inputFile.Wavelengths[0]); DataFromWavelength = (int)Math.Floor(inputFile.Wavelengths[inputFile.Wavelengths.Count - 1]); }
private void btnBrowseFiles_Click(object sender, EventArgs e) { if (openFileDialog.ShowDialog(this) == DialogResult.OK) { string fileExt = Path.GetExtension(openFileDialog.FileName); if (!AbsFluxInputFile.IsFileTypeSupported(fileExt)) { MessageBox.Show( string.Format("{0} files are not supported.", fileExt), "Tangra", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string filePath = Path.GetDirectoryName(openFileDialog.FileName); if (filePath != null && Directory.Exists(filePath)) { int addedFiles = 0; string[] files1 = Directory.GetFiles(filePath, "*.dat"); lbAvailableFiles.Tag = filePath; lbAvailableFiles.Items.Clear(); Cursor = Cursors.WaitCursor; try { foreach (string fileName in files1) { var inputFile = new AbsFluxInputFile(fileName); if (inputFile.ContainsWavelengthData) { lbAvailableFiles.Items.Add(inputFile); addedFiles++; } } } finally { Cursor = Cursors.Default; } if (fileExt != null && !".dat".Equals(fileExt, StringComparison.InvariantCultureIgnoreCase)) { files1 = Directory.GetFiles(filePath, string.Format("*.{0}", fileExt.TrimStart('.'))); foreach (string fileName in files1) { var wrapper = new AbsFluxInputFile(fileName); if (wrapper.ContainsWavelengthData) { lbAvailableFiles.Items.Add(wrapper); addedFiles++; } } } if (addedFiles > 0) { m_NewlyOpened = false; UpdateUIState(); } else { MessageBox.Show("None of the files in the selected location contain wavelength calibrated data.", "Tangra", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
private void btnBrowseFiles_Click(object sender, EventArgs e) { if (openFileDialog.ShowDialog(this) == DialogResult.OK) { string fileExt = Path.GetExtension(openFileDialog.FileName); if (!AbsFluxInputFile.IsFileTypeSupported(fileExt)) { MessageBox.Show( string.Format("{0} files are not supported.", fileExt), "Tangra", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string filePath = Path.GetDirectoryName(openFileDialog.FileName); if (filePath != null && Directory.Exists(filePath)) { int addedFiles = 0; string[] files1 = Directory.GetFiles(filePath, "*.dat"); lbAvailableFiles.Tag = filePath; lbAvailableFiles.Items.Clear(); Cursor = Cursors.WaitCursor; try { foreach (string fileName in files1) { var inputFile = new AbsFluxInputFile(fileName); if (inputFile.ContainsWavelengthData) { lbAvailableFiles.Items.Add(inputFile); addedFiles++; } } } finally { Cursor = Cursors.Default; } if (fileExt != null && !".dat".Equals(fileExt, StringComparison.InvariantCultureIgnoreCase)) { files1 = Directory.GetFiles(filePath, string.Format("*.{0}", fileExt.TrimStart('.'))); foreach (string fileName in files1) { var wrapper = new AbsFluxInputFile(fileName); if (wrapper.ContainsWavelengthData) { lbAvailableFiles.Items.Add(wrapper); addedFiles++; } } } if (addedFiles > 0) { m_NewlyOpened = false; UpdateUIState(); } else MessageBox.Show("None of the files in the selected location contain wavelength calibrated data.", "Tangra", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void IncludeInputFile(AbsFluxInputFile inputFile) { var spectra = new AbsFluxSpectra(inputFile); if (!spectra.IsComplete) { var frm = new frmCompleteSpectra(spectra); if (frm.ShowDialog(this) == DialogResult.Cancel) return; } if (spectra.IsComplete) { m_AbsFluxCalibrator.AddSpectra(spectra); lbIncludedSpecta.Items.Add(spectra); lbAvailableFiles.Items.Remove(inputFile); lbIncludedSpecta.ItemCheck -= lbIncludedSpecta_ItemCheck; try { lbIncludedSpecta.SetItemChecked(lbIncludedSpecta.Items.IndexOf(spectra), true); } finally { lbIncludedSpecta.ItemCheck += lbIncludedSpecta_ItemCheck; } PlotCalibration(); } }