- Timestamp:
- 09/05/11 13:59:23 (13 years ago)
- Location:
- branches/HeuristicLab.DataImporter
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.DataImporter
- Property svn:ignore
-
old new 1 1 *.suo 2 _ReSharper.HeuristicLab.DataImporter
-
- Property svn:ignore
-
branches/HeuristicLab.DataImporter/HeuristicLab.DataImporter.Command/ChangeValues/FilterSavitzkyGolayCommand.cs
r6134 r6706 45 45 public int Order { get; set; } 46 46 47 public int OrderOfDerivative { get; set; } 48 47 49 private FilterSavitzkyGolayCommand() 48 50 : base(null, string.Empty, null) { … … 56 58 this.WindowRight = 16; 57 59 this.Order = 2; 60 this.OrderOfDerivative = 0; 58 61 } 59 62 … … 77 80 column = (DoubleColumn)ColumnGroup.GetColumn(col); 78 81 oldColumns.Add(col, column); 79 ColumnGroup.ReplaceColumn(col, CalcNewColumn(column, this.WindowLeft, this.WindowRight, this.Order ));82 ColumnGroup.ReplaceColumn(col, CalcNewColumn(column, this.WindowLeft, this.WindowRight, this.OrderOfDerivative, this.Order)); 80 83 } 81 84 } … … 97 100 } 98 101 99 private DoubleColumn CalcNewColumn(DoubleColumn oldColumn, int windowLeft, int windowRight, int order) {102 private DoubleColumn CalcNewColumn(DoubleColumn oldColumn, int windowLeft, int windowRight, int derivativeOrder, int order) { 100 103 double[] c; 101 SavitzkyGolay(Math.Abs(windowLeft), Math.Abs(windowRight), order, out c);104 SavitzkyGolay(Math.Abs(windowLeft), Math.Abs(windowRight), derivativeOrder, order, out c); 102 105 103 106 DoubleColumn newCol = (DoubleColumn)oldColumn.CreateCopyOfColumnWithoutValues(); … … 117 120 /// <param name="nl">number of samples to the left</param> 118 121 /// <param name="nr">number of samples to the right</param> 119 /// <param name="m">order of the polynomial to fit</param> 122 /// <param name="ld">order of derivative (smoothing=0)</param> 123 /// <param name="order">order of the polynomial to fit</param> 120 124 /// <param name="c">resulting coefficients for convolution, in correct order (t-nl, ... t-1, t+0, t+1, ... t+nr)</param> 121 private void SavitzkyGolay(int nl, int nr, int order, out double[] c) {125 private void SavitzkyGolay(int nl, int nr, int ld, int order, out double[] c) { 122 126 int np = nl + nr + 1; 123 int ld = 0;124 int m = order;125 127 126 128 int j, k, imj, ipj, kk, mm; 127 129 double fac = 0; 128 130 double sum = 0; 129 if (n p < nl + nr + 1 || nl < 0 || nr < 0 || ld > m || nl + nr < m) throw new ArgumentException();131 if (nl < 0 || nr < 0 || ld > order || nl + nr < order) throw new ArgumentException(); 130 132 131 int[] indx = new int[m + 1]; 132 double[,] a = new double[m + 1, m + 1]; 133 double[] b = new double[m + 1]; 133 double[,] a = new double[order + 1, order + 1]; 134 double[] b = new double[order + 1]; 134 135 c = new double[np]; 135 136 136 for (ipj = 0; ipj <= ( m<< 1); ipj++) {137 for (ipj = 0; ipj <= (order << 1); ipj++) { 137 138 sum = (ipj > 0 ? 0.0 : 1.0); 138 139 for (k = 1; k <= nr; k++) sum += Math.Pow((double)k, (double)ipj); 139 140 for (k = 1; k <= nl; k++) sum += Math.Pow((double)-k, (double)ipj); 140 mm = Math.Min(ipj, 2 * m- ipj);141 mm = Math.Min(ipj, 2 * order - ipj); 141 142 for (imj = -mm; imj <= mm; imj += 2) 142 143 a[(ipj + imj) / 2, (ipj - imj) / 2] = sum; 143 144 } 144 for (j = 0; j < m+ 1; j++) b[j] = 0;145 for (j = 0; j < order + 1; j++) b[j] = 0; 145 146 b[ld] = 1.0; 146 147 alglib.densesolverreport rep; … … 153 154 sum = x[0]; 154 155 fac = 1.0; 155 for (mm = 1; mm <= m; mm++) sum += x[mm] * (fac *= k);156 for (mm = 1; mm <= order; mm++) sum += x[mm] * (fac *= k); 156 157 kk = k + nl; 157 158 c[kk] = sum; -
branches/HeuristicLab.DataImporter/HeuristicLab.DataImporter.Command/View/FilterSavitzkyGolayCommandView.Designer.cs
r6134 r6706 51 51 this.label3 = new System.Windows.Forms.Label(); 52 52 this.numOrder = new System.Windows.Forms.NumericUpDown(); 53 this.numOrderOfDerivative = new System.Windows.Forms.NumericUpDown(); 54 this.label4 = new System.Windows.Forms.Label(); 53 55 ((System.ComponentModel.ISupportInitialize)(this.numWindowLeft)).BeginInit(); 54 56 ((System.ComponentModel.ISupportInitialize)(this.numWindowRight)).BeginInit(); 55 57 ((System.ComponentModel.ISupportInitialize)(this.numOrder)).BeginInit(); 58 ((System.ComponentModel.ISupportInitialize)(this.numOrderOfDerivative)).BeginInit(); 56 59 this.SuspendLayout(); 57 60 // … … 71 74 this.numWindowLeft.Name = "numWindowLeft"; 72 75 this.numWindowLeft.Size = new System.Drawing.Size(120, 20); 73 this.numWindowLeft.TabIndex = 0;76 this.numWindowLeft.TabIndex = 1; 74 77 this.numWindowLeft.Value = new decimal(new int[] { 75 78 4, … … 85 88 this.label1.Name = "label1"; 86 89 this.label1.Size = new System.Drawing.Size(101, 13); 87 this.label1.TabIndex = 1;90 this.label1.TabIndex = 0; 88 91 this.label1.Text = "Window start offset:"; 89 92 // … … 94 97 this.label2.Name = "label2"; 95 98 this.label2.Size = new System.Drawing.Size(99, 13); 96 this.label2.TabIndex = 3;99 this.label2.TabIndex = 2; 97 100 this.label2.Text = "Window end offset:"; 98 101 // … … 107 110 this.numWindowRight.Name = "numWindowRight"; 108 111 this.numWindowRight.Size = new System.Drawing.Size(120, 20); 109 this.numWindowRight.TabIndex = 2;112 this.numWindowRight.TabIndex = 3; 110 113 this.numWindowRight.Value = new decimal(new int[] { 111 114 4, … … 118 121 // 119 122 this.label3.AutoSize = true; 120 this.label3.Location = new System.Drawing.Point( 8, 62);123 this.label3.Location = new System.Drawing.Point(9, 89); 121 124 this.label3.Name = "label3"; 122 this.label3.Size = new System.Drawing.Size( 36, 13);123 this.label3.TabIndex = 4;124 this.label3.Text = "Order :";125 this.label3.Size = new System.Drawing.Size(100, 13); 126 this.label3.TabIndex = 6; 127 this.label3.Text = "Order of polynomial:"; 125 128 // 126 129 // numOrder 127 130 // 128 this.numOrder.Location = new System.Drawing.Point(115, 60);131 this.numOrder.Location = new System.Drawing.Point(115, 87); 129 132 this.numOrder.Maximum = new decimal(new int[] { 130 133 8, … … 134 137 this.numOrder.Name = "numOrder"; 135 138 this.numOrder.Size = new System.Drawing.Size(120, 20); 136 this.numOrder.TabIndex = 5;139 this.numOrder.TabIndex = 7; 137 140 this.numOrder.Value = new decimal(new int[] { 138 141 2, … … 142 145 this.numOrder.ValueChanged += new System.EventHandler(this.numOrder_ValueChanged); 143 146 // 147 // numOrderOfDerivative 148 // 149 this.numOrderOfDerivative.Location = new System.Drawing.Point(115, 60); 150 this.numOrderOfDerivative.Maximum = new decimal(new int[] { 151 3, 152 0, 153 0, 154 0}); 155 this.numOrderOfDerivative.Name = "numOrderOfDerivative"; 156 this.numOrderOfDerivative.Size = new System.Drawing.Size(120, 20); 157 this.numOrderOfDerivative.TabIndex = 5; 158 this.numOrderOfDerivative.ValueChanged += new System.EventHandler(this.numOrderOfDerivative_ValueChanged); 159 // 160 // label4 161 // 162 this.label4.AutoSize = true; 163 this.label4.Location = new System.Drawing.Point(8, 62); 164 this.label4.Name = "label4"; 165 this.label4.Size = new System.Drawing.Size(97, 13); 166 this.label4.TabIndex = 4; 167 this.label4.Text = "Order of derivative:"; 168 // 144 169 // FilterSavitzkyGolayCommandView 145 170 // 146 171 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 147 172 this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; 173 this.Controls.Add(this.numOrderOfDerivative); 174 this.Controls.Add(this.label4); 148 175 this.Controls.Add(this.numOrder); 149 176 this.Controls.Add(this.label3); … … 154 181 this.Name = "FilterSavitzkyGolayCommandView"; 155 182 this.Padding = new System.Windows.Forms.Padding(5); 156 this.Size = new System.Drawing.Size(24 4, 98);183 this.Size = new System.Drawing.Size(246, 117); 157 184 ((System.ComponentModel.ISupportInitialize)(this.numWindowLeft)).EndInit(); 158 185 ((System.ComponentModel.ISupportInitialize)(this.numWindowRight)).EndInit(); 159 186 ((System.ComponentModel.ISupportInitialize)(this.numOrder)).EndInit(); 187 ((System.ComponentModel.ISupportInitialize)(this.numOrderOfDerivative)).EndInit(); 160 188 this.ResumeLayout(false); 161 189 this.PerformLayout(); … … 170 198 private System.Windows.Forms.Label label3; 171 199 private System.Windows.Forms.NumericUpDown numOrder; 200 private System.Windows.Forms.NumericUpDown numOrderOfDerivative; 201 private System.Windows.Forms.Label label4; 172 202 } 173 203 } -
branches/HeuristicLab.DataImporter/HeuristicLab.DataImporter.Command/View/FilterSavitzkyGolayCommandView.cs
r6134 r6706 53 53 get { return this.Command.Order; } 54 54 } 55 public int OrderOfDerivative { 56 get { return this.Command.OrderOfDerivative; } 57 } 55 58 56 59 private void numWindowLeft_ValueChanged(object sender, System.EventArgs e) { … … 62 65 } 63 66 67 private void numOrder_ValueChanged(object sender, EventArgs e) { 68 this.UpdateCommand(); 69 } 70 71 private void numOrderOfDerivative_ValueChanged(object sender, EventArgs e) { 72 this.UpdateCommand(); 73 } 74 64 75 private void UpdateCommand() { 65 76 if (Command != null) { … … 67 78 this.Command.WindowRight = (int)this.numWindowRight.Value; 68 79 this.Command.Order = (int)this.numOrder.Value; 80 this.Command.OrderOfDerivative = (int) this.numOrderOfDerivative.Value; 69 81 } 70 }71 72 private void numOrder_ValueChanged(object sender, EventArgs e) {73 this.UpdateCommand();74 82 } 75 83 }
Note: See TracChangeset
for help on using the changeset viewer.