Beispiel #1
0
        /// <summary>
        /// Get data function for gldas.
        /// </summary>
        /// <param name="errorMsg"></param>
        /// <param name="dataset">nldas dataset parameter</param>
        /// <param name="componentInput"></param>
        /// <returns></returns>
        public string GetData(out string errorMsg, string dataset, ITimeSeriesInput componentInput)
        {
            errorMsg = "";

            // Adjusts date/times by the timezone offset if timelocalized is set to true.
            componentInput.DateTimeSpan = NLDAS.AdjustForOffset(out errorMsg, componentInput) as DateTimeSpan;

            // Constructs the url for the NLDAS data request and it's query string.
            string url = ConstructURL(out errorMsg, dataset, componentInput);

            if (errorMsg.Contains("ERROR"))
            {
                return(null);
            }

            // Uses the constructed url to download time series data.
            string data = DownloadData(out errorMsg, url);

            if (errorMsg.Contains("ERROR"))
            {
                return(null);
            }

            return(data);
        }
Beispiel #2
0
        /// <summary>
        /// Parses data string from nldas and sets the data for the ITimeSeries object.
        /// </summary>
        /// <param name="errorMsg"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        private Dictionary <string, List <string> > SetData(out string errorMsg, string data, bool localTime, string dateFormat, string dataFormat, ITimezone tzDetails)
        {
            errorMsg = "";
            Dictionary <string, List <string> > dataDict = new Dictionary <string, List <string> >();
            List <string> timestepData;
            double        offset = (localTime == true) ? tzDetails.Offset : 0.0;

            string[] tsLines = data.Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries);

            for (int i = 0; i < tsLines.Length; i++)
            {
                timestepData = new List <string>();
                string[] lineData = tsLines[i].Split(new string[] { "T", "\t" }, StringSplitOptions.RemoveEmptyEntries);
                timestepData.Add(Convert.ToDouble(lineData[2]).ToString(dataFormat));
                dataDict[NLDAS.SetDateToLocal(offset, lineData[0] + " " + lineData[1], dateFormat)] = timestepData;
            }
            return(dataDict);
        }