示例#1
0
        /// <summary>
        /// Check temperature data endpoints.
        /// </summary>
        /// <returns></returns>
        public Dictionary <string, string> CheckEndpointStatus()
        {
            switch (this.Input.Source)
            {
            case "nldas":
                return(NLDAS.CheckStatus(this.Input));

            case "gldas":
                return(GLDAS.CheckStatus(this.Input));

            case "daymet":
                return(Daymet.CheckStatus(this.Input));

            default:
                return(new Dictionary <string, string>()
                {
                    { "status", "invalid source" }
                });
            }
        }
示例#2
0
文件: GLDAS.cs 项目: quanted/hms
        /// <summary>
        /// Checks for temporal resolution and runs appropriate aggregation function.
        /// </summary>
        /// <param name="errorMsg"></param>
        /// <param name="output"></param>
        /// <param name="input"></param>
        /// <returns></returns>
        private ITimeSeriesOutput TemporalAggregation(out string errorMsg, ITimeSeriesOutput output, ITimeSeriesInput input)
        {
            errorMsg = "";
            output.Metadata.Add("gldas_temporalresolution", input.TemporalResolution);

            if (input.Units.Contains("imperial"))
            {
                output.Metadata["gldas_unit"] = "F";
            }
            output.Data = (input.Units.Contains("imperial")) ? NLDAS.UnitConversion(out errorMsg, output, input) : output.Data;

            output.Metadata.Add("column_1", "date");

            switch (input.TemporalResolution)
            {
            case "daily":
            case "default":
                // Combined high/low/average
                output.Data = NLDAS.DailyValues(out errorMsg, output, input, "all");
                output.Metadata.Add("column_2", "Max Temperature");
                output.Metadata.Add("column_3", "Min Temperature");
                output.Metadata.Add("column_4", "Average Temperature");
                return(output);

            case "daily-avg":
                output.Data = NLDAS.DailyValues(out errorMsg, output, input, "avg");
                output.Metadata.Add("column_2", "Average Temperature");
                return(output);

            case "daily-high":
                output.Data = NLDAS.DailyValues(out errorMsg, output, input, "high");
                output.Metadata.Add("column_2", "Max Temperature");
                return(output);

            case "daily-low":
                output.Data = NLDAS.DailyValues(out errorMsg, output, input, "low");
                output.Metadata.Add("column_2", "Min Temperature");
                return(output);

            case "weekly":
                // Combined high/low/average
                output.Data = NLDAS.WeeklyValues(out errorMsg, output, input, "all");
                output.Metadata.Add("column_2", "Max Temperature");
                output.Metadata.Add("column_3", "Min Temperature");
                output.Metadata.Add("column_4", "Average Temperature");
                return(output);

            case "weekly-avg":
                output.Data = NLDAS.WeeklyValues(out errorMsg, output, input, "avg");
                output.Metadata.Add("column_2", "Average Temperature");
                return(output);

            case "weekly-high":
                output.Data = NLDAS.WeeklyValues(out errorMsg, output, input, "high");
                output.Metadata.Add("column_2", "Max Temperature");
                return(output);

            case "weekly-low":
                output.Data = NLDAS.WeeklyValues(out errorMsg, output, input, "low");
                output.Metadata.Add("column_2", "Min Temperature");
                return(output);

            case "monthly":
                // Combined high/low/average
                output.Data = NLDAS.MonthlyValues(out errorMsg, output, input, "all");
                output.Metadata.Add("column_2", "Max Temperature");
                output.Metadata.Add("column_3", "Min Temperature");
                output.Metadata.Add("column_4", "Average Temperature");
                return(output);

            case "monthly-avg":
                output.Data = NLDAS.MonthlyValues(out errorMsg, output, input, "avg");
                output.Metadata.Add("column_2", "Average Temperature");
                return(output);

            case "monthly-high":
                output.Data = NLDAS.MonthlyValues(out errorMsg, output, input, "high");
                output.Metadata.Add("column_2", "Max Temperature");
                return(output);

            case "monthly-low":
                output.Data = NLDAS.MonthlyValues(out errorMsg, output, input, "low");
                output.Metadata.Add("column_2", "Min Temperature");
                return(output);

            default:
                return(output);
            }
        }
示例#3
0
        // -------------- Temperature Functions -------------- //

        /// <summary>
        /// Get Temperature data function.
        /// </summary>
        /// <param name="errorMsg"></param>
        /// <returns></returns>
        public ITimeSeriesOutput GetData(out string errorMsg)
        {
            errorMsg = "";

            // If the timezone information is not provided, the tz details are retrieved and set to the geometry.timezone varaible.
            if (this.Input.Geometry.Timezone.Offset == 0)
            {
                Utilities.Time tz = new Utilities.Time();
                this.Input.Geometry.Timezone = tz.GetTimezone(out errorMsg, this.Input.Geometry.Point) as Timezone;
                if (errorMsg.Contains("ERROR"))
                {
                    return(null);
                }
            }

            //TODO: Check Source and run specific subcomponent class for source
            ITimeSeriesOutputFactory iFactory = new TimeSeriesOutputFactory();

            this.Output = iFactory.Initialize();

            switch (this.Input.Source)
            {
            case "nldas":
                // NLDAS Temperature Data call
                NLDAS nldas = new NLDAS();
                this.Output = nldas.GetData(out errorMsg, this.Output, this.Input);
                if (errorMsg.Contains("ERROR"))
                {
                    return(null);
                }
                break;

            case "gldas":
                // GLDAS Temperature Data call
                GLDAS gldas = new GLDAS();
                this.Output = gldas.GetData(out errorMsg, this.Output, this.Input);
                if (errorMsg.Contains("ERROR"))
                {
                    return(null);
                }
                break;

            case "daymet":
                // daymet Temperature Data call
                Daymet daymet = new Daymet();
                this.Output = daymet.GetData(out errorMsg, this.Output, this.Input);
                if (errorMsg.Contains("ERROR"))
                {
                    return(null);
                }
                break;

            case "prism":
                // PRISM Temperature Data call
                PRISM prism = new PRISM();
                this.Output = prism.GetData(out errorMsg, this.Output, this.Input);
                if (errorMsg.Contains("ERROR"))
                {
                    return(null);
                }
                break;

            default:
                errorMsg = "ERROR: 'Source' for temperature was not found among available sources or is invalid.";
                break;
            }
            ;

            // Adds Geometry metadata to the output metadata. NOT WORKING
            this.Output.Metadata.Concat(this.Input.Geometry.GeometryMetadata);

            // Adds Timezone info to metadata
            this.Output.Metadata.Add(this.Input.Source + "_timeZone", this.Input.Geometry.Timezone.Name);
            this.Output.Metadata.Add(this.Input.Source + "_tz_offset", this.Input.Geometry.Timezone.Offset.ToString());

            //TODO: Add output format control

            return(this.Output);
        }