当前位置: 首页>>代码示例>>C#>>正文


C# Series.IndexOf方法代码示例

本文整理汇总了C#中Series.IndexOf方法的典型用法代码示例。如果您正苦于以下问题:C# Series.IndexOf方法的具体用法?C# Series.IndexOf怎么用?C# Series.IndexOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Series的用法示例。


在下文中一共展示了Series.IndexOf方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CheckANTOFlowRampingRate

        // Checks hourly ANTO flow against hourly ANTO canal flows
        private static void CheckANTOFlowRampingRate(Series antoQ, Series antoQC, out Series sOut_Down,
            out Series sOut_Up)
        {
            sOut_Down = new Series();
            sOut_Up = new Series();
            sOut_Down.Name = "ANTO_DailyDownRampingCheck";
            sOut_Down.Provider = "Series";
            sOut_Up.Name = "ANTO_DailyUpRampingCheck";
            sOut_Up.Provider = "Series";

            for (int i = 0; i < antoQ.Count - 24; i++)
            {
                DateTime t1 = antoQ[i].DateTime;
                DateTime t2 = t1.AddHours(23);

                // Calculate GILO change within a 24 hour period
                double ithQ = antoQ[t1].Value;
                double jthQ = antoQ[t2].Value;
                double rampQ = jthQ - ithQ;

                // Calculate total change in SLBO and DICO flows within the same period
                double ithQ1 = 0.0;
                double jthQ1 = 0.0;
                if (antoQC.IndexOf(t1) > 0)
                    double.TryParse(antoQC[t1].Value.ToString(), out ithQ1);
                if (antoQC.IndexOf(t2) > 0)
                    double.TryParse(antoQC[t2].Value.ToString(), out jthQ1);
                double rampImpact = jthQ1 - ithQ1;

                // Check if ANTO Q increase is more than 100%
                if (jthQ > 2.0 * ithQ && rampImpact < 0.0 && ithQ > 1.0 && jthQ > 1.0)
                {
                    if (System.Math.Abs(rampImpact) < rampQ)
                        sOut_Up.Add(t2, -50.0); // Assigns -50 if GILO increase is not due to decrease in DICO and SLBO operations
                    else
                        sOut_Up.Add(t2, -99.99); // Assigns a -99 if increase is due to change in DICO and SLBO operations
                }
                else
                {
                    // Assigns a 0 if GILO flow did not increase in the last 24 hours
                    sOut_Up.Add(t2, 0.0);
                }

                // Check if ANTO Q decrease is more than 50%; same comments as above if-then conditionals
                if (jthQ < 0.5 * ithQ && rampImpact > 0.0 && ithQ > 1.0 && jthQ > 1.0)
                {
                    if (System.Math.Abs(rampQ) > rampImpact)
                        sOut_Down.Add(t2, -50.0);
                    else
                        sOut_Down.Add(t2, -99.99);
                }
                else
                {
                    sOut_Down.Add(t2, 0.0);
                }
            }
        }
开发者ID:usbr,项目名称:Pisces,代码行数:58,代码来源:Program.cs

示例2: GetSerieData

        private static Series GetSerieData(Folder folder)
        {
            var s = new Series();
            s.TimeInterval = TimeInterval.Daily;
            foreach (var msg in folder.Messages)
            {
                var txt = msg.Body.Text;
                var exp = @"Pump Station Average Flow:(\s*\d{1,10}(\.){0,1}\d{0,3})\s*cfs";
                Regex re = new Regex(exp);
                var m = Regex.Match(txt, exp);
                if (m.Success)
                {
                    double d = Convert.ToDouble(m.Groups[1].Value);
                    var t = Reclamation.TimeSeries.Math.RoundToNearestHour(msg.Date.Value);

                    if (s.IndexOf(t) < 0)
                    {
                        s.Add(t, d);
                        //msg.Flags.Add(ImapX.Flags.MessageFlags.Seen);
                        msg.Flags.Add(ImapX.Flags.MessageFlags.Deleted);
                        Console.WriteLine(t.ToString() + " " + d.ToString("F2"));
                    }
                }
            }
            return s;
        }
开发者ID:usbr,项目名称:Pisces,代码行数:26,代码来源:Program.cs

示例3: FileLookupInterpolate2D

        public static Series FileLookupInterpolate2D(Series s1, Series s2, string fileName)
        {
            var rval = new Series();

            if (s1.IsEmpty || s2.IsEmpty)
            {
                Logger.WriteLine("FileLookupInterpolate2D - input series empty");
                return rval;
            }

            if (!File.Exists(fileName))
            {
                Logger.WriteLine("FileLookupInterpolate2D - input fileName, file not found");
                return rval;
            }

            CsvFile csv = new CsvFile(fileName, CsvFile.FieldTypes.AllText);
            foreach (var pt in s1)
            {
                Point point = pt;

                var s2_idx = s2.IndexOf(pt.DateTime);
                if (s2_idx < 0)
                {
                    point.Value = Point.MissingValueFlag;
                }
                else
                {
                    point.Value = Interpoloate2D(csv, pt.Value, s2[s2_idx].Value);
                }
                rval.Add(point);
            }

            return rval;
        }
开发者ID:usbr,项目名称:Pisces,代码行数:35,代码来源:Math.TableLookup.cs

示例4: MissingDate

 private static bool MissingDate(Series s, DateTime t)
 {
     return s.IndexOf(t) < 0;
 }
开发者ID:usbr,项目名称:Pisces,代码行数:4,代码来源:AsceEtCalculator.cs

示例5: ResetResidualBasedOnForecast

        private static double ResetResidualBasedOnForecast(DateTime t,Series fc, double resid)
        {
            if (fc.IndexOf(t) >= 0 && !fc[t].IsMissing )
                     resid = fc[t].Value;

            if (t == t.FirstOfMonth() &&  // residual should not keep going.
                (fc.IndexOf(t) < 0 || fc[t].IsMissing))
                return Point.MissingValueFlag;

            return resid;
        }
开发者ID:usbr,项目名称:Pisces,代码行数:11,代码来源:Math.Hydromet.cs

示例6: FillCorrelation

        private void FillCorrelation(Series s1, Series s2, LineItem series1)
        {
            int sz = s1.Count;

            for (int i = 0; i < sz; i++)
            {
                Point pt = s1[i];

                if (!pt.IsMissing)
                {
                    int idx = s2.IndexOf(pt.DateTime);
                    if (idx >= 0)
                    {
                        Point pt2 = s2[idx];
                        if (!pt2.IsMissing)
                        {
                            series1.AddPoint(pt.Value, pt2.Value);
                        }
                    }
                }
            }
        }
开发者ID:usbr,项目名称:Pisces,代码行数:22,代码来源:ZedGraphDataLoader.cs

示例7: Append

        /// <summary>
        /// Append data to end of series
        /// </summary>
        /// <param name="fromSeries">series with data to append</param>
        /// <param name="toSeries">series to append data to</param>
        /// <returns></returns>
        //[FunctionAttribute("Append series1 to the end of series2",
        //    "Append(series1,series2)")]
        private static void Append(Series fromSeries, Series toSeries)
        {
            DateTime t1 = toSeries.MaxDateTime;
            DateTime t2 = fromSeries.MaxDateTime;

            if (t2 <= t1 || fromSeries.TimeInterval != toSeries.TimeInterval)
            {
                Logger.WriteLine("no data to append or invalid time intervals");
                return;
            }

            int sIndex = fromSeries.IndexOf(t1) + 1;
            if (sIndex <= 0)
            {
                Logger.WriteLine(toSeries.Name + " start append date not found in " + fromSeries.Name);
                return;
            }

            for (int i = sIndex; i < fromSeries.Count; i++)
            {
                Point p = fromSeries[i];
                if (toSeries.IndexOf(p.DateTime) < 0)
                {
                    toSeries.Add(p);
                }
            }
        }
开发者ID:usbr,项目名称:Pisces,代码行数:35,代码来源:Math.DissagregationUofI.cs

示例8: DailyMidnight

        public static Series DailyMidnight(Series s)
        {
            Series rval = new Series();
            rval.TimeInterval = TimeInterval.Daily;
            if (s.Count == 0)
                return rval;

            var t = s.MinDateTime.Date;

            while (t <= s.MaxDateTime)
            {
                int idx = s.IndexOf(t.AddDays(1).Date); // midnight
                if (idx >= 0)
                    rval.Add(t,s[idx].Value);
                else
                    rval.AddMissing(t);

                t = t.AddDays(1).Date;
            }

            return rval;
        }
开发者ID:usbr,项目名称:Pisces,代码行数:22,代码来源:Math.Statistics.Daily.cs

示例9: CheckANTOGageRampingRate

        // Check ANTO GH ramping rate against ANTO canal flows
        private static Series CheckANTOGageRampingRate(Series antoGH, Series antoQC)
        {
            Series rval = new Series();
            rval.Name = "ANTO_HourlyGageHeightRampingCheck";
            rval.Provider = "Series";

            for (int i = 0; i < antoGH.Count - 1; i++)
            {
                DateTime t1 = antoGH[i].DateTime;
                DateTime t2 = antoGH[i + 1].DateTime;

                // Get GH average and difference for processing
                double ghDiff = (antoGH[t2].Value - antoGH[t1].Value) * 12.0;//Convert to inches
                double ghAvg = ((antoGH[t2].Value + antoGH[t1].Value) * 12.0) / 2.0;

                // Get change in DICO and SLBO flows
                double ithQ = 0;
                double jthQ = 0;
                if (antoQC.IndexOf(t1) > 0)
                    double.TryParse(antoQC[t1].Value.ToString(), out ithQ);
                if (antoQC.IndexOf(t2) > 0)
                    double.TryParse(antoQC[t2].Value.ToString(), out jthQ);
                double projQDiff = jthQ - ithQ;

                // See comments on the GILO Gage Height Ramping Check method for explanation.
                //FEET		CFS	 	    INCH		CFS / INCH
                //3.47	    0	        41.64
                //3.50	    0	        42       	0
                //4.00      0.548	    48	        0.175
                //4.25	    3.67	    51	        1.040666667
                //4.50	    15.3	    54	        3.876666667
                //4.75	    42.2	    57	        8.966666667
                //5.00	    84.3	    60	        14.03333333
                //5.25	    141	        63	        18.9
                //5.50	    211	        66	        23.33333333
                //5.75	    297	        69	        28.66666667
                //5.90  	355	        70.8	    32.22222222
                //
                // Determine the 'CFS / INCH' value that would cause a 1" change in GH
                //var a = rtfInterpolate(3.0, 2.5, 2.75, 481.0, 351.0);
                double maxQDiff = 0.0;
                if (ghAvg <= 48.0)
                    maxQDiff = 0.175;
                else if (ghAvg > 48.0 && ghAvg <= 51.0)
                    maxQDiff = rtfInterpolate(51.0, 48.0, ghAvg, 1.04, 0.175);
                else if (ghAvg > 51.0 && ghAvg <= 54.0)
                    maxQDiff = rtfInterpolate(54.0, 51.0, ghAvg, 3.88, 1.04);
                else if (ghAvg > 54.0 && ghAvg <= 57.0)
                    maxQDiff = rtfInterpolate(57.0, 54.0, ghAvg, 8.97, 3.88);
                else if (ghAvg > 57.0 && ghAvg <= 60.0)
                    maxQDiff = rtfInterpolate(60.0, 57.0, ghAvg, 14.03, 8.97);
                else if (ghAvg > 60.0 && ghAvg <= 63.0)
                    maxQDiff = rtfInterpolate(63.0, 60.0, ghAvg, 18.90, 14.03);
                else if (ghAvg > 63.0 && ghAvg <= 66.0)
                    maxQDiff = rtfInterpolate(66.0, 63.0, ghAvg, 23.33, 18.90);
                else if (ghAvg > 66.0 && ghAvg <= 69.0)
                    maxQDiff = rtfInterpolate(69.0, 66.0, ghAvg, 28.67, 23.33);
                else if (ghAvg > 69.0 && ghAvg <= 70.8)
                    maxQDiff = rtfInterpolate(70.8, 69.0, ghAvg, 32.22, 28.67);
                else if (ghAvg > 70.8)
                    maxQDiff = 32.22;

                // If month is March or April, GH threshold is 1"
                if (t1.Month == 3 || t1.Month == 4)
                {
                    if (ghDiff < -1.0) // Check if GH dropped by more than 1"
                    {
                        if (projQDiff > maxQDiff) // GH dropped by >1", check if change in project flows caused it.
                            rval.Add(t2, -99.99); // Change in flow > allowable, assign -99.
                        else
                            rval.Add(t2, -50.00); // Change in flow < allowable, assign -50.
                    }
                    else
                    {
                        // GH didn't drop by more than 1". Assign 0.0
                        rval.Add(t2, 0.00);
                    }
                }
                // All other months have a threshold of 2"
                else
                {
                    if (ghDiff < -2.0) // Check if GH dropped by more than 2"
                    {
                        if (projQDiff > 2.0 * maxQDiff)
                            rval.Add(t2, -99.99);
                        else
                            rval.Add(t2, -50.00);
                    }
                    else
                    {
                        rval.Add(t2, 0.00);
                    }
                }

            }
            return rval;
        }
开发者ID:usbr,项目名称:Pisces,代码行数:98,代码来源:Program.cs

示例10: SetDailyValueForMonth

 private static void SetDailyValueForMonth(Series estimatedDaily, int year, int month, double avgFlow, string flag)
 {
     DateTime t1 = new DateTime(year,month,1);
     DateTime t2 = new DateTime(year,month,DateTime.DaysInMonth(year,month));
     int startIndex = estimatedDaily.IndexOf(t1);
     if (startIndex < 0)
         startIndex = 0;
     for (int j = startIndex; j < estimatedDaily.Count; j++)
     {
         var pt = estimatedDaily[j];
         if (pt.DateTime > t2)
             break;
         if (pt.DateTime.Year == year && pt.DateTime.Month == month)
         {
             pt.Value = avgFlow;
             pt.Flag = flag;
             estimatedDaily[j] = pt;
         }
     }
 }
开发者ID:usbr,项目名称:Pisces,代码行数:20,代码来源:MonthlyToDailyConversion.cs

示例11: ReadSimpleShefA

        /// <summary>
        /// Reads shef .A file and extracts all shef locations and codes that match
        /// simple, only reads single parameter per line
        /// </summary>
        /// <param name="filename">input file to read</param>
        /// <param name="shefloc">shef location to search for</param>
        /// <param name="shefCode">shefcode to search for</param>
        /// <returns></returns>
        public static Series ReadSimpleShefA(string filename, string shefloc, string shefCode)
        {
            //.A BRWLD 150309 PD DH2315 /HE1H .00
            //.A BRWLD 150309 PD DH2315 /HE2H .19

            var rval = new Series();
            TextFile tf = new TextFile(filename);

            for (int i = 0; i < tf.Length; i++)
            {
                var m = ShefASimpleRegex.Match(tf[i]);
                if (m.Success)
                {
                    var loc = m.Groups["shefloc"].Value;
                    var sc = m.Groups["shefcode"].Value;
                    var yy = m.Groups["year"].Value;
                    var mm = m.Groups["month"].Value;
                    var dd = m.Groups["day"].Value;
                    var hh = m.Groups["hour"].Value;
                    var min = m.Groups["min"].Value;

                    var val = m.Groups["value"].Value;

                    if (shefCode == sc
                        && loc == shefloc)
                    {
                        int year, month, day, hour,minute;
                        double num = Point.MissingValueFlag; ;
                        if (int.TryParse(yy, out year)
                            && int.TryParse(mm, out month)
                            && int.TryParse(dd, out day)
                            && int.TryParse(hh, out hour)
                            && int.TryParse(min, out minute)
                            && double.TryParse(val,out num))
                        {
                            var t = new DateTime(year + 2000, month, day, hour, minute,0);
                            if( rval.IndexOf(t)>=0)
                            {
                                Console.WriteLine("Skipping duplicate "+t.ToString()+" :" +num);
                                continue;
                            }
                            rval.Add(t, num);
                        }
                    }
                }
            }

            return rval;
        }
开发者ID:usbr,项目名称:Pisces,代码行数:57,代码来源:SimpleShef.cs

示例12: DewPointTemperature

        public static Series DewPointTemperature(Series ob, Series tu)
        {
            Series tp = new Series();

            if (tu.Count > 0 && ob.Count > 0)
            {
                for (int i = 0; i < ob.Count; i++)
                {
                    var pt = ob[i];
                    if (tu.IndexOf(pt.DateTime) >= 0)
                    {
                        double tpVal = AsceEtCalculator.DewPtTemp(pt.Value, tu[pt.DateTime].Value);
                        if (!double.IsNaN(tpVal))
                        {
                            tp.Add(pt.DateTime, tpVal);
                        }
                        else
                        {
                            Console.WriteLine();
                        }
                    }
                }
            }
            return tp;
        }
开发者ID:usbr,项目名称:Pisces,代码行数:25,代码来源:Math.ET.cs

示例13: Add

        /// <summary>
        /// Copies from series b into series a.
        /// Series a is used as a template, each point
        /// in Series a is added to the corresponding point
        /// in series b.
        /// if subtract is true then subtract a - b
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b"></param>
        /// <param name="subtract"></param>
        /// <returns></returns>
        private static Series Add(Series a, Series b, bool subtract)
        {
            Series rval = new Series();
            //Series.CopyAttributes(a, rval);
            if (a.TimeInterval != b.TimeInterval)
            {
                throw new InvalidOperationException(a.TimeInterval.ToString() + " and " + b.TimeInterval.ToString() + " are not compatable for add or subtract");
            }
            if (a.Units.ToLower() != b.Units.ToLower())
            {
                Logger.WriteLine("Warning:  '"+a.Units +"' and '"+b.Units +"' are not compatible for the add or subtract calculation");
                //throw new InvalidOperationException("'"+a.Units +"' and '"+b.Units +"' are not compatible for the add or subtract calculation");
            }

            int sign = 1;
            if (subtract)
            {
                sign = -1;
            }
            rval.TimeInterval = a.TimeInterval;
            rval.Units = a.Units;
            for (int i = 0; i < a.Count; i++)
            {
                Point newPoint;
                Point ptA = a[i];
                int idx = b.IndexOf(ptA.DateTime);
                if (
                   idx >= 0 && (!ptA.IsMissing)
                  )
                {
                    Point ptB = b[idx];
                    if (ptB.IsMissing)
                    {
                        newPoint = new Point(ptA.DateTime, Point.MissingValueFlag, PointFlag.Missing);
                    }
                    else
                    {
                        newPoint = new Point(ptA.DateTime, ptA.Value + sign * ptB.Value,PointFlag.Computed);
                    }
                }
                else
                { // missing data.
                    newPoint = new Point(ptA.DateTime, Point.MissingValueFlag, PointFlag.Missing);
                }
                rval.Add(newPoint);
            }

            return rval;
        }
开发者ID:usbr,项目名称:Pisces,代码行数:60,代码来源:Math.cs

示例14: Compare

        /// <summary>
        /// Compares series 1 to series2
        /// </summary>
        internal static Series Compare(Series series1, Series series2, Func<double,double,double> f)
        {
            Series rval = series1.Copy();
            for (int i = 0; i < rval.Count; i++)
            {
                Point pt = rval[i];
                var idx2 =  series2.IndexOf(pt.DateTime);
                var missing = new Point(pt.DateTime, Point.MissingValueFlag, PointFlag.Missing);
                if (pt.IsMissing || idx2 < 0)
                {
                    pt = missing;
                }
                else if (idx2 >= 0 && series2[idx2].IsMissing)
                {
                    pt = missing;
                }
                else
                {
                    pt.Value = f(pt.Value,series2[idx2].Value);
                }

                rval[i] = pt;
            }
            return rval;
        }
开发者ID:usbr,项目名称:Pisces,代码行数:28,代码来源:Math.cs

示例15: MultiplyOrDivide

        private static Series MultiplyOrDivide(Series a, Series b, bool division=false)
        {
            Series rval = new Series();
            //Series.CopyAttributes(a, rval);
            if (a.TimeInterval != b.TimeInterval)
            {
                throw new InvalidOperationException(a.TimeInterval.ToString() + " and " + b.TimeInterval.ToString() + " are not compatable for add or subtract");
            }

            rval.TimeInterval = a.TimeInterval;
            rval.Units = a.Units;
            for (int i = 0; i < a.Count; i++)
            {
                Point newPoint;
                Point ptA = a[i];
                int idx = b.IndexOf(ptA.DateTime);
                if (
                   idx >= 0 && (!ptA.IsMissing)
                  )
                {
                    Point ptB = b[idx];
                    if (ptB.IsMissing)
                    {
                        newPoint = new Point(ptA.DateTime, Point.MissingValueFlag, PointFlag.Missing);
                    }
                    else
                    {
                        if (division)
                        {
                            if( ptA.Value == 0)
                                newPoint = new Point(ptA.DateTime, Point.MissingValueFlag, PointFlag.Missing);
                            else
                            newPoint = new Point(ptA.DateTime, ptA.Value / ptB.Value, PointFlag.Computed);
                        }
                        else
                        {
                            newPoint = new Point(ptA.DateTime, ptA.Value * ptB.Value, PointFlag.Computed);
                        }
                    }
                }
                else
                { // missing data.
                    newPoint = new Point(ptA.DateTime, Point.MissingValueFlag, PointFlag.Missing);
                }
                rval.Add(newPoint);
            }

            return rval;
        }
开发者ID:usbr,项目名称:Pisces,代码行数:49,代码来源:Math.cs


注:本文中的Series.IndexOf方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。