/// <summary>
 /// Constructor
 /// </summary>
 public GRIB2MessageIndex()
 {
     DateTime  = new DateTime();
     Parameter = new Variable();
 }
        /// <summary>
        /// Read MICAPS 7 data info
        /// </summary>
        /// <param name="TrajFiles">File paths</param>
        public void ReadDataInfo(string[] TrajFiles)
        {
            this.FileName = TrajFiles[0];
            string aLine;

            string[]      dataArray;
            List <string> dataList = new List <string>();
            int           j, t, LastNonEmpty;
            DateTime      aDateTime = new DateTime();

            InitVariables();
            List <double> times = new List <double>();

            for (t = 0; t < TrajFiles.Length; t++)
            {
                string aFile = TrajFiles[t];
                FileNames.Add(aFile);

                FileStream   fs = new FileStream(aFile, FileMode.Open, FileAccess.Read);
                StreamReader sr = new StreamReader(fs);

                //
                TrajectoryInfo        aTrajInfo    = new TrajectoryInfo();
                List <TrajectoryInfo> trajInfoList = new List <TrajectoryInfo>();
                aLine = sr.ReadLine();
                aLine = sr.ReadLine();
                int trajIdx = -1;
                int trajNum = 0;
                while (aLine != null)
                {
                    if (aLine.Trim() == String.Empty)
                    {
                        aLine = sr.ReadLine();
                        continue;
                    }

                    dataArray    = aLine.Split();
                    LastNonEmpty = -1;
                    dataList.Clear();
                    for (j = 0; j < dataArray.Length; j++)
                    {
                        if (dataArray[j] != string.Empty)
                        {
                            LastNonEmpty++;
                            dataList.Add(dataArray[j]);
                        }
                    }
                    switch (dataList.Count)
                    {
                    case 4:
                        aTrajInfo            = new TrajectoryInfo();
                        aTrajInfo.TrajName   = dataList[0];
                        aTrajInfo.TrajID     = dataList[1];
                        aTrajInfo.TrajCenter = dataList[2];
                        trajIdx  = -1;
                        trajNum += 1;
                        break;

                    case 13:
                        trajIdx += 1;
                        if (trajIdx == 0)
                        {
                            //aDateTime = DateTime.Parse(dataList[0] + "-" + dataList[1] + "-" +
                            //    dataList[2] + " " + dataList[3] + ":00");
                            //aDateTime = DateTime.ParseExact(dataList[0] + "-" + dataList[1] + "-" + dataList[2] +
                            //    " " + dataList[3] + ":00", "yy-MM-dd HH:mm", null);
                            int year = int.Parse(dataList[0]);
                            if (year < 100)
                            {
                                if (year < 50)
                                {
                                    year = 2000 + year;
                                }
                                else
                                {
                                    year = 1900 + year;
                                }
                            }
                            aDateTime = new DateTime(year, int.Parse(dataList[1]), int.Parse(dataList[2]), int.Parse(dataList[3]), 0, 0);
                            if (times.Count == 0)
                            {
                                times.Add(DataConvert.ToDouble(aDateTime));
                            }

                            aTrajInfo.StartTime = aDateTime;
                            aTrajInfo.StartLat  = Single.Parse(dataList[6]);
                            aTrajInfo.StartLon  = Single.Parse(dataList[5]);
                            //aTrajInfo.StartHeight = Single.Parse(dataList[6]);
                            trajInfoList.Add(aTrajInfo);
                        }
                        break;
                    }

                    aLine = sr.ReadLine();
                }
                TrajeoryNums.Add(trajNum);
                TrajeoryNumber += TrajeoryNums[t];
                TrajInfos.Add(trajInfoList);

                Dimension tdim = new Dimension(DimensionType.T);
                tdim.SetValues(times);
                this.TimeDimension = tdim;

                sr.Close();
                fs.Close();

                Variable var = new Variable();
                var.Name      = "Traj";
                var.IsStation = true;
                var.SetDimension(tdim);
                List <Variable> variables = new List <Variable>();
                variables.Add(var);
                this.Variables = variables;
            }
        }