本文整理汇总了C#中Series.AddMissing方法的典型用法代码示例。如果您正苦于以下问题:C# Series.AddMissing方法的具体用法?C# Series.AddMissing怎么用?C# Series.AddMissing使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Series
的用法示例。
在下文中一共展示了Series.AddMissing方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DailySubsetCalculatorValue
/// <summary>
/// Creates a list of Series , one subset for each day
/// used for math functions that need subset by day
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
private static Series DailySubsetCalculatorValue(Series s, Func<Series,double> func,
int requiredNumberOfPoints = 0)
{
Series rval = new Series();
rval.TimeInterval = TimeInterval.Daily;
DateTime t;
if (s.Count > 0)
{
t = s[0].DateTime.Date; // midnight
}
else
{
return rval;
}
while (t < s.MaxDateTime)
{
var subset = Math.Subset(s, new DateRange(t, t.AddDays(1)), false);
subset.RemoveMissing(true);
if (subset.Count < requiredNumberOfPoints)
{
Logger.WriteLine("Error: not enough data points "+s.Name);
Logger.WriteLine("expected "+requiredNumberOfPoints+" points, but had only "+subset.Count);
rval.AddMissing(t);
}
else
if (subset.Count > 0)
{
double d = func(subset);
rval.Add(t, d, PointFlag.Computed);
}
t = t.AddDays(1).Date;
}
return rval;
}
示例2: 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;
}
示例3: DailyCumulative
private static Series DailyCumulative(Series incremental, Series cumulative, int resetMonth, int resetDay)
{
//cumulative.Normalize();
//incremental.Normalize();
DateTime t;
Series rval = new Series();
rval.TimeInterval = TimeInterval.Daily;
if (incremental.Count == 0)
{
Console.WriteLine("there is no data ");
return rval;
}
if (incremental.TimeInterval != TimeInterval.Daily || cumulative.TimeInterval != TimeInterval.Daily)
{
throw new ArgumentException("Error: arguments must both have daily interval");
}
double sum = 0.0;
bool missing = false;
bool primed = false;
int index = 0;
t = GetRunningTotalStartDate(incremental, cumulative);
if (cumulative.IndexOf(t) >= 0 && !cumulative[t].IsMissing)
{
sum = cumulative[t].Value;
rval.Add(cumulative[t]);
primed = true;
index = incremental.IndexOf(t) + 1;
}
else
{
index = incremental.IndexOf(t);
}
for ( ; index < incremental.Count; index++)
{
var t2 = incremental[index].DateTime;
if (t2.Month == resetMonth && t2.Day == resetDay)
{
sum = 0.0;
primed = true;
missing = false;
}
if (primed && !missing && !incremental[index].IsMissing)
{
sum += incremental[index].Value;
rval.Add(incremental[index].DateTime, sum);
}
else
{
rval.AddMissing(incremental[index].DateTime);
Console.WriteLine("Missing data: incremental: " + incremental[index].ToString());
missing = true;
}
}
return rval;
}
示例4: DailyChange
public static Series DailyChange(Series s)
{
Series rval = new Series();
rval.TimeInterval = TimeInterval.Daily;
if (s.Count == 0)
return new Series();
var t = s.MinDateTime.Date;
while (t <= s.MaxDateTime)
{
int idx1 = s.IndexOf(t.Date); // midnight
int idx2 = s.IndexOf(t.AddDays(1).Date); // midnight
if (idx1 >= 0 && idx2 >= 0 && !s[idx1].IsMissing && !s[idx2].IsMissing)
{
double diff = s[idx2].Value - s[idx1].Value;
rval.Add(t, diff);
}
else
{
rval.AddMissing(t);
}
t = t.AddDays(1).Date;
}
return rval;
}
示例5: HydrometResidualForecast
public static Series HydrometResidualForecast(Series forecast, Series runoff, Series residual)
{
var rval = new Series();
rval.TimeInterval = TimeInterval.Daily;
if (runoff.Count < 30 )
{
Logger.WriteLine("Missing or not enough runoff data: HydrometResidualForecast()");
return residual;
}
if (residual.Count == 0)
{
residual.Add(runoff[0].DateTime, 0);
}
double resid = residual[0].Value;
for (int i = 0; i < runoff.Count; i++)
{
var t = runoff[i].DateTime;
resid = ResetResidualBasedOnForecast(t, forecast, resid);
bool missing = Point.IsMissingValue(resid);
if (!missing && !runoff[i].IsMissing && t <=runoff.MaxDateTime)
{
var quTemp = runoff[t].Value;
if (quTemp < 0)
quTemp = 0;
resid = resid - quTemp * 1.98347;
if (resid < 0)
resid = 0;
rval.Add(t, resid);
}
else
{
rval.AddMissing(t);
Console.WriteLine("Missing data: incremental: " + runoff[i].ToString());
missing = true;
}
}
return rval;
}
示例6: ConvertToDaily
internal Series ConvertToDaily()
{
Series estimatedDaily = new Series();
estimatedDaily.HasFlags = true;
estimatedDaily.TimeInterval = TimeInterval.Daily;
if (FillMissingWithZero)
{
daily = Math.FillMissingWithZero(daily, daily.MinDateTime, daily.MaxDateTime);
}
else
{
daily.RemoveMissing();
}
//daily.RemoveMissing();
//int[] levels = {5,10,20,30,40,50,60,70,80,90,95};
//int[] levels = {10,20,30,40,50,60,70,80,90};
List<int> levels = new List<int>();
if (MedianOnly)
{
levels.Add(50);
}
else
{
for (int i = 5; i <= 95; i += 2)
{
levels.Add(i);
}
}
var sHydrograph = Math.SummaryHydrograph(daily, levels.ToArray(), new DateTime(2008, 1, 1), false, false, false, false);//, false);
var summaryHydrographTable = sHydrograph.ToDataTable(true);
for (int i = 1; i < summaryHydrographTable.Columns.Count; i++)
{
summaryHydrographTable.Columns[i].ColumnName = levels[i - 1].ToString();
}
//DataTableOutput.Write(summaryHydrographTable, @"c:\temp\junk.csv", false);
SeriesList monthlySum = new SeriesList();
for (int i = 0; i < sHydrograph.Count; i++)
{
Series sum = Math.MonthlyValues(sHydrograph[i], Math.Sum);
sum.Name = levels[i].ToString();
monthlySum.Add(sum);
}
var monthlyExceedanceSums = monthlySum.ToDataTable(true);
if (monthlySum.Count == 1 && levels.Count == 1)
monthlyExceedanceSums.Columns[1].ColumnName = levels[0].ToString();
var monthlyTable = monthly.Table;
DateTime t = monthly.MinDateTime;
DateTime t2 = monthly.MaxDateTime;
t2 = new DateTime(t2.Year, t2.Month, DateTime.DaysInMonth(t2.Year, t2.Month));
while (t < t2)
{
var tm = new DateTime(t.Year, t.Month, 1);
if (monthly.IndexOf(tm) < 0)
{
estimatedDaily.AddMissing(t);
}
else
{
double mv = monthly[tm].Value;
double mvcfsdays = mv / 1.98347;
double exceedanceValue = 0;
int exceedancePercent = LookupExceedance(monthlyExceedanceSums, t, mvcfsdays, out exceedanceValue);
double ratio = 0;
if (exceedanceValue != 0)
ratio = mvcfsdays / exceedanceValue;
else
ratio = 0;
double shcfs = LookupSummaryHydrograph(summaryHydrographTable, t, exceedancePercent);
estimatedDaily.Add(t, shcfs * ratio,"scaled with "+exceedancePercent+"%");
}
t = t.AddDays(1);
}
VerifyWithMonthlyVolume(monthly, estimatedDaily);
// SmoothSpikes(monthly, daily, estimatedDaily);
return estimatedDaily;
}
示例7: DoAverage
private static void DoAverage(Series sOut, DateTime t, Series sTemp)
{
if (sTemp.Count == 0)
sOut.AddMissing(t);
else
{
double avgVal = sTemp.Values.Average();
sOut.Add(t, avgVal);
}
}
示例8: CreateRuleLine
private Series CreateRuleLine(double forecast, DateTime t1, DateTime t2)
{
Series s = new Series();
s.Name = (forecast/1000000.0 ).ToString("F2");
s.TimeInterval = TimeInterval.Daily;
string flag = "";
DateTime t = t1;
while (t <= t2)
{
var t3 = t;
if (t.Month == 2 && t.Day == 29)
t3 = t.AddDays(-1);
var d = LookupRequiredSpace(t3, forecast, out flag);
if (d == HydrometRuleCurve.MissingValue)
s.AddMissing(t);
else
s.Add(t, d);
t = t.Date.AddDays(1);
}
return s;
}