コード例 #1
0
ファイル: GLDAS.cs プロジェクト: jsclough/hms_backend
        /// <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);
            output.Metadata.Add("column_1", "Date");
            output.Data = ConvertToHourly(out errorMsg, output, input);
            if (input.Units.Contains("imperial"))
            {
                output.Metadata["gldas_unit"] = "in";
            }

            // NLDAS static methods used for aggregation as GLDAS is identical in function. Modifier refers to the 3hr different to nldas's hourly resolution.
            switch (input.TemporalResolution)
            {
            case "daily":
                output.Data = NLDAS.DailyAggregatedSum(out errorMsg, 7, 3.0, output, input);
                output.Metadata.Add("column_2", "Daily Total");
                return(output);

            case "weekly":
                output.Data = NLDAS.WeeklyAggregatedSum(out errorMsg, 3.0, output, input);
                output.Metadata.Add("column_2", "Weekly Total");
                return(output);

            case "monthly":
                output.Data = NLDAS.MonthlyAggregatedSum(out errorMsg, 3.0, output, input);
                output.Metadata.Add("column_2", "Monthly Total");
                return(output);

            default:
                output.Data = (input.Units.Contains("imperial")) ? NLDAS.UnitConversion(out errorMsg, 3.0, output, input) : output.Data;
                output.Metadata.Add("column_2", "Hourly Average");
                return(output);
            }
        }
コード例 #2
0
        /// <summary>
        /// Checks 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("daymet_temporalresolution", input.TemporalResolution);
            output.Metadata.Add("column_1", "Date");

            switch (input.TemporalResolution)
            {
            case "weekly":
                output.Data = NLDAS.WeeklyAggregatedSum(out errorMsg, 1.0, output, input);
                output.Metadata.Add("column_2", "Weekly Total");
                return(output);

            case "monthly":
                output.Data = NLDAS.MonthlyAggregatedSum(out errorMsg, 1.0, output, input);
                output.Metadata.Add("column_2", "Monthly Total");
                return(output);

            case "daily":
            default:
                output.Metadata.Add("column_2", "Daily Total");
                return(output);
            }
        }