Ejemplo n.º 1
0
        /// <summary>
        /// Gets the historic precipitation data.
        /// </summary>
        /// <param name="errorMsg"></param>
        /// <param name="years">Years of historic data.</param>
        /// <param name="input"></param>
        /// <param name="output"></param>
        /// <returns></returns>
        private ITimeSeriesOutput GetHistoricData(out string errorMsg, int years, ITimeSeriesInput input, ITimeSeriesOutput output)
        {
            errorMsg = "";

            Precipitation precip = new Precipitation();

            precip.Input  = input;
            precip.Output = output;
            // Historic end date set to simulated data start date minus one day.
            precip.Input.DateTimeSpan.EndDate = precip.Input.DateTimeSpan.StartDate.AddDays(-1);
            // Historic start date set to 20 years before simulated start date.
            precip.Input.DateTimeSpan.StartDate = precip.Input.DateTimeSpan.StartDate.AddYears(-1 * Math.Abs(years));

            if (input.Geometry.GeometryMetadata.ContainsKey("historicSource"))
            {
                switch (input.Geometry.GeometryMetadata["historicSource"])
                {
                case "nldas":
                    input.Source             = "nldas";
                    input.TemporalResolution = "daily";
                    break;

                case "gldas":
                    input.Source             = "gldas";
                    input.TemporalResolution = "daily";
                    break;

                case "daymet":
                default:
                    input.Source = "daymet";
                    break;
                }
            }
            else
            {
                input.Source = "daymet";
            }
            ITimeSeriesInputFactory iFactory  = new TimeSeriesInputFactory();
            ITimeSeriesInput        tempInput = iFactory.SetTimeSeriesInput(input, new List <string>()
            {
                "precip"
            }, out errorMsg);

            precip.Input  = tempInput;
            precip.Output = precip.GetData(out errorMsg);
            if (errorMsg.Contains("ERROR"))
            {
                return(null);
            }
            return(precip.Output);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets precipitation data.
        /// </summary>
        /// <param name="errorMsg"></param>
        /// <param name="input"></param>
        /// <param name="output"></param>
        /// <returns></returns>
        private ITimeSeriesOutput GetPrecipData(out string errorMsg, ITimeSeriesInput input, ITimeSeriesOutput output)
        {
            errorMsg = "";

            Precipitation.Precipitation precip = new Precipitation.Precipitation();
            precip.Input  = input;
            precip.Output = output;

            if (input.Geometry.GeometryMetadata.ContainsKey("precipSource"))
            {
                switch (input.Geometry.GeometryMetadata["precipSource"])
                {
                case "nldas":
                    input.Source             = "nldas";
                    input.TemporalResolution = "daily";
                    break;

                case "gldas":
                    input.Source             = "gldas";
                    input.TemporalResolution = "daily";
                    break;

                case "daymet":
                default:
                    input.Source = "daymet";
                    break;
                }
            }
            else
            {
                input.Source = "daymet";
            }
            ITimeSeriesInputFactory iFactory  = new TimeSeriesInputFactory();
            ITimeSeriesInput        tempInput = iFactory.SetTimeSeriesInput(input, new List <string>()
            {
                "precip"
            }, out errorMsg);

            precip.Input  = tempInput;
            precip.Output = precip.GetData(out errorMsg);
            if (errorMsg.Contains("ERROR"))
            {
                return(null);
            }
            return(precip.Output);
        }