本文整理汇总了C#中Series.Add方法的典型用法代码示例。如果您正苦于以下问题:C# Series.Add方法的具体用法?C# Series.Add怎么用?C# Series.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Series
的用法示例。
在下文中一共展示了Series.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReservoirContentsWithDatabase
public void ReservoirContentsWithDatabase()
{
Logger.EnableLogger();
var fn = FileUtility.GetTempFileName(".pdb");
System.IO.File.Delete(fn);
SQLiteServer svr = new SQLiteServer(fn);
var db = new TimeSeriesDatabase(svr, Reclamation.TimeSeries.Parser.LookupOption.TableName,false);
var c = new CalculationSeries("instant_karl_af");
var path = Path.Combine(Globals.TestDataPath, "rating_tables");
path = Path.Combine(path, "karl_af.txt");
c.Expression = "FileRatingTable(instant_karl_fb,\""+path+"\")";
c.TimeInterval = TimeInterval.Irregular;
db.AddSeries(c);
var fb = new Series("instant_karl_fb");
fb.TimeInterval = TimeInterval.Irregular;
db.AddSeries(fb);
fb.Add("1-1-2013", 1);
fb.Add("1-2-2013", 2);
fb.Add("1-3-2013", 3);
fb.Add("1-4-2013", 4);
TimeSeriesImporter ti = new TimeSeriesImporter(db);
ti.Import(fb,computeDependencies:true);// this should force a calculation...
var af = db.GetSeriesFromTableName("instant_karl_af");
Assert.NotNull(af, "Series not created");
af.Read();
Assert.AreEqual(4, af.Count);
Assert.AreEqual(300, af[2].Value);
}
示例2: AddForecastSeries
private static void AddForecastSeries(string period, string scenario,
TimeSeriesDatabase dbVic, string name,
int thruMonth, string vicName)
{
string fn = period + scenario + ".pdb";
SQLiteServer svr = new SQLiteServer(fn);
TimeSeriesDatabase db = new TimeSeriesDatabase(svr);
Series sVic = dbVic.GetSeriesFromName(vicName + period + scenario);
sVic.Read();
Series s = new Series(name + "_Forecast");
s.TimeInterval = TimeInterval.Monthly;
s.TimeSeriesDatabase = db;
s.Units = "acre-feet";
//initial model data start date and value
s.Add(sVic[0].DateTime, sVic[0].Value * 1.98347 * sVic[0].DateTime.EndOfMonth().Day);
for (int i = 0; i < sVic.Count; i++)
{
int month = sVic[i].DateTime.Month;
if (month <= 6)
{
Point pt = new Point();
pt.DateTime = sVic[i].DateTime;
pt.Value = SumThruMonthToAcreFt(sVic, pt.DateTime, thruMonth);
s.Add(pt);
}
}
db.AddSeries(s);
SetSeriesDatesToBeginningOfMonth(s);
ConsolePrintSeriesNameAndCount(s);
}
示例3: AboveOrRising
public void AboveOrRising()
{
var ds = db.Alarms;
ds.AddNewAlarmGroup("uny");
ds.alarm_definition.Addalarm_definitionRow(true, "uny",
"uny", "pc", "above 300 or rising 1", "", 10);
ds.SaveTable(ds.alarm_definition);
ds.alarm_recipient.Addalarm_recipientRow("uny", 4,
"5272", "office", "[email protected]");
ds.SaveTable(ds.alarm_recipient);
Series s = new Series();
s.Parameter = "pc";
s.SiteID = "uny";
s.Add(DateTime.Parse("2016-11-21 02:00"), 38002.12);
s.Add(DateTime.Parse("2016-11-21 02:15"), 38005.02);
s.Add(DateTime.Parse("2016-11-21 02:30"), 38002.02);
s.Add(DateTime.Parse("2016-11-21 02:45"), 38002.02);
ds.Check(s);
var queue = ds.GetAlarmQueue();
string sql = "list = 'uny' AND siteid = 'uny' "
+ "AND parameter = 'pc' AND status = 'new'";
Assert.IsTrue(queue.Select(sql).Length == 1);
}
示例4: Below
public void Below()
{
var ds = db.Alarms;
ds.AddNewAlarmGroup("lucky");
ds.alarm_definition.Addalarm_definitionRow(true, "lucky",
"luc", "fb", "below 5525", "", 10);
ds.SaveTable(ds.alarm_definition);
ds.alarm_recipient.Addalarm_recipientRow("lucky", 4,
"5272", "office", "[email protected]");
ds.SaveTable(ds.alarm_recipient);
Series s = new Series();
s.Parameter = "fb";
s.SiteID = "luc";
s.Add(DateTime.Parse("2016-11-21 02:00"), 5520.12);
s.Add(DateTime.Parse("2016-11-21 02:15"), 5520.12);
s.Add(DateTime.Parse("2016-11-21 02:30"), 5520.12);
s.Add(DateTime.Parse("2016-11-21 02:45"), 5520.12);
ds.Check(s);
var queue = ds.GetAlarmQueue();
string sql = "list = 'lucky' AND siteid = 'luc' "
+ "AND parameter = 'fb' AND status = 'new'";
Assert.IsTrue(queue.Select(sql).Length == 1);
}
示例5: 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);
}
}
}
示例6: Feb29Bug
public void Feb29Bug()
{
Series s = new Series();
s.Add("1-1-1921", 0);
s.Add("1921-06-25", 364);
var shifted = Reclamation.TimeSeries.Math.ShiftToYear(s, 2000);
Assert.AreEqual(25, shifted[1].DateTime.Day);
shifted.WriteToConsole();
}
示例7: AverageWithFlags
public void AverageWithFlags()
{
Series s = new Series();
s.Add(DateTime.Parse("1/1/2013 12:30"), -55,"-");
s.Add(DateTime.Parse("1/1/2013 13:00"), 1);
s.Add(DateTime.Parse("1/1/2013 13:15"), 1);
s.Add(DateTime.Parse("1/1/2013 14:01"), 500,"+");
var avg = Math.DailyAverage(s,2);
avg.WriteToConsole();
Assert.AreEqual(1, avg.Count);
Assert.AreEqual(1, avg[0].Value,0.01);
}
示例8: HourlyAverage
public void HourlyAverage()
{
Series s = new Series();
s.Add("1/1/2013 12:30", 55);
s.Add("1/1/2013 13:00", 1);
s.Add("1/1/2013 13:15", 1);
s.Add("1/1/2013 14:01", 500);
var avg = Math.Average(s, TimeInterval.Hourly);
avg.WriteToConsole();
Assert.AreEqual(55, avg["1/1/2013 12:00:00"].Value);
Assert.AreEqual(1, avg["1/1/2013 13:00:00"].Value);
Assert.AreEqual(500, avg["1/1/2013 14:00:00"].Value);
}
示例9: ReadDataIntoSeries
private static void ReadDataIntoSeries(FixedWidthTextFile tf, Series s, int firstRowIndex, int columnIndex,DateTime fileDate)
{
for (int r = firstRowIndex; r < tf.RowCount; r++)
{
int hr;
if (tf[r, 0].Trim() == "" || !int.TryParse(tf[r,0].Trim(),out hr))
continue;
hr = Convert.ToInt32(tf[r, 0].Trim());
DateTime t = fileDate;
if (hr == 24)
t = t.AddDays(1);// use hour zero
else
t = t.AddHours(hr);
var val = tf[r, columnIndex];
double d;
if (!double.TryParse(val, out d))
{
Logger.WriteLine("Error: parsing '" + val + "' as a number");
continue;
}
s.Add(t, d);
}
}
示例10: 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;
}
示例11: DailyEtAscePenmanMontieth
public static Series DailyEtAscePenmanMontieth(Series mm, Series mn, Series mx,
Series ym, Series wr, double windHeight,Series sr, double latitude, double elevation, double Cd, double Cn)
{
Series rval = new Series();
rval.TimeInterval = TimeInterval.Daily;
if (mn.Count == 0)
{
Console.WriteLine("Error: DailyEtAscePenmanMontieth -- input series mn has no data");
return rval;
}
DateTime t = mn[0].DateTime.Date;
DateTime t2 = mn[mn.Count - 1].DateTime.Date;
if (t2 > DateTime.Now.Date.AddDays(-1))
t2 = DateTime.Now.Date.AddDays(-1);
while (t <= t2)
{
var pt = Hydromet.AsceEtCalculator.Calculate(t, mm, mn, mx, ym, wr, windHeight, sr, latitude, elevation, Cd, Cn);
rval.Add(pt);
t = t.AddDays(1);
}
return rval;
}
示例12: 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;
}
示例13: LookupIndex
public void LookupIndex()
{
Series s = new Series();
s.Add("2006-01-01", 0);
s.Add("2006-01-02", 1);
s.Add("2006-01-03", 2);
s.Add("2006-01-04", 3);
s.Add("2006-01-05", 4);
int i = s.LookupIndex(DateTime.Parse("2006-01-03 12:22 AM"));
Assert.AreEqual(3, i);
i = s.LookupIndex(DateTime.Parse("2006-01-03 12:22 AM"),true);
Assert.AreEqual(2, i);
}
示例14: FileRatingTable
public void FileRatingTable()
{
Series s = new Series();
s.Add(DateTime.Now.Date, 1281.95);
var path = Path.Combine(Globals.TestDataPath, "rating_tables", "gcl_af.txt");
var af = TimeSeriesDatabaseDataSet.RatingTableDataTable.ComputeSeries(s, path);
var x = af[0].Value;
Assert.AreEqual(4543763, x, .01);
}
示例15: EqualLengths
public void EqualLengths()
{
var pu = new Series("daily_wrdo_pu");
pu.TimeInterval = TimeInterval.Daily;
pu.Add("10-1-2014", 0);
pu.Add("10-2-2014", 1);
pu.Add("10-3-2014", 2);
pu.Add("10-4-2014", 3);
pu.Add("10-5-2014", 4);
pu.Add("10-6-2014", 5);
var pp = new Series("daily_wrdo_pp");
pp.TimeInterval = TimeInterval.Daily;
pp.Add("10-1-2014", 0);
pp.Add("10-2-2014", 1);
pp.Add("10-3-2014", 1);
pp.Add("10-4-2014", 1);
pp.Add("10-5-2014", 1);
pp.Add("10-6-2014", 1);
var puNew = Reclamation.TimeSeries.Math.DailyWaterYearRunningTotal(pp, pu);
for (int i = 0; i < pu.Count; i++)
{
Assert.AreEqual(puNew[i].Value, pu[i].Value);
}
}