Пример #1
0
        private string GenerateProgramVersionAndAgencyInfo(RinexType version)
        {
            // program, agency, date of generation
            string fileCreationDate = "";

            switch (version)
            {
            case RinexType.Version3:
                fileCreationDate = DateTime.UtcNow.ToString("yyyyMMdd HHmmss") + " UTC";
                break;

            case RinexType.Version2:
            case RinexType.Bipm:
            case RinexType.Cctf:
                fileCreationDate = DateTime.UtcNow.ToString("dd-MMM-yy HH:mm", CultureInfo.InvariantCulture).ToUpper();
                break;

            case RinexType.Unknown:
                break;
            }

            return(string.Format("{0}{1}{2}PGM / RUN BY / DATE",
                                 RinexTools.Consolidate(ProgramName),
                                 RinexTools.Consolidate(AgencyName),
                                 RinexTools.Consolidate(fileCreationDate)
                                 ));
        }
Пример #2
0
        public string ToRinex(RinexType version)
        {
            switch (version)
            {
            case RinexType.Unknown:
                return("");

            case RinexType.Version3:
            case RinexType.Version2:
            case RinexType.Bipm:
                if (observationType.Length != 2)
                {
                    observationType = unknownObservation;
                }
                return(string.Format(CultureInfo.InvariantCulture.NumberFormat, "{0}{1}      {2,7:0.0}    {3} SENSOR MOD/TYPE/ACC", model, type, accuracy, GetObservationType(version)));

            case RinexType.Cctf:
                if (observationType.Length > 4)
                {
                    observationType = unknownObservation;
                }
                return(string.Format(CultureInfo.InvariantCulture.NumberFormat, "{0}{1}      {2,7:0.0}  {3} SENSOR MOD/TYPE/ACC", model, type, accuracy, GetObservationType(version)));
            }
            return("");
        }
Пример #3
0
        private string GenerateVersionHeaderInfo(RinexType version)
        {
            string returnString = "";

            switch (version)
            {
            case RinexType.Version3:
                returnString = "     3.03           METEOROLOGICAL DATA                     RINEX VERSION / TYPE";     // A 22 of RINEX Version 3.03 Update 1 (Example)
                break;

            case RinexType.Version2:
                returnString = "     2.11           METEOROLOGICAL DATA                     RINEX VERSION / TYPE";
                break;

            case RinexType.Bipm:
                returnString = "METEOROLOGICAL DATA                                         DATA TYPE";
                break;

            case RinexType.Cctf:
                returnString = "METEOROLOGICAL DATA  CCTF V1.0                              DATA TYPE";
                break;

            case RinexType.Unknown:
                returnString = "< UNKNOWN TYPE >                                            DATA TYPE";
                break;
            }
            return(returnString);
        }
Пример #4
0
 private void SetBevSpecificMetaData(RinexType version)
 {
     AgencyName      = "BEV";
     StationName     = "BEV";
     StationNumber   = "3";
     bipmStationCode = "BE1_";
     if (version == RinexType.Cctf)
     {
         // the concept of external versus internal sensors was introduced in CCTF
         meteoSensorDescriptions[0] = new MeteoSensorDescription("TE", "KRONEIS EVA700", "SN:700.092-12590592", 0.1);
         meteoSensorDescriptions[1] = new MeteoSensorDescription("HE", "KRONEIS EVA700", "SN:700.092-12590592", 2.0);
         meteoSensorDescriptions[2] = new MeteoSensorDescription("PR", "KRONEIS EVA700", "SN:700.092-12590592", 0.3);
         meteoSensorDescriptions[3] = new MeteoSensorDescription("TI", "VAISALA HMT331", "SN:S2220318", 0.1);
         meteoSensorDescriptions[4] = new MeteoSensorDescription("HI", "VAISALA HMT331", "SN:S2220318", 1.5);
     }
     else
     {
         meteoSensorDescriptions[0] = new MeteoSensorDescription("TD", "KRONEIS EVA700", "SN:700.092-12590592", 0.1);
         meteoSensorDescriptions[1] = new MeteoSensorDescription("HR", "KRONEIS EVA700", "SN:700.092-12590592", 2.0);
         meteoSensorDescriptions[2] = new MeteoSensorDescription("PR", "KRONEIS EVA700", "SN:700.092-12590592", 0.3);
     }
     // GP/TM.281 (PPP-derived antenna coordinates for use in P3 data, 21.08.2018)
     PositionX = 4087027.3000;
     PositionY = 1196557.4300;
     PositionZ = 4732637.1000;
     PositionH = 291.8;  // calculated  http://www.oc.nps.edu/oc2902w/coord/llhxyz.htm
 }
Пример #5
0
 /// <summary>
 /// The BIPM and CCTF file format specification does not include sensor position. Since the height is important for barometric pressure measurements it is included as a comment.
 /// </summary>
 /// <param name="version">The Rinex version.</param>
 private void AddSensorPositionToComments(RinexType version)
 {
     if (version == RinexType.Bipm || version == RinexType.Cctf)
     {
         AddComment(string.Format(CultureInfo.InvariantCulture.NumberFormat, "Height of PR sensor {0:F1} m", PositionH));
     }
 }
Пример #6
0
        public SensorMetaData(RinexType version)
        {
            ProgramName  = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;
            this.version = version;
            switch (this.version)
            {
            case RinexType.Unknown:
            case RinexType.Version3:
            case RinexType.Version2:
            case RinexType.Bipm:
                meteoSensorDescriptions = new MeteoSensorDescription[3];
                break;

            case RinexType.Cctf:
                meteoSensorDescriptions = new MeteoSensorDescription[5];
                break;
            }
            SetBevSpecificMetaData(this.version);
        }
Пример #7
0
        public string GetObservationType(RinexType version)
        {
            switch (version)
            {
            case RinexType.Unknown:
                return(unknownObservation);

            case RinexType.Version3:
            case RinexType.Version2:
            case RinexType.Bipm:
                if (observationType.Length != 2)
                {
                    return(unknownObservation);
                }
                return(observationType);

            case RinexType.Cctf:
                return(RinexTools.Consolidate(observationType, 4));
            }
            return(unknownObservation); // this can not happen
        }
Пример #8
0
        private string GenerateLabNameInfo(RinexType version)
        {
            string returnString = "";

            switch (version)
            {
            case RinexType.Version3:
            case RinexType.Version2:
                returnString = RinexTools.Consolidate(AgencyName, 60) + "LAB NAME";
                break;

            case RinexType.Bipm:
            case RinexType.Cctf:
                returnString = RinexTools.Consolidate(bipmStationCode, 60) + "LAB NAME";
                break;

            case RinexType.Unknown:
                returnString = RinexTools.Consolidate("< UNDEFINED >", 60) + "LAB NAME";
                break;
            }
            return(returnString);
        }
Пример #9
0
        /// <summary>
        /// Generates the file name for a given date according to the RINEX documentation
        /// </summary>
        /// <param name="date">The date (a day).</param>
        /// <param name="type">Rinex type.</param>
        /// <returns>The file name.</returns>
        public static string RinexFileName(DateTime date, RinexType type)
        {
            string mjd      = MjdString(date);
            string mj       = mjd.Substring(0, 2);
            string day      = mjd.Substring(mjd.Length - 3, 3);
            string ddd      = date.DayOfYear.ToString("000");
            string yy       = date.ToString("yy");
            string fileName = "";

            switch (type)
            {
            case RinexType.Unknown:
                fileName = "";
                break;

            case RinexType.Version3:
                //fileName = "BEV0" + ddd + "0." + yy + "M";
                fileName = $"BEV0{ddd}0.{yy}M";     // ver. 3.00, modified in 3.03!
                break;

            case RinexType.Version2:
                // fileName = "BEV0" + ddd + "0." + yy + "M";
                fileName = $"BEV0{ddd}0.{yy}M";     // ver. 2.11
                break;

            case RinexType.Bipm:
                // fileName = "BEmet_" + mj + "." + day;
                fileName = $"BEmet_{mj}.{day}";
                break;

            case RinexType.Cctf:
                // fileName = "metBE" + mj + "." + day;
                fileName = $"metBE{mj}.{day}";
                break;
            }
            return(fileName);
        }
Пример #10
0
        static void Main(string[] args)
        {
            // check command line parameters on provided filename/date
            if (args.Length < 1)
            {
                ConsoleUI.ErrorExit("No filename given", 1);
            }

            Settings settings = new Settings();

            if (settings.Verbatim)
            {
                ConsoleUI.BeVerbatim();
            }
            else
            {
                ConsoleUI.BeSilent();
            }
            ConsoleUI.Welcome();

            // query settings on Rinex output file type
            // actually RinexType.Cctf is the current standard
            RinexType rinexType             = RinexType.Unknown;
            string    rinexTypeFromSettings = settings.RinexType.ToUpper().Trim();

            if (rinexTypeFromSettings == "BIPM")
            {
                rinexType = RinexType.Bipm;
            }
            if (rinexTypeFromSettings == "CCTF")
            {
                rinexType = RinexType.Cctf;
            }
            if (rinexTypeFromSettings == "VERSION2")
            {
                rinexType = RinexType.Version2;
            }
            if (rinexTypeFromSettings == "VERSION3")
            {
                rinexType = RinexType.Version3;
            }

            #region File name handling
            string   baseFileName         = Path.GetFileNameWithoutExtension(args[0]);
            string   evaInputFileName     = Path.ChangeExtension(baseFileName, ".TXT");
            string   vaisalaInputFileName = Path.ChangeExtension($"Vaisala_Data_{baseFileName}", ".txt");
            string   evaInputPath         = Path.Combine(settings.EvaInputDirectory, evaInputFileName);
            string   vaisalaInputPath     = Path.Combine(settings.VaisalaInputDirectory, vaisalaInputFileName);
            DateTime dateToProcess        = DateTime.UtcNow; // just to initialize the type
            // estimate the date (the day) from the base file name and construct the output file name
            try
            {
                dateToProcess = DateTime.ParseExact(baseFileName, "yyyyMMdd", CultureInfo.InvariantCulture);
            }
            catch (Exception)
            {
                ConsoleUI.ErrorExit("Filename syntax invalid", 2);
            }
            string rinexOutputFileName = RinexTools.RinexFileName(dateToProcess, rinexType);
            string rinexOutputPath     = Path.Combine(settings.OutputDirectory, rinexOutputFileName);
            #endregion

            // load outdoor data file
            // this data is mandatory, without this file we can exit
            EvaDataLog evaDataLog = new EvaDataLog($"file: {evaInputPath}");
            try
            {
                StreamReader hFile = File.OpenText(evaInputPath);
                ConsoleUI.ReadingFile(evaInputFileName);
                string line;
                while ((line = hFile.ReadLine()) != null)
                {
                    evaDataLog.NewEntry(line);
                }
                hFile.Close();
                ConsoleUI.Done();
            }
            catch (Exception ex)
            {
                ConsoleUI.ErrorExit($"Error reading input: {ex.Message}", 3);
            }

            // load indoor data file (if in CCTF mode)
            VaisalaDataLog vaisalaDataLog = new VaisalaDataLog($"file: {vaisalaInputPath}");
            if (rinexType == RinexType.Cctf)
            {
                try
                {
                    StreamReader hFile = File.OpenText(vaisalaInputPath);
                    ConsoleUI.ReadingFile(vaisalaInputFileName);
                    string line;
                    while ((line = hFile.ReadLine()) != null)
                    {
                        vaisalaDataLog.NewEntry(line);
                    }
                    hFile.Close();
                    ConsoleUI.Done();
                }
                catch (Exception ex)
                {
                    ConsoleUI.WriteLine($"There was a problem opening {vaisalaInputFileName}");
                    ConsoleUI.WriteLine($" - {ex.Message}");
                    ConsoleUI.WriteLine($" - Missing values substituded by {vaisalaDataLog.GetPodForDate(DateTime.UtcNow).Temperature}");
                }
            }

            // extract relevant data in a new object
            ConsoleUI.StartOperation("Collating data");
            SensorDataLog sensorDataLog = new SensorDataLog($"outdoor: {evaDataLog.Title}, indoor: {vaisalaDataLog.Title}");
            foreach (var edp in evaDataLog.GetData())
            {
                if (rinexType == RinexType.Cctf)
                {
                    VaisalaDataPod vdp = vaisalaDataLog.GetPodForDate(edp.TimeStamp);
                    sensorDataLog.NewEntry(edp.TimeStamp, edp.Temperature1, edp.RelativeHumidity, edp.AbsolutePressure, vdp.Temperature, vdp.RelativeHumidity);
                }
                else
                {
                    sensorDataLog.NewEntry(edp.TimeStamp, edp.Temperature1, edp.RelativeHumidity, edp.AbsolutePressure);
                }
            }
            // prepare meta data
            SensorMetaData sensorMetaData = new SensorMetaData(rinexType);
            sensorMetaData.ProgramName = ConsoleUI.Title + " V" + ConsoleUI.Version;
            sensorMetaData.AddComment("External sensor located close to GNSS antenna");
            sensorMetaData.AddComment($"Input file name: {evaInputFileName}");
            sensorMetaData.AddComment($"Internal sensor data file: {vaisalaInputFileName}");
            ConsoleUI.Done();

            // finaly write the output file
            try
            {
                StreamWriter outFile = new StreamWriter(rinexOutputPath);
                ConsoleUI.WritingFile(rinexOutputFileName);
                outFile.Write(sensorMetaData.ToRinex());
                outFile.Write(sensorDataLog.ToRinex(dateToProcess));
                outFile.Close();
                ConsoleUI.Done();
            }
            catch (Exception ex)
            {
                ConsoleUI.ErrorExit($"Error writing output: {ex.Message}", 4);
            }
            ConsoleUI.WriteLine("");
        }