public void SimpleMoveTo() { Series ts = TestData.Simple2Day; Series original = TestData.Simple2Day; Selection sel = new Selection(ts[0].DateTime,ts[ts.Count-1].DateTime,0,50); Reclamation.TimeSeries.Math.MoveTo(ts,sel,123.456); Console.WriteLine("after move to"); ts.WriteToConsole(true); Console.WriteLine("original"); original.WriteToConsole(true); for(int i=0; i<ts.Count; i++) { if(original[i].Value >=0 && original[i].Value <=50) { Assert.AreEqual(123.456,ts[i].Value,0.0001); Assert.AreEqual("Edited",ts[i].Flag); } else { Assert.AreEqual("",ts[i].Flag); Assert.AreEqual(original[i].Value,ts[i].Value,0.0001); } } }
/// <summary> /// Applies vertical offset to data in selection /// </summary> public static void Offset(Series s, Selection selected, double verticalOffset) { if (s.ReadOnly) { return; } for (int i = 0; i < s.Count; i++) { if (s[i].BoundedBy(selected)) { Point pt = s[i]; pt.Value = pt.Value + verticalOffset; pt.Flag = "Edited"; s[i] = pt; } } }
public bool BoundedBy(Selection select) { return BoundedBy(select.t1,select.t2,select.ymin,select.ymax); }
/// <summary> /// moves all values in selection to specified value. /// can be useful in two part editing. /// first: move many outliers to a known datum (using MoveTo) /// second: manually move points one by one (using point move feature of Series Graph) /// </summary> public static void MoveTo(Series s, Selection selected, double newValue) { if (s.ReadOnly) { return; } for (int i = 0; i < s.Count; i++) { if (s[i].BoundedBy(selected)) { Console.WriteLine("moving "); Point pt = s[i]; Console.WriteLine(pt); pt.Value = newValue; pt.Flag = "Edited"; Console.WriteLine("to "); Console.WriteLine(pt); s[i] = pt; } } }