コード例 #1
0
        /// <summary>
        /// Get discrete Lon/Lat station data
        /// </summary>
        /// <param name="vIdx">varible index</param>
        /// <param name="stations">ref stations</param>
        /// <param name="dataExtent">ref data extent</param>
        /// <returns>discrete data</returns>
        public double[,] GetDiscreteData(int vIdx, ref List <string> stations, ref Global.Extent dataExtent)
        {
            string stName;
            int    i;
            double lon, lat;
            double t;

            t = 0;

            List <string> dataList = new List <string>();

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

            minX = 0;
            maxX = 0;
            minY = 0;
            maxY = 0;
            stations.Clear();

            //Get real variable index
            int varIdx = FieldList.IndexOf(VarList[vIdx]);

            for (i = 0; i < DataList.Count; i++)
            {
                dataList = DataList[i];
                stName   = dataList[0];
                lon      = double.Parse(dataList[1]);
                lat      = double.Parse(dataList[2]);
                t        = double.Parse(dataList[varIdx]);
                //if (lon < 0)
                //{
                //    lon += 360;
                //}
                //Initialize data
                stations.Add(stName);
                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);
        }
コード例 #2
0
        /// <summary>
        /// Get station model data
        /// </summary>
        /// <param name="stIDList">ref station identifer list</param>
        /// <param name="dataExtent">ref data extent</param>
        /// <returns>station model data</returns>
        public double[,] GetStationModelData(ref List <string> stIDList, ref Global.Extent dataExtent)
        {
            string aStid;
            int    i;
            double lon, lat, var;
            string aLine;

            double[,] DiscreteData = new double[10, dataList.Count];
            double minX, maxX, minY, maxY;

            minX = 0;
            maxX = 0;
            minY = 0;
            maxY = 0;
            string lonStr, latStr, varStr;

            stIDList = new List <string>();

            //Loop
            for (i = 0; i < dataList.Count; i++)
            {
                aLine  = dataList[i];
                aStid  = aLine.Substring(4, 6);
                latStr = aLine.Substring(28, 6);
                if (latStr == "+99999")
                {
                    continue;
                }
                lat    = double.Parse(latStr) / 1000;
                lonStr = aLine.Substring(34, 7);
                if (lonStr == "+999999")
                {
                    continue;
                }
                lon = double.Parse(lonStr) / 1000;
                DiscreteData[0, i] = lon;
                DiscreteData[1, i] = lat;
                stIDList.Add(aStid);

                for (int j = 0; j < 8; j++)
                {
                    int    startIdx = 0, vLen = 1, scaleFactor = 1;
                    string undefStr = "";
                    var = MissingValue;
                    bool hasData = true;
                    switch (j)
                    {
                    case 0:        //Wind direction
                        startIdx = 60;
                        vLen     = 3;
                        undefStr = "999";
                        break;

                    case 1:        //Wind speed
                        startIdx    = 65;
                        vLen        = 4;
                        undefStr    = "9999";
                        scaleFactor = 10;
                        break;

                    case 2:        //visibility
                        startIdx = 78;
                        vLen     = 6;
                        undefStr = "999999";
                        break;

                    case 5:        //Temperature
                        startIdx    = 87;
                        vLen        = 5;
                        undefStr    = "+9999";
                        scaleFactor = 10;
                        break;

                    case 6:        //Dew point temperature
                        startIdx    = 93;
                        vLen        = 5;
                        undefStr    = "+9999";
                        scaleFactor = 10;
                        break;

                    case 7:        //Sea level pressure
                        startIdx    = 99;
                        vLen        = 5;
                        undefStr    = "99999";
                        scaleFactor = 10;
                        break;

                    case 3:                        //Present weather
                        if (aLine.Contains("MW1")) //Manual report
                        {
                            startIdx = aLine.IndexOf("MW1") + 3;
                            vLen     = 2;
                        }
                        else if (aLine.Contains("AW1"))        //Automatic report
                        {
                            startIdx = aLine.IndexOf("AW1") + 3;
                            vLen     = 2;
                        }
                        else
                        {
                            hasData = false;
                        }
                        break;

                    case 4:        //Cloud cover
                        if (aLine.Contains("GF1"))
                        {
                            startIdx = aLine.IndexOf("GF1") + 3;
                            vLen     = 2;
                            undefStr = "99";
                        }
                        else
                        {
                            hasData = false;
                        }
                        break;
                    }
                    if (hasData)
                    {
                        varStr = aLine.Substring(startIdx, vLen);
                        if (varStr != undefStr)
                        {
                            try { var = double.Parse(varStr) / scaleFactor; }
                            catch { }
                        }
                    }

                    DiscreteData[j + 2, i] = var;
                }

                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
            return(DiscreteData);
        }
コード例 #3
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);
        }
コード例 #4
0
        /// <summary>
        /// Get discreted data
        /// </summary>
        /// <param name="varIdx">Variable index</param>
        /// <param name="stIDList">ref station identifer list</param>
        /// <param name="dataExtent">ref data extent</param>
        /// <returns>discreted data</returns>
        public double[,] GetDiscreteData(int varIdx, ref List <string> stIDList, ref Global.Extent dataExtent)
        {
            string          aStid;
            int             i;
            double          lon, lat, var;
            string          aLine;
            List <double[]> disDataList = new List <double[]>();

            double[,] DiscreteData;
            double minX, maxX, minY, maxY;

            minX = 0;
            maxX = 0;
            minY = 0;
            maxY = 0;
            string lonStr, latStr, varStr;

            stIDList = new List <string>();

            //Get variable position in the record
            int    startIdx = 0, vLen = 1, scaleFactor = 1;
            string undefStr = "";

            switch (varIdx)
            {
            case 0:        //Wind direction
                startIdx = 60;
                vLen     = 3;
                undefStr = "999";
                break;

            case 1:        //Wind speed
                startIdx    = 65;
                vLen        = 4;
                undefStr    = "9999";
                scaleFactor = 10;
                break;

            case 2:        //visibility
                startIdx = 78;
                vLen     = 6;
                undefStr = "999999";
                break;

            case 5:        //Temperature
                startIdx    = 87;
                vLen        = 5;
                undefStr    = "+9999";
                scaleFactor = 10;
                break;

            case 6:        //Dew point temperature
                startIdx    = 93;
                vLen        = 5;
                undefStr    = "+9999";
                scaleFactor = 10;
                break;

            case 7:        //Sea level pressure
                startIdx    = 99;
                vLen        = 5;
                undefStr    = "99999";
                scaleFactor = 10;
                break;
            }

            //Loop
            for (i = 0; i < dataList.Count; i++)
            {
                aLine  = dataList[i];
                aStid  = aLine.Substring(4, 6);
                latStr = aLine.Substring(28, 6);
                if (latStr == "+99999")
                {
                    continue;
                }
                lat    = double.Parse(latStr) / 1000;
                lonStr = aLine.Substring(34, 7);
                if (lonStr == "+999999")
                {
                    continue;
                }
                lon = double.Parse(lonStr) / 1000;

                var = MissingValue;
                switch (varIdx)
                {
                case 3:                        //Present weather
                    if (aLine.Contains("MW1")) //Manual report
                    {
                        startIdx = aLine.IndexOf("MW1") + 3;
                        vLen     = 2;
                        varStr   = aLine.Substring(startIdx, vLen);
                        var      = double.Parse(varStr);
                    }
                    else if (aLine.Contains("AW1"))        //Automatic report
                    {
                        startIdx = aLine.IndexOf("AW1") + 3;
                        vLen     = 2;
                        varStr   = aLine.Substring(startIdx, vLen);
                        try { var = double.Parse(varStr); }
                        catch { break; }
                    }
                    break;

                case 4:        //Cloud cover
                    if (aLine.Contains("GF1"))
                    {
                        startIdx = aLine.IndexOf("GF1") + 3;
                        vLen     = 2;
                        undefStr = "99";
                        varStr   = aLine.Substring(startIdx, vLen);
                        if (varStr != undefStr)
                        {
                            var = double.Parse(varStr);
                        }
                    }
                    break;

                default:
                    varStr = aLine.Substring(startIdx, vLen);
                    if (varStr != undefStr)
                    {
                        var = double.Parse(varStr) / scaleFactor;
                    }

                    break;
                }

                //DiscreteData[0, i] = lon;
                //DiscreteData[1, i] = lat;
                //DiscreteData[2, i] = var;
                disDataList.Add(new double[] { lon, lat, var });
                stIDList.Add(aStid);

                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 = new double[3, disDataList.Count];
            for (i = 0; i < disDataList.Count; i++)
            {
                DiscreteData[0, i] = disDataList[i][0];
                DiscreteData[1, i] = disDataList[i][1];
                DiscreteData[2, i] = disDataList[i][2];
            }
            return(DiscreteData);
        }