private void InitSpline() { float[] x = new float[table.Count]; float[] elev = new float[table.Count]; float[] time = new float[table.Count]; float[] dElev = new float[table.Count]; float[] dTime = new float[table.Count]; //range spline for (int i = 0; i < table.Count; i++) { x[i] = table[i].Range; elev[i] = table[i].Elev; time[i] = table[i].Time; dElev[i] = table[i].ElevationAdjust; dTime[i] = table[i].TimeAdjust; } elevSpline = new CubicSpline(); timeSpline = new CubicSpline(); elevAdjustSpline = new CubicSpline(); timeAdjustSpline = new CubicSpline(); elevSpline.Fit(x, elev); timeSpline.Fit(x, time); elevAdjustSpline.Fit(x, dElev); timeAdjustSpline.Fit(x, dTime); }
/// <summary> /// Filter noise peaks out using peak slope /// </summary> /// <param name="slopeThreshold"></param> public void FilterNoiseBySlope(double slopeThreshold = 10000) { if (Peaks.Length < 2) { return; } var mzData = new float[Peaks.Length]; var intensityData = new float[Peaks.Length]; var i = 0; for (i = 0; i < Peaks.Length; i++) { mzData[i] = (float)Peaks[i].Mz; intensityData[i] = (float)Peaks[i].Intensity; } var spline = new CubicSpline(); spline.Fit(mzData, intensityData); var intensitySlope = spline.EvalSlope(mzData); var filteredPeaks = new List <Peak>(); for (i = 0; i < Peaks.Length; i++) { if (Math.Abs(intensitySlope[i]) > slopeThreshold) { filteredPeaks.Add(Peaks[i]); } } Peaks = filteredPeaks.ToArray(); }
static void Main(string[] args) { System.Console.WriteLine("Hello, World!"); DoubleArray ee = ArrayRandom.RandomDoubleArray(4096); DoubleArray ef = ArrayRandom.RandomDoubleArray(4096); TimeSeries myTimeSeries = new TimeSeries(ef, ee); TimeSeries myOtherTimeSeries = myTimeSeries; myTimeSeries.x = ef; myTimeSeries.plot(); System.Console.WriteLine(myOtherTimeSeries.x); // IFigure f2 = ShoPlotHelper.Figure(); System.Console.WriteLine("Starting Slow"); System.Console.WriteLine(DateTime.Now); ArraySettings.DisableFastMath(); DoubleArray b = ArrayRandom.RandomDoubleArray(4096); DoubleArray a = ArrayRandom.RandomDoubleArray(1024); for (int i = 0; i < 100; i++) { DoubleArray c = ConvComp.Conv(b, a); //System.Console.WriteLine(i); } System.Console.WriteLine(DateTime.Now); System.Console.WriteLine("Starting Fast"); System.Console.WriteLine(DateTime.Now); ArraySettings.EnableFastMath(); CubicSpline cs = new CubicSpline(); DoubleArray d = ArrayRandom.RandomDoubleArray(4096); DoubleArray e = ArrayRandom.RandomDoubleArray(4096); DoubleArray g = d.Sort(); cs.Fit(g, e); DoubleArray h = cs.Interp(g); for (int i = 0; i < 10000; i++) { //DoubleArray f = ConvComp.Conv(d, e); //cs.Fit(g, e); h = cs.Interp(g); } System.Console.WriteLine(DateTime.Now); System.Console.WriteLine("Bye, World!"); }
static void Main(string[] args) { System.Console.WriteLine("Hello, World!"); DoubleArray ee = ArrayRandom.RandomDoubleArray(4096); DoubleArray ef = ArrayRandom.RandomDoubleArray(4096); TimeSeries myTimeSeries = new TimeSeries(ef,ee); TimeSeries myOtherTimeSeries = myTimeSeries; myTimeSeries.x = ef; myTimeSeries.plot(); System.Console.WriteLine(myOtherTimeSeries.x); // IFigure f2 = ShoPlotHelper.Figure(); System.Console.WriteLine("Starting Slow"); System.Console.WriteLine(DateTime.Now); ArraySettings.DisableFastMath(); DoubleArray b = ArrayRandom.RandomDoubleArray(4096); DoubleArray a = ArrayRandom.RandomDoubleArray(1024); for (int i = 0; i < 100; i++) { DoubleArray c = ConvComp.Conv(b, a); //System.Console.WriteLine(i); } System.Console.WriteLine(DateTime.Now); System.Console.WriteLine("Starting Fast"); System.Console.WriteLine(DateTime.Now); ArraySettings.EnableFastMath(); CubicSpline cs = new CubicSpline(); DoubleArray d = ArrayRandom.RandomDoubleArray(4096); DoubleArray e = ArrayRandom.RandomDoubleArray(4096); DoubleArray g = d.Sort(); cs.Fit(g, e); DoubleArray h = cs.Interp(g); for (int i = 0; i < 10000; i++) { //DoubleArray f = ConvComp.Conv(d, e); //cs.Fit(g, e); h = cs.Interp(g); } System.Console.WriteLine(DateTime.Now); System.Console.WriteLine("Bye, World!"); }