Esempio n. 1
0
        /// <summary>
        /// Convert MICAPS1 data to GrADS station data
        /// </summary>
        /// <param name="inFile"></param>
        /// <param name="outFile"></param>
        public void MICAPS1ToGrADS(string inFile, string outFile)
        {
            MICAPS1DataInfo aDataInfo  = new MICAPS1DataInfo();
            GrADSDataInfo   CGrADSData = new GrADSDataInfo();

            aDataInfo = ReadMicaps1(inFile);
            CGrADSData.WriteGrADSStationData(outFile, aDataInfo);
            CGrADSData.WriteGrADSCtlFile_Station(outFile, aDataInfo);
        }
Esempio n. 2
0
        ///// <summary>
        ///// Get station model data of MICAPS1
        ///// </summary>
        ///// <param name="aMDInfo"></param>
        ///// <param name="dataExtent"></param>
        ///// <returns></returns>
        //public double[,] GetStationModelData_M1(MICAPS1DataInfo aMDInfo, ref Global.Extent dataExtent)
        //{
        //    string aStid;
        //    int i;
        //    Single lon, lat;
        //    List<string> dataList = new List<string>();
        //    double[,] DiscreteData = new double[10, aMDInfo.DataList.Count];
        //    Single minX, maxX, minY, maxY;
        //    minX = 0;
        //    maxX = 0;
        //    minY = 0;
        //    maxY = 0;

        //    for (i = 0; i < aMDInfo.DataList.Count; i++)
        //    {
        //        dataList = aMDInfo.DataList[i];
        //        aStid = (string)dataList[0];
        //        lon = Convert.ToSingle(dataList[1]);
        //        lat = Convert.ToSingle(dataList[2]);
        //        //if (lon < 0)
        //        //{
        //        //    lon += 360;
        //        //}
        //        DiscreteData[0, i] = lon;
        //        DiscreteData[1, i] = lat;
        //        DiscreteData[2, i] = Convert.ToDouble(dataList[6]);    //Wind direction
        //        DiscreteData[3, i] = Convert.ToDouble(dataList[7]);    //Wind speed
        //        DiscreteData[4, i] = Convert.ToDouble(dataList[17]);    //Visibility
        //        DiscreteData[5, i] = Convert.ToDouble(dataList[18]);    //Weather
        //        DiscreteData[6, i] = Convert.ToDouble(dataList[5]);    //Cloud cover
        //        DiscreteData[7, i] = Convert.ToDouble(dataList[19]);    //Temperature
        //        DiscreteData[8, i] = Convert.ToDouble(dataList[16]);    //Dew point
        //        //Pressure
        //        double press = Convert.ToDouble(dataList[8]);
        //        if (Math.Abs(press / aMDInfo.UNDEF - 1) < 0.01)
        //        {
        //            DiscreteData[9, i] = press;
        //        }
        //        else
        //        {
        //            if (press > 800)
        //            {
        //                DiscreteData[9, i] = press / 10 + 1000;
        //            }
        //            else
        //            {
        //                DiscreteData[9, i] = press / 10 + 900;
        //            }
        //        }

        //        if (i == 0)
        //        {
        //            minX = lon;
        //            maxX = minX;
        //            minY = lat;
        //            maxY = minY;
        //        }
        //        else
        //        {
        //            if (minX > lon)
        //            {
        //                minX = lon;
        //            }
        //            else if (maxX < lon)
        //            {
        //                maxX = lon;
        //            }
        //            if (minY > lat)
        //            {
        //                minY = lat;
        //            }
        //            else if (maxY < lat)
        //            {
        //                maxY = lat;
        //            }
        //        }
        //    }
        //    dataExtent.minX = minX;
        //    dataExtent.maxX = maxX;
        //    dataExtent.minY = minY;
        //    dataExtent.maxY = maxY;

        //    return DiscreteData;
        //}

        /// <summary>
        /// Generate data info text of MICAPS 1
        /// </summary>
        /// <param name="aDataInfo"></param>
        /// <returns></returns>
        public string GenerateInfoText_M1(MICAPS1DataInfo aDataInfo)
        {
            string dataInfo;

            dataInfo  = "File Name: " + aDataInfo.FileName;
            dataInfo += Environment.NewLine + "Description: " + aDataInfo.Description;
            dataInfo += Environment.NewLine + "Time: " + aDataInfo.DateTime.ToString("yyyy-MM-dd HH:00");
            dataInfo += Environment.NewLine + "Station Number: " + aDataInfo.stNum;

            return(dataInfo);
        }
Esempio n. 3
0
        /// <summary>
        /// Read MICAPS 1 data info
        /// </summary>
        /// <param name="aFile"></param>
        /// <returns></returns>
        public MICAPS1DataInfo ReadMicaps1(string aFile)
        {
            StreamReader sr = new StreamReader(aFile, Encoding.Default);
            string       aLine;

            string[]              dataArray;
            int                   i, n, LastNonEmpty, dataNum;
            List <string>         dataList    = new List <string>();
            List <List <string> > disDataList = new List <List <string> >();
            MICAPS1DataInfo       aM1DataInfo = new MICAPS1DataInfo();

            aM1DataInfo.FileName = aFile;
            aLine = sr.ReadLine();
            aM1DataInfo.Description = aLine;
            if (aLine.Contains("自动"))
            {
                aM1DataInfo.isAutoStation = true;
            }
            aLine        = sr.ReadLine();
            dataArray    = aLine.Split();
            LastNonEmpty = -1;
            dataList.Clear();
            for (i = 0; i < dataArray.Length; i++)
            {
                if (dataArray[i] != string.Empty)
                {
                    LastNonEmpty++;
                    dataList.Add(dataArray[i]);
                }
            }
            aM1DataInfo.DateTime = Convert.ToDateTime(dataList[0] + "-" + dataList[1] + "-" + dataList[2] +
                                                      " " + dataList[3] + ":00");
            aM1DataInfo.stNum = Convert.ToInt32(dataList[4]);

            dataNum = 0;
            do
            {
                aLine = sr.ReadLine();
                if (aLine == null)
                {
                    break;
                }
                dataArray    = aLine.Split();
                LastNonEmpty = -1;
                dataList.Clear();
                for (i = 0; i < dataArray.Length; i++)
                {
                    if (dataArray[i] != string.Empty)
                    {
                        LastNonEmpty++;
                        dataList.Add(dataArray[i]);
                    }
                }

                for (n = 0; n <= 10; n++)
                {
                    if (dataList.Count < 24)
                    {
                        aLine = sr.ReadLine();
                        if (aLine == null)
                        {
                            break;
                        }
                        dataArray    = aLine.Split();
                        LastNonEmpty = -1;
                        for (i = 0; i < dataArray.Length; i++)
                        {
                            if (dataArray[i] != string.Empty)
                            {
                                LastNonEmpty++;
                                dataList.Add(dataArray[i]);
                            }
                        }
                    }
                    else
                    {
                        break;
                    }
                }

                if (dataList.Count < 24)
                {
                    break;
                }

                if (dataList.Count < 26 && (string)dataList[22] == "1" && (string)dataList[23] == "2")
                {
                    aLine        = sr.ReadLine();
                    dataArray    = aLine.Split();
                    LastNonEmpty = -1;
                    for (i = 0; i < dataArray.Length; i++)
                    {
                        if (dataArray[i] != string.Empty)
                        {
                            LastNonEmpty++;
                            dataList.Add(dataArray[i]);
                        }
                    }
                }

                if (dataNum == 0)
                {
                    if (dataList.Count == 26)
                    {
                        aM1DataInfo.hasAllCols = true;
                    }
                    else
                    {
                        aM1DataInfo.hasAllCols = false;
                    }
                }

                dataNum++;
                if (dataNum == 1)
                {
                    aM1DataInfo.varNum = dataList.Count;
                }
                disDataList.Add(dataList);
                dataList = new List <string>();
            }while (aLine != null);

            sr.Close();

            aM1DataInfo.DataList = disDataList;
            return(aM1DataInfo);
        }
Esempio n. 4
0
        /// <summary>
        /// Get discrete data from MICAPS 1 data info
        /// </summary>
        /// <param name="aMDInfo"></param>
        /// <param name="vIdx"></param>
        /// <param name="dataExtent"></param>
        /// <returns></returns>
        public double[,] GetDiscreteData_M1(MICAPS1DataInfo aMDInfo, int vIdx, ref Global.Extent dataExtent)
        {
            string        aStid;
            int           i;
            Single        lon, lat, t;
            List <string> dataList = new List <string>();

            double[,] DiscreteData = new double[3, aMDInfo.DataList.Count];
            Single minX, maxX, minY, maxY;

            minX = 0;
            maxX = 0;
            minY = 0;
            maxY = 0;

            for (i = 0; i < aMDInfo.DataList.Count; i++)
            {
                dataList = aMDInfo.DataList[i];
                aStid    = (string)dataList[0];
                lon      = Convert.ToSingle(dataList[1]);
                lat      = Convert.ToSingle(dataList[2]);
                t        = Convert.ToSingle(dataList[vIdx]);
                //if (lon < 0)
                //{
                //    lon += 360;
                //}
                DiscreteData[0, i] = lon;
                DiscreteData[1, i] = lat;
                DiscreteData[2, i] = t;

                if (i == 0)
                {
                    minX = lon;
                    maxX = minX;
                    minY = lat;
                    maxY = minY;
                }
                else
                {
                    if (minX > lon)
                    {
                        minX = lon;
                    }
                    else if (maxX < lon)
                    {
                        maxX = lon;
                    }
                    if (minY > lat)
                    {
                        minY = lat;
                    }
                    else if (maxY < lat)
                    {
                        maxY = lat;
                    }
                }
            }
            dataExtent.minX = minX;
            dataExtent.maxX = maxX;
            dataExtent.minY = minY;
            dataExtent.maxY = maxY;

            return(DiscreteData);
        }