예제 #1
0
        /// <summary>
        /// Gets evapotranspiration data using the given TimeSeriesInput parameters.
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <ITimeSeriesOutput> GetEvapotranspiration(EvapotranspirationInput input)
        {
            string errorMsg = "";

            // Constructs default error output object containing error message.
            Utilities.ErrorOutput err = new Utilities.ErrorOutput();

            // Validate evapotranspiration sources.
            errorMsg = (!Enum.TryParse(input.Source, true, out EvapoSources pSource)) ? "ERROR: 'Source' was not found or is invalid." : "";
            if (errorMsg.Contains("ERROR"))
            {
                return(err.ReturnError(errorMsg));
            }

            // Evapotranspiration object
            Evapotranspiration.Evapotranspiration evapo = new Evapotranspiration.Evapotranspiration()
            {
                Algorithm            = input.Algorithm,
                Albedo               = input.Albedo,
                CentralLongitude     = input.CentralLongitude,
                SunAngle             = input.SunAngle,
                Emissivity           = input.Emissivity,
                Model                = input.Model,
                Zenith               = input.Zenith,
                LakeSurfaceArea      = input.LakeSurfaceArea,
                LakeDepth            = input.LakeDepth,
                SubsurfaceResistance = input.SubsurfaceResistance,
                StomatalResistance   = input.StomatalResistance,
                LeafWidth            = input.LeafWidth,
                RoughnessLength      = input.RoughnessLength,
                VegetationHeight     = input.VegetationHeight,
                LeafAreaIndices      = input.LeafAreaIndices,
                AirTemperature       = input.AirTemperature,
                UserData             = input.UserData
            };

            // ITimeSeriesInputFactory object used to validate and initialize all variables of the input object.
            ITimeSeriesInputFactory iFactory = new TimeSeriesInputFactory();

            evapo.Input = iFactory.SetTimeSeriesInput(input, new List <string>()
            {
                "evapotranspiration"
            }, out errorMsg);

            // If error occurs in input validation and setup, errorMsg is added to metadata of an empty object.
            if (errorMsg.Contains("ERROR"))
            {
                return(err.ReturnError(errorMsg));
            }

            // Gets the Evapotranspiration data.
            ITimeSeriesOutput result = evapo.GetData(out errorMsg);

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

            return(result);
        }
예제 #2
0
파일: WSUtilities.cs 프로젝트: quanted/hms
        /// <summary>
        /// Checks the data endpoints for the Evapotranspiration component.
        /// </summary>
        /// <returns></returns>
        public static async Task <Dictionary <string, Dictionary <string, string> > > CheckEvapoEndpoints()
        {
            Dictionary <string, Dictionary <string, string> > endpoints = new Dictionary <string, Dictionary <string, string> >();
            List <Evapotranspiration.Evapotranspiration>      evapos    = new List <Evapotranspiration.Evapotranspiration>();
            List <string> sources = new List <string>()
            {
                "nldas", "gldas"
            };
            ITimeSeriesInput testInput = new TimeSeriesInput()
            {
                Source       = "nldas",
                DateTimeSpan = new DateTimeSpan()
                {
                    StartDate = new DateTime(2005, 01, 01),
                    EndDate   = new DateTime(2005, 01, 05)
                },
                Geometry = new TimeSeriesGeometry()
                {
                    Point = new PointCoordinate()
                    {
                        Latitude  = 33.925673,
                        Longitude = -83.355723
                    },
                    GeometryMetadata = new Dictionary <string, string>()
                }
            };
            ITimeSeriesInputFactory iFactory = new TimeSeriesInputFactory();

            foreach (string source in sources)
            {
                Evapotranspiration.Evapotranspiration evapo = new Evapotranspiration.Evapotranspiration();
                testInput.Source = source;
                evapo.Input      = iFactory.SetTimeSeriesInput(testInput, new List <string>()
                {
                    "evapotranspiration"
                }, out string errorMsg);
                evapos.Add(evapo);
            }

            Parallel.ForEach(evapos, (Evapotranspiration.Evapotranspiration evapo) =>
            {
                endpoints.Add(evapo.Input.Source, evapo.CheckEndpointStatus());
            });
            return(endpoints);
        }
예제 #3
0
        /// <summary>
        /// Gets evapotranspiration data using the given TimeSeriesInput parameters.
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public ITimeSeriesOutput GetEvapotranspiration(ITimeSeriesInput input)
        {
            string errorMsg = "";

            // Constructs default error output object containing error message.
            Utilities.ErrorOutput err = new Utilities.ErrorOutput();

            // Validate evapotranspiration sources.
            errorMsg = (!Enum.TryParse(input.Source, true, out EvapoSources pSource)) ? "ERROR: 'Source' was not found or is invalid." : "";
            if (errorMsg.Contains("ERROR"))
            {
                return(err.ReturnError(errorMsg));
            }

            // Evapotranspiration object
            Evapotranspiration.Evapotranspiration evapo = new Evapotranspiration.Evapotranspiration();

            // ITimeSeriesInputFactory object used to validate and initialize all variables of the input object.
            ITimeSeriesInputFactory iFactory = new TimeSeriesInputFactory();

            evapo.Input = iFactory.SetTimeSeriesInput(input, new List <string>()
            {
                "EVAPOT"
            }, out errorMsg);

            // If error occurs in input validation and setup, errorMsg is added to metadata of an empty object.
            if (errorMsg.Contains("ERROR"))
            {
                return(err.ReturnError(errorMsg));
            }

            // Gets the Evapotranspiration data.
            ITimeSeriesOutput result = evapo.GetData(out errorMsg);

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

            return(result);
        }