public RovingObsLocation GetRovingObsLocation() { if (m_CurrentDataFileRovingObsLocation != null && m_CurrentDataFileRovingObsLocation.IsValid) { return(m_CurrentDataFileRovingObsLocation); } var frmRovObsLoc = new frmRovingObsLocation(); if (frmRovObsLoc.ShowDialog(m_ParentWindow) == DialogResult.OK) { var obsLoc = frmRovObsLoc.ObservatoryLocation; if (obsLoc != null && obsLoc.IsValid) { m_CurrentDataFileRovingObsLocation = obsLoc; } return(obsLoc); } return(new RovingObsLocation() { IsValid = false }); }
public MPCReportFile(string fileName, MPCObsHeader header, Func <RovingObsLocation> rovingObsLocationProvider) { ReportFileName = fileName; Header = header; if (header.COD == MPCObsLine.ROVING_OBS_CODE) { RovingObservatoryLocation = rovingObsLocationProvider(); } }
public MPCReportFile(string fileName, Func <RovingObsLocation> rovingObsLocationProvider) { ReportFileName = fileName; string[] allLines = File.ReadAllLines(fileName); Header = new MPCObsHeader(allLines); if (Header.COD == MPCObsLine.ROVING_OBS_CODE) { RovingObservatoryLocation = rovingObsLocationProvider(); } ObsLines.Clear(); int strippedLines = 0; foreach (string line in allLines) { if (line.Length > 3 && (ObsLines.Count > 0 || HEADER_TOKENS.IndexOf(line.Substring(0, 3)) == -1)) { // Parse observation line MPCObsLine obsLine = MPCObsLine.Parse(line); if (obsLine != null) { ObsLines.Add(obsLine); } else { strippedLines++; } } } if (strippedLines > 0) { MessageBox.Show(string.Format("{0} lines could not be parsed are have been stripped from the file.", strippedLines), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
internal string GetReport(string obsCode, string designation, DateTime obsDate, double normalTime, RovingObsLocation rovingLocation) { MPCObsLine obsLine = new MPCObsLine(obsCode.PadLeft(3).Substring(0, 3)); obsLine.SetObject(MPCObsLine.GetObjectCode(designation) ?? " "); if (m_RegressionRA != null && m_RegressionDE != null) { DateTime mpcTime = obsDate.Date.AddDays(normalTime); double errRA, errDE; double mpcRAHours = m_RegressionRA.ComputeYWithError(normalTime, out errRA, m_ErrorMethod) / 15.0; double mpcDEDeg = m_RegressionDE.ComputeYWithError(normalTime, out errDE, m_ErrorMethod); var errRACosDE = errRA * Math.Cos(mpcDEDeg * Math.PI / 180) * 3600; errDE *= 3600; if (m_PosUncertaintyMedArcSec.HasValue) { errRACosDE = Math.Sqrt(errRACosDE * errRACosDE + m_PosUncertaintyMedArcSec.Value * m_PosUncertaintyMedArcSec.Value); errDE = Math.Sqrt(errDE * errDE + m_PosUncertaintyMedArcSec.Value * m_PosUncertaintyMedArcSec.Value); } if (errRACosDE < m_SmallestReportedUncertaintyArcSec) { errRACosDE = m_SmallestReportedUncertaintyArcSec; } if (errDE < m_SmallestReportedUncertaintyArcSec) { errDE = m_SmallestReportedUncertaintyArcSec; } var mag = m_Entries.Select(x => x.Mag).ToList().Median(); obsLine.SetPosition(mpcRAHours, mpcDEDeg, mpcTime, true, TangraConfig.Settings.Astrometry.ExportHigherPositionAccuracy); obsLine.SetMagnitude(mag, MagnitudeBand.Cousins_R); if (TangraConfig.Settings.Astrometry.ExportUncertainties) { obsLine.SetUncertainty(errRACosDE, errDE); } if (rovingLocation != null) { if (!rovingLocation.IsValid) { return(string.Empty); } else { var line1 = obsLine.BuildRovingObserverLine1(); var line2 = obsLine.BuildRovingObserverLine2(rovingLocation); return(line1 + "\r\n" + line2); } } else { return(obsLine.BuildObservationASCIILine()); } } return(null); }
internal string GetMidPointReport(string obsCode, string designation, DateTime obsDate, RovingObsLocation rovingLocation) { double closestTimeOfDay = GetMidPointDelayCorrectedTimeOfDay(); var normalTime = double.Parse(closestTimeOfDay.ToString("0.000000")); if (double.IsNaN(normalTime) || double.IsInfinity(normalTime)) { return(null); } return(GetReport(obsCode, designation, obsDate, normalTime, rovingLocation)); }
public void ResetCurrentObcLocation() { m_CurrentDataFileRovingObsLocation = null; }